use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCaseBuilder in project bgpcep by opendaylight.
the class RouteOriginAsTwoOctetEcHandlerTest method testHandler.
@Test
public void testHandler() throws BGPDocumentedException, BGPParsingException {
final RouteOriginAsTwoOctetEcHandler handler = new RouteOriginAsTwoOctetEcHandler();
final RouteOriginExtendedCommunityCase expected = new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(24L)).setLocalAdministrator(new byte[] { 4, 2, 8, 7 }).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.rev130919.extended.community.extended.community.RouteOriginExtendedCommunityCaseBuilder in project bgpcep by opendaylight.
the class ExtendedCommunitiesAttributeParserTest method testExtendedCommunityAttributeParser.
@Test
public void testExtendedCommunityAttributeParser() throws BGPDocumentedException, BGPParsingException {
final RouteOriginExtendedCommunityCase routeOrigin = new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(new RouteOriginExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(54L)).setLocalAdministrator(new byte[] { 0, 0, 1, 76 }).build()).build();
final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setTransitive(false).setExtendedCommunity(routeOrigin).build();
final AttributesBuilder attBuilder = new AttributesBuilder();
this.handler.parseAttribute(Unpooled.copiedBuffer(INPUT), attBuilder);
final ExtendedCommunities parsed = attBuilder.getExtendedCommunities().get(0);
Assert.assertEquals(expected, parsed);
final ByteBuf output = Unpooled.buffer(INPUT.length);
this.handler.serializeAttribute(attBuilder.build(), output);
Assert.assertArrayEquals(Bytes.concat(new byte[] { (byte) 192, 16, 8 }, INPUT), ByteArray.readAllBytes(output));
}
Aggregations