Search in sources :

Example 1 with PCEPPathKeyObjectParser

use of org.opendaylight.protocol.pcep.parser.object.PCEPPathKeyObjectParser in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testPathKeyObject.

@Test
public void testPathKeyObject() throws Exception {
    final PCEPPathKeyObjectParser parser = new PCEPPathKeyObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPPathKeyObject.bin"));
    final PathKeyBuilder builder = new PathKeyBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(false);
    final List<PathKeys> list = Lists.newArrayList();
    list.add(new PathKeysBuilder().setLoose(true).setPathKey(new PathKey(0x1234)).setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 })).build());
    builder.setPathKeys(list);
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : PathKeys(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.path.key.PathKeys) PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) PCEPPathKeyObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPPathKeyObjectParser) PathKeysBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.path.key.PathKeysBuilder) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId) PathKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKeyBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with PCEPPathKeyObjectParser

use of org.opendaylight.protocol.pcep.parser.object.PCEPPathKeyObjectParser in project bgpcep by opendaylight.

the class BaseParserExtensionActivator method registerExtensionsObjectParsers.

private static void registerExtensionsObjectParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context, final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg, final EROSubobjectRegistry eroSubReg) {
    final PCEPPathKeyObjectParser pathKeyParser = new PCEPPathKeyObjectParser(eroSubReg);
    regs.add(context.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, pathKeyParser));
    regs.add(context.registerObjectSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKey.class, pathKeyParser));
    final PCEPExcludeRouteObjectParser xroParser = new PCEPExcludeRouteObjectParser(context.getXROSubobjectHandlerRegistry());
    regs.add(context.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, xroParser));
    regs.add(context.registerObjectSerializer(Xro.class, xroParser));
    final PCEPObjectiveFunctionObjectParser objectiveParser = new PCEPObjectiveFunctionObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE, objectiveParser));
    regs.add(context.registerObjectSerializer(Of.class, objectiveParser));
    final PCEPClassTypeObjectParser ctParser = new PCEPClassTypeObjectParser();
    regs.add(context.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, ctParser));
    regs.add(context.registerObjectSerializer(ClassType.class, ctParser));
    final PCEPGlobalConstraintsObjectParser gcParser = new PCEPGlobalConstraintsObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE, gcParser));
    regs.add(context.registerObjectSerializer(Gc.class, gcParser));
    registerMonitoringExtensionParsers(regs, context, tlvReg, viTlvReg);
}
Also used : PCEPObjectiveFunctionObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPObjectiveFunctionObjectParser) ClassType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType) Xro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro) PCEPGlobalConstraintsObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPGlobalConstraintsObjectParser) Of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of) PCEPPathKeyObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPPathKeyObjectParser) PCEPExcludeRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPExcludeRouteObjectParser) PCEPClassTypeObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPClassTypeObjectParser) Gc(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.Gc)

Aggregations

PCEPPathKeyObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPPathKeyObjectParser)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 PCEPClassTypeObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPClassTypeObjectParser)1 PCEPExcludeRouteObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPExcludeRouteObjectParser)1 PCEPGlobalConstraintsObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPGlobalConstraintsObjectParser)1 PCEPObjectiveFunctionObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPObjectiveFunctionObjectParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 ClassType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType)1 Xro (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro)1 Gc (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.gc.object.Gc)1 Of (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of)1 PathKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKeyBuilder)1 PathKeys (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.path.key.PathKeys)1 PathKeysBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.path.key.PathKeysBuilder)1 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)1 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId)1