use of org.opendaylight.protocol.pcep.parser.subobject.XROPathKey32SubobjectParser in project bgpcep by opendaylight.
the class BaseParserExtensionActivator method registerXROParsers.
private static void registerXROParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context) {
final XROIpv4PrefixSubobjectParser ipv4prefixParser = new XROIpv4PrefixSubobjectParser();
regs.add(context.registerXROSubobjectParser(XROIpv4PrefixSubobjectParser.TYPE, ipv4prefixParser));
regs.add(context.registerXROSubobjectSerializer(IpPrefixCase.class, ipv4prefixParser));
regs.add(context.registerXROSubobjectParser(XROIpv6PrefixSubobjectParser.TYPE, new XROIpv6PrefixSubobjectParser()));
final XROAsNumberSubobjectParser asNumberParser = new XROAsNumberSubobjectParser();
regs.add(context.registerXROSubobjectParser(XROAsNumberSubobjectParser.TYPE, asNumberParser));
regs.add(context.registerXROSubobjectSerializer(AsNumberCase.class, asNumberParser));
final XROSRLGSubobjectParser srlgParser = new XROSRLGSubobjectParser();
regs.add(context.registerXROSubobjectParser(XROSRLGSubobjectParser.TYPE, srlgParser));
regs.add(context.registerXROSubobjectSerializer(SrlgCase.class, srlgParser));
final XROUnnumberedInterfaceSubobjectParser unnumberedParser = new XROUnnumberedInterfaceSubobjectParser();
regs.add(context.registerXROSubobjectParser(XROUnnumberedInterfaceSubobjectParser.TYPE, unnumberedParser));
regs.add(context.registerXROSubobjectSerializer(UnnumberedCase.class, unnumberedParser));
final XROPathKey32SubobjectParser pathKeyParser = new XROPathKey32SubobjectParser();
regs.add(context.registerXROSubobjectParser(XROPathKey32SubobjectParser.TYPE, pathKeyParser));
regs.add(context.registerXROSubobjectParser(XROPathKey128SubobjectParser.TYPE, new XROPathKey128SubobjectParser()));
regs.add(context.registerXROSubobjectSerializer(PathKeyCase.class, pathKeyParser));
}
use of org.opendaylight.protocol.pcep.parser.subobject.XROPathKey32SubobjectParser in project bgpcep by opendaylight.
the class PCEPXROSubobjectParserTest method testXROPathKey32Subobject.
@Test
public void testXROPathKey32Subobject() throws PCEPDeserializerException {
final XROPathKey32SubobjectParser parser = new XROPathKey32SubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setMandatory(true);
final PathKeyBuilder pBuilder = new PathKeyBuilder();
pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 }));
pBuilder.setPathKey(new PathKey(4660));
subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(pathKey32Bytes, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(pathKey32Bytes, 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