Search in sources :

Example 1 with OverloadDurationBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testNotifyObjectWithTlv.

@Test
public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin"));
    final CNotificationBuilder builder = new CNotificationBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setType((short) 0xff);
    builder.setValue((short) 0xff);
    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/PCEPNotificationObject1WithTlv.bin"));
    builder.setType((short) 2);
    builder.setValue((short) 1);
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.TlvsBuilder().setOverloadDuration(new OverloadDurationBuilder().setDuration(0xff0000a2L).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 : OverloadDurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) PCEPNotificationObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPNotificationObjectParser) CNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotificationBuilder) 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 OverloadDurationBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testOverloadedDurationTlv.

@Test
public void testOverloadedDurationTlv() throws PCEPDeserializerException {
    final OverloadedDurationTlvParser parser = new OverloadedDurationTlvParser();
    final OverloadDuration tlv = new OverloadDurationBuilder().setDuration(0x7FFFFFFFL).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(overloadedBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(overloadedBytes, ByteArray.getAllBytes(buff));
    assertNull(parser.parseTlv(null));
}
Also used : OverloadDurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder) OverloadDuration(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration) OverloadedDurationTlvParser(org.opendaylight.protocol.pcep.parser.tlv.OverloadedDurationTlvParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 OverloadDurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder)2 PCEPNotificationObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPNotificationObjectParser)1 OverloadedDurationTlvParser (org.opendaylight.protocol.pcep.parser.tlv.OverloadedDurationTlvParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject)1 CNotificationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotificationBuilder)1 OverloadDuration (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration)1