Search in sources :

Example 21 with MaintenanceAssociation

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

the class MaintenanceAssociationCodecTest method testEncodeMa3.

@Test
public void testEncodeMa3() throws CfmConfigException {
    MaintenanceAssociation ma1 = DefaultMaintenanceAssociation.builder(MAID3_OCTET, 10).maNumericId((short) 3).build();
    ObjectNode node = mapper.createObjectNode();
    node.set("ma", context.codec(MaintenanceAssociation.class).encode(ma1, context));
    assertEquals("{\"ma\":{" + "\"maName\":\"12467\"," + "\"maNameType\":\"TWOOCTET\"," + "\"maNumericId\":3," + "\"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 22 with MaintenanceAssociation

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

the class MepWebResourceTest method testCreateMep.

@Test
public void testCreateMep() throws CfmConfigException, IOException {
    MepId mepId2 = MepId.valueOf((short) 2);
    Mep mep2 = DefaultMep.builder(mepId2, DeviceId.deviceId("netconf:2.2.3.4:830"), PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).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, mep2)).andReturn(true).anyTimes();
    replay(mepService);
    ObjectMapper mapper = new ObjectMapper();
    CfmCodecContext context = new CfmCodecContext();
    ObjectNode node = mapper.createObjectNode();
    node.set("mep", context.codec(Mep.class).encode(mep2, 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 201", 201, 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)

Example 23 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation 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());
}
Also used : DefaultMepLbCreate(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepLbCreate) MepLbCreate(org.onosproject.incubator.net.l2monitoring.cfm.MepLbCreate) Response(javax.ws.rs.core.Response) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) DefaultMaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 24 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation 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());
}
Also used : Response(javax.ws.rs.core.Response) CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultMepLtCreate(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepLtCreate) MepLtCreate(org.onosproject.incubator.net.l2monitoring.cfm.MepLtCreate) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) 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) Test(org.junit.Test)

Example 25 with MaintenanceAssociation

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation 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());
}
Also used : DefaultMepLbCreate(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepLbCreate) MepLbCreate(org.onosproject.incubator.net.l2monitoring.cfm.MepLbCreate) Response(javax.ws.rs.core.Response) CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) 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) 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