use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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);
final RpBuilder builder = new RpBuilder().setProcessingRule(true).setIgnore(true).setReoptimization(true).setBiDirectional(false).setLoose(true).setMakeBeforeBreak(true).setOrder(false).setPathKey(false).setSupplyOf(false).setFragmentation(false).setP2mp(false).setEroCompression(false).setPriority(Uint8.valueOf(5)).setRequestId(new RequestId(Uint32.valueOf(0xdeadbeefL))).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder().build());
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
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().setDelete(Uint32.valueOf(0xffffffffL)).setSetup(Uint32.ONE);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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. Cannot 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. Cannot be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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(Uint32.valueOf(0xFFFFFFFFL)).setSetup(Uint32.valueOf(0x00000001L)).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(ORDER_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(ORDER_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
Aggregations