Search in sources :

Example 1 with WavebandSwitchingLabelParser

use of org.opendaylight.protocol.rsvp.parser.impl.subobject.label.WavebandSwitchingLabelParser in project bgpcep by opendaylight.

the class RSVPActivator method registerLabelParsers.

private static void registerLabelParsers(final List<AutoCloseable> regs, final RSVPExtensionProviderContext 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.rsvp.parser.impl.subobject.label.GeneralizedLabelParser) Type1LabelParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.label.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.rsvp.parser.impl.subobject.label.WavebandSwitchingLabelParser)

Example 2 with WavebandSwitchingLabelParser

use of org.opendaylight.protocol.rsvp.parser.impl.subobject.label.WavebandSwitchingLabelParser in project bgpcep by opendaylight.

the class LabelSubobjectParserTest method testWavebandLabel.

@Test
public void testWavebandLabel() throws RSVPParsingException {
    final WavebandSwitchingLabelParser parser = new WavebandSwitchingLabelParser();
    final WavebandSwitchingLabelBuilder iBuilder = new WavebandSwitchingLabelBuilder();
    iBuilder.setWavebandId(0x1234L);
    iBuilder.setStartLabel(0x9999L);
    iBuilder.setEndLabel(0x1111L);
    final WavebandSwitchingLabelCaseBuilder builder = new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(iBuilder.build());
    assertEquals(builder.build(), parser.parseLabel(Unpooled.wrappedBuffer(ByteArray.cutBytes(WAVEBAND_LABEL_BYTES, 2))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeLabel(false, true, builder.build(), buff);
    assertArrayEquals(WAVEBAND_LABEL_BYTES, 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 : WavebandSwitchingLabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) WavebandSwitchingLabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.waveband.switching.label._case.WavebandSwitchingLabelBuilder) WavebandSwitchingLabelParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.label.WavebandSwitchingLabelParser) Test(org.junit.Test)

Aggregations

WavebandSwitchingLabelParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.label.WavebandSwitchingLabelParser)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 GeneralizedLabelParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.label.GeneralizedLabelParser)1 Type1LabelParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.label.Type1LabelParser)1 GeneralizedLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase)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 WavebandSwitchingLabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder)1 WavebandSwitchingLabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.waveband.switching.label._case.WavebandSwitchingLabelBuilder)1