Ray Milkey

Fix buck tests

Change-Id: I3d681e6e5c1d3e98c87ccb3d20a619b216ae6133
Showing 46 changed files with 265 additions and 92 deletions
...@@ -160,4 +160,4 @@ java_library( ...@@ -160,4 +160,4 @@ java_library(
160 name = 'install', 160 name = 'install',
161 visibility = ['PUBLIC'], 161 visibility = ['PUBLIC'],
162 deps = INSTALL 162 deps = INSTALL
163 -)
...\ No newline at end of file ...\ No newline at end of file
163 +)
......
...@@ -11,7 +11,8 @@ COMPILE_DEPS = [ ...@@ -11,7 +11,8 @@ COMPILE_DEPS = [
11 ] 11 ]
12 12
13 TEST_DEPS = [ 13 TEST_DEPS = [
14 - '//lib:TEST', 14 + '//lib:TEST_ADAPTERS',
15 + '//core/common:onos-core-common',
15 ] 16 ]
16 17
17 java_library( 18 java_library(
......
...@@ -12,7 +12,8 @@ COMPILE_DEPS = [ ...@@ -12,7 +12,8 @@ COMPILE_DEPS = [
12 ] 12 ]
13 13
14 TEST_DEPS = [ 14 TEST_DEPS = [
15 - '//lib:TEST', 15 + '//lib:TEST_REST',
16 + '//lib:jersey-server',
16 ] 17 ]
17 18
18 java_library( 19 java_library(
......
...@@ -10,7 +10,7 @@ COMPILE_DEPS = [ ...@@ -10,7 +10,7 @@ COMPILE_DEPS = [
10 ] 10 ]
11 11
12 TEST_DEPS = [ 12 TEST_DEPS = [
13 - '//lib:TEST', 13 + '//lib:TEST_ADAPTERS',
14 ] 14 ]
15 15
16 java_library( 16 java_library(
......
...@@ -16,7 +16,8 @@ COMPILE_DEPS = [ ...@@ -16,7 +16,8 @@ COMPILE_DEPS = [
16 ] 16 ]
17 17
18 TEST_DEPS = [ 18 TEST_DEPS = [
19 - '//lib:TEST', 19 + '//lib:TEST_REST',
20 + '//web/api:onos-rest-tests',
20 ] 21 ]
21 22
22 java_library( 23 java_library(
...@@ -33,4 +34,6 @@ java_test( ...@@ -33,4 +34,6 @@ java_test(
33 TEST_DEPS + 34 TEST_DEPS +
34 [CURRENT_TARGET], 35 [CURRENT_TARGET],
35 source_under_test = [CURRENT_TARGET], 36 source_under_test = [CURRENT_TARGET],
37 + resources_root = 'src/test/resources',
38 + resources = glob(['src/test/resources/**']),
36 ) 39 )
......
...@@ -154,6 +154,13 @@ ...@@ -154,6 +154,13 @@
154 <classifier>tests</classifier> 154 <classifier>tests</classifier>
155 <scope>test</scope> 155 <scope>test</scope>
156 </dependency> 156 </dependency>
157 + <dependency>
158 + <groupId>org.onosproject</groupId>
159 + <artifactId>onos-rest</artifactId>
160 + <version>${project.version}</version>
161 + <classifier>tests</classifier>
162 + <scope>test</scope>
163 + </dependency>
157 </dependencies> 164 </dependencies>
158 165
159 <build> 166 <build>
...@@ -181,4 +188,4 @@ ...@@ -181,4 +188,4 @@
181 </plugin> 188 </plugin>
182 </plugins> 189 </plugins>
183 </build> 190 </build>
184 -</project>
...\ No newline at end of file ...\ No newline at end of file
191 +</project>
......
...@@ -15,8 +15,16 @@ ...@@ -15,8 +15,16 @@
15 */ 15 */
16 package org.onosproject.cpman.rest; 16 package org.onosproject.cpman.rest;
17 17
18 +import java.io.InputStream;
19 +import java.net.HttpURLConnection;
20 +import java.util.Optional;
21 +
22 +import javax.ws.rs.client.Entity;
23 +import javax.ws.rs.client.WebTarget;
24 +import javax.ws.rs.core.MediaType;
25 +import javax.ws.rs.core.Response;
26 +
18 import org.glassfish.jersey.server.ResourceConfig; 27 import org.glassfish.jersey.server.ResourceConfig;
19 -import org.glassfish.jersey.test.JerseyTest;
20 import org.junit.Before; 28 import org.junit.Before;
21 import org.junit.Test; 29 import org.junit.Test;
22 import org.onlab.osgi.ServiceDirectory; 30 import org.onlab.osgi.ServiceDirectory;
...@@ -26,14 +34,7 @@ import org.onosproject.cpman.ControlPlaneMonitorService; ...@@ -26,14 +34,7 @@ import org.onosproject.cpman.ControlPlaneMonitorService;
26 import org.onosproject.cpman.SystemInfo; 34 import org.onosproject.cpman.SystemInfo;
27 import org.onosproject.cpman.impl.SystemInfoFactory; 35 import org.onosproject.cpman.impl.SystemInfoFactory;
28 import org.onosproject.net.DeviceId; 36 import org.onosproject.net.DeviceId;
29 - 37 +import org.onosproject.rest.resources.ResourceTest;
30 -import javax.ws.rs.client.Entity;
31 -import javax.ws.rs.client.WebTarget;
32 -import javax.ws.rs.core.MediaType;
33 -import javax.ws.rs.core.Response;
34 -import java.io.InputStream;
35 -import java.net.HttpURLConnection;
36 -import java.util.Optional;
37 38
38 import static org.easymock.EasyMock.anyInt; 39 import static org.easymock.EasyMock.anyInt;
39 import static org.easymock.EasyMock.anyObject; 40 import static org.easymock.EasyMock.anyObject;
...@@ -48,7 +49,7 @@ import static org.junit.Assert.assertThat; ...@@ -48,7 +49,7 @@ import static org.junit.Assert.assertThat;
48 /** 49 /**
49 * Unit test for ControlMetricsCollector. 50 * Unit test for ControlMetricsCollector.
50 */ 51 */
51 -public class ControlMetricsCollectorResourceTest extends JerseyTest { 52 +public class ControlMetricsCollectorResourceTest extends ResourceTest {
52 53
53 final ControlPlaneMonitorService mockControlPlaneMonitorService = 54 final ControlPlaneMonitorService mockControlPlaneMonitorService =
54 createMock(ControlPlaneMonitorService.class); 55 createMock(ControlPlaneMonitorService.class);
......
...@@ -15,9 +15,12 @@ ...@@ -15,9 +15,12 @@
15 */ 15 */
16 package org.onosproject.cpman.rest; 16 package org.onosproject.cpman.rest;
17 17
18 -import com.google.common.collect.ImmutableSet; 18 +import java.util.Set;
19 +import java.util.concurrent.TimeUnit;
20 +
21 +import javax.ws.rs.client.WebTarget;
22 +
19 import org.glassfish.jersey.server.ResourceConfig; 23 import org.glassfish.jersey.server.ResourceConfig;
20 -import org.glassfish.jersey.test.JerseyTest;
21 import org.junit.Before; 24 import org.junit.Before;
22 import org.junit.Test; 25 import org.junit.Test;
23 import org.onlab.osgi.ServiceDirectory; 26 import org.onlab.osgi.ServiceDirectory;
...@@ -32,10 +35,9 @@ import org.onosproject.codec.impl.CodecManager; ...@@ -32,10 +35,9 @@ import org.onosproject.codec.impl.CodecManager;
32 import org.onosproject.cpman.ControlLoad; 35 import org.onosproject.cpman.ControlLoad;
33 import org.onosproject.cpman.ControlPlaneMonitorService; 36 import org.onosproject.cpman.ControlPlaneMonitorService;
34 import org.onosproject.cpman.codec.ControlLoadCodec; 37 import org.onosproject.cpman.codec.ControlLoadCodec;
38 +import org.onosproject.rest.resources.ResourceTest;
35 39
36 -import javax.ws.rs.client.WebTarget; 40 +import com.google.common.collect.ImmutableSet;
37 -import java.util.Set;
38 -import java.util.concurrent.TimeUnit;
39 41
40 import static org.easymock.EasyMock.anyObject; 42 import static org.easymock.EasyMock.anyObject;
41 import static org.easymock.EasyMock.anyString; 43 import static org.easymock.EasyMock.anyString;
...@@ -49,7 +51,7 @@ import static org.junit.Assert.assertThat; ...@@ -49,7 +51,7 @@ import static org.junit.Assert.assertThat;
49 /** 51 /**
50 * Unit test for ControlMetrics REST API. 52 * Unit test for ControlMetrics REST API.
51 */ 53 */
52 -public class ControlMetricsResourceTest extends JerseyTest { 54 +public class ControlMetricsResourceTest extends ResourceTest {
53 55
54 final ControlPlaneMonitorService mockControlPlaneMonitorService = 56 final ControlPlaneMonitorService mockControlPlaneMonitorService =
55 createMock(ControlPlaneMonitorService.class); 57 createMock(ControlPlaneMonitorService.class);
......
...@@ -15,7 +15,7 @@ COMPILE_DEPS = [ ...@@ -15,7 +15,7 @@ COMPILE_DEPS = [
15 ] 15 ]
16 16
17 TEST_DEPS = [ 17 TEST_DEPS = [
18 - '//lib:TEST', 18 + '//lib:TEST_ADAPTERS',
19 ] 19 ]
20 20
21 java_library( 21 java_library(
......
...@@ -11,7 +11,11 @@ COMPILE_DEPS = [ ...@@ -11,7 +11,11 @@ COMPILE_DEPS = [
11 ] 11 ]
12 12
13 TEST_DEPS = [ 13 TEST_DEPS = [
14 - '//lib:TEST', 14 + '//lib:TEST_ADAPTERS',
15 + '//lib:jersey-test-framework-core',
16 + '//lib:jersey-test-framework-grizzly2',
17 + '//utils/osgi:onlab-osgi-tests',
18 + '//web/api:onos-rest-tests',
15 ] 19 ]
16 20
17 java_library( 21 java_library(
......
...@@ -11,7 +11,7 @@ COMPILE_DEPS = [ ...@@ -11,7 +11,7 @@ COMPILE_DEPS = [
11 ] 11 ]
12 12
13 TEST_DEPS = [ 13 TEST_DEPS = [
14 - '//lib:TEST', 14 + '//lib:TEST_ADAPTERS',
15 ] 15 ]
16 16
17 java_library( 17 java_library(
......
...@@ -12,7 +12,7 @@ COMPILE_DEPS = [ ...@@ -12,7 +12,7 @@ COMPILE_DEPS = [
12 12
13 TEST_DEPS = [ 13 TEST_DEPS = [
14 '//lib:TEST', 14 '//lib:TEST',
15 - '//core/api:onos-api', 15 + '//core/api:onos-api-tests',
16 ] 16 ]
17 17
18 java_library( 18 java_library(
......
...@@ -13,7 +13,7 @@ COMPILE_DEPS = [ ...@@ -13,7 +13,7 @@ COMPILE_DEPS = [
13 ] 13 ]
14 14
15 TEST_DEPS = [ 15 TEST_DEPS = [
16 - '//lib:TEST', 16 + '//lib:TEST_ADAPTERS',
17 ] 17 ]
18 18
19 java_library( 19 java_library(
......
...@@ -9,7 +9,7 @@ COMPILE_DEPS = [ ...@@ -9,7 +9,7 @@ COMPILE_DEPS = [
9 ] 9 ]
10 10
11 TEST_DEPS = [ 11 TEST_DEPS = [
12 - '//lib:TEST', 12 + '//lib:TEST_ADAPTERS',
13 ] 13 ]
14 14
15 java_library( 15 java_library(
...@@ -20,10 +20,11 @@ java_library( ...@@ -20,10 +20,11 @@ java_library(
20 ) 20 )
21 21
22 java_test( 22 java_test(
23 - name = 'tests', 23 + name = 'onos-app-routing-api-tests',
24 srcs = glob([TEST + '/*.java']), 24 srcs = glob([TEST + '/*.java']),
25 deps = COMPILE_DEPS + 25 deps = COMPILE_DEPS +
26 TEST_DEPS + 26 TEST_DEPS +
27 [CURRENT_TARGET], 27 [CURRENT_TARGET],
28 source_under_test = [CURRENT_TARGET], 28 source_under_test = [CURRENT_TARGET],
29 + visibility = ['PUBLIC'],
29 ) 30 )
......
...@@ -15,7 +15,9 @@ COMPILE_DEPS = [ ...@@ -15,7 +15,9 @@ COMPILE_DEPS = [
15 ] 15 ]
16 16
17 TEST_DEPS = [ 17 TEST_DEPS = [
18 - '//lib:TEST', 18 + '//lib:TEST_ADAPTERS',
19 + '//incubator/api:onos-incubator-api-tests',
20 + '//apps/routing-api:onos-app-routing-api-tests',
19 ] 21 ]
20 22
21 java_library( 23 java_library(
......
...@@ -238,9 +238,9 @@ public class BgpSessionManagerTest { ...@@ -238,9 +238,9 @@ public class BgpSessionManagerTest {
238 } 238 }
239 239
240 @SuppressWarnings("unchecked") 240 @SuppressWarnings("unchecked")
241 - private Dictionary<String, String> 241 + private Dictionary
242 getDictionaryMock(ComponentContext componentContext) { 242 getDictionaryMock(ComponentContext componentContext) {
243 - Dictionary<String, String> dictionary = createMock(Dictionary.class); 243 + Dictionary dictionary = createMock(Dictionary.class);
244 expect(dictionary.get("bgpPort")).andReturn("0"); 244 expect(dictionary.get("bgpPort")).andReturn("0");
245 replay(dictionary); 245 replay(dictionary);
246 expect(componentContext.getProperties()).andReturn(dictionary); 246 expect(componentContext.getProperties()).andReturn(dictionary);
...@@ -264,7 +264,7 @@ public class BgpSessionManagerTest { ...@@ -264,7 +264,7 @@ public class BgpSessionManagerTest {
264 bgpSessionManager = new BgpSessionManager(); 264 bgpSessionManager = new BgpSessionManager();
265 // NOTE: We use port 0 to bind on any available port 265 // NOTE: We use port 0 to bind on any available port
266 ComponentContext componentContext = createMock(ComponentContext.class); 266 ComponentContext componentContext = createMock(ComponentContext.class);
267 - Dictionary<String, String> dictionary = getDictionaryMock(componentContext); 267 + Dictionary dictionary = getDictionaryMock(componentContext);
268 replay(componentContext); 268 replay(componentContext);
269 bgpSessionManager.activate(componentContext); 269 bgpSessionManager.activate(componentContext);
270 bgpSessionManager.start(dummyRouteListener); 270 bgpSessionManager.start(dummyRouteListener);
......
...@@ -131,7 +131,7 @@ public class SingleSwitchFibInstallerTest extends AbstractIntentTest { ...@@ -131,7 +131,7 @@ public class SingleSwitchFibInstallerTest extends AbstractIntentTest {
131 131
132 //component context 132 //component context
133 ComponentContext mockContext = EasyMock.createMock(ComponentContext.class); 133 ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
134 - Dictionary<String, Boolean> properties = null; 134 + Dictionary properties = null;
135 expect(mockContext.getProperties()).andReturn(properties); 135 expect(mockContext.getProperties()).andReturn(properties);
136 replay(mockContext); 136 replay(mockContext);
137 137
......
...@@ -11,7 +11,9 @@ COMPILE_DEPS = [ ...@@ -11,7 +11,9 @@ COMPILE_DEPS = [
11 ] 11 ]
12 12
13 TEST_DEPS = [ 13 TEST_DEPS = [
14 - '//lib:TEST', 14 + '//lib:TEST_ADAPTERS',
15 + '//incubator/api:onos-incubator-api-tests',
16 + '//apps/routing-api:onos-app-routing-api-tests',
15 ] 17 ]
16 18
17 java_library( 19 java_library(
......
...@@ -16,7 +16,7 @@ COMPILE_DEPS = [ ...@@ -16,7 +16,7 @@ COMPILE_DEPS = [
16 ] 16 ]
17 17
18 TEST_DEPS = [ 18 TEST_DEPS = [
19 - '//lib:TEST', 19 + '//lib:TEST_ADAPTERS',
20 ] 20 ]
21 21
22 java_library( 22 java_library(
...@@ -35,4 +35,6 @@ java_test( ...@@ -35,4 +35,6 @@ java_test(
35 TEST_DEPS + 35 TEST_DEPS +
36 [CURRENT_TARGET], 36 [CURRENT_TARGET],
37 source_under_test = [CURRENT_TARGET], 37 source_under_test = [CURRENT_TARGET],
38 + resources_root = 'src/test/resources',
39 + resources = glob(['src/test/resources/**']),
38 ) 40 )
......
1 SRC = 'src/main/java/org/onosproject/**/' 1 SRC = 'src/main/java/org/onosproject/**/'
2 #FIXME there are some tests in main 2 #FIXME there are some tests in main
3 -TEST = 'src/main/java/org/onosproject/**/' 3 +TEST = 'src/test/java/org/onosproject/**/'
4 4
5 COMPILE_DEPS = [ 5 COMPILE_DEPS = [
6 '//lib:CORE_DEPS', 6 '//lib:CORE_DEPS',
......
...@@ -16,7 +16,7 @@ COMPILE_DEPS = [ ...@@ -16,7 +16,7 @@ COMPILE_DEPS = [
16 ] 16 ]
17 17
18 TEST_DEPS = [ 18 TEST_DEPS = [
19 - '//lib:TEST', 19 + '//lib:TEST_ADAPTERS',
20 ] 20 ]
21 21
22 java_library( 22 java_library(
......
...@@ -12,7 +12,9 @@ COMPILE_DEPS = [ ...@@ -12,7 +12,9 @@ COMPILE_DEPS = [
12 ] 12 ]
13 13
14 TEST_DEPS = [ 14 TEST_DEPS = [
15 - '//lib:TEST', 15 + '//lib:TEST_REST',
16 + '//utils/osgi:onlab-osgi-tests',
17 + '//web/api:onos-rest-tests',
16 ] 18 ]
17 19
18 java_library( 20 java_library(
......
...@@ -44,6 +44,13 @@ ...@@ -44,6 +44,13 @@
44 <artifactId>onos-app-vtn-rsc</artifactId> 44 <artifactId>onos-app-vtn-rsc</artifactId>
45 <version>${project.version}</version> 45 <version>${project.version}</version>
46 </dependency> 46 </dependency>
47 + <dependency>
48 + <groupId>org.onosproject</groupId>
49 + <artifactId>onos-rest</artifactId>
50 + <version>${project.version}</version>
51 + <classifier>tests</classifier>
52 + <scope>test</scope>
53 + </dependency>
47 </dependencies> 54 </dependencies>
48 <build> 55 <build>
49 <plugins> 56 <plugins>
...@@ -67,4 +74,4 @@ ...@@ -67,4 +74,4 @@
67 </plugins> 74 </plugins>
68 </build> 75 </build>
69 76
70 -</project>
...\ No newline at end of file ...\ No newline at end of file
77 +</project>
......
...@@ -295,7 +295,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest { ...@@ -295,7 +295,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest {
295 String location = "flow_classifiers/4a334cd4-fe9c-4fae-af4b-321c5e2eb051"; 295 String location = "flow_classifiers/4a334cd4-fe9c-4fae-af4b-321c5e2eb051";
296 296
297 Response deleteResponse = wt.path(location) 297 Response deleteResponse = wt.path(location)
298 - .request(MediaType.APPLICATION_JSON_TYPE) 298 + .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
299 .delete(); 299 .delete();
300 assertThat(deleteResponse.getStatus(), 300 assertThat(deleteResponse.getStatus(),
301 is(HttpURLConnection.HTTP_NO_CONTENT)); 301 is(HttpURLConnection.HTTP_NO_CONTENT));
......
...@@ -279,7 +279,7 @@ public class PortChainResourceTest extends VtnResourceTest { ...@@ -279,7 +279,7 @@ public class PortChainResourceTest extends VtnResourceTest {
279 String location = "port_chains/1278dcd4-459f-62ed-754b-87fc5e4a6751"; 279 String location = "port_chains/1278dcd4-459f-62ed-754b-87fc5e4a6751";
280 280
281 Response deleteResponse = wt.path(location) 281 Response deleteResponse = wt.path(location)
282 - .request(MediaType.APPLICATION_JSON_TYPE) 282 + .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
283 .delete(); 283 .delete();
284 assertThat(deleteResponse.getStatus(), 284 assertThat(deleteResponse.getStatus(),
285 is(HttpURLConnection.HTTP_NO_CONTENT)); 285 is(HttpURLConnection.HTTP_NO_CONTENT));
......
...@@ -239,7 +239,7 @@ public class PortPairGroupResourceTest extends VtnResourceTest { ...@@ -239,7 +239,7 @@ public class PortPairGroupResourceTest extends VtnResourceTest {
239 String location = "port_pair_groups/4512d643-24fc-4fae-af4b-321c5e2eb3d1"; 239 String location = "port_pair_groups/4512d643-24fc-4fae-af4b-321c5e2eb3d1";
240 240
241 Response deleteResponse = wt.path(location) 241 Response deleteResponse = wt.path(location)
242 - .request(MediaType.APPLICATION_JSON_TYPE) 242 + .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
243 .delete(); 243 .delete();
244 assertThat(deleteResponse.getStatus(), 244 assertThat(deleteResponse.getStatus(),
245 is(HttpURLConnection.HTTP_NO_CONTENT)); 245 is(HttpURLConnection.HTTP_NO_CONTENT));
......
...@@ -231,7 +231,7 @@ public class PortPairResourceTest extends VtnResourceTest { ...@@ -231,7 +231,7 @@ public class PortPairResourceTest extends VtnResourceTest {
231 String location = "port_pairs/78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"; 231 String location = "port_pairs/78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae";
232 232
233 Response deleteResponse = wt.path(location) 233 Response deleteResponse = wt.path(location)
234 - .request(MediaType.APPLICATION_JSON_TYPE) 234 + .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
235 .delete(); 235 .delete();
236 assertThat(deleteResponse.getStatus(), 236 assertThat(deleteResponse.getStatus(),
237 is(HttpURLConnection.HTTP_NO_CONTENT)); 237 is(HttpURLConnection.HTTP_NO_CONTENT));
......
...@@ -16,12 +16,12 @@ ...@@ -16,12 +16,12 @@
16 package org.onosproject.vtnweb.resources; 16 package org.onosproject.vtnweb.resources;
17 17
18 import org.glassfish.jersey.server.ResourceConfig; 18 import org.glassfish.jersey.server.ResourceConfig;
19 -import org.glassfish.jersey.test.JerseyTest; 19 +import org.onosproject.rest.resources.ResourceTest;
20 20
21 /** 21 /**
22 * Base class for VTN REST API tests. Performs common configuration operations. 22 * Base class for VTN REST API tests. Performs common configuration operations.
23 */ 23 */
24 -public class VtnResourceTest extends JerseyTest { 24 +public class VtnResourceTest extends ResourceTest {
25 25
26 /** 26 /**
27 * Creates a new web-resource test. 27 * Creates a new web-resource test.
......
...@@ -24,7 +24,7 @@ def osgi_jar( ...@@ -24,7 +24,7 @@ def osgi_jar(
24 name = bare_jar_name, 24 name = bare_jar_name,
25 srcs = srcs, 25 srcs = srcs,
26 deps = deps, 26 deps = deps,
27 - visibility = [], #intentially, not visible 27 + visibility = ['PUBLIC'],
28 **kwargs 28 **kwargs
29 ) 29 )
30 30
......
...@@ -18,8 +18,6 @@ osgi_jar( ...@@ -18,8 +18,6 @@ osgi_jar(
18 name = CURRENT_NAME, 18 name = CURRENT_NAME,
19 srcs = glob([SRC + '/*.java']), 19 srcs = glob([SRC + '/*.java']),
20 deps = COMPILE_DEPS, 20 deps = COMPILE_DEPS,
21 - resources_root = 'src/test/resources',
22 - resources = glob(['src/test/resources/**']),
23 visibility = ['PUBLIC'], 21 visibility = ['PUBLIC'],
24 ) 22 )
25 23
...@@ -31,4 +29,6 @@ java_test( ...@@ -31,4 +29,6 @@ java_test(
31 TEST_DEPS + 29 TEST_DEPS +
32 [CURRENT_TARGET], 30 [CURRENT_TARGET],
33 source_under_test = [CURRENT_TARGET], 31 source_under_test = [CURRENT_TARGET],
32 + resources_root = 'src/test/resources',
33 + resources = glob(['src/test/resources/**']),
34 ) 34 )
......
...@@ -23,6 +23,14 @@ import java.util.concurrent.atomic.AtomicLong; ...@@ -23,6 +23,14 @@ import java.util.concurrent.atomic.AtomicLong;
23 * Mock id generator for testing. 23 * Mock id generator for testing.
24 */ 24 */
25 public class MockIdGenerator implements IdGenerator { 25 public class MockIdGenerator implements IdGenerator {
26 +
27 + private static boolean generatorIsBound = false;
28 + public static void bindNewGenerator() {
29 + if (!generatorIsBound) {
30 + generatorIsBound = true;
31 + Intent.bindIdGenerator(new MockIdGenerator());
32 + }
33 + }
26 private AtomicLong nextId = new AtomicLong(0); 34 private AtomicLong nextId = new AtomicLong(0);
27 35
28 @Override 36 @Override
......
...@@ -9,7 +9,10 @@ COMPILE_DEPS = [ ...@@ -9,7 +9,10 @@ COMPILE_DEPS = [
9 ] 9 ]
10 10
11 TEST_DEPS = [ 11 TEST_DEPS = [
12 - '//lib:TEST', 12 + '//lib:TEST_ADAPTERS',
13 + '//core/common:onos-core-common',
14 + '//core/store/dist:onos-core-dist',
15 + '//core/store/dist:onos-core-dist-tests',
13 ] 16 ]
14 17
15 osgi_jar( 18 osgi_jar(
...@@ -26,4 +29,6 @@ java_test( ...@@ -26,4 +29,6 @@ java_test(
26 TEST_DEPS + 29 TEST_DEPS +
27 [CURRENT_TARGET], 30 [CURRENT_TARGET],
28 source_under_test = [CURRENT_TARGET], 31 source_under_test = [CURRENT_TARGET],
32 + resources_root = 'src/test/resources',
33 + resources = glob(['src/test/resources/**']),
29 ) 34 )
......
...@@ -30,10 +30,11 @@ osgi_jar( ...@@ -30,10 +30,11 @@ osgi_jar(
30 ) 30 )
31 31
32 java_test( 32 java_test(
33 - name= 'tests', 33 + name= 'onos-core-dist-tests',
34 srcs = glob([TEST + '/*.java']), 34 srcs = glob([TEST + '/*.java']),
35 deps = COMPILE_DEPS + 35 deps = COMPILE_DEPS +
36 TEST_DEPS + 36 TEST_DEPS +
37 [CURRENT_TARGET], 37 [CURRENT_TARGET],
38 source_under_test = [CURRENT_TARGET], 38 source_under_test = [CURRENT_TARGET],
39 + visibility = ['PUBLIC'],
39 ) 40 )
......
...@@ -8,7 +8,7 @@ COMPILE_DEPS = [ ...@@ -8,7 +8,7 @@ COMPILE_DEPS = [
8 ] 8 ]
9 9
10 TEST_DEPS = [ 10 TEST_DEPS = [
11 - '//lib:TEST', 11 + '//lib:TEST_ADAPTERS',
12 ] 12 ]
13 13
14 osgi_jar( 14 osgi_jar(
...@@ -19,10 +19,11 @@ osgi_jar( ...@@ -19,10 +19,11 @@ osgi_jar(
19 ) 19 )
20 20
21 java_test( 21 java_test(
22 - name = 'tests', 22 + name = 'onos-incubator-api-tests',
23 srcs = glob([TEST + '/*.java']), 23 srcs = glob([TEST + '/*.java']),
24 deps = COMPILE_DEPS + 24 deps = COMPILE_DEPS +
25 TEST_DEPS + 25 TEST_DEPS +
26 [CURRENT_TARGET], 26 [CURRENT_TARGET],
27 source_under_test = [CURRENT_TARGET], 27 source_under_test = [CURRENT_TARGET],
28 + visibility = ['PUBLIC'],
28 ) 29 )
......
...@@ -9,7 +9,11 @@ COMPILE_DEPS = [ ...@@ -9,7 +9,11 @@ COMPILE_DEPS = [
9 ] 9 ]
10 10
11 TEST_DEPS = [ 11 TEST_DEPS = [
12 - '//lib:TEST', 12 + '//lib:TEST_ADAPTERS',
13 + '//core/api:onos-api-tests',
14 + '//core/common:onos-core-common-tests',
15 + '//incubator/store:onos-incubator-store',
16 + '//core/store/serializers:onos-core-serializers',
13 ] 17 ]
14 18
15 osgi_jar( 19 osgi_jar(
......
1 -SRC = 'src/main/java/org/onosproject/incubator/**/' 1 +SRC = 'src/main/java/org/onosproject/incubator/store/**/'
2 -TEST = 'src/test/java/org/onosproject/incubator/**/' 2 +TEST = 'src/test/java/org/onosproject/incubator/store/**/'
3 CURRENT_NAME = 'onos-incubator-store' 3 CURRENT_NAME = 'onos-incubator-store'
4 CURRENT_TARGET = ':' + CURRENT_NAME 4 CURRENT_TARGET = ':' + CURRENT_NAME
5 5
...@@ -12,7 +12,9 @@ COMPILE_DEPS = [ ...@@ -12,7 +12,9 @@ COMPILE_DEPS = [
12 ] 12 ]
13 13
14 TEST_DEPS = [ 14 TEST_DEPS = [
15 - '//lib:TEST', 15 + '//lib:TEST_ADAPTERS',
16 + '//core/api:onos-api-tests',
17 + '//core/common:onos-core-common-tests',
16 ] 18 ]
17 19
18 osgi_jar( 20 osgi_jar(
......
...@@ -76,6 +76,47 @@ java_library( ...@@ -76,6 +76,47 @@ java_library(
76 ], 76 ],
77 ) 77 )
78 78
79 +java_library(
80 + name = 'TEST_ADAPTERS',
81 + visibility = ['PUBLIC'],
82 + exported_deps = [
83 + ':TEST',
84 + '//core/common:onos-core-common',
85 + '//core/api:onos-api-tests',
86 + '//core/common:onos-core-common-tests',
87 + ],
88 +)
89 +
90 +
91 +java_library(
92 + name = 'TEST_REST',
93 + visibility = ['PUBLIC'],
94 + exported_deps = [
95 + ':TEST_ADAPTERS',
96 + '//lib:jersey-client',
97 + '//lib:jersey-server',
98 + '//lib:jersey-common',
99 + '//lib:jersey-test-framework-core',
100 + '//lib:jersey-test-framework-grizzly2',
101 + '//lib:jersey-guava',
102 + '//lib:hk2-api',
103 + '//lib:hk2-locator',
104 + '//lib:hk2-utils',
105 + '//lib:javax.inject',
106 + '//lib:hk2-osgi-resource-locator',
107 + '//lib:jersey-container-grizzly2-http',
108 + '//lib:grizzly-http-server',
109 + '//lib:grizzly-framework',
110 + '//lib:grizzly-http',
111 + '//lib:javax.annotation-api',
112 + '//lib:validation-api',
113 + '//core/common:onos-core-common',
114 + '//core/api:onos-api-tests',
115 + '//core/common:onos-core-common-tests',
116 + '//utils/osgi:onlab-osgi-tests',
117 + ],
118 +)
119 +
79 maven_jar( 120 maven_jar(
80 name = 'minimal-json', 121 name = 'minimal-json',
81 id = 'com.eclipsesource.minimal-json:minimal-json:0.9.4', 122 id = 'com.eclipsesource.minimal-json:minimal-json:0.9.4',
...@@ -448,16 +489,23 @@ maven_jar( ...@@ -448,16 +489,23 @@ maven_jar(
448 ) 489 )
449 490
450 maven_jar( 491 maven_jar(
451 - name = 'aopalliance-repackaged', 492 + name = 'hk2-locator',
452 - id = 'org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34', 493 + id = 'org.glassfish.hk2:hk2-locator:2.4.0-b34',
453 - sha1 = '3d5e856dbc91a3a2b0bcb3a3424f8b62421ae4cf', 494 + sha1 = '1451fc3e5b7f00d7a5ca0feaff2c1bf68be5ac91',
454 license = 'Apache2.0', 495 license = 'Apache2.0',
455 ) 496 )
456 497
457 maven_jar( 498 maven_jar(
458 - name = 'jersey-guava', 499 + name = 'hk2-utils',
459 - id = 'org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.2', 500 + id = 'org.glassfish.hk2:hk2-utils:2.4.0-b34',
460 - sha1 = '7422c693c89640c9685dfa99dbef2da745aa4617', 501 + sha1 = 'aacce18411fffef9621d8fc91464ca0477119c38',
502 + license = 'Apache2.0',
503 +)
504 +
505 +maven_jar(
506 + name = 'hk2-osgi-resource-locator',
507 + id = 'org.glassfish.hk2:osgi-resource-locator:1.0.1',
508 + sha1 = '4ed2b2d4738aed5786cfa64cba5a332779c4c708',
461 license = 'Apache2.0', 509 license = 'Apache2.0',
462 ) 510 )
463 511
...@@ -468,6 +516,61 @@ maven_jar( ...@@ -468,6 +516,61 @@ maven_jar(
468 license = 'Apache2.0', 516 license = 'Apache2.0',
469 ) 517 )
470 518
519 +maven_jar(
520 + name = 'jersey-container-grizzly2-http',
521 + id = 'org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.2',
522 + sha1 = '7f4f0cb7cfad277a4a6d91298d9f2ac309e4383b',
523 + license = 'Apache2.0',
524 +)
525 +
526 +maven_jar(
527 + name = 'grizzly-http-server',
528 + id = 'org.glassfish.grizzly:grizzly-http-server:2.3.23',
529 + sha1 = '4aaf209163d8dca1bfb1907f19c7fd1f2f3ebbf9',
530 + license = 'Apache2.0',
531 +)
532 +
533 +maven_jar(
534 + name = 'grizzly-http',
535 + id = 'org.glassfish.grizzly:grizzly-http:2.3.23',
536 + sha1 = '287ea2c8a765b14fbc494749570ff3889ecd7b83',
537 + license = 'Apache2.0',
538 +)
539 +
540 +maven_jar(
541 + name = 'grizzly-framework',
542 + id = 'org.glassfish.grizzly:grizzly-framework:2.3.23',
543 + sha1 = '262913b1a7ec4156e7e6aa3f8854a4d1a54940b0',
544 + license = 'Apache2.0',
545 +)
546 +
547 +maven_jar(
548 + name = 'javax.annotation-api',
549 + id = 'javax.annotation:javax.annotation-api:1.2',
550 + sha1 = '479c1e06db31c432330183f5cae684163f186146',
551 + license = 'Apache2.0',
552 +)
553 +
554 +maven_jar(
555 + name = 'validation-api',
556 + id = 'javax.validation:validation-api:1.1.0.Final',
557 + sha1 = '8613ae82954779d518631e05daa73a6a954817d5',
558 + license = 'Apache2.0',
559 +)
560 +
561 +maven_jar(
562 + name = 'aopalliance-repackaged',
563 + id = 'org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34',
564 + sha1 = '3d5e856dbc91a3a2b0bcb3a3424f8b62421ae4cf',
565 + license = 'Apache2.0',
566 +)
567 +
568 +maven_jar(
569 + name = 'jersey-guava',
570 + id = 'org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.2',
571 + sha1 = '7422c693c89640c9685dfa99dbef2da745aa4617',
572 + license = 'Apache2.0',
573 +)
471 574
472 maven_jar( 575 maven_jar(
473 name = 'servlet-api', 576 name = 'servlet-api',
......
...@@ -8,10 +8,11 @@ COMPILE_DEPS = [ ...@@ -8,10 +8,11 @@ COMPILE_DEPS = [
8 '//lib:CORE_DEPS', 8 '//lib:CORE_DEPS',
9 '//protocols/bgp/api:onos-bgp-api', 9 '//protocols/bgp/api:onos-bgp-api',
10 '//protocols/bgp/bgpio:onos-bgpio', 10 '//protocols/bgp/bgpio:onos-bgpio',
11 + '//incubator/store:onos-incubator-store',
11 ] 12 ]
12 13
13 TEST_DEPS = [ 14 TEST_DEPS = [
14 - '//lib:TEST', 15 + '//lib:TEST_ADAPTERS',
15 ] 16 ]
16 17
17 osgi_jar( 18 osgi_jar(
......
...@@ -10,7 +10,7 @@ COMPILE_DEPS = [ ...@@ -10,7 +10,7 @@ COMPILE_DEPS = [
10 ] 10 ]
11 11
12 TEST_DEPS = [ 12 TEST_DEPS = [
13 - '//lib:TEST', 13 + '//lib:TEST_ADAPTERS',
14 ] 14 ]
15 15
16 osgi_jar( 16 osgi_jar(
......
...@@ -10,7 +10,7 @@ COMPILE_DEPS = [ ...@@ -10,7 +10,7 @@ COMPILE_DEPS = [
10 ] 10 ]
11 11
12 TEST_DEPS = [ 12 TEST_DEPS = [
13 - '//lib:TEST', 13 + '//lib:TEST_ADAPTERS',
14 ] 14 ]
15 15
16 osgi_jar( 16 osgi_jar(
......
...@@ -11,7 +11,7 @@ COMPILE_DEPS = [ ...@@ -11,7 +11,7 @@ COMPILE_DEPS = [
11 ] 11 ]
12 12
13 TEST_DEPS = [ 13 TEST_DEPS = [
14 - '//lib:TEST', 14 + '//lib:TEST_ADAPTERS',
15 ] 15 ]
16 16
17 osgi_jar( 17 osgi_jar(
......
...@@ -15,7 +15,7 @@ COMPILE_DEPS = [ ...@@ -15,7 +15,7 @@ COMPILE_DEPS = [
15 ] 15 ]
16 16
17 TEST_DEPS = [ 17 TEST_DEPS = [
18 - '//lib:TEST', 18 + '//lib:TEST_ADAPTERS',
19 ] 19 ]
20 20
21 osgi_jar( 21 osgi_jar(
......
...@@ -19,10 +19,11 @@ osgi_jar( ...@@ -19,10 +19,11 @@ osgi_jar(
19 ) 19 )
20 20
21 java_test( 21 java_test(
22 - name = 'tests', 22 + name = 'onlab-osgi-tests',
23 srcs = glob([TEST + '/*.java']), 23 srcs = glob([TEST + '/*.java']),
24 deps = COMPILE_DEPS + 24 deps = COMPILE_DEPS +
25 TEST_DEPS + 25 TEST_DEPS +
26 [CURRENT_TARGET], 26 [CURRENT_TARGET],
27 source_under_test = [CURRENT_TARGET], 27 source_under_test = [CURRENT_TARGET],
28 + visibility = ['PUBLIC'],
28 ) 29 )
......
...@@ -13,7 +13,7 @@ COMPILE_DEPS = [ ...@@ -13,7 +13,7 @@ COMPILE_DEPS = [
13 ] 13 ]
14 14
15 TEST_DEPS = [ 15 TEST_DEPS = [
16 - '//lib:TEST', 16 + '//lib:TEST_REST',
17 ] 17 ]
18 18
19 osgi_jar( 19 osgi_jar(
...@@ -27,11 +27,15 @@ osgi_jar( ...@@ -27,11 +27,15 @@ osgi_jar(
27 web_context = '/onos/v1' 27 web_context = '/onos/v1'
28 ) 28 )
29 29
30 +SOURCE_JAR = CURRENT_TARGET + '-jar'
30 java_test( 31 java_test(
31 - name = 'tests', 32 + name = 'onos-rest-tests',
32 srcs = glob([TEST + '/*.java']), 33 srcs = glob([TEST + '/*.java']),
33 deps = COMPILE_DEPS + 34 deps = COMPILE_DEPS +
34 TEST_DEPS + 35 TEST_DEPS +
35 - [CURRENT_TARGET], 36 + [SOURCE_JAR],
36 - source_under_test = [CURRENT_TARGET], 37 + source_under_test = [SOURCE_JAR],
38 + visibility = ['PUBLIC'],
39 + resources_root = 'src/test/resources',
40 + resources = glob(['src/test/resources/**']),
37 ) 41 )
......
...@@ -15,10 +15,17 @@ ...@@ -15,10 +15,17 @@
15 */ 15 */
16 package org.onosproject.rest.resources; 16 package org.onosproject.rest.resources;
17 17
18 -import com.eclipsesource.json.Json; 18 +import java.io.InputStream;
19 -import com.eclipsesource.json.JsonArray; 19 +import java.net.HttpURLConnection;
20 -import com.eclipsesource.json.JsonObject; 20 +import java.util.Collections;
21 -import com.eclipsesource.json.JsonValue; 21 +import java.util.HashSet;
22 +
23 +import javax.ws.rs.NotFoundException;
24 +import javax.ws.rs.client.Entity;
25 +import javax.ws.rs.client.WebTarget;
26 +import javax.ws.rs.core.MediaType;
27 +import javax.ws.rs.core.Response;
28 +
22 import org.hamcrest.Description; 29 import org.hamcrest.Description;
23 import org.hamcrest.Matchers; 30 import org.hamcrest.Matchers;
24 import org.hamcrest.TypeSafeMatcher; 31 import org.hamcrest.TypeSafeMatcher;
...@@ -40,17 +47,11 @@ import org.onosproject.net.intent.Intent; ...@@ -40,17 +47,11 @@ import org.onosproject.net.intent.Intent;
40 import org.onosproject.net.intent.IntentService; 47 import org.onosproject.net.intent.IntentService;
41 import org.onosproject.net.intent.IntentState; 48 import org.onosproject.net.intent.IntentState;
42 import org.onosproject.net.intent.Key; 49 import org.onosproject.net.intent.Key;
43 -import org.onosproject.net.intent.MockIdGenerator;
44 50
45 -import javax.ws.rs.NotFoundException; 51 +import com.eclipsesource.json.Json;
46 -import javax.ws.rs.client.Entity; 52 +import com.eclipsesource.json.JsonArray;
47 -import javax.ws.rs.client.WebTarget; 53 +import com.eclipsesource.json.JsonObject;
48 -import javax.ws.rs.core.MediaType; 54 +import com.eclipsesource.json.JsonValue;
49 -import javax.ws.rs.core.Response;
50 -import java.io.InputStream;
51 -import java.net.HttpURLConnection;
52 -import java.util.Collections;
53 -import java.util.HashSet;
54 55
55 import static org.easymock.EasyMock.anyObject; 56 import static org.easymock.EasyMock.anyObject;
56 import static org.easymock.EasyMock.createMock; 57 import static org.easymock.EasyMock.createMock;
...@@ -65,6 +66,7 @@ import static org.hamcrest.Matchers.notNullValue; ...@@ -65,6 +66,7 @@ import static org.hamcrest.Matchers.notNullValue;
65 import static org.junit.Assert.assertThat; 66 import static org.junit.Assert.assertThat;
66 import static org.junit.Assert.fail; 67 import static org.junit.Assert.fail;
67 import static org.onosproject.net.intent.IntentTestsMocks.MockIntent; 68 import static org.onosproject.net.intent.IntentTestsMocks.MockIntent;
69 +import static org.onosproject.net.intent.MockIdGenerator.bindNewGenerator;
68 70
69 /** 71 /**
70 * Unit tests for Intents REST APIs. 72 * Unit tests for Intents REST APIs.
...@@ -255,8 +257,7 @@ public class IntentsResourceTest extends ResourceTest { ...@@ -255,8 +257,7 @@ public class IntentsResourceTest extends ResourceTest {
255 257
256 BaseResource.setServiceDirectory(testDirectory); 258 BaseResource.setServiceDirectory(testDirectory);
257 259
258 - mockGenerator = new MockIdGenerator(); 260 + bindNewGenerator();
259 - Intent.bindIdGenerator(mockGenerator);
260 } 261 }
261 262
262 /** 263 /**
...@@ -265,7 +266,6 @@ public class IntentsResourceTest extends ResourceTest { ...@@ -265,7 +266,6 @@ public class IntentsResourceTest extends ResourceTest {
265 @After 266 @After
266 public void tearDownTest() { 267 public void tearDownTest() {
267 verify(mockIntentService); 268 verify(mockIntentService);
268 - Intent.unbindIdGenerator(mockGenerator);
269 } 269 }
270 270
271 /** 271 /**
...@@ -456,7 +456,7 @@ public class IntentsResourceTest extends ResourceTest { ...@@ -456,7 +456,7 @@ public class IntentsResourceTest extends ResourceTest {
456 WebTarget wt = target(); 456 WebTarget wt = target();
457 457
458 Response response = wt.path("intents/app/0x2") 458 Response response = wt.path("intents/app/0x2")
459 - .request(MediaType.APPLICATION_JSON_TYPE) 459 + .request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN)
460 .delete(); 460 .delete();
461 assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT)); 461 assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
462 } 462 }
...@@ -484,7 +484,7 @@ public class IntentsResourceTest extends ResourceTest { ...@@ -484,7 +484,7 @@ public class IntentsResourceTest extends ResourceTest {
484 WebTarget wt = target(); 484 WebTarget wt = target();
485 485
486 Response response = wt.path("intents/app/0x2") 486 Response response = wt.path("intents/app/0x2")
487 - .request(MediaType.APPLICATION_JSON_TYPE) 487 + .request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN)
488 .delete(); 488 .delete();
489 assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT)); 489 assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
490 } 490 }
......
...@@ -36,6 +36,14 @@ public class ResourceTest extends JerseyTest { ...@@ -36,6 +36,14 @@ public class ResourceTest extends JerseyTest {
36 } 36 }
37 37
38 /** 38 /**
39 + * Creates a new web-resource test.
40 + */
41 + public ResourceTest(ResourceConfig config) {
42 + super(config);
43 + this.set("jersey.config.test.container.port", getRandomPort(DEFAULT_PORT));
44 + }
45 +
46 + /**
39 * Returns an unused port number to make sure that each unit test runs in 47 * Returns an unused port number to make sure that each unit test runs in
40 * different port number. 48 * different port number.
41 * 49 *
......