Ray Milkey

Fix buck tests

Change-Id: I3d681e6e5c1d3e98c87ccb3d20a619b216ae6133
Showing 46 changed files with 265 additions and 92 deletions
......@@ -160,4 +160,4 @@ java_library(
name = 'install',
visibility = ['PUBLIC'],
deps = INSTALL
)
\ No newline at end of file
)
......
......@@ -11,7 +11,8 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
'//core/common:onos-core-common',
]
java_library(
......
......@@ -12,7 +12,8 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_REST',
'//lib:jersey-server',
]
java_library(
......
......@@ -10,7 +10,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
java_library(
......
......@@ -16,7 +16,8 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_REST',
'//web/api:onos-rest-tests',
]
java_library(
......@@ -33,4 +34,6 @@ java_test(
TEST_DEPS +
[CURRENT_TARGET],
source_under_test = [CURRENT_TARGET],
resources_root = 'src/test/resources',
resources = glob(['src/test/resources/**']),
)
......
......@@ -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>
......
......@@ -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.ControlPlaneMonitorService;
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 @@ import static org.junit.Assert.assertThat;
/**
* Unit test for ControlMetricsCollector.
*/
public class ControlMetricsCollectorResourceTest extends JerseyTest {
public class ControlMetricsCollectorResourceTest extends ResourceTest {
final ControlPlaneMonitorService mockControlPlaneMonitorService =
createMock(ControlPlaneMonitorService.class);
......
......@@ -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.codec.impl.CodecManager;
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 @@ import static org.junit.Assert.assertThat;
/**
* Unit test for ControlMetrics REST API.
*/
public class ControlMetricsResourceTest extends JerseyTest {
public class ControlMetricsResourceTest extends ResourceTest {
final ControlPlaneMonitorService mockControlPlaneMonitorService =
createMock(ControlPlaneMonitorService.class);
......
......@@ -15,7 +15,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
java_library(
......
......@@ -11,7 +11,11 @@ COMPILE_DEPS = [
]
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(
......
......@@ -11,7 +11,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
java_library(
......
......@@ -12,7 +12,7 @@ COMPILE_DEPS = [
TEST_DEPS = [
'//lib:TEST',
'//core/api:onos-api',
'//core/api:onos-api-tests',
]
java_library(
......
......@@ -13,7 +13,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
java_library(
......
......@@ -9,7 +9,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
java_library(
......@@ -20,10 +20,11 @@ java_library(
)
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'],
)
......
......@@ -15,7 +15,9 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
'//incubator/api:onos-incubator-api-tests',
'//apps/routing-api:onos-app-routing-api-tests',
]
java_library(
......
......@@ -238,9 +238,9 @@ public class BgpSessionManagerTest {
}
@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 @@ public class BgpSessionManagerTest {
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);
......
......@@ -131,7 +131,7 @@ public class SingleSwitchFibInstallerTest extends AbstractIntentTest {
//component context
ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
Dictionary<String, Boolean> properties = null;
Dictionary properties = null;
expect(mockContext.getProperties()).andReturn(properties);
replay(mockContext);
......
......@@ -11,7 +11,9 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
'//incubator/api:onos-incubator-api-tests',
'//apps/routing-api:onos-app-routing-api-tests',
]
java_library(
......
......@@ -16,7 +16,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
java_library(
......@@ -35,4 +35,6 @@ java_test(
TEST_DEPS +
[CURRENT_TARGET],
source_under_test = [CURRENT_TARGET],
resources_root = 'src/test/resources',
resources = glob(['src/test/resources/**']),
)
......
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',
......
......@@ -16,7 +16,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
java_library(
......
......@@ -12,7 +12,9 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_REST',
'//utils/osgi:onlab-osgi-tests',
'//web/api:onos-rest-tests',
]
java_library(
......
......@@ -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>
......
......@@ -295,7 +295,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest {
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));
......
......@@ -279,7 +279,7 @@ public class PortChainResourceTest extends VtnResourceTest {
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));
......
......@@ -239,7 +239,7 @@ public class PortPairGroupResourceTest extends VtnResourceTest {
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));
......
......@@ -231,7 +231,7 @@ public class PortPairResourceTest extends VtnResourceTest {
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));
......
......@@ -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.
......
......@@ -24,7 +24,7 @@ def osgi_jar(
name = bare_jar_name,
srcs = srcs,
deps = deps,
visibility = [], #intentially, not visible
visibility = ['PUBLIC'],
**kwargs
)
......
......@@ -18,8 +18,6 @@ osgi_jar(
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 @@ java_test(
TEST_DEPS +
[CURRENT_TARGET],
source_under_test = [CURRENT_TARGET],
resources_root = 'src/test/resources',
resources = glob(['src/test/resources/**']),
)
......
......@@ -23,6 +23,14 @@ import java.util.concurrent.atomic.AtomicLong;
* 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
......
......@@ -9,7 +9,10 @@ COMPILE_DEPS = [
]
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 @@ java_test(
TEST_DEPS +
[CURRENT_TARGET],
source_under_test = [CURRENT_TARGET],
resources_root = 'src/test/resources',
resources = glob(['src/test/resources/**']),
)
......
......@@ -30,10 +30,11 @@ osgi_jar(
)
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'],
)
......
......@@ -8,7 +8,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
osgi_jar(
......@@ -19,10 +19,11 @@ osgi_jar(
)
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'],
)
......
......@@ -9,7 +9,11 @@ COMPILE_DEPS = [
]
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(
......
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 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
'//core/api:onos-api-tests',
'//core/common:onos-core-common-tests',
]
osgi_jar(
......
......@@ -76,6 +76,47 @@ java_library(
],
)
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,16 +489,23 @@ maven_jar(
)
maven_jar(
name = 'aopalliance-repackaged',
id = 'org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34',
sha1 = '3d5e856dbc91a3a2b0bcb3a3424f8b62421ae4cf',
name = 'hk2-locator',
id = 'org.glassfish.hk2:hk2-locator:2.4.0-b34',
sha1 = '1451fc3e5b7f00d7a5ca0feaff2c1bf68be5ac91',
license = 'Apache2.0',
)
maven_jar(
name = 'jersey-guava',
id = 'org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.2',
sha1 = '7422c693c89640c9685dfa99dbef2da745aa4617',
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',
)
......@@ -468,6 +516,61 @@ maven_jar(
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',
license = 'Apache2.0',
)
maven_jar(
name = 'jersey-guava',
id = 'org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.2',
sha1 = '7422c693c89640c9685dfa99dbef2da745aa4617',
license = 'Apache2.0',
)
maven_jar(
name = 'servlet-api',
......
......@@ -8,10 +8,11 @@ COMPILE_DEPS = [
'//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(
......
......@@ -10,7 +10,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
osgi_jar(
......
......@@ -10,7 +10,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
osgi_jar(
......
......@@ -11,7 +11,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
osgi_jar(
......
......@@ -15,7 +15,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_ADAPTERS',
]
osgi_jar(
......
......@@ -19,10 +19,11 @@ osgi_jar(
)
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'],
)
......
......@@ -13,7 +13,7 @@ COMPILE_DEPS = [
]
TEST_DEPS = [
'//lib:TEST',
'//lib:TEST_REST',
]
osgi_jar(
......@@ -27,11 +27,15 @@ osgi_jar(
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/**']),
)
......
......@@ -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.Intent;
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.hamcrest.Matchers.notNullValue;
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 @@ public class IntentsResourceTest extends ResourceTest {
BaseResource.setServiceDirectory(testDirectory);
mockGenerator = new MockIdGenerator();
Intent.bindIdGenerator(mockGenerator);
bindNewGenerator();
}
/**
......@@ -265,7 +266,6 @@ public class IntentsResourceTest extends ResourceTest {
@After
public void tearDownTest() {
verify(mockIntentService);
Intent.unbindIdGenerator(mockGenerator);
}
/**
......@@ -456,7 +456,7 @@ public class IntentsResourceTest extends ResourceTest {
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 @@ public class IntentsResourceTest extends ResourceTest {
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));
}
......
......@@ -36,6 +36,14 @@ public class ResourceTest extends JerseyTest {
}
/**
* 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.
*
......