use of org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROSrlgSubobjectParser in project bgpcep by opendaylight.
the class XROSubobjectParserTest method testXROSrlgSubobject.
@Test
public void testXROSrlgSubobject() throws RSVPParsingException {
final XROSrlgSubobjectParser parser = new XROSrlgSubobjectParser();
final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
subs.setMandatory(true);
subs.setAttribute(ExcludeRouteSubobjects.Attribute.Srlg);
subs.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(0x12345678L)).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(SRLG_BYTES, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
Assert.assertArrayEquals(SRLG_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
Assert.fail();
} catch (final IllegalArgumentException e) {
Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROSrlgSubobjectParser in project bgpcep by opendaylight.
the class RSVPActivator method registerXROParsers.
private static void registerXROParsers(final List<AutoCloseable> regs, final RSVPExtensionProviderContext 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));
}
Aggregations