use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.generalized.label._case.GeneralizedLabelBuilder in project bgpcep by opendaylight.
the class LabelSubobjectParserTest method testGeneralizedLabel.
@Test
public void testGeneralizedLabel() throws PCEPDeserializerException {
final GeneralizedLabelParser parser = new GeneralizedLabelParser();
final GeneralizedLabelBuilder iBuilder = new GeneralizedLabelBuilder();
iBuilder.setGeneralizedLabel(ByteArray.cutBytes(generalizedLabelBytes, 2));
final GeneralizedLabelCaseBuilder builder = new GeneralizedLabelCaseBuilder().setGeneralizedLabel(iBuilder.build());
assertEquals(builder.build(), parser.parseLabel(Unpooled.wrappedBuffer(ByteArray.cutBytes(generalizedLabelBytes, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeLabel(true, false, builder.build(), buff);
assertArrayEquals(generalizedLabelBytes, ByteArray.getAllBytes(buff));
try {
parser.parseLabel(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseLabel(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
Aggregations