Search in sources :

Example 1 with NoPathVectorBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testNoPathVectorTlv.

@Test
public void testNoPathVectorTlv() throws PCEPDeserializerException {
    final NoPathVectorTlvParser parser = new NoPathVectorTlvParser();
    final NoPathVectorTlv tlv = new NoPathVectorBuilder().setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true)).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(noPathVectorBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(noPathVectorBytes, ByteArray.getAllBytes(buff));
    assertNull(parser.parseTlv(null));
}
Also used : NoPathVectorTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv) NoPathVectorTlvParser(org.opendaylight.protocol.pcep.parser.tlv.NoPathVectorTlvParser) ByteBuf(io.netty.buffer.ByteBuf) NoPathVectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder) Test(org.junit.Test)

Example 2 with NoPathVectorBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testNoPathObjectWithTlv.

@Test
public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));
    final NoPathBuilder builder = new NoPathBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setNatureOfIssue((short) 1);
    builder.setUnsatisfiedConstraints(true);
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.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/PCEPNoPathObject2WithTLV.bin"));
    builder.setNatureOfIssue((short) 0);
    builder.setUnsatisfiedConstraints(false);
    final NoPathVectorBuilder b = new NoPathVectorBuilder();
    b.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true));
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().setNoPathVector(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 : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) PCEPNoPathObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPNoPathObjectParser) NoPathVectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder) NoPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 NoPathVectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder)2 PCEPNoPathObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPNoPathObjectParser)1 NoPathVectorTlvParser (org.opendaylight.protocol.pcep.parser.tlv.NoPathVectorTlvParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 NoPathVectorTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv)1 TlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder)1 NoPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder)1