use of org.opendaylight.protocol.pcep.parser.subobject.WavebandSwitchingLabelParser in project bgpcep by opendaylight.
the class LabelSubobjectParserTest method testWavebandLabel.
@Test
public void testWavebandLabel() throws PCEPDeserializerException {
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(wavebandLabelBytes, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeLabel(false, true, builder.build(), buff);
assertArrayEquals(wavebandLabelBytes, 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());
}
}
use of org.opendaylight.protocol.pcep.parser.subobject.WavebandSwitchingLabelParser 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));
}
Aggregations