use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.AsSpecificExtendedCommunityCase in project bgpcep by opendaylight.
the class AsTwoOctetSpecificEcHandlerTest method testHandler.
@Test
public void testHandler() throws BGPDocumentedException, BGPParsingException {
final AsTwoOctetSpecificEcHandler handler = new AsTwoOctetSpecificEcHandler();
final AsSpecificExtendedCommunityCase expected = new AsSpecificExtendedCommunityCaseBuilder().setAsSpecificExtendedCommunity(new AsSpecificExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(54))).setLocalAdministrator(new byte[] { 0, 0, 1, 76 }).build()).build();
final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
Assert.assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
handler.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(INPUT, output.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.AsSpecificExtendedCommunityCase in project bgpcep by opendaylight.
the class AsTwoOctetSpecificEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof AsSpecificExtendedCommunityCase, "The extended community %s is not AsSpecificExtendedCommunity type.", extendedCommunity);
final AsSpecificExtendedCommunity asSpecific = ((AsSpecificExtendedCommunityCase) extendedCommunity).getAsSpecificExtendedCommunity();
byteAggregator.writeShort(asSpecific.getGlobalAdministrator().getValue().intValue());
byteAggregator.writeBytes(asSpecific.getLocalAdministrator());
}
Aggregations