Search in sources :

Example 6 with CfmCodecContext

use of org.onosproject.cfm.CfmCodecContext in project onos by opennetworkinglab.

the class MaWebResourceTest method testCreateMa.

@Test
public void testCreateMa() throws CfmConfigException {
    MaintenanceDomain md1 = DefaultMaintenanceDomain.builder(MDNAME1).mdLevel(MaintenanceDomain.MdLevel.LEVEL2).build();
    expect(mdService.getMaintenanceDomain(MDNAME1)).andReturn(Optional.ofNullable(md1)).anyTimes();
    expect(mdService.createMaintenanceAssociation(MDNAME1, ma1)).andReturn(false).anyTimes();
    replay(mdService);
    ObjectMapper mapper = new ObjectMapper();
    CfmCodecContext context = new CfmCodecContext();
    ObjectNode node = mapper.createObjectNode();
    node.set("ma", context.codec(MaintenanceAssociation.class).encode(ma1, context));
    final WebTarget wt = target();
    final Response response = wt.path("md/" + MDNAME1.mdName() + "/ma").request().post(Entity.json(node.toString()));
    assertEquals(201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) WebTarget(javax.ws.rs.client.WebTarget) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 7 with CfmCodecContext

use of org.onosproject.cfm.CfmCodecContext 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)

Example 8 with CfmCodecContext

use of org.onosproject.cfm.CfmCodecContext in project onos by opennetworkinglab.

the class MaintenanceAssociationCodecTest method setUp.

@Before
public void setUp() throws Exception, CfmConfigException {
    mapper = new ObjectMapper();
    context = new CfmCodecContext();
}
Also used : CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 9 with CfmCodecContext

use of org.onosproject.cfm.CfmCodecContext in project onos by opennetworkinglab.

the class MepLbEntryCodecTest method setUp.

@Before
public void setUp() throws Exception {
    mapper = new ObjectMapper();
    context = new CfmCodecContext();
}
Also used : CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 10 with CfmCodecContext

use of org.onosproject.cfm.CfmCodecContext in project onos by opennetworkinglab.

the class MepWebResourceTest method setUpTest.

@Before
public void setUpTest() throws CfmConfigException {
    CfmCodecContext context = new CfmCodecContext();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(CfmMepService.class, mepService).add(CfmMdService.class, mdService).add(CodecService.class, context.codecManager());
    setServiceDirectory(testDirectory);
    mepEntry1 = DefaultMepEntry.builder(MEPID1, DeviceId.deviceId("netconf:1.2.3.4:830"), PortNumber.portNumber(1), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).buildEntry();
}
Also used : CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService) Before(org.junit.Before)

Aggregations

CfmCodecContext (org.onosproject.cfm.CfmCodecContext)24 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)19 Before (org.junit.Before)15 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)9 Test (org.junit.Test)9 WebTarget (javax.ws.rs.client.WebTarget)8 Response (javax.ws.rs.core.Response)8 ServiceDirectory (org.onlab.osgi.ServiceDirectory)5 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)5 DefaultMaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation)4 DefaultMaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain)4 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)4 MaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain)4 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)3 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)3 CfmResourceTest (org.onosproject.cfm.impl.CfmResourceTest)2 DefaultMep (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMep)2 DefaultMepEntry (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry)2 DefaultMepLtCreate (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepLtCreate)2 Mep (org.onosproject.incubator.net.l2monitoring.cfm.Mep)2