use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testRPObjectWithTlv.
@Test
public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
final RpBuilder builder = new RpBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setReoptimization(true);
builder.setBiDirectional(false);
builder.setLoose(true);
builder.setMakeBeforeBreak(true);
builder.setOrder(false);
builder.setPathKey(false);
builder.setSupplyOf(false);
builder.setFragmentation(false);
builder.setP2mp(false);
builder.setEroCompression(false);
builder.setPriority((short) 5);
builder.setRequestId(new RequestId(0xdeadbeefL));
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));
builder.setReoptimization(false);
builder.setFragmentation(true);
builder.setEroCompression(true);
final OrderBuilder b = new OrderBuilder();
b.setDelete(0xffffffffL);
b.setSetup(1L);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().setOrder(b.build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
try {
parser.parseObject(new ObjectHeaderImpl(true, true), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseObject(new ObjectHeaderImpl(true, true), 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.rev131005.order.tlv.OrderBuilder in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testOrderTlv.
@Test
public void testOrderTlv() throws PCEPDeserializerException {
final OrderTlvParser parser = new OrderTlvParser();
final Order tlv = new OrderBuilder().setDelete(0xFFFFFFFFL).setSetup(0x00000001L).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(orderBytes, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(orderBytes, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
Aggregations