use of org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROIpv6PrefixSubobjectParser in project bgpcep by opendaylight.
the class EROSubobjectParserTest method testEROIp6PrefixSubobject.
@Test
public void testEROIp6PrefixSubobject() throws RSVPParsingException {
final EROIpv6PrefixSubobjectParser parser = new EROIpv6PrefixSubobjectParser();
final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
subs.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, 22))).build()).build());
subs.setLoose(false);
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(IP_6_PREFIX_BYTES, 2)), false));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
Assert.assertArrayEquals(IP_6_PREFIX_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.ero.EROIpv6PrefixSubobjectParser in project bgpcep by opendaylight.
the class RSVPActivator method registerEROParsers.
private static void registerEROParsers(final List<AutoCloseable> regs, final RSVPExtensionProviderContext 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, pathKeyParser));
regs.add(context.registerEROSubobjectParser(EROPathKey128SubobjectParser.TYPE, 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));
final SERODynamicProtectionSubobjectParser seroDynamicParser = new SERODynamicProtectionSubobjectParser();
final SEROBasicProtectionSubobjectParser seroBasicParser = new SEROBasicProtectionSubobjectParser();
regs.add(context.registerEROSubobjectParser(SERODynamicProtectionSubobjectParser.TYPE, seroBasicParser));
regs.add(context.registerEROSubobjectSerializer(DynamicControlProtectionCase.class, seroDynamicParser));
regs.add(context.registerEROSubobjectSerializer(BasicProtectionCase.class, seroBasicParser));
}
Aggregations