use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCaseBuilder in project bgpcep by opendaylight.
the class PCEPXROSubobjectParserTest method testXROUnnumberedSubobject.
@Test
public void testXROUnnumberedSubobject() throws PCEPDeserializerException {
final XROUnnumberedInterfaceSubobjectParser parser = new XROUnnumberedInterfaceSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setMandatory(true);
subs.setAttribute(Attribute.Node);
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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCaseBuilder in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
}
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
buffer.skipBytes(RESERVED);
return new SubobjectBuilder().setProtectionAvailable(flags.get(LPA_F_OFFSET)).setProtectionInUse(flags.get(LPIU_F_OFFSET)).setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(ByteBufUtils.readUint32(buffer)).setInterfaceId(ByteBufUtils.readUint32(buffer)).build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCaseBuilder 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.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCaseBuilder 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().setLoose(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)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(UNNUMBERED_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.rsvp.rev150820._record.route.subobjects.subobject.type.UnnumberedCaseBuilder in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer) throws RSVPParsingException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: " + CONTENT_LENGTH + ".");
}
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
buffer.skipBytes(RESERVED);
return new SubobjectContainerBuilder().setProtectionAvailable(flags.get(LPA_F_OFFSET)).setProtectionInUse(flags.get(LPIU_F_OFFSET)).setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(ByteBufUtils.readUint32(buffer)).setInterfaceId(ByteBufUtils.readUint32(buffer)).build()).build()).build();
}
Aggregations