use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.
the class MaintenanceDomainCodecTest method testDecodeMd2.
@Test
public void testDecodeMd2() throws IOException {
String mdString = "{\"md\": { \"mdName\": \"test.opennetworking.org\"," + "\"mdNameType\": \"DOMAINNAME\"}}";
InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
JsonNode cfg = mapper.readTree(input);
MaintenanceDomain mdDecode1 = context.codec(MaintenanceDomain.class).decode((ObjectNode) cfg, context);
assertEquals(MDID2_DOMAIN, mdDecode1.mdId());
assertEquals(MaintenanceDomain.MdLevel.LEVEL0, mdDecode1.mdLevel());
assertEquals(0, mdDecode1.mdNumericId());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.
the class MaintenanceDomainCodecTest method testDecodeMd1.
@Test
public void testDecodeMd1() throws IOException {
String mdString = "{\"md\": { \"mdName\": \"test-1\"," + "\"mdNameType\": \"CHARACTERSTRING\"," + "\"mdLevel\": \"LEVEL1\", \"mdNumericId\": 1}}";
InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
JsonNode cfg = mapper.readTree(input);
MaintenanceDomain mdDecode1 = context.codec(MaintenanceDomain.class).decode((ObjectNode) cfg, context);
assertEquals(MDID1_CHAR, mdDecode1.mdId());
assertEquals(MaintenanceDomain.MdLevel.LEVEL1, mdDecode1.mdLevel());
assertEquals(1, mdDecode1.mdNumericId());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.
the class MepWebResourceTest method testAbortLoopback.
@Test
public void testAbortLoopback() throws CfmConfigException {
MepLbCreate mepLbCreate1 = DefaultMepLbCreate.builder(MEPID1).build();
MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).build();
MaintenanceDomain md1 = DefaultMaintenanceDomain.builder(MDNAME1).addToMaList(ma1).build();
expect(mdService.getMaintenanceDomain(MDNAME1)).andReturn(Optional.ofNullable(md1)).anyTimes();
expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
replay(mdService);
final WebTarget wt = target();
final Response response = wt.path("md/" + MDNAME1.mdName() + "/ma/" + MANAME1.maName() + "/mep/" + MEPID1.value() + "/abort-loopback").request().put(Entity.json(""));
assertEquals("Expecting 202", 202, response.getStatus());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.
the class MepWebResourceTest method testTransmitLinktrace.
@Test
public void testTransmitLinktrace() throws CfmConfigException {
MepLtCreate mepLtCreate1 = DefaultMepLtCreate.builder(MEPID1).defaultTtl((short) 20).transmitLtmFlags(BitSet.valueOf(new byte[] { 1 })).build();
MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).build();
MaintenanceDomain md1 = DefaultMaintenanceDomain.builder(MDNAME1).addToMaList(ma1).build();
expect(mdService.getMaintenanceDomain(MDNAME1)).andReturn(Optional.ofNullable(md1)).anyTimes();
expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
replay(mdService);
ObjectMapper mapper = new ObjectMapper();
CfmCodecContext context = new CfmCodecContext();
ObjectNode node = mapper.createObjectNode();
node.set("linktrace", context.codec(MepLtCreate.class).encode(mepLtCreate1, context));
final WebTarget wt = target();
final Response response = wt.path("md/" + MDNAME1.mdName() + "/ma/" + MANAME1.maName() + "/mep/" + MEPID1.value() + "/transmit-linktrace").request().put(Entity.json(node.toString()));
assertEquals("Expecting 202", 202, response.getStatus());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.
the class MepWebResourceTest method testTransmitLoopback.
@Test
public void testTransmitLoopback() throws CfmConfigException {
MepLbCreate mepLbCreate1 = DefaultMepLbCreate.builder(MEPID1).numberMessages(20).dataTlvHex("AA:BB:CC:DD").vlanDropEligible(true).build();
MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).build();
MaintenanceDomain md1 = DefaultMaintenanceDomain.builder(MDNAME1).addToMaList(ma1).build();
expect(mdService.getMaintenanceDomain(MDNAME1)).andReturn(Optional.ofNullable(md1)).anyTimes();
expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
replay(mdService);
ObjectMapper mapper = new ObjectMapper();
CfmCodecContext context = new CfmCodecContext();
ObjectNode node = mapper.createObjectNode();
node.set("loopback", context.codec(MepLbCreate.class).encode(mepLbCreate1, context));
final WebTarget wt = target();
final Response response = wt.path("md/" + MDNAME1.mdName() + "/ma/" + MANAME1.maName() + "/mep/" + MEPID1.value() + "/transmit-loopback").request().put(Entity.json(node.toString()));
assertEquals("Expecting 202", 202, response.getStatus());
}
Aggregations