use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class SimpleXROSubobjectRegistryTest method testSerializerRegistration.
@Test
public void testSerializerRegistration() {
assertNotNull(this.simpleXROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
final ByteBuf output = Unpooled.buffer();
this.simpleXROSubobjectRegistry.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.SubobjectContainer in project bgpcep by opendaylight.
the class RROSubobjectListParser method parseList.
public List<SubobjectContainer> parseList(final ByteBuf buffer) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final List<SubobjectContainer> subs = new ArrayList<>();
while (buffer.isReadable()) {
final int type = buffer.readUnsignedByte();
final int length = buffer.readUnsignedByte() - HEADER_LENGTH;
if (length > buffer.readableBytes()) {
throw new RSVPParsingException("Wrong length specified. Passed: " + length + "; Expected: <= " + buffer.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
final SubobjectContainer sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length));
if (sub == null) {
LOG.warn("Unknown subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
}
return subs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class SimpleEROSubobjectRegistryTest method testUnrecognizedType.
@Test
public void testUnrecognizedType() throws RSVPParsingException {
final int wrongType = 99;
assertNull(this.simpleEROSubobjectRegistry.parseSubobject(wrongType, this.input, false));
final ByteBuf output = Unpooled.EMPTY_BUFFER;
final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
this.simpleEROSubobjectRegistry.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.SubobjectContainer in project bgpcep by opendaylight.
the class TEObjectTest method testSSRODynamicProtectionSubobjectParser.
@Test
public void testSSRODynamicProtectionSubobjectParser() throws RSVPParsingException {
final SRROBasicProtectionSubobjectParser parser = new SRROBasicProtectionSubobjectParser();
final SRRODynamicProtectionSubobjectParser dynamicParser = new SRRODynamicProtectionSubobjectParser();
final SubobjectContainer sub = parser.parseSubobject(Unpooled.copiedBuffer(ByteArray.subByte(TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION, 2, TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION.length - 2)));
final ByteBuf output = Unpooled.buffer();
dynamicParser.serializeSubobject(sub, output);
assertArrayEquals(TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION, ByteArray.getAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class TEObjectTest method testSSROBasicProtectionSubobjectParser.
@Test
public void testSSROBasicProtectionSubobjectParser() throws RSVPParsingException {
final SRROBasicProtectionSubobjectParser parser = new SRROBasicProtectionSubobjectParser();
final SubobjectContainer sub = parser.parseSubobject(Unpooled.copiedBuffer(ByteArray.subByte(TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION, 2, TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION.length - 2)));
final ByteBuf output = Unpooled.buffer();
parser.serializeSubobject(sub, output);
assertArrayEquals(TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION, ByteArray.getAllBytes(output));
}
Aggregations