Cleaning up intent tests setup/teardown to avoid cascading failures
with respect to binding ID generator.
Change-Id: Ia4778f16ff5a3ecb26062e7d7b2c36493081140d
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 fd3d0ae..4992b1a 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
@@ -15,19 +15,19 @@
*/
package org.onosproject.net.optical.intent.impl.compiler;
-import org.junit.After;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.ChassisId;
import org.onosproject.TestApplicationId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
import org.onosproject.net.AbstractProjectableModel;
import org.onosproject.net.Annotations;
-import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPath;
@@ -43,6 +43,9 @@
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.TributarySlot;
+import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.driver.DriverService;
+import org.onosproject.net.driver.DriverServiceAdapter;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowRule;
@@ -50,11 +53,11 @@
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.instructions.Instructions;
+import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.net.intent.FlowRuleIntent;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OtuPort;
@@ -65,12 +68,6 @@
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyServiceAdapter;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.driver.DriverServiceAdapter;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Sets;
import java.util.Arrays;
import java.util.Collection;
@@ -80,23 +77,19 @@
import java.util.Set;
import java.util.stream.Collectors;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.*;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.everyItem;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
-import static org.onosproject.net.AnnotationKeys.STATIC_PORT;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
+import static org.onosproject.net.AnnotationKeys.STATIC_PORT;
import static org.onosproject.net.Device.Type.OTN;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.Link.Type.OPTICAL;
import static org.onosproject.net.NetTestTools.APP_ID;
import static org.onosproject.net.NetTestTools.PID;
-public class OpticalOduIntentCompilerTest {
+public class OpticalOduIntentCompilerTest extends AbstractIntentTest {
private static final String DEV1 = "of:1";
private static final String DEV2 = "of:2";
@@ -109,7 +102,6 @@
private CoreService coreService;
private IntentExtensionService intentExtensionService;
- private final IdGenerator idGenerator = new MockIdGenerator();
private OpticalOduIntentCompiler sut;
private final ApplicationId appId = new TestApplicationId("test");
@@ -274,8 +266,7 @@
sut.resourceService = new MockResourceService();
sut.topologyService = new MockTopologyService();
- Intent.unbindIdGenerator(idGenerator);
- Intent.bindIdGenerator(idGenerator);
+ super.setUp();
intentExtensionService = createMock(IntentExtensionService.class);
intentExtensionService.registerCompiler(OpticalOduIntent.class, sut);
@@ -285,11 +276,6 @@
replay(coreService, intentExtensionService);
}
- @After
- public void tearDown() {
- Intent.unbindIdGenerator(idGenerator);
- }
-
/**
* Tests compile of OpticalOduIntent with allocation of TributarySlots.
* Compile two ODUCLT ports (with CLT_1GBE), over OTU ports (with OTU2):