use of org.opendaylight.protocol.pcep.ietf.initiated.InitiatedSrpObjectParser in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testSRPObjectWithPSTTlv.
@Test
public void testSRPObjectWithPSTTlv() throws PCEPDeserializerException {
final byte[] srpObjectWithPstTlvBytes = { 0x21, 0x10, 0x00, 0x14, 0x0, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x01, /* pst-tlv */
0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
final InitiatedSrpObjectParser parser = new InitiatedSrpObjectParser(this.tlvRegistry, this.viTlvRegistry);
final SrpBuilder builder = new SrpBuilder().setProcessingRule(false).setIgnore(false).setOperationId(new SrpIdNumber(Uint32.ONE)).addAugmentation(new Srp1Builder().setRemove(true).build()).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.srp.TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst(Uint8.ZERO).build()).build());
final ByteBuf result = Unpooled.wrappedBuffer(srpObjectWithPstTlvBytes);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(srpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
}
use of org.opendaylight.protocol.pcep.ietf.initiated.InitiatedSrpObjectParser in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testSrpObject.
@Test
public void testSrpObject() throws PCEPDeserializerException {
final InitiatedSrpObjectParser parser = new InitiatedSrpObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { (byte) 0x21, (byte) 0x10, (byte) 0x00, (byte) 0x0c, 0, 0, 0, (byte) 0x01, 0, 0, 0, (byte) 0x01 });
final SrpBuilder builder = new SrpBuilder().setProcessingRule(false).setIgnore(false).setOperationId(new SrpIdNumber(Uint32.ONE)).addAugmentation(new Srp1Builder().setRemove(true).build()).setTlvs(new TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Aggregations