use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder in project bgpcep by opendaylight.
the class PcepRROSubobjectParserTest method testRROUnnumberedSubobject.
@Test
public void testRROUnnumberedSubobject() throws PCEPDeserializerException {
final RROUnnumberedInterfaceSubobjectParser parser = new RROUnnumberedInterfaceSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder().setProtectionAvailable(false).setProtectionInUse(true).setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(Uint32.valueOf(0x12345000L)).setInterfaceId(Uint32.valueOf(0xffffffffL)).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(UNNUMBERED_BYTES, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(UNNUMBERED_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder in project bgpcep by opendaylight.
the class PcepRROSubobjectParserTest method testRROPathKey128Subobject.
@Test
public void testRROPathKey128Subobject() throws PCEPDeserializerException {
final RROPathKey128SubobjectParser parser = new RROPathKey128SubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
final PathKeyBuilder pBuilder = new PathKeyBuilder().setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 })).setPathKey(new PathKey(Uint16.valueOf(4660)));
subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(PATH_KEY128_BYTES, 2))));
final ByteBuf buff = Unpooled.buffer();
RROPathKey128SubobjectParser.serializeSubobject(subs.build(), buff);
assertArrayEquals(PATH_KEY128_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder in project bgpcep by opendaylight.
the class PcepRROSubobjectParserTest method testRROIp6PrefixSubobject.
@Test
public void testRROIp6PrefixSubobject() throws PCEPDeserializerException {
final RROIpv6PrefixSubobjectParser parser = new RROIpv6PrefixSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder().setProtectionAvailable(false).setProtectionInUse(true).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());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(IP6_PREFIX_BYTES, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(IP6_PREFIX_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null);
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);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder in project bgpcep by opendaylight.
the class PcepXROSubobjectParserTest method testXROAsNumberSubobject.
@Test
public void testXROAsNumberSubobject() throws PCEPDeserializerException {
final XROAsNumberSubobjectParser parser = new XROAsNumberSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder().setMandatory(true).setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(Uint32.valueOf(0x64))).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(AS_NUMBER_BYTES, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(AS_NUMBER_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder in project bgpcep by opendaylight.
the class PcepXROSubobjectParserTest method testXROIp4PrefixSubobject.
@Test
public void testXROIp4PrefixSubobject() throws PCEPDeserializerException {
final XROIpv4PrefixSubobjectParser parser = new XROIpv4PrefixSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder().setMandatory(false).setAttribute(Attribute.Interface).setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/22"))).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(IP4_PREFIX_BYTES, 2)), false));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(IP4_PREFIX_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
}
Aggregations