Updating Microsemi Driver to onos-yang-tools 2.x
Change-Id: I80e3348087518a8f9a742c813b6238371a3f8f97
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/EA1000FlowRuleProgrammableTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/EA1000FlowRuleProgrammableTest.java
new file mode 100644
index 0000000..24aad06
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/EA1000FlowRuleProgrammableTest.java
@@ -0,0 +1,363 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.EthType.EtherType;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.VlanId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.DefaultApplicationId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.flow.DefaultFlowEntry;
+import org.onosproject.net.flow.DefaultFlowRule;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.FlowEntry;
+import org.onosproject.net.flow.FlowEntry.FlowEntryState;
+import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.criteria.Criterion;
+import org.onosproject.net.flow.criteria.Criterion.Type;
+import org.onosproject.net.flow.criteria.IPCriterion;
+import org.onosproject.net.flow.criteria.PortCriterion;
+import org.onosproject.net.flow.criteria.VlanIdCriterion;
+import org.onosproject.net.flow.instructions.Instruction;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class EA1000FlowRuleProgrammableTest {
+ EA1000FlowRuleProgrammable frProgramable;
+
+ @Before
+ public void setUp() throws Exception {
+ frProgramable = new EA1000FlowRuleProgrammable();
+ frProgramable.setHandler(new MockEa1000DriverHandler());
+ assertNotNull(frProgramable.handler().data().deviceId());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetFlowEntries() {
+ //From MockNetconfSession sample of MseaSaFiltering
+ Collection<FlowEntry> flowEntries = frProgramable.getFlowEntries();
+
+ assertNotNull(flowEntries);
+ //There will be 12 flow entries
+ // 2 for IP Src Address filtering
+ // 2 for EVC 7 - one each port
+ // 8 for EVC 8 - one for host port, 7 on optics port because of ceVlanMap 12:14,20:22,25
+ assertEquals(12, flowEntries.size());
+
+ //Test the first Flow Entry
+ Iterator<FlowEntry> feIter = flowEntries.iterator();
+ while (feIter.hasNext()) {
+ FlowEntry fe = feIter.next();
+ assertTrue(fe.isPermanent());
+ assertEquals(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT, fe.priority());
+
+ Set<Criterion> criteria = fe.selector().criteria();
+ IPCriterion ipCr = null;
+ PortNumber port = null;
+ for (Criterion cr:criteria.toArray(new Criterion[criteria.size()])) {
+ if (cr.type() == Criterion.Type.IPV4_SRC) {
+ ipCr = (IPCriterion) cr;
+ } else if (cr.type() == Criterion.Type.IN_PORT) {
+ port = ((PortCriterion) cr).port();
+ } else if (cr.type() == Criterion.Type.VLAN_VID) {
+ VlanId vid = ((VlanIdCriterion) cr).vlanId();
+ } else {
+ fail("Unexpected Criterion type: " + cr.type().toString());
+ }
+ }
+ if (ipCr != null && (port == null || port.toLong() != 0L)) {
+ fail("Port number not equal 0 when IP Src Address filter is present");
+ }
+
+ List<Instruction> instructions = fe.treatment().allInstructions();
+
+ if (fe.tableId() == 1) {
+ //Note that in MockNetconf session 10.10.10.10/16 was entered
+ //but it has been corrected to the following by the OF implementation
+ assertEquals("10.10.0.0/16", ipCr.ip().toString());
+ assertEquals(FlowEntryState.ADDED, fe.state());
+ } else if (fe.tableId() == 2) {
+ //Likewise 20.30.40.50 has been truncated because of the 18 bit mask
+ assertEquals("20.30.0.0/18", ipCr.ip().toString());
+ assertEquals(FlowEntryState.ADDED, fe.state());
+ } else if (fe.tableId() == 7 || fe.tableId() == 8) {
+ // 7 and 8 are EVC entries - 2 elements - IN_PORT and VLAN_ID
+ assertEquals(2, fe.selector().criteria().size());
+ //In MockNetconfSession we're rigged it so that the last two chars of the
+ //flow id is the same as the VlanId
+ short vlanId = ((VlanIdCriterion) fe.selector().getCriterion(Type.VLAN_VID)).vlanId().toShort();
+ long flowId = fe.id().id();
+ String flowIdStr = String.valueOf(flowId).substring(String.valueOf(flowId).length() - 2);
+ assertEquals(flowIdStr, String.valueOf(vlanId));
+ if (((PortCriterion) fe.selector().getCriterion(Type.IN_PORT)).port().toLong() == 1L) {
+ assertEquals(Instruction.Type.L2MODIFICATION, instructions.get(0).type());
+ }
+ } else {
+ fail("Unexpected Flow Entry Rule " + fe.tableId());
+ }
+ }
+ }
+
+ @Test
+ public void testSetFlowEntries() {
+ Criterion matchInPort = Criteria.matchInPort(PortNumber.portNumber(0));
+
+ TrafficTreatment treatmentDrop = DefaultTrafficTreatment.builder().drop().build();
+
+ Collection<FlowRule> frAddedList = new HashSet<FlowRule>();
+
+ FlowRule fr4 = new DefaultFlowRule.Builder()
+ .forDevice(frProgramable.handler().data().deviceId())
+ .forTable(4)
+ .withSelector(DefaultTrafficSelector.builder()
+ .matchIPSrc(IpPrefix.valueOf("192.168.60.0/22"))
+ .add(matchInPort).build())
+ .withTreatment(treatmentDrop)
+ .fromApp(new DefaultApplicationId(4, "Filter4"))
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frAddedList.add(fr4);
+
+ FlowRule fr5 = new DefaultFlowRule.Builder()
+ .forDevice(frProgramable.handler().data().deviceId())
+ .forTable(5)
+ .withSelector(DefaultTrafficSelector.builder()
+ .matchIPSrc(IpPrefix.valueOf("192.168.50.0/23"))
+ .add(matchInPort).build())
+ .withTreatment(treatmentDrop)
+ .withCookie(Long.valueOf("5e0000abaa2772", 16))
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frAddedList.add(fr5);
+
+ //Add in some EVCs - especially with complex ceVlanMaps
+ FlowRule frEvc1Vid19P0 = new DefaultFlowRule.Builder()
+ .forDevice(frProgramable.handler().data().deviceId())
+ .forTable(1)
+ .withSelector(DefaultTrafficSelector.builder()
+ .matchInPort(PortNumber.portNumber(0L))
+ .matchVlanId(VlanId.vlanId((short) 19))
+ .build())
+ .withTreatment(DefaultTrafficTreatment.builder()
+ .popVlan()
+ .build())
+ .withCookie(Long.valueOf("1e0000abaa0019", 16))
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frAddedList.add(frEvc1Vid19P0);
+
+ FlowRule frEvc1Vid20P0 = new DefaultFlowRule.Builder()
+ .forDevice(frProgramable.handler().data().deviceId())
+ .forTable(1)
+ .withSelector(DefaultTrafficSelector.builder()
+ .matchInPort(PortNumber.portNumber(0L))
+ .matchVlanId(VlanId.vlanId((short) 20))
+ .build())
+ .withTreatment(DefaultTrafficTreatment.builder()
+ .popVlan()
+ .build())
+ .withCookie(Long.valueOf("1e0000abaa0020", 16))
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frAddedList.add(frEvc1Vid20P0);
+
+ FlowRule frEvc1Vid21P1 = new DefaultFlowRule.Builder()
+ .forDevice(frProgramable.handler().data().deviceId())
+ .forTable(1)
+ .withSelector(DefaultTrafficSelector.builder()
+ .matchInPort(PortNumber.portNumber(1L))
+ .matchVlanId(VlanId.vlanId((short) 21))
+ .build())
+ .withTreatment(DefaultTrafficTreatment.builder()
+ .setVlanId(VlanId.vlanId((short) 250))
+ .pushVlan(EtherType.QINQ.ethType())
+ .build())
+ .withCookie(Long.valueOf("1e0000abaa0121", 16))
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frAddedList.add(frEvc1Vid21P1);
+
+ FlowRule frEvc1Vid22P1 = new DefaultFlowRule.Builder()
+ .forDevice(frProgramable.handler().data().deviceId())
+ .forTable(1)
+ .withSelector(DefaultTrafficSelector.builder()
+ .matchInPort(PortNumber.portNumber(1L))
+ .matchVlanId(VlanId.vlanId((short) 22))
+ .build())
+ .withTreatment(DefaultTrafficTreatment.builder()
+ .setVlanId(VlanId.vlanId((short) 250))
+ .pushVlan(EtherType.QINQ.ethType())
+ .build())
+ .withCookie(Long.valueOf("1e0000abaa0122", 16))
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frAddedList.add(frEvc1Vid22P1);
+
+ Collection<FlowRule> returnedFrList = frProgramable.applyFlowRules(frAddedList);
+
+ assertNotNull(returnedFrList);
+ assertEquals(6, returnedFrList.size());
+
+ //Test the scenario like in FlowRuleManager$InternalFlowRuleProviderService.pushFlowMetricsInternal()
+ Map<FlowEntry, FlowEntry> storedRules = Maps.newHashMap();
+ frAddedList.forEach(f -> storedRules.put(new DefaultFlowEntry(f), new DefaultFlowEntry(f)));
+ List<FlowEntry> feList = Lists.newArrayList();
+ returnedFrList.forEach(f -> feList.add(new DefaultFlowEntry(f)));
+
+ for (FlowEntry rule : feList) {
+ FlowEntry fer = storedRules.remove(rule);
+ assertNotNull(fer);
+ assertTrue(fer.exactMatch(rule));
+ }
+
+ for (FlowRule fr:returnedFrList.toArray(new FlowRule[2])) {
+ if (fr.tableId() == 4) {
+ assertEquals("IPV4_SRC:192.168.60.0/22",
+ ((IPCriterion) fr.selector().getCriterion(Type.IPV4_SRC)).toString());
+ } else if (fr.tableId() == 5) {
+ assertEquals("IPV4_SRC:192.168.50.0/23",
+ ((IPCriterion) fr.selector().getCriterion(Type.IPV4_SRC)).toString());
+ assertEquals(Long.valueOf("5e0000abaa2772", 16), fr.id().id());
+ } else if (fr.tableId() == 1) {
+ //TODO add in tests
+ } else {
+ fail("Unexpected flow rule " + fr.tableId() + " in test");
+ }
+ }
+ }
+
+ @Test
+ public void testRemoveFlowEntries() {
+ TrafficSelector.Builder tsBuilder = DefaultTrafficSelector.builder();
+ Criterion matchInPort0 = Criteria.matchInPort(PortNumber.portNumber(0));
+ Criterion matchInPort1 = Criteria.matchInPort(PortNumber.portNumber(1));
+
+ TrafficTreatment.Builder trDropBuilder = DefaultTrafficTreatment.builder();
+ TrafficTreatment treatmentDrop = trDropBuilder.drop().build();
+
+ Collection<FlowRule> frRemoveList = new HashSet<FlowRule>();
+ ApplicationId app = new DefaultApplicationId(1, "org.onosproject.rest");
+
+ Criterion matchIpSrc1 = Criteria.matchIPSrc(IpPrefix.valueOf("10.10.10.10/16"));
+ TrafficSelector selector1 = tsBuilder.add(matchIpSrc1).add(matchInPort0).build();
+ FlowRule.Builder frBuilder1 = new DefaultFlowRule.Builder();
+ frBuilder1.forDevice(frProgramable.handler().data().deviceId())
+ .withSelector(selector1)
+ .withTreatment(treatmentDrop)
+ .forTable(2)
+ .fromApp(app)
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT);
+ frRemoveList.add(frBuilder1.build());
+
+ Criterion matchIpSrc2 = Criteria.matchIPSrc(IpPrefix.valueOf("10.30.10.10/16"));
+ TrafficSelector selector2 = tsBuilder.add(matchIpSrc2).add(matchInPort0).build();
+ FlowRule.Builder frBuilder2 = new DefaultFlowRule.Builder();
+ frBuilder2.forDevice(frProgramable.handler().data().deviceId())
+ .withSelector(selector2)
+ .withTreatment(treatmentDrop)
+ .forTable(3)
+ .fromApp(app)
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frRemoveList.add(frBuilder2.build());
+
+
+ TrafficTreatment.Builder trVlanPopBuilder = DefaultTrafficTreatment.builder();
+ TrafficTreatment treatmentVlanPop = trVlanPopBuilder.popVlan().build();
+
+
+ Criterion matchVlan710 = Criteria.matchVlanId(VlanId.vlanId((short) 710));
+ TrafficSelector selector3 = DefaultTrafficSelector.builder().add(matchVlan710).add(matchInPort1).build();
+ FlowRule.Builder frBuilder3 = new DefaultFlowRule.Builder();
+ frBuilder3.forDevice(frProgramable.handler().data().deviceId())
+ .withSelector(selector3)
+ .withTreatment(treatmentVlanPop)
+ .forTable(7)
+ .fromApp(app)
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frRemoveList.add(frBuilder3.build());
+
+
+ Criterion matchVlan101 = Criteria.matchVlanId(VlanId.vlanId((short) 101));
+ TrafficSelector selector4 = DefaultTrafficSelector.builder().add(matchVlan101).add(matchInPort1).build();
+ FlowRule.Builder frBuilder4 = new DefaultFlowRule.Builder();
+ frBuilder4.forDevice(frProgramable.handler().data().deviceId())
+ .withSelector(selector4)
+ .withTreatment(treatmentVlanPop)
+ .forTable(1)
+ .fromApp(app)
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frRemoveList.add(frBuilder4.build());
+
+ Criterion matchVlan102 = Criteria.matchVlanId(VlanId.vlanId((short) 102));
+ TrafficSelector selector5 = DefaultTrafficSelector.builder().add(matchVlan102).add(matchInPort0).build();
+ FlowRule.Builder frBuilder5 = new DefaultFlowRule.Builder();
+ frBuilder5.forDevice(frProgramable.handler().data().deviceId())
+ .withSelector(selector5)
+ .withTreatment(treatmentVlanPop)
+ .forTable(1)
+ .fromApp(app)
+ .makePermanent()
+ .withPriority(EA1000FlowRuleProgrammable.PRIORITY_DEFAULT)
+ .build();
+ frRemoveList.add(frBuilder5.build());
+
+ Collection<FlowRule> removedFrList = frProgramable.removeFlowRules(frRemoveList);
+ assertNotNull(removedFrList);
+ assertEquals(5, removedFrList.size());
+
+ for (FlowRule frRemoved:removedFrList) {
+ assertNotNull(frRemoved);
+ }
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/EA1000MeterProviderTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/EA1000MeterProviderTest.java
new file mode 100644
index 0000000..b00b321
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/EA1000MeterProviderTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi;
+
+import java.util.HashSet;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.core.DefaultApplicationId;
+import org.onosproject.drivers.microsemi.yang.MockMseaUniEvcServiceManager;
+import org.onosproject.drivers.microsemi.yang.MockNetconfSessionEa1000;
+import org.onosproject.drivers.netconf.MockNetconfController;
+import org.onosproject.drivers.netconf.MockNetconfDevice;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.meter.Band;
+import org.onosproject.net.meter.DefaultBand;
+import org.onosproject.net.meter.DefaultMeter;
+import org.onosproject.net.meter.Meter;
+import org.onosproject.net.meter.Meter.Unit;
+import org.onosproject.net.meter.MeterId;
+import org.onosproject.net.meter.MeterOperation;
+import org.onosproject.net.meter.MeterOperation.Type;
+import org.onosproject.netconf.NetconfController;
+
+public class EA1000MeterProviderTest {
+
+ private EA1000MeterProvider meterProvider;
+ private NetconfController controller;
+ private DeviceId mockDeviceId;
+ private MockMseaUniEvcServiceManager mseaUniEvcServiceSvc;
+
+ @Before
+ public void setUp() throws Exception {
+ mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
+ controller = new MockNetconfController();
+ MockNetconfDevice device = (MockNetconfDevice) controller.connectDevice(mockDeviceId);
+ device.setNcSessionImpl(MockNetconfSessionEa1000.class);
+ mseaUniEvcServiceSvc = new MockMseaUniEvcServiceManager();
+ mseaUniEvcServiceSvc.activate();
+ meterProvider = new TestEA1000MeterProvider(controller, mseaUniEvcServiceSvc);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testPerformMeterOperationDeviceIdMeterAdd() {
+ DeviceId mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
+
+ Band cbsBand = DefaultBand.builder()
+ .ofType(Band.Type.REMARK) //Committed - CIR & CBS
+ .withRate(37500L)
+ .burstSize(2000)
+ .dropPrecedence((short) 0)
+ .build();
+
+ Band ebsBand = DefaultBand.builder()
+ .ofType(Band.Type.DROP) //Excess - EIR & EBS
+ .withRate(50000L) //The rate at which we drop - for EA 1000 subtract CIR to get EIR
+ .burstSize(3000) //The burst rate to drop at
+ .build();
+
+ Meter.Builder mBuilder = DefaultMeter.builder()
+ .forDevice(mockDeviceId)
+ .withId(MeterId.meterId(1))
+ .fromApp(new DefaultApplicationId(101, "unit.test"))
+ .burst()
+ .withUnit(Unit.KB_PER_SEC)
+ .withBands(new HashSet<Band>() { { add(cbsBand); add(ebsBand); } });
+
+ MeterOperation meterOp = new MeterOperation(mBuilder.build(), Type.ADD);
+
+ meterProvider.performMeterOperation(mockDeviceId, meterOp);
+ //The NETCONF XML generated by this matches the pattern
+ // sampleXmlRegexEditConfigBwpGroup1
+ // in MockNetconfSession
+ }
+
+ @Test
+ public void testPerformMeterOperationDeviceIdMeterRemove() {
+ DeviceId mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
+
+ Band cbsBand = DefaultBand.builder()
+ .ofType(Band.Type.REMARK) //Committed - CIR & CBS
+ .withRate(37500L)
+ .burstSize(2000)
+ .dropPrecedence((short) 0)
+ .build();
+
+ Meter.Builder mBuilder = DefaultMeter.builder()
+ .forDevice(mockDeviceId)
+ .withId(MeterId.meterId(1))
+ .fromApp(new DefaultApplicationId(101, "unit.test"))
+ .burst()
+ .withBands(new HashSet<Band>() { { add(cbsBand); } });
+
+ MeterOperation meterOp = new MeterOperation(mBuilder.build(), Type.REMOVE);
+
+ meterProvider.performMeterOperation(mockDeviceId, meterOp);
+ //The NETCONF XML generated by this matches the pattern
+ // sampleXmlRegexEditConfigBwpGroup1
+ // in MockNetconfSession
+ }
+
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/MicrosemiDriversLoaderTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/MicrosemiDriversLoaderTest.java
new file mode 100644
index 0000000..a53c6e3
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/MicrosemiDriversLoaderTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi;
+
+import org.junit.Before;
+import org.onosproject.net.driver.AbstractDriverLoaderTest;
+
+
+/**
+ * Microsemi drivers loader test.
+ */
+public class MicrosemiDriversLoaderTest extends AbstractDriverLoaderTest {
+
+ @Before
+ public void setUp() {
+ loader = new MicrosemiDriversLoader();
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/MockEa1000DriverHandler.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/MockEa1000DriverHandler.java
new file mode 100644
index 0000000..78a9d32
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/MockEa1000DriverHandler.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onosproject.core.CoreService;
+import org.onosproject.drivers.microsemi.yang.MockMseaSaFilteringManager;
+import org.onosproject.drivers.microsemi.yang.MockMseaUniEvcServiceManager;
+import org.onosproject.drivers.microsemi.yang.MockNetconfSessionEa1000;
+import org.onosproject.drivers.microsemi.yang.MseaSaFilteringNetconfService;
+import org.onosproject.drivers.microsemi.yang.MseaUniEvcServiceNetconfService;
+import org.onosproject.drivers.netconf.MockCoreService;
+import org.onosproject.drivers.netconf.MockNetconfController;
+import org.onosproject.drivers.netconf.MockNetconfDevice;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.Behaviour;
+import org.onosproject.net.driver.DefaultDriver;
+import org.onosproject.net.driver.DefaultDriverData;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverData;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.net.flow.FlowRuleProgrammable;
+import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfException;
+
+/**
+ * A Mock implementation of the DriverHandler to facilitate unit tests.
+ *
+ * This brings in the implementations of MockMseaSaFilteringManager, MockMseaUniEvcServiceManager,
+ * MockCoreService, MockNetconfDevice and MockNetconfSessionEa1000
+ */
+public class MockEa1000DriverHandler implements DriverHandler {
+
+ private static final String MICROSEMI_DRIVERS = "com.microsemi.drivers";
+
+ private DriverData mockDriverData;
+
+ private NetconfController ncc;
+ private MockMseaSaFilteringManager mseaSaFilteringService;
+ private MockMseaUniEvcServiceManager mseaUniEvcService;
+ private CoreService coreService;
+
+ public MockEa1000DriverHandler() throws NetconfException {
+ Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours =
+ new HashMap<Class<? extends Behaviour>, Class<? extends Behaviour>>();
+ behaviours.put(FlowRuleProgrammable.class, FlowRuleProgrammable.class);
+
+ Map<String, String> properties = new HashMap<String, String>();
+
+ Driver mockDriver =
+ new DefaultDriver("mockDriver", null, "ONOSProject", "1.0.0", "1.0.0", behaviours, properties);
+ DeviceId mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
+ mockDriverData = new DefaultDriverData(mockDriver, mockDeviceId);
+
+
+ ncc = new MockNetconfController();
+ MockNetconfDevice device = (MockNetconfDevice) ncc.connectDevice(mockDeviceId);
+ device.setNcSessionImpl(MockNetconfSessionEa1000.class);
+
+ mseaSaFilteringService = new MockMseaSaFilteringManager();
+ mseaSaFilteringService.activate();
+
+ mseaUniEvcService = new MockMseaUniEvcServiceManager();
+ mseaUniEvcService.activate();
+
+ coreService = new MockCoreService();
+ coreService.registerApplication(MICROSEMI_DRIVERS);
+ }
+
+ @Override
+ public Driver driver() {
+ return mockDriverData.driver();
+ }
+
+ @Override
+ public DriverData data() {
+ return mockDriverData;
+ }
+
+ @Override
+ public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T get(Class<T> serviceClass) {
+ if (serviceClass.equals(NetconfController.class)) {
+ return (T) ncc;
+
+ } else if (serviceClass.equals(MseaSaFilteringNetconfService.class)) {
+ return (T) mseaSaFilteringService;
+
+ } else if (serviceClass.equals(MseaUniEvcServiceNetconfService.class)) {
+ return (T) mseaUniEvcService;
+
+ } else if (serviceClass.equals(CoreService.class)) {
+ return (T) coreService;
+
+ }
+
+ return null;
+ }
+
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/RpcResultParserTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/RpcResultParserTest.java
new file mode 100644
index 0000000..64dd80e
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/RpcResultParserTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.junit.Test;
+
+public class RpcResultParserTest {
+
+ private static final String SAMPLE1_XML = "/systemReply-Sample1.xml";
+ private static final String SAMPLE2_XML = "/systemReply-Sample2.xml";
+
+ @Test
+ public void testSerialNumber1() {
+ String serialNumberReply = loadXml(SAMPLE1_XML);
+ String serialNumber = RpcResultParser.parseXml(serialNumberReply, "serial-number");
+ assertEquals("Eagle Simulator.", serialNumber);
+ }
+
+ @Test
+ public void testSerialNumber2() {
+ String serialNumberReply = loadXml(SAMPLE2_XML);
+ String serialNumber = RpcResultParser.parseXml(serialNumberReply, "serial-number");
+ assertEquals(null, serialNumber);
+ }
+
+ @Test
+ public void testOsRelease1() {
+ String osReleaseReply = loadXml(SAMPLE1_XML);
+ String osRelease = RpcResultParser.parseXml(osReleaseReply, "os-release");
+ assertEquals("2.6.33-arm1-MSEA1000--00326-g643be76.x.0.0.212", osRelease);
+ }
+
+ @Test
+ public void testOsRelease2() {
+ String osReleaseReply = loadXml(SAMPLE2_XML);
+ String osRelease = RpcResultParser.parseXml(osReleaseReply, "os-release");
+ assertEquals(null, osRelease);
+ }
+
+ @Test
+ public void testLongitude() {
+ String longitudeReply = loadXml(SAMPLE1_XML);
+ String longitudeStr = RpcResultParser.parseXml(longitudeReply, "longitude");
+ assertEquals("-8.4683990", longitudeStr);
+ }
+
+ @Test
+ public void testLatitude() {
+ String latitudeReply = loadXml(SAMPLE1_XML);
+ String latitudeStr = RpcResultParser.parseXml(latitudeReply, "latitude");
+ assertEquals("51.9036140", latitudeStr);
+ }
+
+
+ private static String loadXml(final String fileName) {
+
+ InputStream inputStream = RpcResultParserTest.class.getResourceAsStream(fileName);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ StringBuilder result = new StringBuilder();
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ result.append(line);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return result.toString();
+ }
+}
\ No newline at end of file
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/TestEA1000MeterProvider.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/TestEA1000MeterProvider.java
new file mode 100644
index 0000000..e56e121
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/TestEA1000MeterProvider.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi;
+
+import org.onosproject.drivers.microsemi.yang.MseaUniEvcServiceNetconfService;
+import org.onosproject.netconf.NetconfController;
+
+public class TestEA1000MeterProvider extends EA1000MeterProvider {
+
+ public TestEA1000MeterProvider(NetconfController controller,
+ MseaUniEvcServiceNetconfService mseaUniEvcServiceSvc) {
+ this.controller = controller;
+ this.mseaUniEvcServiceSvc = mseaUniEvcServiceSvc;
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/CeVlanMapUtilsTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/CeVlanMapUtilsTest.java
new file mode 100644
index 0000000..c7b3e72
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/CeVlanMapUtilsTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
+
+public class CeVlanMapUtilsTest {
+
+ @Test
+ public void testGetVlanSet() {
+ Short[] vlanArray = CeVlanMapUtils.getVlanSet("101:102");
+ assertEquals(2, vlanArray.length);
+
+ vlanArray = CeVlanMapUtils.getVlanSet("101:103,107,110:115");
+ assertEquals(10, vlanArray.length);
+
+ vlanArray = CeVlanMapUtils.getVlanSet("1:4095");
+ assertEquals(4095, vlanArray.length);
+ }
+
+ @Test
+ public void testVlanListAsString() {
+ String ceVlanMap = CeVlanMapUtils.vlanListAsString(new Short[]{101, 102, 103});
+ assertEquals("101:103", ceVlanMap);
+
+ ceVlanMap = CeVlanMapUtils.vlanListAsString(new Short[]{0, 101, 104, 108});
+ assertEquals("101,104,108", ceVlanMap);
+ }
+
+ @Test
+ public void testAddtoCeVlanMap() {
+ String ceVlanMap = CeVlanMapUtils.addtoCeVlanMap("101:102", (short) 103);
+ assertEquals("101:103", ceVlanMap);
+
+ ceVlanMap = CeVlanMapUtils.addtoCeVlanMap("101:102", (short) 0);
+ assertEquals("101:102", ceVlanMap);
+
+ ceVlanMap = CeVlanMapUtils.addtoCeVlanMap("101:102", (short) 104);
+ assertEquals("101:102,104", ceVlanMap);
+ }
+
+ @Test
+ public void testRemoveZeroIfPossible() {
+ String ceVlanMap = CeVlanMapUtils.removeZeroIfPossible("101:102");
+ assertEquals("101:102", ceVlanMap);
+
+ ceVlanMap = CeVlanMapUtils.removeZeroIfPossible("0,101:102");
+ assertEquals("101:102", ceVlanMap);
+
+ ceVlanMap = CeVlanMapUtils.removeZeroIfPossible("0");
+ assertEquals("0", ceVlanMap);
+ }
+
+ @Test
+ public void testRemoveFromCeVlanMap() {
+ String ceVlanMap = CeVlanMapUtils.removeFromCeVlanMap("101:102", (short) 102);
+ assertEquals("101", ceVlanMap);
+
+ ceVlanMap = CeVlanMapUtils.removeFromCeVlanMap("101:103", (short) 102);
+ assertEquals("101,103", ceVlanMap);
+ }
+
+ @Test
+ public void testCombineVlanSets() {
+ assertEquals("101:104", CeVlanMapUtils.combineVlanSets("101:102", "103:104"));
+
+ assertEquals("101:103", CeVlanMapUtils.combineVlanSets("101:102", "103"));
+
+ assertEquals("101:102,104", CeVlanMapUtils.combineVlanSets("101:102", "104"));
+
+ assertEquals("99,101:102", CeVlanMapUtils.combineVlanSets("101:102", "99"));
+
+ assertEquals("101:102", CeVlanMapUtils.combineVlanSets("101:102", "0"));
+
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/IetfSystemManagerTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/IetfSystemManagerTest.java
new file mode 100644
index 0000000..098ecdd
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/IetfSystemManagerTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.UncheckedIOException;
+import java.text.ParseException;
+import java.time.OffsetDateTime;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.drivers.microsemi.yang.impl.IetfSystemManager;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfException;
+import org.onosproject.netconf.NetconfSession;
+import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.system.AugmentedSysSystem;
+import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.system.DefaultAugmentedSysSystem;
+import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.systemstate.platform.AugmentedSysPlatform;
+import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystem;
+import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.IetfSystemOpParam;
+import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.DefaultSystem;
+import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.System;
+import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.system.DefaultClock;
+import org.onosproject.yang.gen.v1.ietfsystem.rev20140806.ietfsystem.system.clock.timezone.DefaultTimezoneName;
+import org.onosproject.yang.gen.v1.ietfsystemmicrosemi.rev20160505.ietfsystemmicrosemi.systemstate.platform.DefaultAugmentedSysPlatform;
+
+public class IetfSystemManagerTest {
+
+ IetfSystemManager sysSvc = null;
+ NetconfSession session;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ sysSvc = new MockIetfSystemManager();
+ sysSvc.activate();
+ } catch (UncheckedIOException e) {
+ fail(e.getMessage());
+ }
+ NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo("netconf", "netconf", Ip4Address.valueOf("1.2.3.4"), 830);
+ session = new MockNetconfSessionEa1000(deviceInfo);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ sysSvc.deactivate();
+ }
+
+ @Test
+ public void testGetIetfSystemSession() throws NetconfException {
+ System system = new DefaultSystem();
+ system.clock(new DefaultClock());
+
+ IetfSystemOpParam sampleSystem = new IetfSystemOpParam();
+ sampleSystem.system(system);
+
+ IetfSystem sys = sysSvc.getIetfSystem(sampleSystem, session);
+ assertNotNull(sys);
+
+ assertEquals(sys.system().clock().timezone().getClass(), DefaultTimezoneName.class);
+ DefaultTimezoneName tzName = (DefaultTimezoneName) sys.system().clock().timezone();
+ assertEquals("Etc/UTC", tzName.timezoneName().string());
+ }
+
+ @Test
+ public void testGetIetfSystemInit() throws NetconfException {
+
+ IetfSystem sys = sysSvc.getIetfSystemInit(session);
+ assertNotNull(sys);
+ assertNotNull(sys.system());
+
+ AugmentedSysSystem sysSystem = (AugmentedSysSystem) sys.system().augmentation(DefaultAugmentedSysSystem.class);
+
+ assertEquals("-8.4683990", sysSystem.longitude().toPlainString());
+ assertEquals("51.9036140", sysSystem.latitude().toPlainString());
+ assertEquals("4.4.0-53-generic", sys.systemState().platform().osRelease());
+
+ AugmentedSysPlatform sysSystemState =
+ (AugmentedSysPlatform) sys.systemState().platform().augmentation(DefaultAugmentedSysPlatform.class);
+
+ assertEquals("Eagle Simulator.", sysSystemState.deviceIdentification().serialNumber());
+ }
+
+ @Test
+ public void testSetCurrentDatetime() throws NetconfException, ParseException {
+ sysSvc.setCurrentDatetime(OffsetDateTime.now(), session);
+ //Look at MockNetconfSessionEa1000::sampleXmlRegexSetCurrentDatetime() for catching an error
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockIetfSystemManager.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockIetfSystemManager.java
new file mode 100644
index 0000000..f035c70
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockIetfSystemManager.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+
+import org.onosproject.drivers.microsemi.yang.impl.IetfSystemManager;
+import org.onosproject.yang.MockYangRuntimeManager;
+import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
+import org.onosproject.yang.serializers.xml.XmlSerializer;
+
+public class MockIetfSystemManager extends IetfSystemManager {
+
+ @Override
+ public void activate() {
+ yCtx = new MockYangSerializerContext();
+ xSer = new XmlSerializer();
+ yangModelRegistry = new MockYangRuntimeManager();
+ ((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
+ (DefaultYangModelRegistry) yCtx.getContext());
+ ((MockYangRuntimeManager) yangModelRegistry).activate();
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaCfmManager.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaCfmManager.java
new file mode 100644
index 0000000..fb20697
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaCfmManager.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import org.onosproject.drivers.microsemi.yang.impl.MseaCfmManager;
+import org.onosproject.yang.MockYangRuntimeManager;
+import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
+import org.onosproject.yang.serializers.xml.XmlSerializer;
+
+public class MockMseaCfmManager extends MseaCfmManager {
+
+ @Override
+ public void activate() {
+ yCtx = new MockYangSerializerContext();
+ xSer = new XmlSerializer();
+ yangModelRegistry = new MockYangRuntimeManager();
+ ((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
+ (DefaultYangModelRegistry) yCtx.getContext());
+ ((MockYangRuntimeManager) yangModelRegistry).activate();
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaSaFilteringManager.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaSaFilteringManager.java
new file mode 100644
index 0000000..a2de180
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaSaFilteringManager.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import org.onosproject.drivers.microsemi.yang.impl.MseaSaFilteringManager;
+import org.onosproject.yang.MockYangRuntimeManager;
+import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
+import org.onosproject.yang.serializers.xml.XmlSerializer;
+
+public class MockMseaSaFilteringManager extends MseaSaFilteringManager {
+
+ @Override
+ public void activate() {
+ yCtx = new MockYangSerializerContext();
+ xSer = new XmlSerializer();
+ yangModelRegistry = new MockYangRuntimeManager();
+ ((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
+ (DefaultYangModelRegistry) yCtx.getContext());
+ ((MockYangRuntimeManager) yangModelRegistry).activate();
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaUniEvcServiceManager.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaUniEvcServiceManager.java
new file mode 100644
index 0000000..e7921c2
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockMseaUniEvcServiceManager.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import org.onosproject.drivers.microsemi.yang.impl.MseaUniEvcServiceManager;
+import org.onosproject.yang.MockYangRuntimeManager;
+import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+import org.onosproject.yang.serializers.xml.MockYangSerializerContext;
+import org.onosproject.yang.serializers.xml.XmlSerializer;
+
+public class MockMseaUniEvcServiceManager extends MseaUniEvcServiceManager {
+ @Override
+ public void activate() {
+ yCtx = new MockYangSerializerContext();
+ xSer = new XmlSerializer();
+ yangModelRegistry = new MockYangRuntimeManager();
+ ((MockYangRuntimeManager) yangModelRegistry).setModelRegistry(
+ (DefaultYangModelRegistry) yCtx.getContext());
+ ((MockYangRuntimeManager) yangModelRegistry).activate();
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockNetconfSessionEa1000.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockNetconfSessionEa1000.java
new file mode 100644
index 0000000..fc6da58
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockNetconfSessionEa1000.java
@@ -0,0 +1,1034 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Pattern;
+
+import org.onosproject.netconf.DatastoreId;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfDeviceOutputEventListener;
+import org.onosproject.netconf.NetconfException;
+import org.onosproject.netconf.NetconfSession;
+import org.onosproject.netconf.TargetConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MockNetconfSessionEa1000 implements NetconfSession {
+ private static final Logger log = LoggerFactory
+ .getLogger(MockNetconfSessionEa1000.class);
+
+ private static final String MESSAGE_ID_STRING = "message-id";
+ private static final String EQUAL = "=";
+ private static final String RPC_OPEN = "<rpc ";
+ private static final String RPC_CLOSE = "</rpc>";
+ private static final String GET_OPEN = "<get>";
+ private static final String GET_CLOSE = "</get>";
+ private static final String NEW_LINE = "\n";
+ private static final String SUBTREE_FILTER_OPEN = "<filter type=\"subtree\">";
+ private static final String SUBTREE_FILTER_CLOSE = "</filter>";
+ private static final String WITH_DEFAULT_OPEN = "<with-defaults ";
+ private static final String WITH_DEFAULT_CLOSE = "</with-defaults>";
+ private static final String EDIT_CONFIG_OPEN = "<edit-config>";
+ private static final String EDIT_CONFIG_CLOSE = "</edit-config>";
+ private static final String TARGET_OPEN = "<target>";
+ private static final String TARGET_CLOSE = "</target>";
+ private static final String DEFAULT_OPERATION_OPEN = "<default-operation>";
+ private static final String DEFAULT_OPERATION_CLOSE = "</default-operation>";
+ private static final String CONFIG_OPEN = "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">";
+ private static final String CONFIG_CLOSE = "</config>";
+
+ private static final String ENDPATTERN = "]]>]]>";
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ private static final String NETCONF_BASE_NAMESPACE =
+ "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"";
+ private static final String NETCONF_WITH_DEFAULTS_NAMESPACE =
+ "xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\"";
+
+
+ private Pattern sampleXmlRegex1 =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<get>).*(<filter).*"
+ + "(<system).*(<clock/>).*(</system>).*(</filter>)*.(</get>).*(</rpc).*(]]>){2}",
+ Pattern.DOTALL);
+
+ private Pattern sampleXmlRegex2 =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<get>).*(<filter).*(<system-state).*(</system-state>).*"
+ + "(<system).*(</system>).*(</filter>).*(</get>).*(</rpc).*(]]>){2}",
+ Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexSaFiltering =
+ Pattern.compile("(<\\?xml).*"
+ + "(<rpc).*(<get>).*"
+ + "(<filter type=\"subtree\">).*(<source-ipaddress-filtering).*"
+ + "(</filter>).*(</get>).*(</rpc>).*"
+ + "(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexEditConfigSaFilt =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
+ + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
+ + "(<source-ipaddress-filtering).*(<interface-eth0>).*"
+ + "(<source-address-range>).*(<range-id>).*(</range-id>).*"
+ + "(<name>).*(</name>).*(<ipv4-address-prefix>).*(</ipv4-address-prefix>).*"
+ + "(</source-address-range>).*(</interface-eth0>)*(</source-ipaddress-filtering>).*"
+ + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexEditDeleteSaFilt =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
+ + "(<target><running/></target>)\\R?"
+ + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
+ + "(<source-ipaddress-filtering "
+ + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">)\\R?"
+ + "(<interface-eth0>)\\R?"
+ + "((<source-address-range nc:operation=\"delete\">)\\R?"
+ + "(<range-id>)[0-9]*(</range-id>)\\R?"
+ + "((<name>)[a-zA-Z0-9]*(</name>))?\\R?"
+ + "((<ipv4-address-prefix>)[0-9\\\\./]*(</ipv4-address-prefix>))?\\R?"
+ + "(</source-address-range>))++\\R?"
+ + "(</interface-eth0>)\\R?"
+ + "(</source-ipaddress-filtering>)\\R?"
+ + "(</config>)\\R?"
+ + "(</edit-config>)\\R?(</rpc>).*(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexUniEvc =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?"
+ + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?"
+ + "(<filter type=\"subtree\">)\\R?"
+ + "(<mef-services "
+ + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\"/>)\\R?"
+ + "(</filter>)\\R?(</get-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexUniEvcUni =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?"
+ + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?"
+ + "(<filter type=\"subtree\">)\\R?"
+ + "(<mef-services "
+ + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?"
+ + "(<uni/>)\\R?"
+ + "(</mef-services>)\\R?"
+ + "(</filter>)\\R?(</get-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexEditConfigUni1Evc =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
+ + "(<target><running/></target>)\\R?"
+ + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
+ + "(<mef-services).*(<uni>)\\R?(<name>).*(</name>)\\R?"
+ + "(<evc>)\\R?(<evc-index>).*(</evc-index>)\\R?(<name>).*(</name>)\\R?"
+ + "(<evc-per-uni>)\\R?"
+ + "(<evc-per-uni-c>)\\R?"
+ + "(<ce-vlan-map>)[0-9]*(</ce-vlan-map>)\\R?"
+ + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ + "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?"
+ + "(<outer-tag-vlan>)[0-9]*(</outer-tag-vlan>)\\R?(</tag-push>)\\R?"
+ + "((<flow-mapping>)\\R?"
+ + "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?"
+ + "(<flow-id>)[0-9]*(</flow-id>)\\R?"
+ + "(</flow-mapping>)\\R?)*"
+ + "(</evc-per-uni-c>)\\R?"
+ + "(<evc-per-uni-n>)\\R?"
+ + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
+ + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ + "(<tag-pop).*"
+ + "((<flow-mapping>)\\R?"
+ + "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?"
+ + "(<flow-id>)[0-9]*(</flow-id>)\\R?"
+ + "(</flow-mapping>)\\R?)*"
+ + "(</evc-per-uni-n>)\\R?"
+ + "(</evc-per-uni>)\\R?"
+ + "(</evc>)\\R?"
+ + "(</uni>)\\R?"
+ + "(</mef-services>)\\R?"
+ + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexEditConfigUni2Evc =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
+ + "(<target><running/></target>)\\R?"
+ + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
+ + "(<mef-services).*(<uni>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?"
+ + "(<evc>)\\R?(<evc-index>)[0-9]*(</evc-index>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?"
+ + "(<evc-per-uni>)\\R?"
+ + "(<evc-per-uni-c>)\\R?"
+ + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
+ + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ + "(</evc-per-uni-c>)\\R?"
+ + "(<evc-per-uni-n>)\\R?"
+ + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
+ + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ + "(<evc-per-uni-service-type>).*(</evc-per-uni-service-type>)\\R?"
+ + "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?(<outer-tag-vlan>).*"
+ + "(</outer-tag-vlan>)\\R?(</tag-push>)\\R?"
+ + "(</evc-per-uni-n>)\\R?"
+ + "(</evc-per-uni>)\\R?"
+ + "(</evc>)\\R?"
+ + "(<evc>)\\R?(<evc-index>)[0-9]*(</evc-index>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?"
+ + "(<evc-per-uni>)\\R?"
+ + "(<evc-per-uni-c>)\\R?"
+ + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
+ + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ + "(</evc-per-uni-c>)\\R?"
+ + "(<evc-per-uni-n>)\\R?"
+ + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
+ + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
+ + "(</evc-per-uni-n>)\\R?"
+ + "(</evc-per-uni>)\\R?"
+ + "(</evc>)\\R?(</uni>).*"
+ + "(</mef-services>)\\R?"
+ + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexEditConfigUniProfiles =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
+ + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
+ + "(<mef-services).*(<profiles>).*"
+ + "(<bwp-group>).*(<group-index>).*(</group-index>).*(</bwp-group>).*"
+ + "(<bwp-group>).*(<group-index>).*(</group-index>).*"
+ + "(<bwp>).*(<cos-index>).*(</cos-index>).*(<color-mode>).*(</color-mode>).*(</bwp>).*"
+ + "(<bwp>).*(<cos-index>).*(</cos-index>).*(<color-mode>).*(</color-mode>).*(</bwp>).*"
+ + "(</bwp-group>).*"
+ + "(</profiles>).*(</mef-services>).*"
+ + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexEditConfigEvcDelete =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
+ + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
+ + "(<mef-services).*"
+ + "(<uni>).*"
+ + "(<evc nc:operation=\"delete\">).*(<evc-index>).*(</evc-index>).*(</evc>).*"
+ + "(</uni>).*"
+ + "(</mef-services>).*"
+ + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexGetConfigCeVlanMapsEvc =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?"
+ + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?"
+ + "(<filter type=\"subtree\">)\\R?"
+ + "(<mef-services).*"
+ + "(<uni>)\\R?"
+ + "(<evc>)\\R?"
+ + "(<evc-index/>)\\R?"
+ + "(<evc-per-uni>)\\R?"
+ + "(<evc-per-uni-c><ce-vlan-map/><flow-mapping/><ingress-bwp-group-index/></evc-per-uni-c>)\\R?"
+ + "(<evc-per-uni-n><ce-vlan-map/><flow-mapping/><ingress-bwp-group-index/></evc-per-uni-n>)\\R?"
+ + "(</evc-per-uni>)\\R?"
+ + "(</evc>)\\R?"
+ + "(</uni>)\\R?"
+ + "(</mef-services>)\\R?"
+ + "(</filter>)\\R?"
+ + "(</get-config>)\\R?"
+ + "(</rpc>)\\R?"
+ + "(]]>){2}", Pattern.DOTALL);
+
+ //For test testRemoveEvcUniFlowEntries()
+ private Pattern sampleXmlRegexEditConfigCeVlanMapReplace =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
+ + "(<target><running/></target>).*"
+ + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
+ + "(<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">).*"
+ + "(<uni>).*"
+ + "(<evc nc:operation=\"delete\">).*(<evc-index>.*</evc-index>).*(</evc>).*"
+ + "(<evc nc:operation=\"delete\">).*(<evc-index>.*</evc-index>).*(</evc>).*"
+ + "(<evc>).*(<evc-index>).*(</evc-index>).*(<evc-per-uni>).*"
+ + "(<evc-per-uni-c>).*"
+ + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
+ + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
+ + "(</evc-per-uni-c>).*"
+ + "(<evc-per-uni-n>).*"
+ + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
+ + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
+ + "(</evc-per-uni-n>).*"
+ + "(</evc-per-uni>).*(</evc>).*"
+ + "(<evc>).*(<evc-index>).*(</evc-index>).*(<evc-per-uni>).*"
+ + "(<evc-per-uni-c>).*"
+ + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
+ + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
+ + "(</evc-per-uni-c>).*"
+ + "(<evc-per-uni-n>).*"
+ + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
+ + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
+ + "(</evc-per-uni-n>).*"
+ + "(</evc-per-uni>).*(</evc>).*"
+ + "(</uni>).*(</mef-services>).*"
+ + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
+
+
+ //For testPerformMeterOperationDeviceIdMeterAdd()
+ private Pattern sampleXmlRegexEditConfigBwpGroup1 =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
+ + "(<target>\\R?<running/>\\R?</target>)\\R?"
+ + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
+ + "(<mef-services "
+ + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?"
+ + "(<profiles>)\\R?"
+ + "(<bwp-group>)\\R?"
+ + "(<group-index>)[0-9]*(</group-index>)\\R?"
+ + "(<bwp>)\\R?"
+ + "(<cos-index>)[0-9]*(</cos-index>)\\R?"
+ + "(<name>).*(</name>)\\R?"
+ + "(<committed-information-rate>)[0-9]*(</committed-information-rate>)\\R?"
+ + "(<committed-burst-size>)[0-9]*(</committed-burst-size>)\\R?"
+ + "(<excess-information-rate>)[0-9]*(</excess-information-rate>)\\R?"
+ + "(<excess-burst-size>)[0-9]*(</excess-burst-size>)\\R?"
+ + "(</bwp>)\\R?"
+ + "(</bwp-group>)\\R?"
+ + "(<cos>)\\R?"
+ + "(<cos-index>)[0-9](</cos-index>)\\R?"
+ + "(<name>).*(</name>)\\R?"
+ + "(<outgoing-cos-value>)[0-9]*(</outgoing-cos-value>)\\R?"
+ + "(<color-aware>true</color-aware>)\\R?"
+ + "(<color-forward>true</color-forward>)\\R?"
+ + "(<evc-cos-type-all-8-prio-to-1-evc-color>)\\R?"
+ + "(<evc-all-8-color-to>green</evc-all-8-color-to>)\\R?"
+ + "(</evc-cos-type-all-8-prio-to-1-evc-color>)\\R?"
+ + "(</cos>)\\R?"
+ + "(</profiles>)\\R?"
+ + "(</mef-services>)\\R?"
+ + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
+
+ //For testPerformMeterOperationDeviceIdMeterRemove()
+ private Pattern sampleXmlRegexEditConfigBwpGroup1Delete =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
+ + "(<target>\\R?<running/>\\R?</target>)\\R?"
+ + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
+ + "(<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?"
+ + "(<profiles>)\\R?"
+ + "((<bwp-group nc:operation=\"delete\">)\\R?"
+ + "(<group-index>)[0-9]*(</group-index>)\\R?"
+ + "(<bwp>.*</bwp>)?"
+ + "(</bwp-group>))++\\R?"
+ + "(</profiles>)\\R?"
+ + "(</mef-services>)\\R?"
+ + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
+
+ private Pattern sampleXmlRegexSetCurrentDatetime =
+ Pattern.compile("(<\\?xml).*(<rpc).*"
+ + "(<set-current-datetime xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">)\\R?"
+ + "(<current-datetime>)"
+ + "[0-9]{4}-[0-9]{2}-[0-9]{2}(T)[0-9]{2}:[0-9]{2}:[0-9]{2}[+-][0-9]{2}:[0-9]{2}"
+ + "(</current-datetime>)\\R?"
+ + "(</set-current-datetime>)\\R?"
+ + "(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
+
+ //For testGetConfigMseaCfmEssentials
+ private Pattern sampleXmlRegexGetMseaCfmEssentials =
+ Pattern.compile("(<\\?xml).*(<rpc).*(<get>)\\R?"
+ + "(<filter type=\"subtree\">)\\R?"
+ + "(<mef-cfm).*"
+ + "(<maintenance-domain>)\\R?"
+ + "(<id/>)\\R?"
+ + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
+ + "(<md-level/>)\\R?"
+ + "(<maintenance-association>)\\R?"
+ + "(<id/>)\\R?"
+ + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
+ + "(<ccm-interval>)[0-9]{1,3}(ms</ccm-interval>)\\R?"
+ + "(<remote-meps/>)\\R?"
+ + "(<component-list/>)\\R?"
+ + "(<maintenance-association-end-point>)\\R?"
+ + "(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)\\R?"
+ + "(<interface/>)\\R?"
+ + "(<primary-vid/>)\\R?"
+ + "(<administrative-state/>)\\R?"
+ + "(<ccm-ltm-priority/>)\\R?"
+ + "(<continuity-check/>)\\R?"
+ + "(<mac-address/>)\\R?"
+ + "(<msea-soam-fm:port-status/>)\\R?"
+ + "(<msea-soam-fm:interface-status/>)\\R?"
+ + "(<msea-soam-fm:last-defect-sent/>)\\R?"
+ + "(<msea-soam-fm:rdi-transmit-status/>)\\R?"
+ + "(<loopback/>)\\R?"
+ + "(<remote-mep-database/>)\\R?"
+ + "(<linktrace/>)\\R?"
+ + "(</maintenance-association-end-point>)\\R?"
+ + "(</maintenance-association>)\\R?"
+ + "(</maintenance-domain>)\\R?"
+ + "(</mef-cfm>)\\R?"
+ + "(</filter>)\\R?"
+ + "(</get>)\\R?"
+ + "(</rpc>)\\R?"
+ + "(]]>){2}", Pattern.DOTALL);
+
+
+ private static final String SAMPLE_SYSTEM_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
+ + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+ + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n"
+ + "<clock><timezone-name>Etc/UTC</timezone-name></clock>\n"
+ + "</system>\n"
+ + "</data>\n"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_SYSTEM_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">"
+ + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+ + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n"
+ + "<longitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">-8.4683990</longitude>\n"
+ + "<latitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">51.9036140</latitude>\n"
+ + "</system>\n"
+ + "<system-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\""
+ + " xmlns:sysms=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">\n"
+ + "<platform>\n"
+ + "<os-release>4.4.0-53-generic</os-release>\n"
+ + "<sysms:device-identification>\n"
+ + "<sysms:serial-number>Eagle Simulator.</sysms:serial-number>\n"
+ + "</sysms:device-identification>\n"
+ + "</platform>\n"
+ + "</system-state>\n"
+ + "</data>"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_MSEASAFILTERING_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
+ + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+ + "<source-ipaddress-filtering "
+ + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">\n"
+ + "<interface-eth0>\n"
+ + "<filter-admin-state>inactive</filter-admin-state>\n"
+ + "<source-address-range>\n"
+ + "<range-id>1</range-id>\n"
+ + "<ipv4-address-prefix>10.10.10.10/16</ipv4-address-prefix>\n"
+ + "<name>Filter1</name>\n"
+ + "</source-address-range>\n"
+ + "<source-address-range>\n"
+ + "<range-id>2</range-id>\n"
+ + "<ipv4-address-prefix>20.30.40.50/18</ipv4-address-prefix>\n"
+ + "<name>Flow:5e0000abaa2772</name>\n"
+ + "</source-address-range>\n"
+ + "</interface-eth0>\n"
+ + "</source-ipaddress-filtering>\n"
+ + "</data>\n"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_MSEAEVCUNI_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
+ + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+ + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\"/>"
+ + "</data>\n"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_MSEAEVCUNI_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
+ + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+ + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n"
+ + "<uni>\n"
+ + "<name>Flow:7557655abfecd57865</name>\n"
+ + "<evc>\n"
+ + "<evc-index>7</evc-index\n>"
+ + "<name>evc-7</name>\n"
+ + "<evc-per-uni>\n"
+ + "<evc-per-uni-c>\n"
+ + "<ce-vlan-map>10</ce-vlan-map>\n"
+ + "<ingress-bwp-group-index>1</ingress-bwp-group-index>\n"
+ + "<tag-push>\n"
+ + "<push-tag-type>pushStag</push-tag-type>\n"
+ + "<outer-tag-vlan>3</outer-tag-vlan>\n"
+ + "</tag-push>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>10</ce-vlan-id>\n"
+ + "<flow-id>27021600672053710</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n"
+ + "</evc-per-uni-c>\n"
+ + "<evc-per-uni-n>\n"
+ + "<ce-vlan-map>11</ce-vlan-map>\n"
+ + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>11</ce-vlan-id>\n"
+ + "<flow-id>27021600672053711</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "</evc-per-uni-n>\n"
+ + "</evc-per-uni>\n"
+ + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n"
+ + "<evc-status>\n"
+ + "<operational-state>unknown</operational-state>\n"
+ + "<max-mtu-size>9600</max-mtu-size>\n"
+ + "<max-num-uni>2</max-num-uni>\n"
+ + "</evc-status>\n"
+ + "</evc>\n"
+ + "<evc>\n"
+ + "<evc-index>8</evc-index>\n"
+ + "<name>evc-8</name>\n"
+ + "<evc-per-uni>\n"
+ + "<evc-per-uni-c>\n"
+ + "<ce-vlan-map>12:14,20:22,25</ce-vlan-map>\n"
+ + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
+ + "<tag-pop />\n"
+ + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>12</ce-vlan-id>\n"
+ + "<flow-id>27021600672053712</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>13</ce-vlan-id>\n"
+ + "<flow-id>27021600672053713</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>14</ce-vlan-id>\n"
+ + "<flow-id>27021600672053714</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>20</ce-vlan-id>\n"
+ + "<flow-id>27021600672053720</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>21</ce-vlan-id>\n"
+ + "<flow-id>27021600672053721</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>22</ce-vlan-id>\n"
+ + "<flow-id>27021600672053722</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>25</ce-vlan-id>\n"
+ + "<flow-id>27021600672053725</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "</evc-per-uni-c>\n"
+ + "<evc-per-uni-n>\n"
+ + "<ce-vlan-map>13</ce-vlan-map>\n"
+ + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>13</ce-vlan-id>\n"
+ + "<flow-id>27021600672053713</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "</evc-per-uni-n>\n"
+ + "</evc-per-uni>\n"
+ + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n"
+ + "<evc-status>\n"
+ + "<operational-state>unknown</operational-state>\n"
+ + "<max-mtu-size>9600</max-mtu-size>\n"
+ + "<max-num-uni>2</max-num-uni>\n"
+ + "</evc-status>\n"
+ + "</evc>\n"
+ + "</uni>\n"
+ + "<profiles>\n"
+ + "<bwp-group>\n"
+ + "<group-index>0</group-index>\n"
+ + "</bwp-group>\n"
+ + "</profiles>\n"
+ + "</mef-services>\n"
+ + "</data>\n"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
+ + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+ + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n"
+ + "<uni>\n"
+
+ + "<evc><evc-index>1</evc-index>\n"
+ + "<evc-per-uni>\n"
+ + "<evc-per-uni-c>\n"
+ + "<ce-vlan-map>101</ce-vlan-map>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>101</ce-vlan-id>\n"
+ + "<flow-id>27021598629213101</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "</evc-per-uni-c>\n"
+ + "<evc-per-uni-n>\n"
+ + "<ce-vlan-map>102</ce-vlan-map>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>102</ce-vlan-id>\n"
+ + "<flow-id>27021598629213102</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "</evc-per-uni-n>\n"
+ + "</evc-per-uni>\n"
+ + "</evc>\n"
+
+ + "<evc><evc-index>7</evc-index>\n"
+ + "<evc-per-uni>\n"
+ + "<evc-per-uni-c>\n"
+ + "<ce-vlan-map>700,710,720</ce-vlan-map>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>700</ce-vlan-id>\n"
+ + "<flow-id>27021598629213700</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>710</ce-vlan-id>\n"
+ + "<flow-id>27021598629213710</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>720</ce-vlan-id>\n"
+ + "<flow-id>27021598629213720</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "</evc-per-uni-c>\n"
+ + "<evc-per-uni-n>\n"
+ + "<ce-vlan-map>701:703</ce-vlan-map>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>701</ce-vlan-id>\n"
+ + "<flow-id>27021598629213701</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>702</ce-vlan-id>\n"
+ + "<flow-id>27021598629213702</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "<flow-mapping>\n"
+ + "<ce-vlan-id>703</ce-vlan-id>\n"
+ + "<flow-id>27021598629213703</flow-id>\n"
+ + "</flow-mapping>\n"
+ + "</evc-per-uni-n>\n"
+ + "</evc-per-uni>\n"
+ + "</evc>\n"
+
+ + "<evc><evc-index>8</evc-index>\n"
+ + "<evc-per-uni>\n"
+ + "<evc-per-uni-c>\n<ce-vlan-map>800,810,820</ce-vlan-map>\n</evc-per-uni-c>\n"
+ + "<evc-per-uni-n>\n<ce-vlan-map>801:803</ce-vlan-map>\n</evc-per-uni-n>\n"
+ + "</evc-per-uni>\n"
+ + "</evc>\n"
+
+ + "</uni>\n"
+ + "</mef-services>\n"
+ + "</data>\n"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_MSEACFM_MD_MA_MEP_REPLY =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
+ + "<data>"
+ + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
+ + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
+ + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
+ + "<maintenance-domain>"
+ + "<id>1</id>"
+ + "<name>md-1</name>"
+ + "<md-level>3</md-level>"
+ + "<maintenance-association>"
+ + "<id>1</id>"
+ + "<name>ma-1-1</name>"
+ + "<ccm-interval>10ms</ccm-interval>" //Causing problems on create of MA
+ + "<remote-meps>1</remote-meps>"
+ + "<remote-meps>2</remote-meps>"
+ + "<component-list>"
+ + "<vid>100</vid>"
+ + "<tag-type>vlan-stag</tag-type>"
+ + "</component-list>"
+ + "<maintenance-association-end-point>"
+ + "<mep-identifier>1</mep-identifier>"
+ + "<interface>eth1</interface>"
+ + "<primary-vid>100</primary-vid>"
+ + "<administrative-state>true</administrative-state>"
+ + "<ccm-ltm-priority>4</ccm-ltm-priority>"
+ + "<continuity-check>"
+ + "<cci-enabled>true</cci-enabled>"
+ + "<fng-state>report-defect</fng-state>"
+ + "<highest-priority-defect-found>remote-mac-error</highest-priority-defect-found>"
+ + "<active-defects> remote-mac-error invalid-ccm</active-defects>"
+ + "<last-error-ccm>U2FtcGxlIGxhc3QgZXJyb3IgY2NtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA==</last-error-ccm>"
+ + "<ccm-sequence-error-count>10</ccm-sequence-error-count>"
+ + "<sent-ccms>15</sent-ccms>"
+ + "</continuity-check>"
+ + "<mac-address>53:65:61:6e:20:43</mac-address>"
+ + "<msea-soam-fm:port-status>no-status-tlv</msea-soam-fm:port-status>"
+ + "<msea-soam-fm:interface-status>no-status-tlv</msea-soam-fm:interface-status>"
+// + "<msea-soam-fm:last-defect-sent/>" --Can't handle this at the moment
+ + "<msea-soam-fm:rdi-transmit-status>false</msea-soam-fm:rdi-transmit-status>"
+ + "<loopback>"
+ + "<replies-received>123</replies-received>"
+ + "<replies-transmitted>456</replies-transmitted>"
+ + "</loopback>"
+ + "<remote-mep-database>"
+ + "<remote-mep>"
+ + "<remote-mep-id>2</remote-mep-id>"
+ + "<remote-mep-state>ok</remote-mep-state>"
+ + "<failed-ok-time>1490692834</failed-ok-time>"
+ + "<mac-address>53:65:61:6e:20:43</mac-address>"
+ + "<rdi>true</rdi>"
+ + "<port-status-tlv>up</port-status-tlv>"
+ + "<interface-status-tlv>dormant</interface-status-tlv>"
+ + "</remote-mep>"
+ + "</remote-mep-database>"
+ + "<linktrace>"
+ + "<unexpected-replies-received>0</unexpected-replies-received>"
+ + "<msea-soam-fm:ltm-msgs-transmitted>2</msea-soam-fm:ltm-msgs-transmitted>"
+ + "<msea-soam-fm:ltm-msgs-received>2</msea-soam-fm:ltm-msgs-received>"
+ + "<msea-soam-fm:ltr-msgs-transmitted>2</msea-soam-fm:ltr-msgs-transmitted>"
+ + "<msea-soam-fm:ltr-msgs-received>2</msea-soam-fm:ltr-msgs-received>"
+ + "<linktrace-database/>"
+ + "</linktrace>"
+ + "</maintenance-association-end-point>"
+ + "<remote-meps>4</remote-meps>"
+ + "</maintenance-association>"
+ + "</maintenance-domain>"
+ + "</mef-cfm>"
+ + "</data>"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_MSEACFM_MD_MA_MEP_REPLY2 =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
+ + "<data>"
+ + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
+ + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
+ + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
+ + "<maintenance-domain>"
+ + "<id>1</id>"
+ + "<name>Microsemi</name>"
+ + "<md-level>2</md-level>"
+ + "<maintenance-association>"
+ + "<id>1</id>"
+ + "<name>example-ma</name>"
+ + "<remote-meps>1</remote-meps>"
+ + "<remote-meps>2</remote-meps>"
+ + "<component-list>"
+ + "<vid>100</vid>"
+ + "<tag-type>vlan-stag</tag-type>"
+ + "</component-list>"
+ + "<maintenance-association-end-point>"
+ + "<mep-identifier>4</mep-identifier>"
+ + "<interface>eth1</interface>"
+ + "<primary-vid>100</primary-vid>"
+ + "<administrative-state>true</administrative-state>"
+ + "<ccm-ltm-priority>4</ccm-ltm-priority>"
+ + "<continuity-check>"
+ + "<cci-enabled>true</cci-enabled>"
+ + "<fng-state>defect-reported</fng-state>"
+ + "<highest-priority-defect-found>remote-invalid-ccm</highest-priority-defect-found>"
+// + "<active-defects> remote-invalid-ccm</active-defects>"
+ + "<active-defects/>"
+ + "<ccm-sequence-error-count>0</ccm-sequence-error-count>"
+ + "<sent-ccms>41013</sent-ccms>"
+ + "</continuity-check>"
+ + "<mac-address>00:b0:ae:03:ff:31</mac-address>"
+ + "<msea-soam-fm:port-status>up</msea-soam-fm:port-status>"
+ + "<msea-soam-fm:interface-status>up</msea-soam-fm:interface-status>"
+ + "<msea-soam-fm:rdi-transmit-status>true</msea-soam-fm:rdi-transmit-status>"
+ + "<loopback>"
+ + "<replies-received>0</replies-received>"
+ + "<replies-transmitted>0</replies-transmitted>"
+ + "</loopback>"
+ + "<remote-mep-database>"
+ + "<remote-mep>"
+ + "<remote-mep-id>1</remote-mep-id>"
+ + "<remote-mep-state>failed</remote-mep-state>"
+ + "<failed-ok-time>26315533</failed-ok-time>"
+ + "<mac-address>00:00:00:00:00:00</mac-address>"
+ + "<rdi>false</rdi>"
+ + "<port-status-tlv>no-status-tlv</port-status-tlv>"
+ + "<interface-status-tlv>no-status-tlv</interface-status-tlv>"
+ + "</remote-mep>"
+ + "<remote-mep>"
+ + "<remote-mep-id>2</remote-mep-id>"
+ + "<remote-mep-state>failed</remote-mep-state>"
+ + "<failed-ok-time>26315541</failed-ok-time>"
+ + "<mac-address>00:00:00:00:00:00</mac-address>"
+ + "<rdi>false</rdi>"
+ + "<port-status-tlv>no-status-tlv</port-status-tlv>"
+ + "<interface-status-tlv>no-status-tlv</interface-status-tlv>"
+ + "</remote-mep>"
+ + "</remote-mep-database>"
+ + "<linktrace />"
+ + "</maintenance-association-end-point>"
+ + "<remote-meps>4</remote-meps>"
+ + "</maintenance-association>"
+ + "</maintenance-domain>"
+ + "</mef-cfm>"
+ + "</data>"
+ + "</rpc-reply>";
+
+ private static final String SAMPLE_REPLY_OK = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"2\">"
+ + "<ok/>"
+ + "</rpc-reply>";
+
+ private NetconfDeviceInfo deviceInfo;
+
+ private final AtomicInteger messageIdInteger = new AtomicInteger(0);
+
+ public MockNetconfSessionEa1000(NetconfDeviceInfo deviceInfo) throws NetconfException {
+ this.deviceInfo = deviceInfo;
+ }
+
+ @Override
+ public CompletableFuture<String> request(String request) throws NetconfException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String get(String request) throws NetconfException {
+
+ return sendRequest(request);
+ }
+
+ @Override
+ public String get(String filterSchema, String withDefaultsMode) throws NetconfException {
+ StringBuilder rpc = new StringBuilder(XML_HEADER);
+ rpc.append(RPC_OPEN);
+ rpc.append(MESSAGE_ID_STRING);
+ rpc.append(EQUAL);
+ rpc.append("\"");
+ rpc.append(messageIdInteger.get());
+ rpc.append("\" ");
+ rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
+ rpc.append(GET_OPEN).append(NEW_LINE);
+ if (filterSchema != null) {
+ rpc.append(SUBTREE_FILTER_OPEN).append(NEW_LINE);
+ rpc.append(filterSchema).append(NEW_LINE);
+ rpc.append(SUBTREE_FILTER_CLOSE).append(NEW_LINE);
+ }
+ if (withDefaultsMode != null) {
+ rpc.append(WITH_DEFAULT_OPEN).append(NETCONF_WITH_DEFAULTS_NAMESPACE).append(">");
+ rpc.append(withDefaultsMode).append(WITH_DEFAULT_CLOSE).append(NEW_LINE);
+ }
+ rpc.append(GET_CLOSE).append(NEW_LINE);
+ rpc.append(RPC_CLOSE).append(NEW_LINE);
+ rpc.append(ENDPATTERN);
+ String reply = sendRequest(rpc.toString());
+ checkReply(reply);
+ return reply;
+ }
+
+ @Override
+ public String doWrappedRpc(String request) throws NetconfException {
+ StringBuilder rpc = new StringBuilder(XML_HEADER);
+ rpc.append(RPC_OPEN);
+ rpc.append(MESSAGE_ID_STRING);
+ rpc.append(EQUAL);
+ rpc.append("\"");
+ rpc.append(messageIdInteger.get());
+ rpc.append("\" ");
+ rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
+ rpc.append(request);
+ rpc.append(RPC_CLOSE).append(NEW_LINE);
+ rpc.append(ENDPATTERN);
+ String reply = sendRequest(rpc.toString());
+ checkReply(reply);
+ return reply;
+ }
+
+ @Override
+ public String requestSync(String request) throws NetconfException {
+ if (!request.contains(ENDPATTERN)) {
+ request = request + NEW_LINE + ENDPATTERN;
+ }
+ String reply = sendRequest(request);
+ checkReply(reply);
+ return reply;
+ }
+
+
+ @Override
+ public String getConfig(DatastoreId targetConfiguration, String configurationSchema) throws NetconfException {
+ StringBuilder rpc = new StringBuilder(XML_HEADER);
+ rpc.append("<rpc ");
+ rpc.append(MESSAGE_ID_STRING);
+ rpc.append(EQUAL);
+ rpc.append("\"");
+ rpc.append(messageIdInteger.get());
+ rpc.append("\" ");
+ rpc.append("xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
+ rpc.append("<get-config>\n");
+ rpc.append("<source>\n");
+ rpc.append("<").append(targetConfiguration).append("/>");
+ rpc.append("</source>");
+ if (configurationSchema != null) {
+ rpc.append("<filter type=\"subtree\">\n");
+ rpc.append(configurationSchema).append("\n");
+ rpc.append("</filter>\n");
+ }
+ rpc.append("</get-config>\n");
+ rpc.append("</rpc>\n");
+ rpc.append(ENDPATTERN);
+ String reply = sendRequest(rpc.toString());
+ return checkReply(reply) ? reply : "ERROR " + reply;
+ }
+
+ @Override
+ public boolean editConfig(String newConfiguration) throws NetconfException {
+ return editConfig(DatastoreId.RUNNING, null, newConfiguration);
+ }
+
+ @Override
+ public boolean editConfig(DatastoreId targetConfiguration, String mode, String newConfiguration)
+ throws NetconfException {
+ newConfiguration = newConfiguration.trim();
+ StringBuilder rpc = new StringBuilder(XML_HEADER);
+ rpc.append(RPC_OPEN);
+ rpc.append(MESSAGE_ID_STRING);
+ rpc.append(EQUAL);
+ rpc.append("\"");
+ rpc.append(messageIdInteger.get());
+ rpc.append("\" ");
+ rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
+ rpc.append(EDIT_CONFIG_OPEN).append("\n");
+ rpc.append(TARGET_OPEN);
+ rpc.append("<").append(targetConfiguration).append("/>");
+ rpc.append(TARGET_CLOSE).append("\n");
+ if (mode != null) {
+ rpc.append(DEFAULT_OPERATION_OPEN);
+ rpc.append(mode);
+ rpc.append(DEFAULT_OPERATION_CLOSE).append("\n");
+ }
+ rpc.append(CONFIG_OPEN).append("\n");
+ rpc.append(newConfiguration);
+ rpc.append(CONFIG_CLOSE).append("\n");
+ rpc.append(EDIT_CONFIG_CLOSE).append("\n");
+ rpc.append(RPC_CLOSE);
+ rpc.append(ENDPATTERN);
+ log.debug(rpc.toString());
+ String reply = sendRequest(rpc.toString());
+ return checkReply(reply);
+ }
+
+ @Override
+ public boolean copyConfig(String targetConfiguration, String newConfiguration) throws NetconfException {
+ return copyConfig(TargetConfig.valueOf(targetConfiguration), newConfiguration);
+ }
+
+ @Override
+ public void startSubscription() throws NetconfException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void startSubscription(String filterSchema) throws NetconfException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void endSubscription() throws NetconfException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean lock() throws NetconfException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean unlock() throws NetconfException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean close() throws NetconfException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getSessionId() {
+ return "mockSessionId";
+ }
+
+ @Override
+ public String getServerCapabilities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setDeviceCapabilities(List<String> capabilities) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private boolean checkReply(String reply) throws NetconfException {
+ if (reply != null) {
+ if (!reply.contains("<rpc-error>")) {
+ log.debug("Device {} sent reply {}", deviceInfo, reply);
+ return true;
+ } else if (reply.contains("<ok/>")
+ || (reply.contains("<rpc-error>")
+ && reply.contains("warning"))) {
+ log.debug("Device {} sent reply {}", deviceInfo, reply);
+ return true;
+ }
+ }
+ log.warn("Device {} has error in reply {}", deviceInfo, reply);
+ return false;
+ }
+
+ private String sendRequest(String request) throws NetconfException {
+ log.info("Mocking NETCONF Session send request: \n" + request);
+
+ if (sampleXmlRegex1.matcher(request).matches()) {
+ return SAMPLE_SYSTEM_REPLY;
+
+ } else if (sampleXmlRegex2.matcher(request).matches()) {
+ return SAMPLE_SYSTEM_REPLY_INIT;
+
+ } else if (sampleXmlRegexSaFiltering.matcher(request).matches()) {
+ return SAMPLE_MSEASAFILTERING_FE_REPLY;
+
+ } else if (sampleXmlRegexEditConfigSaFilt.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexEditDeleteSaFilt.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexUniEvc.matcher(request).matches()) {
+ return SAMPLE_MSEAEVCUNI_REPLY_INIT;
+
+ } else if (sampleXmlRegexUniEvcUni.matcher(request).matches()) {
+ return SAMPLE_MSEAEVCUNI_FE_REPLY;
+
+ } else if (sampleXmlRegexEditConfigUni1Evc.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexEditConfigUni2Evc.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexEditConfigUniProfiles.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexEditConfigEvcDelete.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexGetConfigCeVlanMapsEvc.matcher(request).matches()) {
+ return SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY;
+
+ } else if (sampleXmlRegexEditConfigCeVlanMapReplace.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexEditConfigBwpGroup1.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexEditConfigBwpGroup1Delete.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexSetCurrentDatetime.matcher(request).matches()) {
+ return SAMPLE_REPLY_OK;
+
+ } else if (sampleXmlRegexGetMseaCfmEssentials.matcher(request).matches()) {
+ return SAMPLE_MSEACFM_MD_MA_MEP_REPLY2;
+
+ } else {
+ throw new NetconfException("MocknetconfSession. No sendRequest() case for query: " +
+ request);
+ }
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaCfmManagerTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaCfmManagerTest.java
new file mode 100644
index 0000000..e3a81bc
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaCfmManagerTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.UncheckedIOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.drivers.microsemi.yang.impl.MseaCfmManager;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfException;
+import org.onosproject.netconf.NetconfSession;
+import org.onosproject.yang.gen.v1.mseacfm.rev20160229.MseaCfm;
+import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.DefaultMefCfm;
+import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.MefCfm;
+import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.DefaultMaintenanceDomain;
+import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.MaintenanceDomain;
+import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.DefaultNameCharacterString;
+import org.onosproject.yang.gen.v1.mseacfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.NameCharacterString;
+import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.Identifier45;
+
+public class MseaCfmManagerTest {
+
+ MseaCfmManager mseaCfmService;
+ NetconfSession session;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ mseaCfmService = new MockMseaCfmManager();
+ mseaCfmService.activate();
+ } catch (UncheckedIOException e) {
+ fail(e.getMessage());
+ }
+ NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo("netconf", "netconf", Ip4Address.valueOf("1.2.3.4"), 830);
+ session = new MockNetconfSessionEa1000(deviceInfo);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetConfigMseaCfmEssentials() throws NetconfException {
+ MseaCfm mseaCfm = mseaCfmService.getMepEssentials("md-1", "ma-1-1", 1, session);
+ assertNotNull(mseaCfm);
+
+ //See SAMPLE_MSEACFM_MD_MA_MEP_REPLY in MockNetconfSessionEa1000
+ assertEquals(1, mseaCfm.mefCfm().maintenanceDomain().size());
+ assertEquals(2, mseaCfm.mefCfm().maintenanceDomain().get(0).mdLevel().uint8());
+ }
+
+ /**
+ * Create the Maintenance Domain "md-1".
+ * @throws NetconfException
+ */
+ @Test
+ public void testSetMseaCfm() throws NetconfException {
+ NameCharacterString mdName = new DefaultNameCharacterString();
+ mdName.name(Identifier45.fromString("md-1"));
+
+ MaintenanceDomain yangMd = new DefaultMaintenanceDomain();
+ yangMd.id((short) 1);
+ yangMd.mdNameAndTypeCombo(mdName);
+
+ MefCfm mefCfm = new DefaultMefCfm();
+ mefCfm.addToMaintenanceDomain(yangMd);
+ //FIXME implement this
+// MseaCfmOpParam mseaCfmOpParam = (MseaCfmOpParam) MseaCfmOpParam.builder().mefCfm(mefCfm).build();
+// mseaCfmService.setMseaCfm(mseaCfmOpParam, session, NcDsType.running);
+ }
+
+ @Test
+ public void testTransmitLoopback() throws NetconfException {
+ try {
+ mseaCfmService.transmitLoopback(null, session);
+ } catch (UnsupportedOperationException e) {
+ assertTrue(e.getMessage().contains("Not yet implemented"));
+ }
+ }
+
+ @Test
+ public void testAbortLoopback() throws NetconfException {
+ try {
+ mseaCfmService.abortLoopback(null, session);
+ } catch (UnsupportedOperationException e) {
+ assertTrue(e.getMessage().contains("Not yet implemented"));
+ }
+ }
+
+ @Test
+ public void testTransmitLinktrace() throws NetconfException {
+ try {
+ mseaCfmService.transmitLinktrace(null, session);
+ } catch (UnsupportedOperationException e) {
+ assertTrue(e.getMessage().contains("Not yet implemented"));
+ }
+ }
+
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaSaFilteringManagerTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaSaFilteringManagerTest.java
new file mode 100644
index 0000000..acb6ae6
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaSaFilteringManagerTest.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.UncheckedIOException;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.drivers.microsemi.yang.impl.MseaSaFilteringManager;
+import org.onosproject.netconf.DatastoreId;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfException;
+import org.onosproject.netconf.NetconfSession;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFiltering;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.MseaSaFilteringOpParam;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.DefaultSourceIpaddressFiltering;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.SourceIpaddressFiltering;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.DefaultInterfaceEth0;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.InterfaceEth0;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.DefaultSourceAddressRange;
+import org.onosproject.yang.gen.v1.mseasafiltering.rev20160412.mseasafiltering.sourceipaddressfiltering.interfaceeth0.SourceAddressRange;
+
+public class MseaSaFilteringManagerTest {
+
+ MseaSaFilteringManager mseaSaSvc;
+ NetconfSession session;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ mseaSaSvc = new MockMseaSaFilteringManager();
+ mseaSaSvc.activate();
+ } catch (UncheckedIOException e) {
+ fail(e.getMessage());
+ }
+ NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo("netconf", "netconf", Ip4Address.valueOf("1.2.3.4"), 830);
+ session = new MockNetconfSessionEa1000(deviceInfo);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetMseaSaFilteringMseaSaFilteringOpParamNetconfSession() throws NetconfException {
+ SourceIpaddressFiltering sip = new DefaultSourceIpaddressFiltering();
+
+ MseaSaFilteringOpParam op = new MseaSaFilteringOpParam();
+ op.sourceIpaddressFiltering(sip);
+
+ MseaSaFiltering result = mseaSaSvc.getMseaSaFiltering(op, session);
+
+ //Results come from MockNetconfSession SAMPLE_MSEASAFILTERING_REPLY_INIT
+ assertNotNull(result.sourceIpaddressFiltering().interfaceEth0().sourceAddressRange());
+ List<SourceAddressRange> ranges = result.sourceIpaddressFiltering().interfaceEth0().sourceAddressRange();
+ assertEquals(2, ranges.size());
+
+ for (SourceAddressRange sa:ranges) {
+ if (sa.rangeId() == 1) {
+ assertEquals("10.10.10.10/16", sa.ipv4AddressPrefix());
+
+ } else if (sa.rangeId() == 2) {
+ assertEquals("20.30.40.50/18", sa.ipv4AddressPrefix());
+ }
+ }
+ }
+
+ @Test
+ public void testSetMseaSaFilteringMseaSaFilteringOpParamNetconfSessionNcDsType() {
+
+ MseaSaFilteringOpParam mseaSaFilteringConfig =
+ createConfigForEdit("192.168.60.10/27", (short) 3, "Filter3");
+
+ //Calling on the edit-config just makes the change and hopefully does not throw a Netconf Exception
+ try {
+ mseaSaSvc.setMseaSaFiltering(mseaSaFilteringConfig, session, DatastoreId.RUNNING);
+ } catch (NetconfException e) {
+ e.printStackTrace();
+ fail("NETCONF Exception: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testDeleteMseaSaFilteringMseaSaFilteringOpParamNetconfSessionNcDsType() {
+
+ MseaSaFilteringOpParam mseaSaFilteringConfig =
+ createConfigForEdit("192.168.60.10/27", (short) 3, "Filter3");
+
+ SourceAddressRange sar2 = new DefaultSourceAddressRange();
+ sar2.ipv4AddressPrefix("10.205.86.10/27");
+ sar2.rangeId((short) 4);
+ sar2.name("Filter4");
+
+ mseaSaFilteringConfig.sourceIpaddressFiltering().interfaceEth0()
+ .addToSourceAddressRange(sar2);
+
+ //Calling on the edit-config just makes the change and hopefully does not throw a Netconf Exception
+ try {
+ mseaSaSvc.deleteMseaSaFilteringRange(mseaSaFilteringConfig, session, DatastoreId.RUNNING);
+ } catch (NetconfException e) {
+ e.printStackTrace();
+ fail("NETCONF Exception: " + e.getMessage());
+ }
+ }
+
+ /**
+ * This is also called from the test case EA1000FlowRuleProgrammableTest().
+ * In the ea1000driver project
+ * @return
+ */
+ public static MseaSaFilteringOpParam createConfigForEdit(String ipAddrPrefix, short rangeId, String rangeName) {
+ SourceAddressRange sar = new DefaultSourceAddressRange();
+ sar.ipv4AddressPrefix(ipAddrPrefix);
+ sar.rangeId(rangeId);
+ sar.name(rangeName);
+
+ InterfaceEth0 eth0 = new DefaultInterfaceEth0();
+ eth0.addToSourceAddressRange(sar);
+
+ SourceIpaddressFiltering sip = new DefaultSourceIpaddressFiltering();
+ sip.interfaceEth0(eth0);
+
+ MseaSaFilteringOpParam op = new MseaSaFilteringOpParam();
+ op.sourceIpaddressFiltering(sip);
+
+ return op;
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaUniEvcServiceManagerTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaUniEvcServiceManagerTest.java
new file mode 100644
index 0000000..8d8b2bd
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MseaUniEvcServiceManagerTest.java
@@ -0,0 +1,496 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.UncheckedIOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.drivers.microsemi.yang.impl.MseaUniEvcServiceManager;
+import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
+import org.onosproject.netconf.DatastoreId;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfException;
+import org.onosproject.netconf.NetconfSession;
+import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.Identifier45;
+import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.ServiceListType;
+import org.onosproject.yang.gen.v1.mseatypes.rev20160229.mseatypes.VlanIdType;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcService;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.MseaUniEvcServiceOpParam;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.DefaultMefServices;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.MefServices;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.EvcPerUniServiceTypeEnum;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.TagPush;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.tagpush.tagpush.PushTagTypeEnum;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.evcperuniextensionattributes.tagmanipulation.DefaultTagPush;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.Profiles;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.DefaultProfiles;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.DefaultUni;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.Uni;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.BwpGroup;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.Cos;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.DefaultBwpGroup;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.DefaultCos;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.Bwp;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.DefaultBwp;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.profiles.bwpgroup.bwp.ColorModeEnum;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.DefaultEvc;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.Evc;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.UniSideInterfaceAssignmentEnum;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.DefaultEvcPerUni;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.EvcPerUni;
+import org.onosproject.drivers.microsemi.yang.custom.CustomEvcPerUnic;
+import org.onosproject.drivers.microsemi.yang.custom.CustomEvcPerUnin;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnic;
+import org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni.EvcPerUnin;
+
+public class MseaUniEvcServiceManagerTest {
+
+ MseaUniEvcServiceManager mseaUniEvcServiceSvc;
+ NetconfSession session;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ mseaUniEvcServiceSvc = new MockMseaUniEvcServiceManager();
+ mseaUniEvcServiceSvc.activate();
+ } catch (UncheckedIOException e) {
+ fail(e.getMessage());
+ }
+ NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo("netconf", "netconf", Ip4Address.valueOf("1.2.3.4"), 830);
+ session = new MockNetconfSessionEa1000(deviceInfo);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetMseaUniEvcServiceMseaUniEvcServiceOpParamNetconfSession() {
+ MefServices mefServices = new DefaultMefServices();
+ mefServices.uni(new DefaultUni());
+
+ MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
+ evcUni.mefServices(mefServices);
+
+ MseaUniEvcService result = null;
+ try {
+ result =
+ mseaUniEvcServiceSvc.getConfigMseaUniEvcService(
+ evcUni, session, DatastoreId.RUNNING);
+ } catch (NetconfException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ fail("Error: " + e.getMessage());
+ }
+
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testSetMseaUniEvcServiceMseaUniEvcServiceOpParamEvcs() {
+ TagPush tp1 = new DefaultTagPush();
+ org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317.mseaunievcservice
+ .evcperuniextensionattributes.tagmanipulation
+ .tagpush.TagPush tpInner1 =
+ new org.onosproject.yang.gen.v1.mseaunievcservice.rev20160317
+ .mseaunievcservice.evcperuniextensionattributes
+ .tagmanipulation.tagpush.DefaultTagPush();
+ tpInner1.outerTagVlan(new VlanIdType(3));
+ tpInner1.pushTagType(PushTagTypeEnum.PUSHSTAG);
+ tp1.tagPush(tpInner1);
+
+ EvcPerUnin epun1 = new CustomEvcPerUnin();
+ epun1.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL);
+ epun1.ceVlanMap(ServiceListType.fromString("10"));
+ epun1.ingressBwpGroupIndex("0");
+ epun1.tagManipulation(tp1);
+
+ EvcPerUnic epuc1 = new CustomEvcPerUnic();
+ epuc1.ceVlanMap(new ServiceListType("11"));
+ epuc1.ingressBwpGroupIndex("0");
+
+ EvcPerUni epu1 = new DefaultEvcPerUni();
+ epu1.evcPerUnic(epuc1);
+ epu1.evcPerUnin(epun1);
+
+ List<Evc> evcList = new ArrayList<Evc>();
+ Evc evc1 = new DefaultEvc();
+ evc1.evcIndex(1);
+ evc1.name(new Identifier45("evc-1"));
+ evc1.evcPerUni(epu1);
+
+ evcList.add(evc1);
+
+
+ EvcPerUnin epun2 = new CustomEvcPerUnin();
+ epun2.ceVlanMap(ServiceListType.fromString("13"));
+ epun2.ingressBwpGroupIndex("0");
+
+ EvcPerUnic epuc2 = new CustomEvcPerUnic();
+ epuc2.ceVlanMap(new ServiceListType("12"));
+ epuc2.ingressBwpGroupIndex("0");
+
+ EvcPerUni epu2 = new DefaultEvcPerUni();
+ epu2.evcPerUnic(epuc2);
+ epu2.evcPerUnin(epun2);
+
+ Evc evc2 = new DefaultEvc();
+ evc2.evcIndex(2);
+ evc2.name(new Identifier45("evc-2"));
+ evc2.evcPerUni(epu2);
+
+ evcList.add(evc2);
+
+ Uni uni = new DefaultUni();
+ uni.name(new Identifier45("testUni"));
+ uni.evc(evcList);
+
+ MefServices mefServices = new DefaultMefServices();
+ mefServices.uni(uni);
+
+ MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
+ evcUni.mefServices(mefServices);
+ try {
+ mseaUniEvcServiceSvc.setMseaUniEvcService(evcUni, session, DatastoreId.RUNNING);
+ } catch (NetconfException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ fail("Error: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSetMseaUniEvcServiceMseaUniEvcServiceOpParamProfiles() {
+ List<Cos> cosList = new ArrayList<Cos>();
+ Cos cos0 = new DefaultCos();
+ cos0.cosIndex(0);
+ cos0.name("cos0");
+ cosList.add(cos0);
+
+ Cos cos1 = new DefaultCos();
+ cos1.cosIndex(1);
+ cos1.name("cos1");
+ cosList.add(cos1);
+
+ List<BwpGroup> bwpGroupList = new ArrayList<BwpGroup>();
+ BwpGroup bwpGrp = new DefaultBwpGroup();
+ bwpGrp.groupIndex((short) 0);
+ bwpGroupList.add(bwpGrp);
+
+ List<Bwp> bwpList = new ArrayList<Bwp>();
+ Bwp bwp1 = new DefaultBwp();
+ bwp1.cosIndex(0);
+ bwp1.colorMode(ColorModeEnum.COLORAWARE);
+ bwpList.add(bwp1);
+
+ Bwp bwp2 = new DefaultBwp();
+ bwp2.cosIndex(1);
+ bwp2.colorMode(ColorModeEnum.COLORBLIND);
+ bwpList.add(bwp2);
+
+ BwpGroup bwpGrp1 = new DefaultBwpGroup();
+ bwpGrp1.groupIndex((short) 1);
+ bwpGrp1.bwp(bwpList);
+ bwpGroupList.add(bwpGrp1);
+
+ Profiles profiles = new DefaultProfiles();
+ profiles.bwpGroup(bwpGroupList);
+
+ MefServices mefServices = new DefaultMefServices();
+ mefServices.profiles(profiles);
+
+ MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
+ evcUni.mefServices(mefServices);
+ try {
+ mseaUniEvcServiceSvc.setMseaUniEvcService(evcUni, session, DatastoreId.RUNNING);
+ } catch (NetconfException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ fail("Error: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testDeleteMseaUniEvcServiceMseaUniEvcServiceOpParamProfiles() {
+ List<Cos> cosList = new ArrayList<Cos>();
+ Cos cos0 = new DefaultCos();
+ cos0.cosIndex(0);
+ cos0.name("cos0");
+ cosList.add(cos0);
+
+ Cos cos1 = new DefaultCos();
+ cos1.cosIndex(1);
+ cos1.name("cos1");
+ cosList.add(cos1);
+
+ List<BwpGroup> bwpGroupList = new ArrayList<BwpGroup>();
+ BwpGroup bwpGrp = new DefaultBwpGroup();
+ bwpGrp.groupIndex((short) 0);
+ bwpGroupList.add(bwpGrp);
+
+ List<Bwp> bwpList = new ArrayList<Bwp>();
+ Bwp bwp1 = new DefaultBwp();
+ bwp1.cosIndex(0);
+ bwp1.colorMode(ColorModeEnum.COLORAWARE);
+ bwpList.add(bwp1);
+
+ Bwp bwp2 = new DefaultBwp();
+ bwp2.cosIndex(1);
+ bwp2.colorMode(ColorModeEnum.COLORBLIND);
+ bwpList.add(bwp2);
+
+ BwpGroup bwpGrp1 = new DefaultBwpGroup();
+ bwpGrp1.groupIndex((short) 1);
+ bwpGrp1.bwp(bwpList);
+ bwpGroupList.add(bwpGrp1);
+
+ Profiles profiles = new DefaultProfiles();
+ profiles.bwpGroup(bwpGroupList);
+
+ MefServices mefServices = new DefaultMefServices();
+ mefServices.profiles(profiles);
+
+ MseaUniEvcServiceOpParam evcUni = new MseaUniEvcServiceOpParam();
+ evcUni.mefServices(mefServices);
+ try {
+ mseaUniEvcServiceSvc.deleteMseaUniEvcService(evcUni, session, DatastoreId.RUNNING);
+ } catch (NetconfException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ fail("Error: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetMseaUniEvcCeVlanMaps() {
+
+ try {
+ MseaUniEvcService ceVlanMapsResult7 =
+ mseaUniEvcServiceSvc.getmseaUniEvcCeVlanMaps(session, DatastoreId.RUNNING);
+
+ assertNotNull(ceVlanMapsResult7.mefServices().uni().evc());
+
+ List<Evc> evcList = ceVlanMapsResult7.mefServices().uni().evc();
+ assertEquals(3, evcList.size());
+ for (Evc evc : evcList) {
+ assertNotNull(evc.evcPerUni().evcPerUnic().ceVlanMap());
+ assertNotNull(evc.evcPerUni().evcPerUnin().ceVlanMap());
+
+ if (evc.evcIndex() == 7) {
+ assertEquals("700,710,720", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
+ assertEquals("701:703", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
+ }
+ }
+
+ } catch (NetconfException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ fail("Error: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testChangeEvcCeVlanMap() {
+ EvcPerUnin epun1 = new CustomEvcPerUnin();
+ epun1.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL);
+ epun1.ceVlanMap(ServiceListType.fromString("10"));
+ epun1.ingressBwpGroupIndex("0");
+
+ EvcPerUnic epuc1 = new CustomEvcPerUnic();
+ epuc1.ceVlanMap(new ServiceListType("11"));
+ epuc1.ingressBwpGroupIndex("0");
+
+ EvcPerUni epu = new DefaultEvcPerUni();
+ epu.evcPerUnic(epuc1);
+ epu.evcPerUnin(epun1);
+
+ Evc evc = new DefaultEvc();
+ evc.evcPerUni(epu);
+
+ assertEquals("10", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
+ assertEquals("11", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
+
+ assertEquals("11", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
+ }
+
+ @Test
+ public void testChangeEvcCeVlanMapNoValues() {
+ EvcPerUnin epun1 = new CustomEvcPerUnin();
+ epun1.evcPerUniServiceType(EvcPerUniServiceTypeEnum.EVPL);
+ epun1.ingressBwpGroupIndex("0");
+
+ EvcPerUnic epuc1 = new CustomEvcPerUnic();
+ epuc1.ingressBwpGroupIndex("0");
+
+ EvcPerUni epu = new DefaultEvcPerUni();
+ epu.evcPerUnic(epuc1);
+ epu.evcPerUnin(epun1);
+
+ Evc evc = new DefaultEvc();
+ evc.evcIndex(1);
+ evc.evcPerUni(epu);
+
+ assertEquals("0", evc.evcPerUni().evcPerUnin().ceVlanMap().string());
+ assertEquals("0", evc.evcPerUni().evcPerUnic().ceVlanMap().string());
+ }
+
+ @Test
+ public void testRemoveEvcUniFlowEntries() {
+
+ Map<Integer, String> ceVlanUpdates = new TreeMap<>();
+ ceVlanUpdates.put((1 << 2), "");
+ ceVlanUpdates.put((1 << 2) + 1, "");
+ ceVlanUpdates.put((2 << 2), "");
+ ceVlanUpdates.put((2 << 2) + 1, "");
+
+ ceVlanUpdates.put((7 << 2), "700,710,720");
+ ceVlanUpdates.put((7 << 2) + 1, "701:703");
+ ceVlanUpdates.put((8 << 2), "800,810,820");
+ ceVlanUpdates.put((8 << 2) + 1, "801,802,803");
+
+ Map<Integer, List<Short>> flowVlanIdMap = new HashMap<>();
+ //These should get ignored because whole EVC is being deleted
+ flowVlanIdMap.put(1 << 2, new ArrayList<Short>());
+ flowVlanIdMap.get(1 << 2).add((short) 11);
+
+ flowVlanIdMap.put((1 << 2) + 1, new ArrayList<Short>());
+ flowVlanIdMap.get((1 << 2) + 1).add((short) 12L);
+
+ //These are the EVCs being removed
+ flowVlanIdMap.put(7 << 2, new ArrayList<Short>());
+ flowVlanIdMap.get(7 << 2).add((short) 730L);
+ flowVlanIdMap.get(7 << 2).add((short) 740L);
+
+ flowVlanIdMap.put((7 << 2) + 1, new ArrayList<Short>());
+ flowVlanIdMap.get((7 << 2) + 1).add((short) 705L);
+ flowVlanIdMap.get((7 << 2) + 1).add((short) 706L);
+
+ flowVlanIdMap.put(8 << 2, new ArrayList<Short>());
+ flowVlanIdMap.get(8 << 2).add((short) 830L);
+ flowVlanIdMap.get(8 << 2).add((short) 840L);
+
+ flowVlanIdMap.put((8 << 2) + 1, new ArrayList<Short>());
+ flowVlanIdMap.get((8 << 2) + 1).add((short) 805L);
+ flowVlanIdMap.get((8 << 2) + 1).add((short) 806L);
+
+ try {
+ mseaUniEvcServiceSvc.removeEvcUniFlowEntries(
+ ceVlanUpdates, flowVlanIdMap, session, DatastoreId.RUNNING,
+ UniSideInterfaceAssignmentEnum.UNI_C_ON_OPTICS);
+ } catch (NetconfException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ fail("Error: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetVlanSet1() {
+ Short[] vlanIds = CeVlanMapUtils.getVlanSet("10");
+ assertEquals(1, vlanIds.length);
+ }
+
+ @Test
+ public void testGetVlanSet2() {
+ Short[] vlanIds = CeVlanMapUtils.getVlanSet("10:20");
+ assertEquals(11, vlanIds.length);
+ assertEquals(10, vlanIds[0].shortValue());
+ assertEquals(20, vlanIds[10].shortValue());
+ }
+
+ @Test
+ public void testGetVlanSet3() {
+ Short[] vlanIds = CeVlanMapUtils.getVlanSet("10:20,30:40");
+ assertEquals(22, vlanIds.length);
+ assertEquals(10, vlanIds[0].shortValue());
+ assertEquals(40, vlanIds[21].shortValue());
+ }
+
+ @Test
+ public void testGetVlanSet4() {
+ Short[] vlanIds = CeVlanMapUtils.getVlanSet("10,20,30");
+ assertEquals(3, vlanIds.length);
+ assertEquals(10, vlanIds[0].shortValue());
+ assertEquals(30, vlanIds[2].shortValue());
+ }
+
+ @Test
+ public void testVlanListAsString() {
+ assertEquals("20:22", CeVlanMapUtils.vlanListAsString(new Short[]{20, 21, 22}));
+
+ assertEquals("20:22,24:25",
+ CeVlanMapUtils.vlanListAsString(new Short[]{20, 21, 22, 24, 25}));
+
+ assertEquals("30,33,36:40",
+ CeVlanMapUtils.vlanListAsString(new Short[]{30, 33, 36, 37, 38, 39, 40}));
+
+ assertEquals("20", CeVlanMapUtils.vlanListAsString(new Short[]{20}));
+
+ assertEquals("20,22,24,26,28",
+ CeVlanMapUtils.vlanListAsString(new Short[]{20, 22, 24, 26, 28}));
+ }
+
+ @Test
+ public void testAddtoCeVlanMap() {
+ assertEquals("20,22:24,26,28",
+ CeVlanMapUtils.addtoCeVlanMap("20,22,24,26,28", (short) 23));
+
+ assertEquals("20:26,28",
+ CeVlanMapUtils.addtoCeVlanMap("20,21,22,24,25,26,28", (short) 23));
+
+ assertEquals("20,23",
+ CeVlanMapUtils.addtoCeVlanMap("20", (short) 23));
+
+ assertEquals("20,22:23",
+ CeVlanMapUtils.addtoCeVlanMap("20,22", (short) 23));
+ }
+
+ @Test
+ public void testCombineVlanSets() {
+ assertEquals("10:11,13:14", CeVlanMapUtils.combineVlanSets("10:11", "13:14"));
+
+ assertEquals("10:14", CeVlanMapUtils.combineVlanSets("10:11", "12:14"));
+
+ assertEquals("10:11,14", CeVlanMapUtils.combineVlanSets("10:11", "14"));
+
+ assertEquals("10:12", CeVlanMapUtils.combineVlanSets("10:11", "11:12"));
+ }
+
+ @Test
+ public void testRemoveZeroIfPossible() {
+ assertEquals("0", CeVlanMapUtils.removeZeroIfPossible(""));
+
+ assertEquals("0", CeVlanMapUtils.removeZeroIfPossible("0"));
+
+ assertEquals("1,3", CeVlanMapUtils.removeZeroIfPossible("0:1,3"));
+
+ assertEquals("1:2", CeVlanMapUtils.removeZeroIfPossible("0:2"));
+
+ assertEquals("10:12", CeVlanMapUtils.removeZeroIfPossible("0,10:12"));
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/package-info.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/package-info.java
new file mode 100644
index 0000000..4173ece
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Package for Microsemi device drivers support for NETCONF for EA1000.
+ */
+package org.onosproject.drivers.microsemi.yang;
\ No newline at end of file
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/utils/IetfYangTypesUtilsTest.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/utils/IetfYangTypesUtilsTest.java
new file mode 100644
index 0000000..da0954f
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/utils/IetfYangTypesUtilsTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.drivers.microsemi.yang.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.ietfyangtypes.rev20130715.ietfyangtypes.DateAndTime;
+
+public class IetfYangTypesUtilsTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testFromYangDateTime() {
+ OffsetDateTime odt = IetfYangTypesUtils.fromYangDateTime(DateAndTime.fromString("2015-07-08T12:49:20.9Z"));
+ assertEquals(OffsetDateTime.of(2015, 7, 8, 12, 49, 20, 900000000, ZoneOffset.UTC), odt);
+ }
+
+ @Test
+ public void testFromYangDateTimeZoned() {
+ ZonedDateTime zdt = IetfYangTypesUtils.fromYangDateTimeZoned(DateAndTime.fromString("2015-07-08T12:49:20.9Z"),
+ ZoneId.systemDefault());
+
+ assertEquals(OffsetDateTime.of(2015, 7, 8, 12, 49, 20, 900000000, ZoneOffset.UTC).toInstant(),
+ zdt.toOffsetDateTime().toInstant());
+ }
+
+ @Test
+ public void testFromYangDateTimeToLocal() {
+ LocalDateTime ldt = IetfYangTypesUtils
+ .fromYangDateTimeToLocal(DateAndTime.fromString("2015-07-08T12:49:20.9Z"));
+
+ OffsetDateTime odtExpected = OffsetDateTime.of(2015, 7, 8, 12, 49, 20, 900000000, ZoneOffset.UTC);
+ ZoneOffset offsetForcurrentZone = ZoneId.systemDefault().getRules().getOffset(ldt);
+ assertEquals(odtExpected.toInstant(), ldt.toInstant(offsetForcurrentZone));
+ }
+
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/yang/MockYangRuntimeManager.java b/drivers/microsemi/src/test/java/org/onosproject/yang/MockYangRuntimeManager.java
new file mode 100644
index 0000000..e2f4389
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/yang/MockYangRuntimeManager.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yang;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.core.CoreService;
+import org.onosproject.drivers.netconf.MockCoreService;
+import org.onosproject.yang.model.ModelConverter;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.NodeKey;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaContextProvider;
+import org.onosproject.yang.model.YangModel;
+import org.onosproject.yang.runtime.CompositeData;
+import org.onosproject.yang.runtime.CompositeStream;
+import org.onosproject.yang.runtime.ModelRegistrationParam;
+import org.onosproject.yang.runtime.RuntimeContext;
+import org.onosproject.yang.runtime.YangModelRegistry;
+import org.onosproject.yang.runtime.YangRuntimeService;
+import org.onosproject.yang.runtime.YangSerializer;
+import org.onosproject.yang.runtime.YangSerializerRegistry;
+import org.onosproject.yang.runtime.impl.DefaultModelConverter;
+import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+import org.onosproject.yang.runtime.impl.DefaultYangRuntimeHandler;
+import org.onosproject.yang.runtime.impl.DefaultYangSerializerRegistry;
+import org.onosproject.yang.serializers.json.JsonSerializer;
+import org.onosproject.yang.serializers.xml.XmlSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class MockYangRuntimeManager implements YangModelRegistry,
+ YangSerializerRegistry, YangRuntimeService, ModelConverter,
+ SchemaContextProvider {
+
+ private static final String APP_ID = "org.onosproject.yang";
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ private DefaultYangModelRegistry modelRegistry;
+ private DefaultYangSerializerRegistry serializerRegistry;
+ private DefaultYangRuntimeHandler runtimeService;
+ private DefaultModelConverter modelConverter;
+
+ public void setModelRegistry(DefaultYangModelRegistry yReg) {
+ this.modelRegistry = yReg;
+ }
+
+ @Activate
+ public void activate() {
+ coreService = new MockCoreService();
+ coreService.registerApplication(APP_ID);
+ serializerRegistry = new DefaultYangSerializerRegistry();
+ runtimeService =
+ new DefaultYangRuntimeHandler(serializerRegistry, modelRegistry);
+ serializerRegistry.registerSerializer(new JsonSerializer());
+ serializerRegistry.registerSerializer(new XmlSerializer());
+ modelConverter = new DefaultModelConverter(modelRegistry);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+
+ @Override
+ public void registerModel(ModelRegistrationParam p) {
+ modelRegistry.registerModel(p);
+ }
+
+ @Override
+ public void unregisterModel(ModelRegistrationParam p) {
+ modelRegistry.unregisterModel(p);
+ }
+
+ @Override
+ public Set<YangModel> getModels() {
+ return modelRegistry.getModels();
+ }
+
+ @Override
+ public void registerSerializer(YangSerializer ys) {
+ serializerRegistry.registerSerializer(ys);
+ }
+
+ @Override
+ public void unregisterSerializer(YangSerializer ys) {
+ serializerRegistry.unregisterSerializer(ys);
+ }
+
+ @Override
+ public Set<YangSerializer> getSerializers() {
+ return serializerRegistry.getSerializers();
+ }
+
+ @Override
+ public CompositeData decode(CompositeStream cs, RuntimeContext rc) {
+ return runtimeService.decode(cs, rc);
+ }
+
+ @Override
+ public CompositeStream encode(CompositeData cd, RuntimeContext rc) {
+ return runtimeService.encode(cd, rc);
+ }
+
+ @Override
+ public ModelObjectData createModel(ResourceData resourceData) {
+ return modelConverter.createModel(resourceData);
+ }
+
+ @Override
+ public ResourceData createDataNode(ModelObjectData modelObjectData) {
+ return modelConverter.createDataNode(modelObjectData);
+ }
+
+ @Override
+ public SchemaContext getSchemaContext(ResourceId resourceId) {
+ checkNotNull(resourceId, " resource id can't be null.");
+ NodeKey key = resourceId.nodeKeys().get(0);
+ if (resourceId.nodeKeys().size() == 1 &&
+ "/".equals(key.schemaId().name())) {
+ return modelRegistry;
+ }
+ log.info("To be implemented.");
+ return null;
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSchemaNodeProvider.java b/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSchemaNodeProvider.java
new file mode 100644
index 0000000..dab269d
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSchemaNodeProvider.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yang.serializers.xml;
+
+
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.model.YangModel;
+import org.onosproject.yang.runtime.AppModuleInfo;
+import org.onosproject.yang.runtime.DefaultAppModuleInfo;
+import org.onosproject.yang.runtime.DefaultModelRegistrationParam;
+import org.onosproject.yang.runtime.ModelRegistrationParam;
+import org.onosproject.yang.runtime.YangModelRegistry;
+import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.onosproject.yang.compiler.datamodel.utils.DataModelUtils;
+import org.onosproject.yang.compiler.utils.UtilConstants;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.runtime.helperutils.YangApacheUtils;
+import org.onosproject.yang.runtime.RuntimeHelper;
+
+public class MockYangSchemaNodeProvider {
+
+ private static final String FS = File.separator;
+ private static final String PATH = System.getProperty("user.dir") +
+ FS + "buck-out" + FS + "gen" +
+ FS + "models" + FS + "microsemi" + FS + "onos-models-microsemi-schema" + FS;
+ private static final String SER_FILE_PATH = "yang" + FS + "resources" +
+ FS + "YangMetaData.ser";
+ private static final String META_PATH =
+ PATH.replace("drivers/microsemi", "")
+ + SER_FILE_PATH;
+ private static final String TEMP_FOLDER_PATH = PATH + UtilConstants.TEMP;
+ private YangModelRegistry reg = new DefaultYangModelRegistry();
+ private List<YangNode> nodes = new ArrayList<>();
+
+ /**
+ * Creates an instance of mock bundle context.
+ */
+ public MockYangSchemaNodeProvider() {
+ }
+
+ /**
+ * Process YANG schema node for a application.
+ */
+ public void processSchemaRegistry() {
+ try {
+ //Need to deserialize generated meta data file for unit tests.
+ Set<YangNode> appNode = DataModelUtils.deSerializeDataModel(META_PATH);
+ RuntimeHelper.addLinkerAndJavaInfo(appNode);
+ nodes.addAll(appNode);
+ reg.registerModel(prepareParam(nodes));
+ YangIoUtils.deleteDirectory(TEMP_FOLDER_PATH);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("YangMetaData.ser could not " +
+ "be loaded from " + META_PATH, e);
+ }
+ }
+
+ /**
+ * Unregister given nodes from runtime service.
+ *
+ * @param nodes list of nodes
+ */
+ public void unRegister(List<YangNode> nodes) {
+ reg.unregisterModel(prepareParam(nodes));
+ }
+
+ /**
+ * Prepares model registration parameter.
+ *
+ * @param nodes list of nodes
+ * @return model registration parameter
+ */
+ private ModelRegistrationParam prepareParam(List<YangNode> nodes) {
+ //Process loading class file.
+ String appName;
+ ClassLoader classLoader = getClass().getClassLoader();
+
+ //Create model registration param.
+ ModelRegistrationParam.Builder b =
+ DefaultModelRegistrationParam.builder();
+
+ //create a new YANG model
+ YangModel model = YangApacheUtils.processYangModel(META_PATH, nodes);
+ //set YANG model
+ b.setYangModel(model);
+
+ Iterator<YangNode> it = nodes.iterator();
+ while (it.hasNext()) {
+ YangSchemaNode node = it.next();
+
+ //If service class is not generated then use
+ // interface file to load this class.
+ appName = RuntimeHelper.getInterfaceClassName(node);
+ Class<?> cls;
+ try {
+ cls = classLoader.loadClass(appName);
+ } catch (ClassNotFoundException e) {
+ continue;
+ }
+
+ //generate app info.
+ AppModuleInfo info = new DefaultAppModuleInfo(cls, null);
+ b.addAppModuleInfo(YangApacheUtils.processModuleId((YangNode) node), info);
+ }
+ return b.build();
+ }
+
+ /**
+ * Returns schema registry.
+ *
+ * @return schema registry
+ */
+ public DefaultYangModelRegistry registry() {
+ return (DefaultYangModelRegistry) reg;
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java b/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
new file mode 100644
index 0000000..cfe7b9b
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yang.serializers.xml;
+
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.runtime.Annotation;
+import org.onosproject.yang.runtime.DefaultAnnotation;
+import org.onosproject.yang.runtime.YangSerializerContext;
+import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class MockYangSerializerContext implements YangSerializerContext {
+
+ private static MockYangSchemaNodeProvider schemaProvider =
+ new MockYangSchemaNodeProvider();
+ private static final String NETCONF_NS =
+ "urn:ietf:params:xml:ns:netconf:base:1.0";
+ private static final String XMNLS_NC = "xmlns:xc";
+
+
+ @Override
+ public SchemaContext getContext() {
+ schemaProvider.processSchemaRegistry();
+ DefaultYangModelRegistry registry = schemaProvider.registry();
+ return registry;
+ }
+
+ @Override
+ public List<Annotation> getProtocolAnnotations() {
+ Annotation annotation = new DefaultAnnotation(XMNLS_NC, NETCONF_NS);
+ List<Annotation> protocolAnnotation = new LinkedList<>();
+ protocolAnnotation.add(annotation);
+ return protocolAnnotation;
+ }
+}