Search in sources :

Example 1 with MaintenanceAssociation

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());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultMaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) Test(org.junit.Test)

Example 2 with MaintenanceAssociation

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) JsonNode(com.fasterxml.jackson.databind.JsonNode) DefaultMaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) Test(org.junit.Test)

Example 3 with MaintenanceAssociation

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());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultMaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) Test(org.junit.Test)

Example 4 with MaintenanceAssociation

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) JsonNode(com.fasterxml.jackson.databind.JsonNode) DefaultMaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) Test(org.junit.Test)

Example 5 with MaintenanceAssociation

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());
}
Also used : Response(javax.ws.rs.core.Response) CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultMep(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMep) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) DefaultMaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) WebTarget(javax.ws.rs.client.WebTarget) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) Test(org.junit.Test)

Aggregations

MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)25 DefaultMaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation)19 Test (org.junit.Test)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)10 MaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 ByteArrayInputStream (java.io.ByteArrayInputStream)6 InputStream (java.io.InputStream)6 Consumes (javax.ws.rs.Consumes)6 Produces (javax.ws.rs.Produces)6 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)6 WebTarget (javax.ws.rs.client.WebTarget)5 Response (javax.ws.rs.core.Response)5 DefaultMaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain)5 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)5 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)5 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)5 Path (javax.ws.rs.Path)4 CfmCodecContext (org.onosproject.cfm.CfmCodecContext)4