Fix buck tests

Change-Id: I3d681e6e5c1d3e98c87ccb3d20a619b216ae6133
diff --git a/BUCK b/BUCK
index 2fed8c3..7fd1019 100644
--- a/BUCK
+++ b/BUCK
@@ -160,4 +160,4 @@
     name = 'install',
     visibility = ['PUBLIC'],
     deps = INSTALL
-)
\ No newline at end of file
+)
diff --git a/apps/aaa/BUCK b/apps/aaa/BUCK
index fdccf43..da39409 100644
--- a/apps/aaa/BUCK
+++ b/apps/aaa/BUCK
@@ -11,7 +11,8 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
+    '//core/common:onos-core-common',
 ]
 
 java_library(
diff --git a/apps/acl/BUCK b/apps/acl/BUCK
index 1ee2411..8b509fd 100644
--- a/apps/acl/BUCK
+++ b/apps/acl/BUCK
@@ -12,7 +12,8 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_REST',
+    '//lib:jersey-server',
 ]
 
 java_library(
diff --git a/apps/cpman/api/BUCK b/apps/cpman/api/BUCK
index fb4f6f5..156a545 100644
--- a/apps/cpman/api/BUCK
+++ b/apps/cpman/api/BUCK
@@ -10,7 +10,7 @@
  ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 java_library(
diff --git a/apps/cpman/app/BUCK b/apps/cpman/app/BUCK
index c23153e..7a78bab 100644
--- a/apps/cpman/app/BUCK
+++ b/apps/cpman/app/BUCK
@@ -16,7 +16,8 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_REST',
+    '//web/api:onos-rest-tests',
 ]
 
 java_library(
@@ -33,4 +34,6 @@
            TEST_DEPS +
            [CURRENT_TARGET],
     source_under_test = [CURRENT_TARGET],
+    resources_root = 'src/test/resources',
+    resources = glob(['src/test/resources/**']),
 )
diff --git a/apps/cpman/app/pom.xml b/apps/cpman/app/pom.xml
index 8ec1f1f..25150b7 100644
--- a/apps/cpman/app/pom.xml
+++ b/apps/cpman/app/pom.xml
@@ -154,6 +154,13 @@
             <classifier>tests</classifier>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-rest</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
@@ -181,4 +188,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>
diff --git a/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java b/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java
index 42c73cc..a0ef91c 100644
--- a/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java
+++ b/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java
@@ -15,8 +15,16 @@
  */
 package org.onosproject.cpman.rest;
 
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.util.Optional;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
 import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.test.JerseyTest;
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
@@ -26,14 +34,7 @@
 import org.onosproject.cpman.SystemInfo;
 import org.onosproject.cpman.impl.SystemInfoFactory;
 import org.onosproject.net.DeviceId;
-
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.Optional;
+import org.onosproject.rest.resources.ResourceTest;
 
 import static org.easymock.EasyMock.anyInt;
 import static org.easymock.EasyMock.anyObject;
@@ -48,7 +49,7 @@
 /**
  * Unit test for ControlMetricsCollector.
  */
-public class ControlMetricsCollectorResourceTest extends JerseyTest {
+public class ControlMetricsCollectorResourceTest extends ResourceTest {
 
     final ControlPlaneMonitorService mockControlPlaneMonitorService =
                                      createMock(ControlPlaneMonitorService.class);
diff --git a/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsResourceTest.java b/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsResourceTest.java
index 62e5924..e78d3cd 100644
--- a/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsResourceTest.java
+++ b/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsResourceTest.java
@@ -15,9 +15,12 @@
  */
 package org.onosproject.cpman.rest;
 
-import com.google.common.collect.ImmutableSet;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.client.WebTarget;
+
 import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.test.JerseyTest;
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
@@ -32,10 +35,9 @@
 import org.onosproject.cpman.ControlLoad;
 import org.onosproject.cpman.ControlPlaneMonitorService;
 import org.onosproject.cpman.codec.ControlLoadCodec;
+import org.onosproject.rest.resources.ResourceTest;
 
-import javax.ws.rs.client.WebTarget;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
+import com.google.common.collect.ImmutableSet;
 
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.anyString;
@@ -49,7 +51,7 @@
 /**
  * Unit test for ControlMetrics REST API.
  */
-public class ControlMetricsResourceTest extends JerseyTest {
+public class ControlMetricsResourceTest extends ResourceTest {
 
     final ControlPlaneMonitorService mockControlPlaneMonitorService =
             createMock(ControlPlaneMonitorService.class);
diff --git a/apps/dhcp/app/BUCK b/apps/dhcp/app/BUCK
index 9449e44..5fa8ca7 100644
--- a/apps/dhcp/app/BUCK
+++ b/apps/dhcp/app/BUCK
@@ -15,7 +15,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 java_library(
diff --git a/apps/faultmanagement/BUCK b/apps/faultmanagement/BUCK
index f837268..9d59162 100644
--- a/apps/faultmanagement/BUCK
+++ b/apps/faultmanagement/BUCK
@@ -11,7 +11,11 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
+    '//lib:jersey-test-framework-core',
+    '//lib:jersey-test-framework-grizzly2',
+    '//utils/osgi:onlab-osgi-tests',
+    '//web/api:onos-rest-tests',
 ]
 
 java_library(
diff --git a/apps/flowanalyzer/BUCK b/apps/flowanalyzer/BUCK
index c7ef685..a47701d 100644
--- a/apps/flowanalyzer/BUCK
+++ b/apps/flowanalyzer/BUCK
@@ -11,7 +11,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 java_library(
diff --git a/apps/graphitemetrics/BUCK b/apps/graphitemetrics/BUCK
index aa0a1f6..858d542 100644
--- a/apps/graphitemetrics/BUCK
+++ b/apps/graphitemetrics/BUCK
@@ -12,7 +12,7 @@
 
 TEST_DEPS = [
     '//lib:TEST',
-    '//core/api:onos-api',
+    '//core/api:onos-api-tests',
 ]
 
 java_library(
diff --git a/apps/influxdbmetrics/BUCK b/apps/influxdbmetrics/BUCK
index 5fdf08f..a7305c9 100644
--- a/apps/influxdbmetrics/BUCK
+++ b/apps/influxdbmetrics/BUCK
@@ -13,7 +13,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 java_library(
diff --git a/apps/routing-api/BUCK b/apps/routing-api/BUCK
index ca457c1..35f868d 100644
--- a/apps/routing-api/BUCK
+++ b/apps/routing-api/BUCK
@@ -9,7 +9,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 java_library(
@@ -20,10 +20,11 @@
 )
 
 java_test(
-    name = 'tests',
+    name = 'onos-app-routing-api-tests',
     srcs = glob([TEST + '/*.java']),
     deps = COMPILE_DEPS +
            TEST_DEPS +
            [CURRENT_TARGET],
     source_under_test = [CURRENT_TARGET],
+    visibility = ['PUBLIC'],
 )
diff --git a/apps/routing/BUCK b/apps/routing/BUCK
index 1c69daa..b725adf 100644
--- a/apps/routing/BUCK
+++ b/apps/routing/BUCK
@@ -15,7 +15,9 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
+    '//incubator/api:onos-incubator-api-tests',
+    '//apps/routing-api:onos-app-routing-api-tests',
 ]
 
 java_library(
diff --git a/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java b/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
index 2ed69b4..2d2731a 100644
--- a/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
+++ b/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
@@ -238,9 +238,9 @@
     }
 
     @SuppressWarnings("unchecked")
-    private Dictionary<String, String>
+    private Dictionary
             getDictionaryMock(ComponentContext componentContext) {
-        Dictionary<String, String> dictionary = createMock(Dictionary.class);
+        Dictionary dictionary = createMock(Dictionary.class);
         expect(dictionary.get("bgpPort")).andReturn("0");
         replay(dictionary);
         expect(componentContext.getProperties()).andReturn(dictionary);
@@ -264,7 +264,7 @@
         bgpSessionManager = new BgpSessionManager();
         // NOTE: We use port 0 to bind on any available port
         ComponentContext componentContext = createMock(ComponentContext.class);
-        Dictionary<String, String> dictionary = getDictionaryMock(componentContext);
+        Dictionary dictionary = getDictionaryMock(componentContext);
         replay(componentContext);
         bgpSessionManager.activate(componentContext);
         bgpSessionManager.start(dummyRouteListener);
diff --git a/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java b/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java
index 29c8352..e8b15f9 100644
--- a/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java
+++ b/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java
@@ -131,7 +131,7 @@
 
         //component context
         ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
-        Dictionary<String, Boolean> properties = null;
+        Dictionary properties = null;
         expect(mockContext.getProperties()).andReturn(properties);
         replay(mockContext);
 
diff --git a/apps/sdnip/BUCK b/apps/sdnip/BUCK
index e7d4796..9fdb1c4 100644
--- a/apps/sdnip/BUCK
+++ b/apps/sdnip/BUCK
@@ -11,7 +11,9 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
+    '//incubator/api:onos-incubator-api-tests',
+    '//apps/routing-api:onos-app-routing-api-tests',
 ]
 
 java_library(
diff --git a/apps/segmentrouting/BUCK b/apps/segmentrouting/BUCK
index ed46955..5f27c94 100644
--- a/apps/segmentrouting/BUCK
+++ b/apps/segmentrouting/BUCK
@@ -16,7 +16,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 java_library(
@@ -35,4 +35,6 @@
            TEST_DEPS +
            [CURRENT_TARGET],
     source_under_test = [CURRENT_TARGET],
+    resources_root = 'src/test/resources',
+    resources = glob(['src/test/resources/**']),
 )
diff --git a/apps/test/BUCK b/apps/test/BUCK
index 822f341..8e97d9b 100644
--- a/apps/test/BUCK
+++ b/apps/test/BUCK
@@ -1,6 +1,6 @@
 SRC = 'src/main/java/org/onosproject/**/'
 #FIXME there are some tests in main
-TEST = 'src/main/java/org/onosproject/**/'
+TEST = 'src/test/java/org/onosproject/**/'
 
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
diff --git a/apps/vpls/BUCK b/apps/vpls/BUCK
index baa88df..fe84ee8 100644
--- a/apps/vpls/BUCK
+++ b/apps/vpls/BUCK
@@ -16,7 +16,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 java_library(
diff --git a/apps/vtn/BUCK b/apps/vtn/BUCK
index 2b41c08..c12f5d9 100644
--- a/apps/vtn/BUCK
+++ b/apps/vtn/BUCK
@@ -12,7 +12,9 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_REST',
+    '//utils/osgi:onlab-osgi-tests',
+    '//web/api:onos-rest-tests',
 ]
 
 java_library(
diff --git a/apps/vtn/vtnweb/pom.xml b/apps/vtn/vtnweb/pom.xml
index ab0e6cf..9bf48da 100644
--- a/apps/vtn/vtnweb/pom.xml
+++ b/apps/vtn/vtnweb/pom.xml
@@ -44,6 +44,13 @@
             <artifactId>onos-app-vtn-rsc</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-rest</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -67,4 +74,4 @@
         </plugins>
     </build>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/FlowClassifierResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/FlowClassifierResourceTest.java
index 4ce8e7b..10b156b 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/FlowClassifierResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/FlowClassifierResourceTest.java
@@ -295,7 +295,7 @@
         String location = "flow_classifiers/4a334cd4-fe9c-4fae-af4b-321c5e2eb051";
 
         Response deleteResponse = wt.path(location)
-                .request(MediaType.APPLICATION_JSON_TYPE)
+                .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
                 .delete();
         assertThat(deleteResponse.getStatus(),
                    is(HttpURLConnection.HTTP_NO_CONTENT));
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainResourceTest.java
index 6fa7933..4ce996d 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainResourceTest.java
@@ -279,7 +279,7 @@
         String location = "port_chains/1278dcd4-459f-62ed-754b-87fc5e4a6751";
 
         Response deleteResponse = wt.path(location)
-                .request(MediaType.APPLICATION_JSON_TYPE)
+                .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
                 .delete();
         assertThat(deleteResponse.getStatus(),
                    is(HttpURLConnection.HTTP_NO_CONTENT));
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairGroupResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairGroupResourceTest.java
index b631def..5baa3a9 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairGroupResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairGroupResourceTest.java
@@ -239,7 +239,7 @@
         String location = "port_pair_groups/4512d643-24fc-4fae-af4b-321c5e2eb3d1";
 
         Response deleteResponse = wt.path(location)
-                .request(MediaType.APPLICATION_JSON_TYPE)
+                .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
                 .delete();
         assertThat(deleteResponse.getStatus(),
                    is(HttpURLConnection.HTTP_NO_CONTENT));
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairResourceTest.java
index e436bbe..7335406 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairResourceTest.java
@@ -231,7 +231,7 @@
         String location = "port_pairs/78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae";
 
         Response deleteResponse = wt.path(location)
-                .request(MediaType.APPLICATION_JSON_TYPE)
+                .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
                 .delete();
         assertThat(deleteResponse.getStatus(),
                    is(HttpURLConnection.HTTP_NO_CONTENT));
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/VtnResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/VtnResourceTest.java
index af9c15b..cd2ec05 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/VtnResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/VtnResourceTest.java
@@ -16,12 +16,12 @@
 package org.onosproject.vtnweb.resources;
 
 import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.test.JerseyTest;
+import org.onosproject.rest.resources.ResourceTest;
 
 /**
  * Base class for VTN REST API tests.  Performs common configuration operations.
  */
-public class VtnResourceTest extends JerseyTest {
+public class VtnResourceTest extends ResourceTest {
 
     /**
      * Creates a new web-resource test.
diff --git a/bucklets/onos.bucklet b/bucklets/onos.bucklet
index c7837b3..ee4b17d 100644
--- a/bucklets/onos.bucklet
+++ b/bucklets/onos.bucklet
@@ -24,7 +24,7 @@
       name = bare_jar_name,
       srcs = srcs,
       deps = deps,
-      visibility = [], #intentially, not visible
+      visibility = ['PUBLIC'],
       **kwargs
   )
 
diff --git a/core/api/BUCK b/core/api/BUCK
index f4d5eb7..2ba9801 100644
--- a/core/api/BUCK
+++ b/core/api/BUCK
@@ -18,8 +18,6 @@
     name = CURRENT_NAME,
     srcs = glob([SRC + '/*.java']),
     deps = COMPILE_DEPS,
-    resources_root = 'src/test/resources',
-    resources = glob(['src/test/resources/**']),
     visibility = ['PUBLIC'],
 )
 
@@ -31,4 +29,6 @@
            TEST_DEPS +
            [CURRENT_TARGET],
     source_under_test = [CURRENT_TARGET],
+    resources_root = 'src/test/resources',
+    resources = glob(['src/test/resources/**']),
 )
diff --git a/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java b/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java
index 5e84cd8..433a201 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java
@@ -23,6 +23,14 @@
  * Mock id generator for testing.
  */
 public class MockIdGenerator implements IdGenerator {
+
+    private static boolean generatorIsBound = false;
+    public static void bindNewGenerator() {
+        if (!generatorIsBound) {
+            generatorIsBound = true;
+            Intent.bindIdGenerator(new MockIdGenerator());
+        }
+    }
     private AtomicLong nextId = new AtomicLong(0);
 
     @Override
diff --git a/core/net/BUCK b/core/net/BUCK
index 07139f9..bffb300 100644
--- a/core/net/BUCK
+++ b/core/net/BUCK
@@ -9,7 +9,10 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
+    '//core/common:onos-core-common',
+    '//core/store/dist:onos-core-dist',
+    '//core/store/dist:onos-core-dist-tests',
 ]
 
 osgi_jar(
@@ -26,4 +29,6 @@
            TEST_DEPS +
            [CURRENT_TARGET],
     source_under_test = [CURRENT_TARGET],
+    resources_root = 'src/test/resources',
+    resources = glob(['src/test/resources/**']),
 )
diff --git a/core/store/dist/BUCK b/core/store/dist/BUCK
index c9bd95c..6c56b3f 100644
--- a/core/store/dist/BUCK
+++ b/core/store/dist/BUCK
@@ -30,10 +30,11 @@
 )
 
 java_test(
-    name= 'tests',
+    name= 'onos-core-dist-tests',
     srcs = glob([TEST + '/*.java']),
     deps = COMPILE_DEPS +
            TEST_DEPS +
            [CURRENT_TARGET],
     source_under_test = [CURRENT_TARGET],
+    visibility = ['PUBLIC'],
 )
diff --git a/incubator/api/BUCK b/incubator/api/BUCK
index e1d3ede..ac2ce6c 100644
--- a/incubator/api/BUCK
+++ b/incubator/api/BUCK
@@ -8,7 +8,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 osgi_jar(
@@ -19,10 +19,11 @@
 )
 
 java_test(
-    name = 'tests',
+    name = 'onos-incubator-api-tests',
     srcs = glob([TEST + '/*.java']),
     deps = COMPILE_DEPS +
            TEST_DEPS +
            [CURRENT_TARGET],
     source_under_test = [CURRENT_TARGET],
+    visibility = ['PUBLIC'],
 )
diff --git a/incubator/net/BUCK b/incubator/net/BUCK
index 430f32d..28ee974 100644
--- a/incubator/net/BUCK
+++ b/incubator/net/BUCK
@@ -9,7 +9,11 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
+    '//core/api:onos-api-tests',
+    '//core/common:onos-core-common-tests',
+    '//incubator/store:onos-incubator-store',
+    '//core/store/serializers:onos-core-serializers',
 ]
 
 osgi_jar(
diff --git a/incubator/store/BUCK b/incubator/store/BUCK
index afc1908..d117f29 100644
--- a/incubator/store/BUCK
+++ b/incubator/store/BUCK
@@ -1,5 +1,5 @@
-SRC = 'src/main/java/org/onosproject/incubator/**/'
-TEST = 'src/test/java/org/onosproject/incubator/**/'
+SRC = 'src/main/java/org/onosproject/incubator/store/**/'
+TEST = 'src/test/java/org/onosproject/incubator/store/**/'
 CURRENT_NAME = 'onos-incubator-store'
 CURRENT_TARGET = ':' + CURRENT_NAME
 
@@ -12,7 +12,9 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
+    '//core/api:onos-api-tests',
+    '//core/common:onos-core-common-tests',
 ]
 
 osgi_jar(
diff --git a/lib/BUCK b/lib/BUCK
index 0826537..5899d81 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -76,6 +76,47 @@
   ],
 )
 
+java_library(
+  name = 'TEST_ADAPTERS',
+  visibility = ['PUBLIC'],
+  exported_deps = [
+    ':TEST',
+    '//core/common:onos-core-common',
+    '//core/api:onos-api-tests',
+    '//core/common:onos-core-common-tests',
+  ],
+)
+
+
+java_library(
+  name = 'TEST_REST',
+  visibility = ['PUBLIC'],
+  exported_deps = [
+    ':TEST_ADAPTERS',
+    '//lib:jersey-client',
+    '//lib:jersey-server',
+    '//lib:jersey-common',
+    '//lib:jersey-test-framework-core',
+    '//lib:jersey-test-framework-grizzly2',
+    '//lib:jersey-guava',
+    '//lib:hk2-api',
+    '//lib:hk2-locator',
+    '//lib:hk2-utils',
+    '//lib:javax.inject',
+    '//lib:hk2-osgi-resource-locator',
+    '//lib:jersey-container-grizzly2-http',
+    '//lib:grizzly-http-server',
+    '//lib:grizzly-framework',
+    '//lib:grizzly-http',
+    '//lib:javax.annotation-api',
+    '//lib:validation-api',
+    '//core/common:onos-core-common',
+    '//core/api:onos-api-tests',
+    '//core/common:onos-core-common-tests',
+    '//utils/osgi:onlab-osgi-tests',
+  ],
+)
+
 maven_jar(
   name = 'minimal-json',
   id = 'com.eclipsesource.minimal-json:minimal-json:0.9.4',
@@ -448,6 +489,76 @@
 )
 
 maven_jar(
+  name = 'hk2-locator',
+  id = 'org.glassfish.hk2:hk2-locator:2.4.0-b34',
+  sha1 = '1451fc3e5b7f00d7a5ca0feaff2c1bf68be5ac91',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'hk2-utils',
+  id = 'org.glassfish.hk2:hk2-utils:2.4.0-b34',
+  sha1 = 'aacce18411fffef9621d8fc91464ca0477119c38',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'hk2-osgi-resource-locator',
+  id = 'org.glassfish.hk2:osgi-resource-locator:1.0.1',
+  sha1 = '4ed2b2d4738aed5786cfa64cba5a332779c4c708',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'javax.inject',
+  id = 'org.glassfish.hk2.external:javax.inject:2.4.0-b34',
+  sha1 = 'a6a3d4935af7b03e44126b5aac2c2a0ce98fe6e9',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'jersey-container-grizzly2-http',
+  id = 'org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.2',
+  sha1 = '7f4f0cb7cfad277a4a6d91298d9f2ac309e4383b',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'grizzly-http-server',
+  id = 'org.glassfish.grizzly:grizzly-http-server:2.3.23',
+  sha1 = '4aaf209163d8dca1bfb1907f19c7fd1f2f3ebbf9',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'grizzly-http',
+  id = 'org.glassfish.grizzly:grizzly-http:2.3.23',
+  sha1 = '287ea2c8a765b14fbc494749570ff3889ecd7b83',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'grizzly-framework',
+  id = 'org.glassfish.grizzly:grizzly-framework:2.3.23',
+  sha1 = '262913b1a7ec4156e7e6aa3f8854a4d1a54940b0',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'javax.annotation-api',
+  id = 'javax.annotation:javax.annotation-api:1.2',
+  sha1 = '479c1e06db31c432330183f5cae684163f186146',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'validation-api',
+  id = 'javax.validation:validation-api:1.1.0.Final',
+  sha1 = '8613ae82954779d518631e05daa73a6a954817d5',
+  license = 'Apache2.0',
+)
+
+maven_jar(
   name = 'aopalliance-repackaged',
   id = 'org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34',
   sha1 = '3d5e856dbc91a3a2b0bcb3a3424f8b62421ae4cf',
@@ -462,14 +573,6 @@
 )
 
 maven_jar(
-  name = 'javax.inject',
-  id = 'org.glassfish.hk2.external:javax.inject:2.4.0-b34',
-  sha1 = 'a6a3d4935af7b03e44126b5aac2c2a0ce98fe6e9',
-  license = 'Apache2.0',
-)
-
-
-maven_jar(
   name = 'servlet-api',
   id = 'javax.servlet:servlet-api:2.5',
   sha1 = '5959582d97d8b61f4d154ca9e495aafd16726e34',
diff --git a/providers/bgp/topology/BUCK b/providers/bgp/topology/BUCK
index 59e56f6..3d3aad6 100644
--- a/providers/bgp/topology/BUCK
+++ b/providers/bgp/topology/BUCK
@@ -8,10 +8,11 @@
     '//lib:CORE_DEPS',
     '//protocols/bgp/api:onos-bgp-api',
     '//protocols/bgp/bgpio:onos-bgpio',
+    '//incubator/store:onos-incubator-store',
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 osgi_jar(
diff --git a/providers/lldp/BUCK b/providers/lldp/BUCK
index 3e40240..ce40918 100644
--- a/providers/lldp/BUCK
+++ b/providers/lldp/BUCK
@@ -10,7 +10,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 osgi_jar(
diff --git a/providers/netcfglinks/BUCK b/providers/netcfglinks/BUCK
index e30244e..78866ad 100644
--- a/providers/netcfglinks/BUCK
+++ b/providers/netcfglinks/BUCK
@@ -10,7 +10,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 osgi_jar(
diff --git a/providers/openflow/device/BUCK b/providers/openflow/device/BUCK
index 56244d1..4b87aa4 100644
--- a/providers/openflow/device/BUCK
+++ b/providers/openflow/device/BUCK
@@ -11,7 +11,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 osgi_jar(
diff --git a/providers/pcep/tunnel/BUCK b/providers/pcep/tunnel/BUCK
index f98afa9..3bf97b6 100644
--- a/providers/pcep/tunnel/BUCK
+++ b/providers/pcep/tunnel/BUCK
@@ -15,7 +15,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_ADAPTERS',
 ]
 
 osgi_jar(
diff --git a/utils/osgi/BUCK b/utils/osgi/BUCK
index ef9ac97..a661069 100644
--- a/utils/osgi/BUCK
+++ b/utils/osgi/BUCK
@@ -19,10 +19,11 @@
 )
 
 java_test(
-  name = 'tests',
+  name = 'onlab-osgi-tests',
   srcs = glob([TEST + '/*.java']),
   deps = COMPILE_DEPS +
          TEST_DEPS +
          [CURRENT_TARGET],
   source_under_test = [CURRENT_TARGET],
+  visibility = ['PUBLIC'],
 )
diff --git a/web/api/BUCK b/web/api/BUCK
index bf2d6c3..2b1d0fb 100644
--- a/web/api/BUCK
+++ b/web/api/BUCK
@@ -13,7 +13,7 @@
 ]
 
 TEST_DEPS = [
-    '//lib:TEST',
+    '//lib:TEST_REST',
 ]
 
 osgi_jar(
@@ -27,11 +27,15 @@
     web_context = '/onos/v1'
 )
 
+SOURCE_JAR = CURRENT_TARGET + '-jar'
 java_test(
-    name = 'tests',
+    name = 'onos-rest-tests',
     srcs = glob([TEST + '/*.java']),
     deps = COMPILE_DEPS +
            TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+           [SOURCE_JAR],
+    source_under_test = [SOURCE_JAR],
+    visibility = ['PUBLIC'],
+    resources_root = 'src/test/resources',
+    resources = glob(['src/test/resources/**']),
 )
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/IntentsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/IntentsResourceTest.java
index 16abe70..a52d72e 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/IntentsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/IntentsResourceTest.java
@@ -15,10 +15,17 @@
  */
 package org.onosproject.rest.resources;
 
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonArray;
-import com.eclipsesource.json.JsonObject;
-import com.eclipsesource.json.JsonValue;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.HashSet;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
 import org.hamcrest.Description;
 import org.hamcrest.Matchers;
 import org.hamcrest.TypeSafeMatcher;
@@ -40,17 +47,11 @@
 import org.onosproject.net.intent.IntentService;
 import org.onosproject.net.intent.IntentState;
 import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.MockIdGenerator;
 
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.Collections;
-import java.util.HashSet;
+import com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonArray;
+import com.eclipsesource.json.JsonObject;
+import com.eclipsesource.json.JsonValue;
 
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.createMock;
@@ -65,6 +66,7 @@
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 import static org.onosproject.net.intent.IntentTestsMocks.MockIntent;
+import static org.onosproject.net.intent.MockIdGenerator.bindNewGenerator;
 
 /**
  * Unit tests for Intents REST APIs.
@@ -255,8 +257,7 @@
 
         BaseResource.setServiceDirectory(testDirectory);
 
-        mockGenerator = new MockIdGenerator();
-        Intent.bindIdGenerator(mockGenerator);
+        bindNewGenerator();
     }
 
     /**
@@ -265,7 +266,6 @@
     @After
     public void tearDownTest() {
         verify(mockIntentService);
-        Intent.unbindIdGenerator(mockGenerator);
     }
 
     /**
@@ -456,7 +456,7 @@
         WebTarget wt = target();
 
         Response response = wt.path("intents/app/0x2")
-                .request(MediaType.APPLICATION_JSON_TYPE)
+                .request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN)
                 .delete();
         assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
     }
@@ -484,7 +484,7 @@
         WebTarget wt = target();
 
         Response response = wt.path("intents/app/0x2")
-                .request(MediaType.APPLICATION_JSON_TYPE)
+                .request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN)
                 .delete();
         assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
     }
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/ResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/ResourceTest.java
index 465f25c..7a93eac 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/ResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/ResourceTest.java
@@ -36,6 +36,14 @@
     }
 
     /**
+     * Creates a new web-resource test.
+     */
+    public ResourceTest(ResourceConfig config) {
+        super(config);
+        this.set("jersey.config.test.container.port", getRandomPort(DEFAULT_PORT));
+    }
+
+    /**
      * Returns an unused port number to make sure that each unit test runs in
      * different port number.
      *