use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class AbstractObjectWithTlvsTest method setUp.
@Before
public void setUp() throws PCEPDeserializerException {
MockitoAnnotations.initMocks(this);
this.tlv = new OfListBuilder().setCodes(Lists.newArrayList(new OfId(10))).build();
this.viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(EN).build();
Mockito.doNothing().when(this.viTlvRegistry).serializeVendorInformationTlv(Mockito.any(VendorInformationTlv.class), Mockito.any(ByteBuf.class));
Mockito.doReturn(Optional.of(this.viTlv)).when(this.viTlvRegistry).parseVendorInformationTlv(EN, Unpooled.wrappedBuffer(new byte[0]));
Mockito.doNothing().when(this.tlvRegistry).serializeTlv(Mockito.any(Tlv.class), Mockito.any(ByteBuf.class));
Mockito.doReturn(this.tlv).when(this.tlvRegistry).parseTlv(4, Unpooled.wrappedBuffer(new byte[] { 5, 6 }));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testCloseObjectWithVendorInformationTlv.
@Test
public void testCloseObjectWithVendorInformationTlv() throws IOException, PCEPDeserializerException {
final byte[] closeBytes = { 0x0f, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x05, /* vendor-information TLV */
0x00, 0x07, 0x00, 0x08, /* enterprise number */
0x00, 0x00, 0x00, 0x00, /* enterprise specific information */
0x00, 0x00, 0x00, 0x05 };
final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationTlv viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
final CCloseBuilder builder = new CCloseBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
builder.setReason((short) 5);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.c.close.TlvsBuilder().setVendorInformationTlv(Lists.newArrayList(viTlv)).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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class AbstractVendorInformationTlvParser method parseTlv.
@Override
public final VendorInformationTlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
final VendorInformationTlvBuilder viTlvBuider = new VendorInformationTlvBuilder();
viTlvBuider.setEnterpriseNumber(getEnterpriseNumber());
if (buffer.isReadable()) {
final EnterpriseSpecificInformation esInformation = parseEnterpriseSpecificInformation(buffer.slice());
if (esInformation != null) {
viTlvBuider.setEnterpriseSpecificInformation(esInformation);
}
}
return viTlvBuider.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlvBuilder in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testVendorInformationTlv.
@Test
public void testVendorInformationTlv() throws PCEPDeserializerException {
final TestVendorInformationTlvParser parser = new TestVendorInformationTlvParser();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationTlv viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
final VendorInformationTlv parsedTlv = parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(VENDOR_INFO_BYTES, 8)));
assertEquals(viTlv, parsedTlv);
final ByteBuf buff = Unpooled.buffer(VENDOR_INFO_BYTES.length);
parser.serializeTlv(viTlv, buff);
assertArrayEquals(VENDOR_INFO_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
Aggregations