use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ExtendedCommunity in project bgpcep by opendaylight.
the class RouteTarget4OctectASEcHandlerTest method testHandler.
@Test
public void testHandler() throws BGPDocumentedException, BGPParsingException {
final As4RouteTargetExtendedCommunityCase expected = new As4RouteTargetExtendedCommunityCaseBuilder().setAs4RouteTargetExtendedCommunity(new As4RouteTargetExtendedCommunityBuilder().setAs4SpecificCommon(AS_COMMON).build()).build();
final ExtendedCommunity exComm = this.handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
Assert.assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
this.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.ExtendedCommunity 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.ExtendedCommunity in project bgpcep by opendaylight.
the class Generic4OctASEcHandlerTest method testHandler.
@Test
public void testHandler() throws BGPDocumentedException, BGPParsingException {
final As4GenericSpecExtendedCommunityCase expected = new As4GenericSpecExtendedCommunityCaseBuilder().setAs4GenericSpecExtendedCommunity(new As4GenericSpecExtendedCommunityBuilder().setAs4SpecificCommon(AS_COMMON).build()).build();
final ExtendedCommunity exComm = this.handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
Assert.assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
this.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.ExtendedCommunity in project bgpcep by opendaylight.
the class SourceASHandlerTest method testHandler.
@Test
public void testHandler() {
final SourceAsExtendedCommunityCase expected = new SourceAsExtendedCommunityCaseBuilder().setSourceAsExtendedCommunity(new SourceAsExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(Uint32.ONE)).build()).build();
final ExtendedCommunity exComm = this.handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
Assert.assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
this.handler.serializeExtendedCommunity(expected, output);
Assert.assertArrayEquals(INPUT, output.array());
assertEquals(9, this.handler.getSubType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ExtendedCommunity 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