use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl 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));
}
use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.
the class PCEPBandwidthUsageObjectCodecTest method testCodec.
@Test
public void testCodec() throws PCEPDeserializerException {
final BandwidthUsageObjectCodec codec = new BandwidthUsageObjectCodec(5);
assertEquals(5, codec.getType());
final BandwidthUsageBuilder builder = new BandwidthUsageBuilder();
builder.setBwSample(Lists.newArrayList(new Bandwidth(new byte[] { 0x00, 0x00, 0x10, 0x00 }), new Bandwidth(new byte[] { 0x00, 0x00, 0x40, 0x00 })));
builder.setIgnore(false);
builder.setProcessingRule(false);
final BandwidthUsage parsedObject = codec.parseObject(new ObjectHeaderImpl(false, false), Unpooled.wrappedBuffer(BW_BYTES, 4, BW_BYTES.length - 4));
assertEquals(builder.build(), parsedObject);
final ByteBuf buffer = Unpooled.buffer(BW_BYTES.length);
codec.serializeObject(builder.build(), buffer);
assertArrayEquals(BW_BYTES, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.
the class PCCEndPointIpv4ObjectParserTest method testParseObject.
@Test
public void testParseObject() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4Address(IP1)));
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4Address(IP2)));
final EndpointsObj output = (EndpointsObj) new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
assertEquals(IP1, ((Ipv4Case) output.getAddressFamily()).getIpv4().getSourceIpv4Address().getValue());
assertEquals(IP2, ((Ipv4Case) output.getAddressFamily()).getIpv4().getDestinationIpv4Address().getValue());
assertFalse(output.isIgnore());
assertFalse(output.isProcessingRule());
}
use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.
the class PCCEndPointIpv4ObjectParserTest method testParseEmptyObject.
@Test(expected = PCEPDeserializerException.class)
public void testParseEmptyObject() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
bytes.writeByte(4);
new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
}
Aggregations