Improve microsemi unit test run time
Change-Id: Id1a5ad9d7e47dabde61d16aced464510d0818c42
diff --git a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000CfmMepProgrammableTest.java b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000CfmMepProgrammableTest.java
index 1f87634..fbfbb13 100644
--- a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000CfmMepProgrammableTest.java
+++ b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000CfmMepProgrammableTest.java
@@ -23,6 +23,7 @@
import static org.onosproject.drivers.microsemi.yang.utils.MdNameUtil.getYangMdNameFromApiMdId;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.onosproject.drivers.microsemi.yang.utils.MaNameUtil;
@@ -58,10 +59,17 @@
private CfmMepProgrammable cfmProgrammable;
+ private static MockEa1000DriverHandler mockHandler;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ mockHandler = new MockEa1000DriverHandler();
+ }
+
@Before
public void setUp() throws Exception {
cfmProgrammable = new EA1000CfmMepProgrammable();
- cfmProgrammable.setHandler(new MockEa1000DriverHandler());
+ cfmProgrammable.setHandler(mockHandler);
assertNotNull(cfmProgrammable.handler().data().deviceId());
}
@@ -118,8 +126,7 @@
assertNotNull(mepEntry.activeRemoteMepList());
BitSet bs1 = new BitSet();
bs1.clear();
-//FIXME Waiting on patch https://gerrit.onosproject.org/#/c/15778/
-// assertEquals("Expecting 2 Remote Meps", 2, mepEntry.activeRemoteMepList().size());
+ assertEquals("Expecting 2 Remote Meps", 2, mepEntry.activeRemoteMepList().size());
mepEntry.activeRemoteMepList().forEach(rmep -> {
if (rmep.remoteMepId().value() == 1) {
assertEquals(RemoteMepState.RMEP_FAILED.name(),
diff --git a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000FlowRuleProgrammableTest.java b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000FlowRuleProgrammableTest.java
index aa04dab..fe95582 100644
--- a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000FlowRuleProgrammableTest.java
+++ b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000FlowRuleProgrammableTest.java
@@ -29,6 +29,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onlab.packet.EthType.EtherType;
import org.onlab.packet.IpPrefix;
@@ -59,10 +60,16 @@
public class EA1000FlowRuleProgrammableTest {
EA1000FlowRuleProgrammable frProgramable;
+ private static MockEa1000DriverHandler mockHandler;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ mockHandler = new MockEa1000DriverHandler();
+ }
@Before
public void setUp() throws Exception {
frProgramable = new EA1000FlowRuleProgrammable();
- frProgramable.setHandler(new MockEa1000DriverHandler());
+ frProgramable.setHandler(mockHandler);
assertNotNull(frProgramable.handler().data().deviceId());
}
@@ -142,7 +149,7 @@
TrafficTreatment treatmentDrop = DefaultTrafficTreatment.builder().drop().build();
- Collection<FlowRule> frAddedList = new HashSet<FlowRule>();
+ Collection<FlowRule> frAddedList = new HashSet<>();
FlowRule fr4 = new DefaultFlowRule.Builder()
.forDevice(frProgramable.handler().data().deviceId())
@@ -279,7 +286,7 @@
TrafficTreatment.Builder trDropBuilder = DefaultTrafficTreatment.builder();
TrafficTreatment treatmentDrop = trDropBuilder.drop().build();
- Collection<FlowRule> frRemoveList = new HashSet<FlowRule>();
+ Collection<FlowRule> frRemoveList = new HashSet<>();
ApplicationId app = new DefaultApplicationId(1, "org.onosproject.rest");
Criterion matchIpSrc1 = Criteria.matchIPSrc(IpPrefix.valueOf("10.10.10.10/16"));
diff --git a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000SoamDmProgrammableTest.java b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000SoamDmProgrammableTest.java
index 59c674e..7017bd6 100644
--- a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000SoamDmProgrammableTest.java
+++ b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/EA1000SoamDmProgrammableTest.java
@@ -26,6 +26,7 @@
import java.util.Collection;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority;
import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdCharStr;
@@ -51,10 +52,16 @@
MaIdShort maId11 = MaIdCharStr.asMaId("ma-1-1");
MepId mep111 = MepId.valueOf((short) 1);
+ private static MockEa1000DriverHandler mockHandler;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ mockHandler = new MockEa1000DriverHandler();
+ }
@Before
public void setUp() throws Exception {
dmProgrammable = new EA1000SoamDmProgrammable();
- dmProgrammable.setHandler(new MockEa1000DriverHandler());
+ dmProgrammable.setHandler(mockHandler);
assertNotNull(dmProgrammable.handler().data().deviceId());
}
diff --git a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/yang/MseaCfmManagerTest.java b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/yang/MseaCfmManagerTest.java
index bb65a4d..161621b 100644
--- a/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/yang/MseaCfmManagerTest.java
+++ b/drivers/microsemi/ea1000/src/test/java/org/onosproject/drivers/microsemi/yang/MseaCfmManagerTest.java
@@ -61,7 +61,6 @@
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.NameCharacterString;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.NameDomainName;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.namedomainname.NameDomainNameUnion;
-import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.targetaddressgroup.AddressType;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.targetaddressgroup.addresstype.DefaultMacAddress;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.targetaddressgroup.addresstype.DefaultMepId;
import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.transmitloopback.DefaultTransmitLoopbackInput;
@@ -381,7 +380,7 @@
DefaultTargetAddress ta = new DefaultTargetAddress();
DefaultMepId mepId = new DefaultMepId();
mepId.mepId(MepIdType.of(4));
- ta.addressType((AddressType) mepId);
+ ta.addressType(mepId);
lbTr1.targetAddress(ta);
// lbTr1.dataTlv(new byte[]{0x01, 0x02, 0x03}); Not supported in onos-yang-tools just yet
diff --git a/drivers/microsemi/ea1000/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java b/drivers/microsemi/ea1000/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
index bb931f0..f5c0753 100644
--- a/drivers/microsemi/ea1000/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
+++ b/drivers/microsemi/ea1000/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
@@ -23,27 +23,35 @@
import org.onosproject.yang.runtime.YangSerializerContext;
import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+
import java.util.LinkedList;
import java.util.List;
public class MockYangSerializerContext implements YangSerializerContext {
- private static MockMicrosemiRegistrator schemaProviderMicrosemi =
- new MockMicrosemiRegistrator();
private static MockYangRegistrator schemaProviderYang =
new MockYangRegistrator();
+
+ private static Supplier<MockMicrosemiRegistrator> schemaProviderMicrosemi =
+ Suppliers.memoize(() -> {
+ MockMicrosemiRegistrator r = new MockMicrosemiRegistrator();
+ r.addAppInfo(schemaProviderYang.getAppInfo());
+ r.activate();
+ return r;
+ });
+
private static final String NETCONF_NS =
"urn:ietf:params:xml:ns:netconf:base:1.0";
private static final String XMNLS_NC = "xmlns:xc";
public MockYangSerializerContext() {
- schemaProviderMicrosemi.addAppInfo(schemaProviderYang.getAppInfo());
- schemaProviderMicrosemi.activate();
}
@Override
public SchemaContext getContext() {
- DefaultYangModelRegistry registry = (DefaultYangModelRegistry) schemaProviderMicrosemi.registry();
+ DefaultYangModelRegistry registry = (DefaultYangModelRegistry) schemaProviderMicrosemi.get().registry();
return registry;
}