Cleaning up intent tests setup/teardown to avoid cascading failures
with respect to binding ID generator.
Change-Id: Ia4778f16ff5a3ecb26062e7d7b2c36493081140d
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 55232d1..4b7cf84 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
@@ -55,14 +55,14 @@
import org.onosproject.net.intent.IntentEvent;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.IntentListener;
-import org.onosproject.net.intent.WorkPartitionService;
-import org.onosproject.net.intent.WorkPartitionServiceAdapter;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentState;
import org.onosproject.net.intent.IntentTestsMocks;
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.intent.TestableIntentService;
+import org.onosproject.net.intent.WorkPartitionService;
+import org.onosproject.net.intent.WorkPartitionServiceAdapter;
import org.onosproject.net.intent.constraint.EncapsulationConstraint;
import org.onosproject.store.service.TestStorageService;
@@ -108,7 +108,6 @@
private WorkPartitionService workPartitionService;
private ServiceDirectory testDirectory;
private TestListener listener = new TestListener();
- private IdGenerator idGenerator = new MockIdGenerator();
private static final int MAX_WAIT_TIME = 5;
private static final int MAX_PERMITS = 1;
private static Semaphore created;
@@ -121,8 +120,7 @@
coreService = new VirtualNetworkIntentManagerTest.TestCoreService();
- Intent.unbindIdGenerator(idGenerator);
- Intent.bindIdGenerator(idGenerator);
+ MockIdGenerator.cleanBind();
TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
@@ -158,7 +156,7 @@
virtualNetworkManagerStore.deactivate();
manager.deactivate();
NetTestTools.injectEventDispatcher(manager, null);
- Intent.unbindIdGenerator(idGenerator);
+ MockIdGenerator.unbind();
intentService.removeListener(listener);
created = null;
withdrawn = null;
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
index 202046e..765b4cb 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
@@ -70,7 +70,6 @@
import org.onosproject.net.group.GroupService;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.FakeIntentManager;
-import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentState;
import org.onosproject.net.intent.Key;
@@ -83,11 +82,11 @@
import org.onosproject.net.topology.TopologyService;
import org.onosproject.store.service.TestStorageService;
-import java.util.Collection;
-import java.util.List;
import java.util.ArrayList;
-import java.util.Set;
+import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import static org.junit.Assert.*;
@@ -107,7 +106,6 @@
private TestListener listener = new TestListener();
private TestableIntentService intentService = new FakeIntentManager();
private TopologyService topologyService;
- private IdGenerator idGenerator = new MockIdGenerator();
private ConnectPoint cp6;
private ConnectPoint cp7;
@@ -117,8 +115,7 @@
@Before
public void setUp() throws Exception {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
- Intent.unbindIdGenerator(idGenerator);
- Intent.bindIdGenerator(idGenerator);
+ MockIdGenerator.cleanBind();
coreService = new TestCoreService();
TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
@@ -145,7 +142,7 @@
manager.removeListener(listener);
manager.deactivate();
NetTestTools.injectEventDispatcher(manager, null);
- Intent.unbindIdGenerator(idGenerator);
+ MockIdGenerator.cleanBind();
}
/**