Search in sources :

Example 1 with SrPceCapabilityBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.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();
    builder.setProcessingRule(false);
    builder.setIgnore(false);
    builder.setVersion(new ProtocolVersion((short) 1));
    builder.setKeepalive((short) 30);
    builder.setDeadTimer((short) 120);
    builder.setSessionId((short) 1);
    final Tlvs1 tlv = new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 1).build()).build();
    builder.setTlvs(new TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder().build()).addAugmentation(Tlvs1.class, tlv).addAugmentation(Tlvs3.class, new Tlvs3Builder().build()).build());
    final ByteBuf result = Unpooled.wrappedBuffer(openObjectBytes);
    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(openObjectBytes, ByteArray.getAllBytes(buffer));
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) Tlvs3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.Tlvs1Builder) ByteBuf(io.netty.buffer.ByteBuf) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.Tlvs1) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder) SrPceCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.pce.capability.tlv.SrPceCapabilityBuilder) Test(org.junit.Test)

Example 2 with SrPceCapabilityBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.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().setMsd((short) 1).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));
}
Also used : SrPceCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.pce.capability.tlv.SrPceCapability) ByteBuf(io.netty.buffer.ByteBuf) SrPceCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.pce.capability.tlv.SrPceCapabilityBuilder) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 SrPceCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.pce.capability.tlv.SrPceCapabilityBuilder)2 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 Tlvs3Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder)1 Tlvs1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.Tlvs1)1 Tlvs1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.Tlvs1Builder)1 SrPceCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.pce.capability.tlv.SrPceCapability)1 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion)1 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder)1 TlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder)1