Fix buck tests

Change-Id: I3d681e6e5c1d3e98c87ccb3d20a619b216ae6133
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.