Search in sources :

Example 21 with CfmCodecContext

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

the class MdWebResourceTest method setUpTest.

@Before
public void setUpTest() throws CfmConfigException {
    CfmCodecContext context = new CfmCodecContext();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(CfmMdService.class, mdService).add(CodecService.class, context.codecManager());
    setServiceDirectory(testDirectory);
    mdList = new ArrayList<>();
    mdList.add(DefaultMaintenanceDomain.builder(MDNAME1).mdLevel(MaintenanceDomain.MdLevel.LEVEL1).build());
    mdList.add(DefaultMaintenanceDomain.builder(MDNAME2).mdLevel(MaintenanceDomain.MdLevel.LEVEL2).build());
}
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)

Example 22 with CfmCodecContext

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

the class LmWebResourceTest method setUpTest.

@Before
public void setUpTest() throws CfmConfigException, SoamConfigException {
    CfmCodecContext context = new CfmCodecContext();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(CfmMepService.class, mepService).add(SoamService.class, soamService).add(CodecService.class, context.codecManager());
    setServiceDirectory(testDirectory);
    lm1 = DefaultLmEntry.builder(DelayMeasurementCreate.Version.Y17312008, MepId.valueOf((short) 10), Mep.Priority.PRIO1, LossMeasurementCreate.LmType.LMLMM, LMID1).build();
    lm2 = DefaultLmEntry.builder(DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 10), Mep.Priority.PRIO2, LossMeasurementCreate.LmType.LMLMM, LMID2).measuredAvailabilityBackwardStatus(LossMeasurementEntry.AvailabilityType.AVAILABLE).measuredAvailabilityForwardStatus(LossMeasurementEntry.AvailabilityType.UNKNOWN).measuredBackwardFlr(MilliPct.ofPercent(49.9f)).measuredForwardFlr(MilliPct.ofRatio(0.51f)).measuredBackwardLastTransitionTime(now).measuredForwardLastTransitionTime(now).build();
}
Also used : CfmCodecContext(org.onosproject.cfm.CfmCodecContext) SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) Before(org.junit.Before)

Example 23 with CfmCodecContext

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

the class LmWebResourceTest method testCreateLm.

@Test
public void testCreateLm() throws CfmConfigException, SoamConfigException {
    MepEntry mep1 = DefaultMepEntry.builder(MEPID1, DeviceId.deviceId("netconf:1.2.3.4:830"), PortNumber.portNumber(1), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).buildEntry();
    expect(mepService.getMep(MDNAME1, MANAME1, MEPID1)).andReturn(mep1).anyTimes();
    replay(mepService);
    ObjectMapper mapper = new ObjectMapper();
    CfmCodecContext context = new CfmCodecContext();
    ObjectNode node = mapper.createObjectNode();
    node.set("lm", context.codec(LossMeasurementCreate.class).encode(lm1, context));
    final WebTarget wt = target();
    final Response response = wt.path("md/" + MDNAME1.mdName() + "/ma/" + MANAME1.maName() + "/mep/" + MEPID1.value() + "/lm").request().post(Entity.json(node.toString()));
    assertEquals(201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) CfmCodecContext(org.onosproject.cfm.CfmCodecContext) DefaultMepEntry(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry) MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) WebTarget(javax.ws.rs.client.WebTarget) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) CfmResourceTest(org.onosproject.cfm.impl.CfmResourceTest)

Example 24 with CfmCodecContext

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

the class MaWebResourceTest method setUpTest.

@Before
public void setUpTest() throws CfmConfigException {
    CfmCodecContext context = new CfmCodecContext();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(CfmMdService.class, mdService).add(CodecService.class, context.codecManager());
    setServiceDirectory(testDirectory);
    ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).addToRemoteMepIdList(MepId.valueOf((short) 101)).addToRemoteMepIdList(MepId.valueOf((short) 102)).ccmInterval(MaintenanceAssociation.CcmInterval.INTERVAL_3MS).maNumericId((short) 1).addToComponentList(DefaultComponent.builder(1).tagType(Component.TagType.VLAN_STAG).mhfCreationType(Component.MhfCreationType.NONE).idPermission(Component.IdPermissionType.MANAGE).addToVidList(VlanId.vlanId((short) 1010)).build()).build();
}
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