Search in sources :

Example 1 with CfmCodecContext

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

the class MdWebResourceTest method testCreateMd.

@Test
public void testCreateMd() throws CfmConfigException {
    MaintenanceDomain md3 = DefaultMaintenanceDomain.builder(MdIdCharStr.asMdId("md-3")).mdLevel(MaintenanceDomain.MdLevel.LEVEL3).mdNumericId((short) 3).build();
    expect(mdService.createMaintenanceDomain(mdList.get(1))).andReturn(false).anyTimes();
    replay(mdService);
    ObjectMapper mapper = new ObjectMapper();
    CfmCodecContext context = new CfmCodecContext();
    ObjectNode node = mapper.createObjectNode();
    node.set("md", context.codec(MaintenanceDomain.class).encode(mdList.get(1), context));
    final WebTarget wt = target();
    final Response response = wt.path("md").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 2 with CfmCodecContext

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

the class MepEntryCodecTest method setUp.

@Before
public void setUp() throws Exception, CfmConfigException {
    mapper = new ObjectMapper();
    context = new CfmCodecContext();
    MepEntryBuilder builder = DefaultMepEntry.builder(MepId.valueOf((short) 22), DeviceId.deviceId("netconf:1234:830"), PortNumber.portNumber(2), MepDirection.UP_MEP, MdIdCharStr.asMdId("md-1"), MaIdCharStr.asMaId("ma-1-1")).macAddress(MacAddress.valueOf("aa:bb:cc:dd:ee:ff"));
    builder = (MepEntryBuilder) builder.administrativeState(true).cciEnabled(true).ccmLtmPriority(Priority.PRIO1);
    mepEntry1 = builder.buildEntry();
}
Also used : CfmCodecContext(org.onosproject.cfm.CfmCodecContext) MepEntryBuilder(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry.MepEntryBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 3 with CfmCodecContext

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

the class RemoteMepEntryCodecTest method setUp.

@Before
public void setUp() throws Exception, CfmConfigException {
    mapper = new ObjectMapper();
    context = new CfmCodecContext();
    remoteMep1 = DefaultRemoteMepEntry.builder(MepId.valueOf((short) 10), RemoteMepState.RMEP_OK).failedOrOkTime(Duration.ofMillis(546546546L)).interfaceStatusTlvType(InterfaceStatusTlvType.IS_LOWERLAYERDOWN).macAddress(MacAddress.IPV4_MULTICAST).portStatusTlvType(PortStatusTlvType.PS_NO_STATUS_TLV).rdi(true).senderIdTlvType(SenderIdTlvType.SI_NETWORK_ADDRESS).build();
}
Also used : CfmCodecContext(org.onosproject.cfm.CfmCodecContext) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 4 with CfmCodecContext

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

the class DmEntryCodecTest method setUp.

@Before
public void setUp() throws Exception, SoamConfigException {
    mapper = new ObjectMapper();
    context = new CfmCodecContext();
    DmEntryBuilder builder = DefaultDelayMeasurementEntry.builder(SoamId.valueOf(12), DmType.DM1DMTX, Version.Y17312008, MepId.valueOf((short) 10), Priority.PRIO4);
    builder = builder.sessionStatus(SessionStatus.NOT_ACTIVE);
    builder = builder.frameDelayTwoWay(Duration.ofNanos(101 * 1000));
    builder = builder.frameDelayForward(Duration.ofNanos(102 * 1000));
    builder = builder.frameDelayBackward(Duration.ofNanos(103 * 1000));
    builder = builder.interFrameDelayVariationTwoWay(Duration.ofNanos(104 * 1000));
    builder = builder.interFrameDelayVariationForward(Duration.ofNanos(105 * 1000));
    builder = builder.interFrameDelayVariationBackward(Duration.ofNanos(106 * 1000));
    builder.addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_BACKWARD_MAX);
    builder.addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_TWO_WAY_MAX);
    builder.addToMeasurementsEnabled(MeasurementOption.INTER_FRAME_DELAY_VARIATION_BACKWARD_BINS);
    dmEntry1 = builder.build();
}
Also used : CfmCodecContext(org.onosproject.cfm.CfmCodecContext) DmEntryBuilder(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry.DmEntryBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 5 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)

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