Search in sources :

Example 1 with GeneralizedLabelParser

use of org.opendaylight.protocol.pcep.parser.subobject.GeneralizedLabelParser in project bgpcep by opendaylight.

the class LabelSubobjectParserTest method testGeneralizedLabel.

@Test
public void testGeneralizedLabel() throws PCEPDeserializerException {
    final GeneralizedLabelParser parser = new GeneralizedLabelParser();
    final GeneralizedLabelBuilder iBuilder = new GeneralizedLabelBuilder();
    iBuilder.setGeneralizedLabel(ByteArray.cutBytes(generalizedLabelBytes, 2));
    final GeneralizedLabelCaseBuilder builder = new GeneralizedLabelCaseBuilder().setGeneralizedLabel(iBuilder.build());
    assertEquals(builder.build(), parser.parseLabel(Unpooled.wrappedBuffer(ByteArray.cutBytes(generalizedLabelBytes, 2))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeLabel(true, false, builder.build(), buff);
    assertArrayEquals(generalizedLabelBytes, ByteArray.getAllBytes(buff));
    try {
        parser.parseLabel(null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseLabel(Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : GeneralizedLabelParser(org.opendaylight.protocol.pcep.parser.subobject.GeneralizedLabelParser) GeneralizedLabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCaseBuilder) GeneralizedLabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.generalized.label._case.GeneralizedLabelBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with GeneralizedLabelParser

use of org.opendaylight.protocol.pcep.parser.subobject.GeneralizedLabelParser in project bgpcep by opendaylight.

the class BaseParserExtensionActivator method registerLabelParsers.

private static void registerLabelParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context) {
    final Type1LabelParser type1Parser = new Type1LabelParser();
    regs.add(context.registerLabelParser(Type1LabelParser.CTYPE, type1Parser));
    regs.add(context.registerLabelSerializer(Type1LabelCase.class, type1Parser));
    final GeneralizedLabelParser generalizedParser = new GeneralizedLabelParser();
    regs.add(context.registerLabelParser(GeneralizedLabelParser.CTYPE, generalizedParser));
    regs.add(context.registerLabelSerializer(GeneralizedLabelCase.class, generalizedParser));
    final WavebandSwitchingLabelParser wavebandParser = new WavebandSwitchingLabelParser();
    regs.add(context.registerLabelParser(WavebandSwitchingLabelParser.CTYPE, wavebandParser));
    regs.add(context.registerLabelSerializer(WavebandSwitchingLabelCase.class, wavebandParser));
}
Also used : GeneralizedLabelParser(org.opendaylight.protocol.pcep.parser.subobject.GeneralizedLabelParser) Type1LabelParser(org.opendaylight.protocol.pcep.parser.subobject.Type1LabelParser) WavebandSwitchingLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCase) GeneralizedLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase) Type1LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase) WavebandSwitchingLabelParser(org.opendaylight.protocol.pcep.parser.subobject.WavebandSwitchingLabelParser)

Aggregations

GeneralizedLabelParser (org.opendaylight.protocol.pcep.parser.subobject.GeneralizedLabelParser)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 Type1LabelParser (org.opendaylight.protocol.pcep.parser.subobject.Type1LabelParser)1 WavebandSwitchingLabelParser (org.opendaylight.protocol.pcep.parser.subobject.WavebandSwitchingLabelParser)1 GeneralizedLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase)1 GeneralizedLabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCaseBuilder)1 Type1LabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase)1 WavebandSwitchingLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCase)1 GeneralizedLabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.generalized.label._case.GeneralizedLabelBuilder)1