Removed the setServiceDirectory() method from the base web resource
This is a testing only API and potentially dangerous to allow to be public.
I modified the tests that use it to set the value using TestUtils.setField()
Change-Id: Ic590f4641f4e3de208dffa16b3df9a9a2106114b
diff --git a/apps/acl/src/test/java/org/onosproject/acl/AclWebResourceTest.java b/apps/acl/src/test/java/org/onosproject/acl/AclWebResourceTest.java
index 897e8b4..003cf8c 100644
--- a/apps/acl/src/test/java/org/onosproject/acl/AclWebResourceTest.java
+++ b/apps/acl/src/test/java/org/onosproject/acl/AclWebResourceTest.java
@@ -27,6 +27,7 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.onlab.junit.TestUtils;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.rest.BaseResource;
@@ -65,7 +66,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(AclService.class, mockAclService)
.add(AclStore.class, mockAclStore);
- BaseResource.setServiceDirectory(testDirectory);
+ TestUtils.setField(BaseResource.class, "services", testDirectory);
AclRule.idGenerator = new MockIdGenerator();
}
diff --git a/apps/cfm/src/test/java/org/onosproject/cfm/impl/MaWebResourceTest.java b/apps/cfm/src/test/java/org/onosproject/cfm/impl/MaWebResourceTest.java
index 6378ea9..8216dde 100644
--- a/apps/cfm/src/test/java/org/onosproject/cfm/impl/MaWebResourceTest.java
+++ b/apps/cfm/src/test/java/org/onosproject/cfm/impl/MaWebResourceTest.java
@@ -22,7 +22,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.VlanId;
-import org.onlab.rest.BaseResource;
import org.onosproject.cfm.CfmCodecContext;
import org.onosproject.codec.CodecService;
import org.onosproject.incubator.net.l2monitoring.cfm.Component;
@@ -43,7 +42,6 @@
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
-
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -72,7 +70,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(CfmMdService.class, mdService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
ma1 = DefaultMaintenanceAssociation
.builder(MANAME1, MDNAME1.getNameLength())
diff --git a/apps/cfm/src/test/java/org/onosproject/cfm/impl/MdWebResourceTest.java b/apps/cfm/src/test/java/org/onosproject/cfm/impl/MdWebResourceTest.java
index f4c9b5a..3c65176 100644
--- a/apps/cfm/src/test/java/org/onosproject/cfm/impl/MdWebResourceTest.java
+++ b/apps/cfm/src/test/java/org/onosproject/cfm/impl/MdWebResourceTest.java
@@ -21,7 +21,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.cfm.CfmCodecContext;
import org.onosproject.codec.CodecService;
import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain;
@@ -65,7 +64,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(CfmMdService.class, mdService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
mdList = new ArrayList<>();
diff --git a/apps/cfm/src/test/java/org/onosproject/cfm/impl/MepWebResourceTest.java b/apps/cfm/src/test/java/org/onosproject/cfm/impl/MepWebResourceTest.java
index 4dd83db..fde5428 100644
--- a/apps/cfm/src/test/java/org/onosproject/cfm/impl/MepWebResourceTest.java
+++ b/apps/cfm/src/test/java/org/onosproject/cfm/impl/MepWebResourceTest.java
@@ -22,7 +22,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.VlanId;
-import org.onlab.rest.BaseResource;
import org.onosproject.cfm.CfmCodecContext;
import org.onosproject.codec.CodecService;
import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation;
@@ -86,7 +85,7 @@
.add(CfmMepService.class, mepService)
.add(CfmMdService.class, mdService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
mepEntry1 = DefaultMepEntry.builder(
MEPID1,
diff --git a/apps/cfm/src/test/java/org/onosproject/soam/impl/DmWebResourceTest.java b/apps/cfm/src/test/java/org/onosproject/soam/impl/DmWebResourceTest.java
index 702bc09..6fac3a3 100644
--- a/apps/cfm/src/test/java/org/onosproject/soam/impl/DmWebResourceTest.java
+++ b/apps/cfm/src/test/java/org/onosproject/soam/impl/DmWebResourceTest.java
@@ -21,7 +21,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.cfm.CfmCodecContext;
import org.onosproject.cfm.impl.CfmResourceTest;
import org.onosproject.codec.CodecService;
@@ -50,7 +49,6 @@
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
-
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -61,7 +59,9 @@
import java.util.List;
import static junit.framework.TestCase.fail;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@@ -88,7 +88,7 @@
.add(CfmMepService.class, mepService)
.add(SoamService.class, soamService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
DelayMeasurementStatCurrent.DmStatCurrentBuilder dmCurrBuilder1 =
(DelayMeasurementStatCurrent.DmStatCurrentBuilder)
diff --git a/apps/cfm/src/test/java/org/onosproject/soam/impl/LmWebResourceTest.java b/apps/cfm/src/test/java/org/onosproject/soam/impl/LmWebResourceTest.java
index 9dd70e6..44b4960 100644
--- a/apps/cfm/src/test/java/org/onosproject/soam/impl/LmWebResourceTest.java
+++ b/apps/cfm/src/test/java/org/onosproject/soam/impl/LmWebResourceTest.java
@@ -21,7 +21,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.cfm.CfmCodecContext;
import org.onosproject.cfm.impl.CfmResourceTest;
import org.onosproject.codec.CodecService;
@@ -87,7 +86,7 @@
.add(CfmMepService.class, mepService)
.add(SoamService.class, soamService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
lm1 = DefaultLmEntry.builder(
DelayMeasurementCreate.Version.Y17312008,
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 b505cd5..a225113 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
@@ -32,7 +32,6 @@
import org.onlab.metrics.MetricsService;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.cpman.ControlPlaneMonitorService;
import org.onosproject.cpman.SystemInfo;
import org.onosproject.cpman.impl.SystemInfoFactory;
@@ -86,7 +85,7 @@
new TestServiceDirectory()
.add(ControlPlaneMonitorService.class, mockControlPlaneMonitorService)
.add(MetricsService.class, mockMetricsService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
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 8549167..7c48680 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
@@ -22,7 +22,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.IpAddress;
-import org.onlab.rest.BaseResource;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.NodeId;
@@ -151,7 +150,7 @@
mockControlPlaneMonitorService)
.add(ClusterService.class, mockClusterService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
nodeId = new NodeId("1");
mockControlLoad = new MockControlLoad();
diff --git a/apps/faultmanagement/fmweb/src/test/java/org/onosproject/faultmanagement/web/AlarmsWebResourceTest.java b/apps/faultmanagement/fmweb/src/test/java/org/onosproject/faultmanagement/web/AlarmsWebResourceTest.java
index 94315c7..778c23f 100644
--- a/apps/faultmanagement/fmweb/src/test/java/org/onosproject/faultmanagement/web/AlarmsWebResourceTest.java
+++ b/apps/faultmanagement/fmweb/src/test/java/org/onosproject/faultmanagement/web/AlarmsWebResourceTest.java
@@ -20,7 +20,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.rest.resources.ResourceTest;
@@ -48,7 +47,7 @@
// Currently no alarms-service implemented
// .add(AlarmsService.class, alarmsService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
@Test
diff --git a/apps/mappingmanagement/web/src/test/java/org/onosproject/mapping/web/MappingsWebResourceTest.java b/apps/mappingmanagement/web/src/test/java/org/onosproject/mapping/web/MappingsWebResourceTest.java
index d2f4c86..4d5f06d 100644
--- a/apps/mappingmanagement/web/src/test/java/org/onosproject/mapping/web/MappingsWebResourceTest.java
+++ b/apps/mappingmanagement/web/src/test/java/org/onosproject/mapping/web/MappingsWebResourceTest.java
@@ -30,7 +30,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.IpPrefix;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.mapping.DefaultMappingKey;
@@ -278,7 +277,7 @@
.add(DeviceService.class, mockDeviceService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/apps/ofagent/src/test/java/org/onosproject/ofagent/rest/OFAgentWebResourceTest.java b/apps/ofagent/src/test/java/org/onosproject/ofagent/rest/OFAgentWebResourceTest.java
index 74e2c4a..32eb857 100644
--- a/apps/ofagent/src/test/java/org/onosproject/ofagent/rest/OFAgentWebResourceTest.java
+++ b/apps/ofagent/src/test/java/org/onosproject/ofagent/rest/OFAgentWebResourceTest.java
@@ -27,7 +27,6 @@
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.IpAddress;
import org.onlab.packet.TpPort;
-import org.onlab.rest.BaseResource;
import org.onosproject.incubator.net.virtual.NetworkId;
import org.onosproject.incubator.net.virtual.TenantId;
import org.onosproject.ofagent.api.OFAgent;
@@ -141,7 +140,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(OFAgentAdminService.class, mockOFAgentAdminService)
.add(OFAgentService.class, mockOFAgentService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java
index 4b9d0b9..9d95e44 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java
@@ -17,21 +17,8 @@
package org.onosproject.pce.pceservice;
import com.google.common.collect.Lists;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onosproject.pce.pceservice.PathComputationTest.D2;
-import static org.easymock.EasyMock.createMock;
-
import com.google.common.testing.EqualsTester;
-
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
+import org.junit.Test;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.pce.pceservice.constraint.CostConstraint;
import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
@@ -39,23 +26,17 @@
import java.util.List;
+import static org.easymock.EasyMock.createMock;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.onosproject.pce.pceservice.PathComputationTest.D2;
+
/**
* Unit tests for DefaultPcePath class.
*/
public class DefaultPcePathTest {
private PceStore pceStore = createMock(PceStore.class);
- @Before
- public void setup() {
-
- ServiceDirectory testDirectory = new TestServiceDirectory()
- .add(PceStore.class, pceStore);
- BaseResource.setServiceDirectory(testDirectory);
- }
-
- @After
- public void tearDownTest() {
- }
/**
* Checks the operation of equals() methods.
*/
diff --git a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathResourceTest.java b/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathResourceTest.java
index ae05d7e..51f5c2d 100644
--- a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathResourceTest.java
+++ b/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathResourceTest.java
@@ -44,6 +44,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onlab.junit.TestUtils;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.IpAddress;
@@ -109,7 +110,7 @@
.add(TunnelService.class, tunnelService)
.add(PceStore.class, pceStore)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ TestUtils.setField(BaseResource.class, "services", testDirectory);
// Tunnel creation
// Links
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/ClassifierResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/ClassifierResourceTest.java
index 2307da4..5fa977c 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/ClassifierResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/ClassifierResourceTest.java
@@ -23,7 +23,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
@@ -57,7 +56,7 @@
SfcCodecContext context = new SfcCodecContext();
ServiceDirectory testDirectory = new TestServiceDirectory().add(ClassifierService.class, classifierService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
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 f98605e..da9d6d8 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
@@ -23,7 +23,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.IpPrefix;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.vtnrsc.FlowClassifier;
import org.onosproject.vtnrsc.FlowClassifierId;
@@ -208,7 +207,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(FlowClassifierService.class, flowClassifierService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainDeviceMapResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainDeviceMapResourceTest.java
index c4e219b..15c2104 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainDeviceMapResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainDeviceMapResourceTest.java
@@ -15,27 +15,15 @@
*/
package org.onosproject.vtnweb.resources;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-import javax.ws.rs.client.WebTarget;
-
+import com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonObject;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.net.DeviceId;
import org.onosproject.vtnrsc.FiveTuple;
@@ -49,10 +37,19 @@
import org.onosproject.vtnrsc.portchain.PortChainService;
import org.onosproject.vtnweb.web.SfcCodecContext;
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
+import javax.ws.rs.client.WebTarget;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
/**
* Unit tests for port chain device map REST APIs.
@@ -223,7 +220,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(PortChainService.class, portChainService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
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 4fbc63f..dd81814 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
@@ -15,35 +15,15 @@
*/
package org.onosproject.vtnweb.resources;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-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 com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonObject;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.net.DeviceId;
import org.onosproject.vtnrsc.FiveTuple;
@@ -57,10 +37,27 @@
import org.onosproject.vtnrsc.portchain.PortChainService;
import org.onosproject.vtnweb.web.SfcCodecContext;
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
+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.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
/**
* Unit tests for port chain REST APIs.
@@ -221,7 +218,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(PortChainService.class, portChainService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainSfMapResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainSfMapResourceTest.java
index d8983b0..e3866ce 100644
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainSfMapResourceTest.java
+++ b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainSfMapResourceTest.java
@@ -15,6 +15,25 @@
*/
package org.onosproject.vtnweb.resources;
+import com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonObject;
+import com.google.common.collect.Lists;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.osgi.ServiceDirectory;
+import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.codec.CodecService;
+import org.onosproject.vtnrsc.PortPairId;
+import org.onosproject.vtnrsc.ServiceFunctionGroup;
+import org.onosproject.vtnrsc.portchainsfmap.PortChainSfMapService;
+import org.onosproject.vtnweb.web.SfcCodecContext;
+
+import javax.ws.rs.client.WebTarget;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
@@ -23,28 +42,6 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.ws.rs.client.WebTarget;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
-import org.onosproject.codec.CodecService;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.ServiceFunctionGroup;
-import org.onosproject.vtnrsc.portchainsfmap.PortChainSfMapService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.Lists;
-
/**
* Unit tests for port chain sf map REST APIs.
*/
@@ -68,7 +65,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(PortChainSfMapService.class, portChainSfMapService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
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 c781c88..a5f2150 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
@@ -19,13 +19,11 @@
import com.eclipsesource.json.JsonObject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.vtnrsc.PortPairGroup;
import org.onosproject.vtnrsc.PortPairGroupId;
@@ -43,6 +41,7 @@
import java.net.HttpURLConnection;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -151,7 +150,7 @@
ServiceDirectory testDirectory = new TestServiceDirectory()
.add(PortPairGroupService.class, portPairGroupService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
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 7f73b83..63e89b9 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
@@ -22,7 +22,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.vtnrsc.PortPair;
import org.onosproject.vtnrsc.PortPairId;
@@ -135,7 +134,7 @@
SfcCodecContext context = new SfcCodecContext();
ServiceDirectory testDirectory = new TestServiceDirectory().add(PortPairService.class, portPairService)
.add(CodecService.class, context.codecManager());
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
index 9d6e547..c7d21cc 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
@@ -25,7 +25,6 @@
import org.onlab.junit.TestUtils;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.TestApplicationId;
import org.onosproject.common.event.impl.TestEventDispatcher;
import org.onosproject.core.ApplicationId;
@@ -76,7 +75,10 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Junit tests for VirtualNetworkIntentService.
@@ -149,7 +151,6 @@
.add(VirtualNetworkStore.class, virtualNetworkManagerStore)
.add(IntentService.class, intentService)
.add(WorkPartitionService.class, workPartitionService);
- BaseResource.setServiceDirectory(testDirectory);
TestUtils.setField(manager, "serviceDirectory", testDirectory);
manager.activate();
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
index 38d2e82..6218a15 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
@@ -21,7 +21,6 @@
import org.junit.Test;
import org.onlab.junit.TestUtils;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.common.event.impl.TestEventDispatcher;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
@@ -55,7 +54,9 @@
import java.util.concurrent.atomic.AtomicLong;
import static junit.framework.TestCase.assertTrue;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
/**
* Junit tests for VirtualNetworkTopologyService.
@@ -77,7 +78,6 @@
TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
virtualNetworkManagerStore.activate();
- BaseResource.setServiceDirectory(testDirectory);
manager = new VirtualNetworkManager();
manager.store = virtualNetworkManagerStore;
manager.coreService = coreService;
diff --git a/utils/rest/src/main/java/org/onlab/rest/BaseResource.java b/utils/rest/src/main/java/org/onlab/rest/BaseResource.java
index 093220f..44d7c99 100644
--- a/utils/rest/src/main/java/org/onlab/rest/BaseResource.java
+++ b/utils/rest/src/main/java/org/onlab/rest/BaseResource.java
@@ -28,18 +28,6 @@
private static ServiceDirectory services = new DefaultServiceDirectory();
/**
- * Sets alternate service directory to be used for lookups.
- * <p>
- * Intended to ease unit testing and not intended for use in production.
- * </p>
- *
- * @param serviceDirectory alternate service directory
- */
- public static void setServiceDirectory(ServiceDirectory serviceDirectory) {
- services = serviceDirectory;
- }
-
- /**
* Returns reference to the specified service implementation.
*
* @param service service class
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java
index 48cbd2d..3de04ba 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java
@@ -27,7 +27,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.app.ApplicationAdminService;
import org.onosproject.app.ApplicationService;
import org.onosproject.app.ApplicationState;
@@ -295,7 +294,7 @@
.add(CoreService.class, coreService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/ComponentConfigWebResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/ComponentConfigWebResourceTest.java
index d5621c9..6ff02e3 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/ComponentConfigWebResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/ComponentConfigWebResourceTest.java
@@ -20,7 +20,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.cfg.ComponentConfigAdapter;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cfg.ConfigProperty;
@@ -51,7 +50,7 @@
ServiceDirectory testDirectory =
new TestServiceDirectory()
.add(ComponentConfigService.class, service);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
@Test
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/DeviceKeyWebResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/DeviceKeyWebResourceTest.java
index 8ae7b3d..7ecaf38 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/DeviceKeyWebResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/DeviceKeyWebResourceTest.java
@@ -26,7 +26,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.key.DeviceKey;
@@ -109,7 +108,7 @@
.add(DeviceKeyAdminService.class, mockDeviceKeyAdminService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/DevicesResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/DevicesResourceTest.java
index 169cb11..75d33a8 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/DevicesResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/DevicesResourceTest.java
@@ -27,7 +27,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.DefaultPort;
@@ -36,16 +35,15 @@
import org.onosproject.net.MastershipRole;
import org.onosproject.net.Port;
import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DriverService;
import org.onosproject.net.driver.DefaultDriver;
-import org.onosproject.net.driver.TestBehaviourImpl;
+import org.onosproject.net.driver.DriverService;
import org.onosproject.net.driver.TestBehaviour;
+import org.onosproject.net.driver.TestBehaviourImpl;
import org.onosproject.net.driver.TestBehaviourTwo;
import org.onosproject.net.driver.TestBehaviourTwoImpl;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.WebTarget;
-
import java.util.ArrayList;
import java.util.List;
@@ -247,7 +245,7 @@
.add(DriverService.class, mockDriverService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/FlowObjectiveResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/FlowObjectiveResourceTest.java
index 6d858d5..eb99cff 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/FlowObjectiveResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/FlowObjectiveResourceTest.java
@@ -23,7 +23,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.core.CoreService;
@@ -79,7 +78,7 @@
.add(CodecService.class, codecService)
.add(CoreService.class, mockCoreService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java
index 6e8255c..72e9a00 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java
@@ -15,19 +15,10 @@
*/
package org.onosproject.rest.resources;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-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 com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonArray;
+import com.eclipsesource.json.JsonObject;
+import com.google.common.collect.ImmutableSet;
import org.hamcrest.Description;
import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeMatcher;
@@ -37,7 +28,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.MacAddress;
-import org.onlab.rest.BaseResource;
import org.onosproject.app.ApplicationService;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
@@ -61,10 +51,17 @@
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.instructions.Instruction;
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonArray;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.ImmutableSet;
+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.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.easymock.EasyMock.anyObject;
@@ -276,7 +273,7 @@
.add(CoreService.class, mockCoreService)
.add(ApplicationService.class, mockApplicationService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/GroupsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/GroupsResourceTest.java
index 1efbd33..ab4cf9d 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/GroupsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/GroupsResourceTest.java
@@ -28,7 +28,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.codec.impl.GroupCodec;
@@ -241,7 +240,7 @@
.add(CodecService.class, codecService)
.add(CoreService.class, mockCoreService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/HostResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/HostResourceTest.java
index 99fa074..4bb9523 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/HostResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/HostResourceTest.java
@@ -31,7 +31,6 @@
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.DefaultHost;
@@ -99,7 +98,7 @@
.add(HostAdminService.class, mockHostService)
.add(CodecService.class, codecService)
.add(HostProviderRegistry.class, mockHostProviderRegistry);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
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 b9b5dbd..e57af12 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
@@ -29,7 +29,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.MacAddress;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.codec.impl.MockCodecContext;
@@ -746,7 +745,7 @@
.add(CodecService.class, codecService)
.add(CoreService.class, mockCoreService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
MockIdGenerator.cleanBind();
}
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/LinksResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/LinksResourceTest.java
index 1063002..e26bcee 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/LinksResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/LinksResourceTest.java
@@ -27,7 +27,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.ConnectPoint;
@@ -162,7 +161,7 @@
.add(LinkService.class, mockLinkService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/MastershipResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/MastershipResourceTest.java
index 724075c..76d9a8d 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/MastershipResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/MastershipResourceTest.java
@@ -28,7 +28,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.cluster.NodeId;
import org.onosproject.cluster.RoleInfo;
import org.onosproject.codec.CodecService;
@@ -170,7 +169,7 @@
.add(DeviceService.class, mockDeviceService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/MetersResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/MetersResourceTest.java
index e225cdd..235ca0f 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/MetersResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/MetersResourceTest.java
@@ -28,7 +28,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.codec.impl.MeterCodec;
@@ -239,7 +238,7 @@
.add(CodecService.class, codecService)
.add(CoreService.class, mockCoreService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/MetricsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/MetricsResourceTest.java
index feac73f..75e7f02 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/MetricsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/MetricsResourceTest.java
@@ -31,7 +31,6 @@
import org.onlab.metrics.MetricsService;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
@@ -68,7 +67,7 @@
new TestServiceDirectory()
.add(MetricsService.class, mockMetricsService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/MulticastRouteResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/MulticastRouteResourceTest.java
index 33af8f4..64c13b4 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/MulticastRouteResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/MulticastRouteResourceTest.java
@@ -27,7 +27,6 @@
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
import org.onlab.packet.IpAddress;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.mcast.McastRoute;
@@ -85,7 +84,7 @@
new TestServiceDirectory()
.add(MulticastRouteService.class, mockMulticastRouteService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/NetworkConfigWebResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/NetworkConfigWebResourceTest.java
index b02e1a6..b2fbf60 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/NetworkConfigWebResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/NetworkConfigWebResourceTest.java
@@ -15,24 +15,18 @@
*/
package org.onosproject.rest.resources;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.HashSet;
-import java.util.Set;
-
-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 com.eclipsesource.json.Json;
+import com.eclipsesource.json.JsonObject;
+import com.eclipsesource.json.JsonValue;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableSet;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.net.DefaultDevice;
import org.onosproject.net.Device;
import org.onosproject.net.Link;
@@ -41,12 +35,15 @@
import org.onosproject.net.config.NetworkConfigServiceAdapter;
import org.onosproject.net.config.SubjectFactory;
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.eclipsesource.json.JsonValue;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.ImmutableSet;
+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.HashSet;
+import java.util.Set;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.replay;
@@ -204,7 +201,7 @@
ServiceDirectory testDirectory =
new TestServiceDirectory()
.add(NetworkConfigService.class, mockNetworkConfigService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/PathsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/PathsResourceTest.java
index 4d415f5..97d04bb 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/PathsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/PathsResourceTest.java
@@ -26,7 +26,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.ElementId;
@@ -143,7 +142,7 @@
.add(PathService.class, mockPathService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/RegionsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/RegionsResourceTest.java
index 3a0300d..69894e4 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/RegionsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/RegionsResourceTest.java
@@ -28,7 +28,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.cluster.NodeId;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
@@ -142,7 +141,7 @@
.add(RegionService.class, mockRegionService)
.add(RegionAdminService.class, mockRegionAdminService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
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 f032cd9..24036f6 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
@@ -21,6 +21,9 @@
import org.glassfish.jersey.test.jetty.JettyTestContainerFactory;
import org.glassfish.jersey.test.spi.TestContainerException;
import org.glassfish.jersey.test.spi.TestContainerFactory;
+import org.onlab.junit.TestUtils;
+import org.onlab.osgi.ServiceDirectory;
+import org.onlab.rest.BaseResource;
/**
* Base class for REST API tests.
@@ -58,4 +61,13 @@
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new JettyTestContainerFactory();
}
+
+ /**
+ * Sets up the test services directory in the base resource environment.
+ *
+ * @param testDirectory new test directory
+ */
+ protected void setServiceDirectory(ServiceDirectory testDirectory) {
+ TestUtils.setField(BaseResource.class, "services", testDirectory);
+ }
}
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/StatisticsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/StatisticsResourceTest.java
index 66b6eb0..a1bbccb 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/StatisticsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/StatisticsResourceTest.java
@@ -24,7 +24,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.Link;
@@ -92,7 +91,7 @@
.add(StatisticService.class, mockStatisticService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/TenantWebResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/TenantWebResourceTest.java
index 69bd45b..781cfae 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/TenantWebResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/TenantWebResourceTest.java
@@ -28,7 +28,6 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.incubator.net.virtual.TenantId;
@@ -44,9 +43,19 @@
import java.net.HttpURLConnection;
import java.util.HashSet;
-import static org.easymock.EasyMock.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
/**
* Unit tests for tenant REST APIs.
@@ -77,7 +86,7 @@
.add(VirtualNetworkAdminService.class, mockVnetAdminService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/TopologyResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/TopologyResourceTest.java
index 95a7416..4499a25 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/TopologyResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/TopologyResourceTest.java
@@ -23,16 +23,15 @@
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultPort;
+import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
-import org.onosproject.net.Device;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.DefaultPort;
import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.provider.ProviderId;
@@ -43,8 +42,10 @@
import org.onosproject.net.topology.TopologyCluster;
import org.onosproject.net.topology.TopologyService;
import org.onosproject.net.topology.TopologyServiceAdapter;
+
import javax.ws.rs.client.WebTarget;
import java.util.Set;
+
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
@@ -183,7 +184,7 @@
.add(DeviceService.class, mockDeviceService)
.add(TopologyService.class, topologyService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/VirtualNetworkWebResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/VirtualNetworkWebResourceTest.java
index 97c703b..2ab185c 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/VirtualNetworkWebResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/VirtualNetworkWebResourceTest.java
@@ -33,7 +33,6 @@
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
-import org.onlab.rest.BaseResource;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.incubator.net.virtual.DefaultVirtualDevice;
@@ -75,8 +74,16 @@
import java.util.function.BiPredicate;
import java.util.function.Function;
-import static org.easymock.EasyMock.*;
-import static org.hamcrest.Matchers.*;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
@@ -187,7 +194,7 @@
.add(VirtualNetworkService.class, mockVnetService)
.add(CodecService.class, codecService);
- BaseResource.setServiceDirectory(testDirectory);
+ setServiceDirectory(testDirectory);
}
/**