Jian Li
Committed by Gerrit Code Review

Replace Grizzly2 test container to Jetty test container

Grizzly2 test framework does not produce the same test results
compare to production REST API test through jetty web server.
By default Jersey 2.x uses the Grizzly2 test framework, this
commit tries to replace this test framework to Jetty based
http test framework.

Change-Id: I7bcb19bf73801cc66036487fd5a964e32ce1ba61
......@@ -106,7 +106,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
......
......@@ -144,7 +144,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
<dependency>
......
......@@ -15,7 +15,7 @@ COMPILE_DEPS = [
TEST_DEPS = [
'//lib:TEST_ADAPTERS',
'//lib:jersey-test-framework-core',
'//lib:jersey-test-framework-grizzly2',
'//lib:jersey-test-framework-jetty',
'//utils/osgi:onlab-osgi-tests',
'//web/api:onos-rest-tests',
'//incubator/api:onos-incubator-api-tests',
......
......@@ -77,7 +77,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -81,17 +81,20 @@ java_library(
':jersey-server',
':jersey-common',
':jersey-test-framework-core',
':jersey-test-framework-grizzly2',
':jersey-test-framework-jetty',
':jersey-container-jetty-http',
':jetty-continuation',
':jetty-http',
':javax.servlet-api',
':jetty-server',
':jetty-io',
':jetty-util',
':jersey-guava',
':hk2-api',
':hk2-locator',
':hk2-utils',
':javax.inject',
':hk2-osgi-resource-locator',
':jersey-container-grizzly2-http',
':grizzly-http-server',
':grizzly-framework',
':grizzly-http',
':javax.annotation-api',
':validation-api',
'//core/common:onos-core-common',
......@@ -592,45 +595,87 @@ remote_file(
)
prebuilt_jar(
name = 'grizzly-framework',
binary_jar = ':grizzly-framework-2.3.23.jar',
maven_coords = 'org.glassfish.grizzly:grizzly-framework:2.3.23',
name = 'jetty-server',
binary_jar = ':jetty-server-9.1.6.v20160112.jar',
maven_coords = 'org.eclipse.jetty:jetty-server:9.1.6.v20160112',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'grizzly-framework-2.3.23.jar',
out = 'grizzly-framework-2.3.23.jar',
url = 'mvn:org.glassfish.grizzly:grizzly-framework:jar:2.3.23',
sha1 = '262913b1a7ec4156e7e6aa3f8854a4d1a54940b0',
name = 'jetty-server-9.1.6.v20160112.jar',
out = 'jetty-server-9.1.6.v20160112.jar',
url = 'mvn:org.eclipse.jetty:jetty-server:jar:9.1.6.v20160112',
sha1 = '15f8b12fe0e2105f46d7c3b372054adc85e941a9',
)
prebuilt_jar(
name = 'grizzly-http',
binary_jar = ':grizzly-http-2.3.23.jar',
maven_coords = 'org.glassfish.grizzly:grizzly-http:2.3.23',
name = 'jetty-util',
binary_jar = ':jetty-util-9.1.6.v20160112.jar',
maven_coords = 'org.eclipse.jetty:jetty-util:9.1.6.v20160112',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'jetty-util-9.1.6.v20160112.jar',
out = 'jetty-util-9.1.6.v20160112.jar',
url = 'mvn:org.eclipse.jetty:jetty-util:jar:9.1.6.v20160112',
sha1 = 'd4337bc023fe99b072abc56425b8a317ffd3f462',
)
prebuilt_jar(
name = 'jetty-continuation',
binary_jar = ':jetty-continuation-9.1.6.v20160112.jar',
maven_coords = 'org.eclipse.jetty:jetty-continuation:9.1.6.v20160112',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'jetty-continuation-9.1.6.v20160112.jar',
out = 'jetty-continuation-9.1.6.v20160112.jar',
url = 'mvn:org.eclipse.jetty:jetty-continuation:jar:9.1.6.v20160112',
sha1 = 'c8f35dfc6321cc15224404c9c4ede79988eeae34',
)
prebuilt_jar(
name = 'jetty-http',
binary_jar = ':jetty-http-9.1.6.v20160112.jar',
maven_coords = 'org.eclipse.jetty:jetty-http:9.1.6.v20160112',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'grizzly-http-2.3.23.jar',
out = 'grizzly-http-2.3.23.jar',
url = 'mvn:org.glassfish.grizzly:grizzly-http:jar:2.3.23',
sha1 = '287ea2c8a765b14fbc494749570ff3889ecd7b83',
name = 'jetty-http-9.1.6.v20160112.jar',
out = 'jetty-http-9.1.6.v20160112.jar',
url = 'mvn:org.eclipse.jetty:jetty-http:jar:9.1.6.v20160112',
sha1 = 'c3675e6ebc350aafbc9dd7686265af9f65165b36',
)
prebuilt_jar(
name = 'grizzly-http-server',
binary_jar = ':grizzly-http-server-2.3.23.jar',
maven_coords = 'org.glassfish.grizzly:grizzly-http-server:2.3.23',
name = 'jetty-io',
binary_jar = ':jetty-io-9.1.6.v20160112.jar',
maven_coords = 'org.eclipse.jetty:jetty-io:9.1.6.v20160112',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'grizzly-http-server-2.3.23.jar',
out = 'grizzly-http-server-2.3.23.jar',
url = 'mvn:org.glassfish.grizzly:grizzly-http-server:jar:2.3.23',
sha1 = '4aaf209163d8dca1bfb1907f19c7fd1f2f3ebbf9',
name = 'jetty-io-9.1.6.v20160112.jar',
out = 'jetty-io-9.1.6.v20160112.jar',
url = 'mvn:org.eclipse.jetty:jetty-io:jar:9.1.6.v20160112',
sha1 = '717fc5a269becb2537849105de1547dc1a4476b0',
)
prebuilt_jar(
name = 'javax.servlet-api',
binary_jar = ':javax.servlet-api-3.1.0.jar',
maven_coords = 'javax.servlet:javax.servlet-api:3.1.0',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'javax.servlet-api-3.1.0.jar',
out = 'javax.servlet-api-3.1.0.jar',
url = 'mvn:javax.servlet:javax.servlet-api:jar:3.1.0',
sha1 = '3cd63d075497751784b2fa84be59432f4905bf7c',
)
prebuilt_jar(
......@@ -914,17 +959,17 @@ remote_file(
)
prebuilt_jar(
name = 'jersey-container-grizzly2-http',
binary_jar = ':jersey-container-grizzly2-http-2.22.2.jar',
maven_coords = 'org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.2',
name = 'jersey-container-jetty-http',
binary_jar = ':jersey-container-jetty-http-2.22.2.jar',
maven_coords = 'org.glassfish.jersey.containers:jersey-container-jetty-http:2.22.2',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'jersey-container-grizzly2-http-2.22.2.jar',
out = 'jersey-container-grizzly2-http-2.22.2.jar',
url = 'mvn:org.glassfish.jersey.containers:jersey-container-grizzly2-http:jar:2.22.2',
sha1 = '7f4f0cb7cfad277a4a6d91298d9f2ac309e4383b',
name = 'jersey-container-jetty-http-2.22.2.jar',
out = 'jersey-container-jetty-http-2.22.2.jar',
url = 'mvn:org.glassfish.jersey.containers:jersey-container-jetty-http:jar:2.22.2',
sha1 = '7421abf505bda989087745a458b5ccf2cd327297',
)
prebuilt_jar(
......@@ -984,31 +1029,17 @@ remote_file(
)
prebuilt_jar(
name = 'jersey-test-framework-grizzly2',
binary_jar = ':jersey-test-framework-provider-grizzly2-2.22.2.jar',
maven_coords = 'org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.22.2',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'jersey-test-framework-provider-grizzly2-2.22.2.jar',
out = 'jersey-test-framework-provider-grizzly2-2.22.2.jar',
url = 'mvn:org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:jar:2.22.2',
sha1 = '05aa3952528f09ce94360ab238446163d2544344',
)
prebuilt_jar(
name = 'jetty-util',
binary_jar = ':jetty-util-8.1.18.v20150929.jar',
maven_coords = 'org.eclipse.jetty:jetty-util:8.1.18.v20150929',
name = 'jersey-test-framework-jetty',
binary_jar = ':jersey-test-framework-provider-jetty-2.22.2.jar',
maven_coords = 'org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-jetty:2.22.2',
visibility = [ 'PUBLIC' ],
)
remote_file(
name = 'jetty-util-8.1.18.v20150929.jar',
out = 'jetty-util-8.1.18.v20150929.jar',
url = 'mvn:org.eclipse.jetty:jetty-util:jar:8.1.18.v20150929',
sha1 = 'fb8fb3debf99a626c827535bf06451a337c6b085',
name = 'jersey-test-framework-provider-jetty-2.22.2.jar',
out = 'jersey-test-framework-provider-jetty-2.22.2.jar',
url = 'mvn:org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-jetty:jar:2.22.2',
sha1 = 'ab3b0418403f6a5cfc311f92b7cd589dc32f60ed',
)
prebuilt_jar(
......
......@@ -59,17 +59,20 @@
"jersey-server",
"jersey-common",
"jersey-test-framework-core",
"jersey-test-framework-grizzly2",
"jersey-test-framework-jetty",
"jersey-container-jetty-http",
"jetty-continuation",
"jetty-http",
"jetty-server",
"jetty-io",
"jetty-util",
"javax.servlet-api",
"jersey-guava",
"hk2-api",
"hk2-locator",
"hk2-utils",
"javax.inject",
"hk2-osgi-resource-locator",
"jersey-container-grizzly2-http",
"grizzly-http-server",
"grizzly-framework",
"grizzly-http",
"javax.annotation-api",
"validation-api",
"//core/common:onos-core-common",
......@@ -115,9 +118,7 @@
"easymock": "mvn:org.easymock:easymock:3.4",
"error_prone_annotations": "mvn:com.google.errorprone:error_prone_annotations:2.0.2",
"ganymed-ssh2": "mvn:ch.ethz.ganymed:ganymed-ssh2:262",
"grizzly-framework": "mvn:org.glassfish.grizzly:grizzly-framework:2.3.23",
"grizzly-http": "mvn:org.glassfish.grizzly:grizzly-http:2.3.23",
"grizzly-http-server": "mvn:org.glassfish.grizzly:grizzly-http-server:2.3.23",
"jersey-container-jetty-http": "mvn:org.glassfish.jersey.containers:jersey-container-jetty-http:2.22.2",
"guava": "mvn:com.google.guava:guava:19.0",
"guava-testlib": "mvn:com.google.guava:guava-testlib:19.0",
"hamcrest-all": "mvn:org.hamcrest:hamcrest-all:1.3",
......@@ -138,14 +139,19 @@
"javax.ws.rs-api": "mvn:javax.ws.rs:javax.ws.rs-api:2.0.1",
"jersey-client": "mvn:org.glassfish.jersey.core:jersey-client:2.22.2",
"jersey-common": "mvn:org.glassfish.jersey.core:jersey-common:2.22.2",
"jersey-container-grizzly2-http": "mvn:org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.2",
"jersey-guava": "mvn:org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.2",
"jersey-media-multipart": "mvn:org.glassfish.jersey.media:jersey-media-multipart:2.22.2",
"jersey-server": "mvn:org.glassfish.jersey.core:jersey-server:2.22.2",
"jersey-test-framework-core": "mvn:org.glassfish.jersey.test-framework:jersey-test-framework-core:2.22.2",
"jersey-test-framework-grizzly2": "mvn:org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.22.2",
"jetty-util": "mvn:org.eclipse.jetty:jetty-util:8.1.18.v20150929",
"jersey-test-framework-jetty": "mvn:org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-jetty:2.22.2",
"jetty-util": "mvn:org.eclipse.jetty:jetty-util:9.1.6.v20160112",
"jetty-websocket": "mvn:org.eclipse.jetty:jetty-websocket:8.1.18.v20150929",
"jetty-server": "mvn:org.eclipse.jetty:jetty-server:9.1.6.v20160112",
"jetty-continuation": "mvn:org.eclipse.jetty:jetty-continuation:9.1.6.v20160112",
"jetty-http": "mvn:org.eclipse.jetty:jetty-http:9.1.6.v20160112",
"jetty-io": "mvn:org.eclipse.jetty:jetty-io:9.1.6.v20160112",
"jetty-server": "mvn:org.eclipse.jetty:jetty-server:9.1.6.v20160112",
"javax.servlet-api": "mvn:javax.servlet:javax.servlet-api:3.1.0",
"joda-time": "mvn:joda-time:joda-time:2.9",
"jsch": "mvn:com.jcraft:jsch:0.1.53",
"jsr305": "mvn:com.google.code.findbugs:jsr305:3.0.1",
......
......@@ -261,7 +261,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -58,7 +58,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
<dependency>
......
......@@ -53,6 +53,11 @@
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
......
......@@ -17,12 +17,16 @@ package org.onosproject.rest.resources;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.jetty.JettyTestContainerFactory;
import org.glassfish.jersey.test.spi.TestContainerException;
import org.glassfish.jersey.test.spi.TestContainerFactory;
import java.io.IOException;
import java.net.ServerSocket;
/**
* Base class for REST API tests. Performs common configuration operations.
* Base class for REST API tests.
* Performs common configuration operations.
*/
public class ResourceTest extends JerseyTest {
private static final int DEFAULT_PORT = 9998;
......@@ -61,4 +65,15 @@ public class ResourceTest extends JerseyTest {
return defaultPort;
}
}
/**
* Configures the jetty test container as default test container.
*
* @return test container factory
* @throws TestContainerException
*/
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new JettyTestContainerFactory();
}
}
......
......@@ -95,7 +95,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
......