use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class AbstractBmpMessageWithTlvParserTest method testParseTlvs.
@Test
public void testParseTlvs() throws BmpDeserializationException {
final ByteBuf buffer = Unpooled.EMPTY_BUFFER;
final TlvsBuilder builder = new TlvsBuilder();
this.parser.parseTlvs(builder, buffer);
assertNull(builder.getDescriptionTlv());
this.parser.parseTlvs(builder, Unpooled.wrappedBuffer(DATA));
assertNotNull(builder.getDescriptionTlv());
assertEquals("test", builder.getDescriptionTlv().getDescription());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class AbstractBmpMessageWithTlvParserTest method testParseCorruptedTlv.
@Test(expected = BmpDeserializationException.class)
public void testParseCorruptedTlv() throws BmpDeserializationException {
final byte[] wrongData = { 0, 1, 0, 10, 't', 'e', 's', 't' };
this.parser.parseTlvs(new TlvsBuilder(), Unpooled.wrappedBuffer(wrongData));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testErrorObjectWithTlv.
@Test
public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
final ErrorObjectBuilder builder = new ErrorObjectBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setType((short) 1);
builder.setValue((short) 1);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
builder.setType((short) 7);
builder.setValue((short) 0);
builder.setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder().setRequestId(new RequestId(0x00001155L)).build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
try {
parser.parseObject(new ObjectHeaderImpl(true, true), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class SyncOptimizationsOpenObjectParser method addTlv.
@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
super.addTlv(tbuilder, tlv);
final Tlvs3Builder syncOptTlvsBuilder = new Tlvs3Builder();
if (tbuilder.getAugmentation(Tlvs3.class) != null) {
final Tlvs3 t = tbuilder.getAugmentation(Tlvs3.class);
if (t.getLspDbVersion() != null) {
syncOptTlvsBuilder.setLspDbVersion(t.getLspDbVersion());
}
if (t.getSpeakerEntityId() != null) {
syncOptTlvsBuilder.setSpeakerEntityId(t.getSpeakerEntityId());
}
}
if (tlv instanceof LspDbVersion) {
syncOptTlvsBuilder.setLspDbVersion((LspDbVersion) tlv);
}
if (tlv instanceof SpeakerEntityId) {
syncOptTlvsBuilder.setSpeakerEntityId((SpeakerEntityId) tlv);
}
tbuilder.addAugmentation(Tlvs3.class, syncOptTlvsBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testSrpObject.
@Test
public void testSrpObject() throws IOException, PCEPDeserializerException {
final CInitiated00SrpObjectParser parser = new CInitiated00SrpObjectParser(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();
builder.setProcessingRule(false);
builder.setIgnore(false);
builder.setOperationId(new SrpIdNumber(1L));
builder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(true).build());
builder.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