Search in sources :

Example 1 with OrderBuilder

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());
    }
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) PCEPRequestParameterObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser) OrderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject) Test(org.junit.Test)

Example 2 with OrderBuilder

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));
}
Also used : Order(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order) OrderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder) ByteBuf(io.netty.buffer.ByteBuf) OrderTlvParser(org.opendaylight.protocol.pcep.parser.tlv.OrderTlvParser) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 OrderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder)2 PCEPRequestParameterObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser)1 OrderTlvParser (org.opendaylight.protocol.pcep.parser.tlv.OrderTlvParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)1 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject)1 Order (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order)1 TlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder)1 RpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder)1