use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder in project bgpcep by opendaylight.
the class SrObjectParserTest method testOpenObjectWithSpcTlv.
@Test
public void testOpenObjectWithSpcTlv() throws PCEPDeserializerException {
final PcepOpenObjectWithSpcTlvParser parser = new PcepOpenObjectWithSpcTlvParser(this.tlvRegistry, this.viTlvRegistry);
final OpenBuilder builder = new OpenBuilder().setProcessingRule(false).setIgnore(false).setVersion(new ProtocolVersion(Uint8.ONE)).setKeepalive(Uint8.valueOf(30)).setDeadTimer(Uint8.valueOf(120)).setSessionId(Uint8.ONE);
builder.setTlvs(new TlvsBuilder().addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Tlvs1Builder().build()).addAugmentation(new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setNFlag(Boolean.TRUE).setXFlag(Boolean.TRUE).setMsd(Uint8.ONE).build()).build()).addAugmentation(new Tlvs3Builder().build()).build());
final ByteBuf result = Unpooled.wrappedBuffer(OPEN_OBJECT_BYTES);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buffer = Unpooled.buffer();
parser.serializeObject(builder.build(), buffer);
parser.serializeTlvs(null, Unpooled.EMPTY_BUFFER);
parser.serializeTlvs(new TlvsBuilder().build(), Unpooled.EMPTY_BUFFER);
assertArrayEquals(OPEN_OBJECT_BYTES, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder in project bgpcep by opendaylight.
the class SrTlvParserTest method testSrPceCapabilityParser.
@Test
public void testSrPceCapabilityParser() throws PCEPDeserializerException {
final SrPceCapabilityTlvParser parser = new SrPceCapabilityTlvParser();
final SrPceCapability spcTlv = new SrPceCapabilityBuilder().setNFlag(Boolean.TRUE).setXFlag(Boolean.TRUE).setMsd(Uint8.ONE).build();
assertEquals(spcTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SPC_TLV_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(spcTlv, buff);
assertArrayEquals(SPC_TLV_BYTES, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder in project bgpcep by opendaylight.
the class SrPceCapabilityTlvParser method parseTlv.
@Override
public Tlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
final BitArray bitSet = BitArray.valueOf(buffer.readerIndex(OFFSET).readByte());
final boolean n = bitSet.get(N_FLAG_POSITION);
final boolean x = bitSet.get(X_FLAG_POSITION);
return new SrPceCapabilityBuilder().setNFlag(n).setXFlag(x).setMsd(ByteBufUtils.readUint8(buffer)).build();
}
Aggregations