Search in sources :

Example 16 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.

the class MaintenanceAssociationCodecTest method testDecodeMa1.

@Test
public void testDecodeMa1() throws IOException {
    String mdString = "{\"ma\": {    \"maName\": \"ma-1\"," + "\"maNameType\": \"CHARACTERSTRING\"," + "\"component-list\": [], " + "\"rmep-list\": [], " + "\"maNumericId\": 1}}";
    InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
    JsonNode cfg = mapper.readTree(input);
    MaintenanceAssociation maDecode1 = ((MaintenanceAssociationCodec) context.codec(MaintenanceAssociation.class)).decode((ObjectNode) cfg, context, 10);
    assertEquals(MAID1_CHAR, maDecode1.maId());
    assertEquals(1, maDecode1.maNumericId());
}
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 17 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.

the class MaintenanceAssociationCodecTest method testDecodeMa2.

@Test
public void testDecodeMa2() throws IOException {
    String mdString = "{\"ma\": {    \"maName\": 1234," + "\"maNameType\": \"PRIMARYVID\"," + "\"component-list\": [], " + "\"rmep-list\": [], " + "\"maNumericId\": 2}}";
    InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
    JsonNode cfg = mapper.readTree(input);
    MaintenanceAssociation maDecode2 = ((MaintenanceAssociationCodec) context.codec(MaintenanceAssociation.class)).decode((ObjectNode) cfg, context, 10);
    assertEquals(MAID2_VID, maDecode2.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 18 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.

the class MaintenanceAssociationCodecTest method testDecodeMa4.

@Test
public void testDecodeMa4() throws IOException {
    String mdString = "{\"ma\": {    \"maName\": \"aa:bb:cc:dd:ee:ff:99\"," + "\"maNameType\": \"RFC2685VPNID\"," + "\"component-list\": [], " + "\"rmep-list\": [], " + "\"maNumericId\": 4}}";
    InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
    JsonNode cfg = mapper.readTree(input);
    MaintenanceAssociation maDecode4 = ((MaintenanceAssociationCodec) context.codec(MaintenanceAssociation.class)).decode((ObjectNode) cfg, context, 10);
    assertEquals(MAID4_RFC, maDecode4.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 19 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.

the class MaintenanceAssociationCodecTest method testEncodeMa5.

@Test
public void testEncodeMa5() throws CfmConfigException {
    MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MAID5_Y1731, 10).maNumericId((short) 5).build();
    ObjectNode node = mapper.createObjectNode();
    node.set("ma", context.codec(MaintenanceAssociation.class).encode(ma1, context));
    assertEquals("{\"ma\":{" + "\"maName\":\"abc:defghij\"," + "\"maNameType\":\"ICCY1731\"," + "\"maNumericId\":5," + "\"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 20 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation in project onos by opennetworkinglab.

the class MaintenanceAssociationCodecTest method testDecodeMa1NoTypeGiven.

@Test
public void testDecodeMa1NoTypeGiven() throws IOException {
    String mdString = "{\"ma\": {    \"maName\": \"ma-1\"," + "\"component-list\": [], " + "\"rmep-list\": [], " + "\"maNumericId\": 1}}";
    InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
    JsonNode cfg = mapper.readTree(input);
    MaintenanceAssociation maDecode1 = ((MaintenanceAssociationCodec) context.codec(MaintenanceAssociation.class)).decode((ObjectNode) cfg, context, 10);
    assertEquals(MAID1_CHAR, maDecode1.maId());
    assertEquals(1, maDecode1.maNumericId());
}
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)

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