use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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.rev181109.NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true)).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(NO_PATH_VECTOR_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(NO_PATH_VECTOR_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder in project bgpcep by opendaylight.
the class MessagesUtil method createNoPathMessage.
public static Pcrep createNoPathMessage(final Rp rp, final byte reason) {
/* Prepare NoPath Object */
final Flags flags = new Flags(false, false, false, false, false, false, reason == UNKNOWN_DESTINATION, reason == UNKNOWN_SOURCE);
final NoPathVectorBuilder npvBuilder = new NoPathVectorBuilder().setFlags(flags);
final TlvsBuilder tlvsBuilder = new TlvsBuilder().setNoPathVector(npvBuilder.build());
final NoPathBuilder npBuilder = new NoPathBuilder().setProcessingRule(false).setIgnore(false).setNatureOfIssue(Uint8.ZERO).setUnsatisfiedConstraints(true).setTlvs(tlvsBuilder.build());
/* Prepare Reply */
final RepliesBuilder replyBuilder = new RepliesBuilder().setRp(rp).setResult(new FailureCaseBuilder().setNoPath(npBuilder.build()).build());
/* Prepare PcRep Message */
final PcrepMessageBuilder msgBuilder = new PcrepMessageBuilder().setReplies(Lists.newArrayList(replyBuilder.build()));
return new PcrepBuilder().setPcrepMessage(msgBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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().setProcessingRule(true).setIgnore(true).setNatureOfIssue(Uint8.ONE).setUnsatisfiedConstraints(true).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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(Uint8.ZERO);
builder.setUnsatisfiedConstraints(false);
final NoPathVectorBuilder b = new NoPathVectorBuilder();
b.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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.rev181109.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. 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());
}
}
Aggregations