use of org.opendaylight.protocol.pcep.parser.subobject.EROUnnumberedInterfaceSubobjectParser in project bgpcep by opendaylight.
the class BaseParserExtensionActivator method registerEROParsers.
private static void registerEROParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context, final LabelRegistry labelReg) {
final EROIpv4PrefixSubobjectParser ipv4prefixParser = new EROIpv4PrefixSubobjectParser();
regs.add(context.registerEROSubobjectParser(EROIpv4PrefixSubobjectParser.TYPE, ipv4prefixParser));
regs.add(context.registerEROSubobjectSerializer(IpPrefixCase.class, ipv4prefixParser));
regs.add(context.registerEROSubobjectParser(EROIpv6PrefixSubobjectParser.TYPE, new EROIpv6PrefixSubobjectParser()));
final EROAsNumberSubobjectParser asNumberParser = new EROAsNumberSubobjectParser();
regs.add(context.registerEROSubobjectParser(EROAsNumberSubobjectParser.TYPE, asNumberParser));
regs.add(context.registerEROSubobjectSerializer(AsNumberCase.class, asNumberParser));
final EROUnnumberedInterfaceSubobjectParser unnumberedParser = new EROUnnumberedInterfaceSubobjectParser();
regs.add(context.registerEROSubobjectParser(EROUnnumberedInterfaceSubobjectParser.TYPE, unnumberedParser));
regs.add(context.registerEROSubobjectSerializer(UnnumberedCase.class, unnumberedParser));
final EROPathKey32SubobjectParser pathKeyParser = new EROPathKey32SubobjectParser();
regs.add(context.registerEROSubobjectParser(EROPathKey32SubobjectParser.TYPE_32, pathKeyParser));
regs.add(context.registerEROSubobjectParser(EROPathKey128SubobjectParser.TYPE_128, new EROPathKey128SubobjectParser()));
regs.add(context.registerEROSubobjectSerializer(PathKeyCase.class, pathKeyParser));
final EROLabelSubobjectParser labelParser = new EROLabelSubobjectParser(labelReg);
regs.add(context.registerEROSubobjectParser(EROLabelSubobjectParser.TYPE, labelParser));
regs.add(context.registerEROSubobjectSerializer(LabelCase.class, labelParser));
}
use of org.opendaylight.protocol.pcep.parser.subobject.EROUnnumberedInterfaceSubobjectParser in project bgpcep by opendaylight.
the class PCEPEROSubobjectParserTest method testEROUnnumberedSubobject.
@Test
public void testEROUnnumberedSubobject() throws PCEPDeserializerException {
final EROUnnumberedInterfaceSubobjectParser parser = new EROUnnumberedInterfaceSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setLoose(true);
subs.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(0x12345000L).setInterfaceId(0xffffffffL).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(unnumberedBytes, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(unnumberedBytes, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
Aggregations