use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class SimpleBmpTlvRegistryTest method testParseTlv.
@Test
public void testParseTlv() throws BmpDeserializationException {
final Tlv output = this.bmpTlvRegistry.parseTlv(DESCRIPTION_TLV_TYPE, this.input);
assertNotNull(output);
assertTrue(output instanceof MockDescriptionTlv);
final ByteBuf aggregator = Unpooled.EMPTY_BUFFER;
this.bmpTlvRegistry.serializeTlv(output, aggregator);
Mockito.verify(this.descriptionTlvSerializer).serializeTlv(output, aggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testStatefulTlv.
@Test
public void testStatefulTlv() throws PCEPDeserializerException {
final StatefulStatefulCapabilityTlvParser parser = new StatefulStatefulCapabilityTlvParser();
final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(STATEFUL_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(STATEFUL_BYTES, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testLspIdentifiers4Tlv.
@Test
public void testLspIdentifiers4Tlv() throws PCEPDeserializerException {
final StatefulLSPIdentifierIpv4TlvParser parser = new StatefulLSPIdentifierIpv4TlvParser();
final Ipv4Builder afi = new Ipv4Builder();
afi.setIpv4TunnelSenderAddress(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 })));
afi.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }))));
afi.setIpv4TunnelEndpointAddress(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 })));
final LspIdentifiers tlv = new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(afi.build()).build()).setLspId(new LspId(Uint32.valueOf(65535))).setTunnelId(new TunnelId(Uint16.valueOf(4660))).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(LSP_IDENTIFIERS4_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(LSP_IDENTIFIERS4_BYTES, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testUserErrorSpecTlv.
@Test
public void testUserErrorSpecTlv() throws PCEPDeserializerException {
final StatefulRSVPErrorSpecTlvParser parser = new StatefulRSVPErrorSpecTlvParser();
final UserErrorBuilder builder = new UserErrorBuilder().setEnterprise(new EnterpriseNumber(Uint32.valueOf(12345))).setSubOrg(Uint8.valueOf(5)).setValue(Uint16.valueOf(38)).setDescription("user desc");
final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new UserCaseBuilder().setUserError(builder.build()).build()).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(USER_ERROR_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(USER_ERROR_BYTES, ByteArray.getAllBytes(buff));
}
Aggregations