diff --git a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java index 4f122e176a..7d26dcd034 100644 --- a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java +++ b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalConnectivityTest.java @@ -72,6 +72,7 @@ public class OpticalConnectivityTest { } }; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); } diff --git a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java index 254df53022..78a58b5928 100644 --- a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java +++ b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java @@ -248,6 +248,7 @@ public class OpticalPathProvisionerTest { return counter++; } }; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); } diff --git a/apps/newoptical/src/test/java/org/onosproject/newoptical/PacketLinkRealizedByOpticalTest.java b/apps/newoptical/src/test/java/org/onosproject/newoptical/PacketLinkRealizedByOpticalTest.java index 4252eddad2..610d2bd28c 100644 --- a/apps/newoptical/src/test/java/org/onosproject/newoptical/PacketLinkRealizedByOpticalTest.java +++ b/apps/newoptical/src/test/java/org/onosproject/newoptical/PacketLinkRealizedByOpticalTest.java @@ -54,6 +54,7 @@ public class PacketLinkRealizedByOpticalTest { } }; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); } diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java index 1c0eceb8ae..1ce3e6c53f 100644 --- a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java +++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java @@ -377,6 +377,7 @@ public class OpticalCircuitIntentCompilerTest { sut.intentService = new TestIntentService(); sut.intentSetMultimap = new MockIntentSetMultimap(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intentExtensionService = createMock(IntentExtensionService.class); diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java index f3d3e43a7e..fd3d0aee4e 100644 --- a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java +++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java @@ -274,6 +274,7 @@ public class OpticalOduIntentCompilerTest { sut.resourceService = new MockResourceService(); sut.topologyService = new MockTopologyService(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intentExtensionService = createMock(IntentExtensionService.class); diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompilerTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompilerTest.java index 0c2d25e099..66e5c07c95 100644 --- a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompilerTest.java +++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompilerTest.java @@ -81,6 +81,7 @@ public class OpticalPathIntentCompilerTest { .andReturn(appId); sut.coreService = coreService; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intent = OpticalPathIntent.builder() diff --git a/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java b/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java index 3ebc858658..6dfcea5977 100644 --- a/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java +++ b/apps/vpls/src/test/java/org/onosproject/vpls/VplsTest.java @@ -245,6 +245,7 @@ public class VplsTest { @Before public void setUp() throws Exception { idGenerator = new TestIdGenerator(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); applicationService = createMock(ApplicationService.class); diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentDataTest.java b/core/api/src/test/java/org/onosproject/net/intent/IntentDataTest.java index 77b9030de2..de215c6899 100644 --- a/core/api/src/test/java/org/onosproject/net/intent/IntentDataTest.java +++ b/core/api/src/test/java/org/onosproject/net/intent/IntentDataTest.java @@ -55,6 +55,7 @@ public class IntentDataTest { @Before public void setUpTest() { idGenerator = new MockIdGenerator(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); timestamp1 = new MockTimestamp(1); diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java b/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java index e4d906b2f2..1bafca8c4b 100644 --- a/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java +++ b/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java @@ -47,6 +47,7 @@ public class IntentServiceTest { public void setUp() { service = createIntentService(); service.addListener(listener); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); } diff --git a/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java b/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java index 02e8de13d8..2059cfc59d 100644 --- a/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java +++ b/core/api/src/test/java/org/onosproject/net/intent/MockIdGenerator.java @@ -25,10 +25,13 @@ import java.util.concurrent.atomic.AtomicLong; public class MockIdGenerator implements IdGenerator { private static boolean generatorIsBound = false; + private static MockIdGenerator idGenerator; public static void bindNewGenerator() { if (!generatorIsBound) { generatorIsBound = true; - Intent.bindIdGenerator(new MockIdGenerator()); + idGenerator = new MockIdGenerator(); + Intent.unbindIdGenerator(idGenerator); + Intent.bindIdGenerator(idGenerator); } } private AtomicLong nextId = new AtomicLong(0); diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java index 68304ebc83..d939f967ea 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java @@ -167,6 +167,7 @@ public class IntentManager batchExecutor = newSingleThreadExecutor(groupedThreads("onos/intent", "batch", log)); workerExecutor = newFixedThreadPool(numThreads, groupedThreads("onos/intent", "worker-%d", log)); idGenerator = coreService.getIdGenerator("intent-ids"); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); log.info("Started"); } diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentAccumulatorTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentAccumulatorTest.java index 71b53961f9..8914f176e5 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentAccumulatorTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentAccumulatorTest.java @@ -57,6 +57,7 @@ public class IntentAccumulatorTest { @Before public void localSetup() { mockGenerator = new MockIdGenerator(); + Intent.unbindIdGenerator(mockGenerator); Intent.bindIdGenerator(mockGenerator); intent1 = new MockIntent(1L); diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTest.java index a6e6067fa8..101569db99 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTest.java @@ -89,13 +89,13 @@ public class IntentCleanupTest { assertTrue("store should be empty", Sets.newHashSet(cleanup.store.getIntents()).isEmpty()); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); } @After public void tearDown() { cleanup.deactivate(); - Intent.unbindIdGenerator(idGenerator); } diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java index 42ef127c1d..0d2c4408ba 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentCleanupTestMock.java @@ -72,6 +72,7 @@ public class IntentCleanupTestMock { assertTrue("store should be empty", Sets.newHashSet(cleanup.store.getIntents()).isEmpty()); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); } diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java index 5ebef81d7d..6ed50af322 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java @@ -89,6 +89,7 @@ public class ObjectiveTrackerTest { deviceListener = TestUtils.getField(tracker, "deviceListener"); resourceListener = TestUtils.getField(tracker, "resourceListener"); mockGenerator = new MockIdGenerator(); + Intent.unbindIdGenerator(mockGenerator); Intent.bindIdGenerator(mockGenerator); } diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java index 27ef08bc2e..9d83e2c0a9 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java @@ -65,6 +65,7 @@ public class LinkCollectionEncapIntentCompilerTest extends AbstractLinkCollectio expect(coreService.registerApplication("org.onosproject.net.intent")).andReturn(appId); sut.coreService = coreService; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intentExtensionService = createMock(IntentExtensionService.class); diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java index 84720b5ec5..7df4af3e6d 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerP2PTest.java @@ -68,6 +68,7 @@ public class LinkCollectionIntentCompilerP2PTest extends AbstractLinkCollectionT .andReturn(appId); sut.coreService = coreService; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intentExtensionService = createMock(IntentExtensionService.class); diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java index fd2e32e000..a905eaca93 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java @@ -80,6 +80,7 @@ public class LinkCollectionIntentCompilerTest extends AbstractLinkCollectionTest .andReturn(appId); sut.coreService = coreService; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intent = LinkCollectionIntent.builder() diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java index b0465f07ab..01b86ba9a1 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionOptimizationTest.java @@ -65,6 +65,7 @@ public class LinkCollectionOptimizationTest extends AbstractLinkCollectionTest { .andReturn(appId); sut.coreService = coreService; + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intentExtensionService = createMock(IntentExtensionService.class); diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompilerTest.java index fa0a0df261..2ddca7dbce 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompilerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompilerTest.java @@ -98,6 +98,7 @@ public class MplsPathIntentCompilerTest { sut.coreService = coreService; sut.resourceService = new MockResourceService(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intent = MplsPathIntent.builder() diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java index f7579d80e5..3ee89aea72 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PathIntentCompilerTest.java @@ -176,6 +176,7 @@ public class PathIntentCompilerTest { sut.coreService = coreService; sut.resourceService = new MockResourceService(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); intent = PathIntent.builder() diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java index 2a5593135b..9e508c6958 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java @@ -88,6 +88,7 @@ public class CompilingTest { idGenerator = new MockIdGenerator(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); // Intent creation should be placed after binding an ID generator diff --git a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java index ba88e787f7..42ec399463 100644 --- a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java +++ b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java @@ -58,6 +58,7 @@ public class GossipIntentStoreTest { intentStore.partitionService = new WorkPartitionServiceAdapter(); intentStore.clusterService = new ClusterServiceAdapter(); idGenerator = new MockIdGenerator(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); builder1 = HostToHostIntent .builder() 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 158fcef3e5..629dd568a5 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 @@ -92,6 +92,7 @@ public class VirtualNetworkManagerTest extends TestDeviceParams { @Before public void setUp() throws Exception { virtualNetworkManagerStore = new DistributedVirtualNetworkStore(); + Intent.unbindIdGenerator(idGenerator); Intent.bindIdGenerator(idGenerator); coreService = new TestCoreService();