Search in sources :

Example 6 with MepLbCreate

use of org.onosproject.incubator.net.l2monitoring.cfm.MepLbCreate 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 7 with MepLbCreate

use of org.onosproject.incubator.net.l2monitoring.cfm.MepLbCreate 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

MepLbCreate (org.onosproject.incubator.net.l2monitoring.cfm.MepLbCreate)7 Test (org.junit.Test)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 DefaultMepLbCreate (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepLbCreate)4 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)3 MaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 WebTarget (javax.ws.rs.client.WebTarget)2 Response (javax.ws.rs.core.Response)2 DefaultMaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation)2 DefaultMaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain)2 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)2 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1