use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.
the class MaintenanceAssociationCodecTest method testEncodeMa1.
@Test
public void testEncodeMa1() throws CfmConfigException {
MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MAID1_CHAR, 10).maNumericId((short) 1).build();
ObjectNode node = mapper.createObjectNode();
node.set("ma", context.codec(MaintenanceAssociation.class).encode(ma1, context));
assertEquals("{\"ma\":{" + "\"maName\":\"ma-1\"," + "\"maNameType\":\"CHARACTERSTRING\"," + "\"maNumericId\":1," + "\"component-list\":[]," + "\"rmep-list\":[]}}", node.toString());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.
the class MaintenanceAssociationCodecTest method testDecodeMa3.
@Test
public void testDecodeMa3() throws IOException {
String mdString = "{\"ma\": { \"maName\": 12467," + "\"maNameType\": \"TWOOCTET\"," + "\"component-list\": [], " + "\"rmep-list\": [], " + "\"maNumericId\": 3}}";
InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
JsonNode cfg = mapper.readTree(input);
MaintenanceAssociation maDecode3 = ((MaintenanceAssociationCodec) context.codec(MaintenanceAssociation.class)).decode((ObjectNode) cfg, context, 10);
assertEquals(MAID3_OCTET, maDecode3.maId());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.
the class MaintenanceAssociationCodecTest method testEncodeMa2.
@Test
public void testEncodeMa2() throws CfmConfigException {
MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MAID2_VID, 10).maNumericId((short) 2).build();
ObjectNode node = mapper.createObjectNode();
node.set("ma", context.codec(MaintenanceAssociation.class).encode(ma1, context));
assertEquals("{\"ma\":{" + "\"maName\":\"1234\"," + "\"maNameType\":\"PRIMARYVID\"," + "\"maNumericId\":2," + "\"component-list\":[]," + "\"rmep-list\":[]}}", node.toString());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.
the class MaintenanceAssociationCodecTest method testDecodeMa5.
@Test
public void testDecodeMa5() throws IOException {
String mdString = "{\"ma\": { \"maName\": \"abc:defghij\"," + "\"maNameType\": \"ICCY1731\"," + "\"component-list\": [], " + "\"rmep-list\": [], " + "\"maNumericId\": 5}}";
InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
JsonNode cfg = mapper.readTree(input);
MaintenanceAssociation maDecode5 = ((MaintenanceAssociationCodec) context.codec(MaintenanceAssociation.class)).decode((ObjectNode) cfg, context, 10);
assertEquals(MAID5_Y1731, maDecode5.maId());
}
use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.
the class MepWebResourceTest method testCreateMepAlreadyExists.
@Test
public void testCreateMepAlreadyExists() throws CfmConfigException, IOException {
MepId mepId3 = MepId.valueOf((short) 3);
Mep mep3 = DefaultMep.builder(mepId3, DeviceId.deviceId("netconf:3.2.3.4:830"), PortNumber.portNumber(3), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).cciEnabled(true).ccmLtmPriority(Mep.Priority.PRIO3).administrativeState(false).primaryVid(VlanId.vlanId((short) 3)).defectAbsentTime(Duration.ofMinutes(2)).defectPresentTime(Duration.ofMinutes(3)).fngAddress(Mep.FngAddress.notSpecified()).lowestFaultPriorityDefect(Mep.LowestFaultDefect.ALL_DEFECTS).build();
MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).build();
expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
replay(mdService);
expect(mepService.createMep(MDNAME1, MANAME1, mep3)).andReturn(false).anyTimes();
replay(mepService);
ObjectMapper mapper = new ObjectMapper();
CfmCodecContext context = new CfmCodecContext();
ObjectNode node = mapper.createObjectNode();
node.set("mep", context.codec(Mep.class).encode(mep3, context));
final WebTarget wt = target();
final Response response = wt.path("md/" + MDNAME1.mdName() + "/ma/" + MANAME1.maName() + "/mep").request().post(Entity.json(node.toString()));
assertEquals("Expecting 304", 304, response.getStatus());
}
Aggregations