use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder in project bgpcep by opendaylight.
the class SimpleEROSubobjectRegistryTest method testSerializerRegistration.
@Test
public void testSerializerRegistration() {
assertNotNull(this.simpleEROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
final ByteBuf output = Unpooled.buffer();
this.simpleEROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(1, output.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder in project bgpcep by opendaylight.
the class SimpleRROSubobjectRegistryTest method testUnrecognizedType.
@Test
public void testUnrecognizedType() throws RSVPParsingException {
final int wrongType = 99;
assertNull(this.simpleRROSubobjectRegistry.parseSubobject(wrongType, this.input));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder in project bgpcep by opendaylight.
the class SimpleRROSubobjectRegistryTest method testSerializerRegistration.
@Test
public void testSerializerRegistration() {
assertNotNull(this.simpleRROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
final ByteBuf output = Unpooled.buffer();
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleRROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(1, output.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder in project bgpcep by opendaylight.
the class SimpleXROSubobjectRegistryTest method testUnrecognizedType.
@Test
public void testUnrecognizedType() throws RSVPParsingException {
final int wrongType = 99;
assertNull(this.simpleXROSubobjectRegistry.parseSubobject(wrongType, this.input, false));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleXROSubobjectRegistry.serializeSubobject(container, output);
assertEquals(0, output.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder in project bgpcep by opendaylight.
the class EROIpv4PrefixSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setLoose(loose);
if (buffer.readableBytes() != CONTENT4_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
}
final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv4Util.IP4_LENGTH), length)));
builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
return builder.build();
}
Aggregations