use of org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07LspaObjectParser in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testLspaObject.
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
final Stateful07LspaObjectParser parser = new Stateful07LspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
final LspaBuilder builder = new LspaBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject3RandVals.bin"));
final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName(new byte[] { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d, (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65 })).build();
builder.setIgnore(false);
builder.setProcessingRule(false);
builder.setExcludeAny(new AttributeFilter(0x20A1FEE3L));
builder.setIncludeAny(new AttributeFilter(0x1A025CC7L));
builder.setIncludeAll(new AttributeFilter(0x2BB66532L));
builder.setHoldPriority((short) 0x02);
builder.setSetupPriority((short) 0x03);
builder.setLocalProtectionDesired(true);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder().addAugmentation(Tlvs2.class, new Tlvs2Builder().setSymbolicPathName(tlv).build()).build());
// Tlvs container does not contain toString
final Object o = parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4));
assertEquals(tlv, ((Lspa) o).getTlvs().getAugmentation(Tlvs2.class).getSymbolicPathName());
// assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), ByteArray.cutBytes(result,
// 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Aggregations