use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.
the class PMSITunnelAttributeHandlerTest method testMldpP2MpLsp.
@Test
public void testMldpP2MpLsp() throws Exception {
final ByteBuf actualIpv4 = Unpooled.buffer();
final Attributes expectedIpv4Att = buildMldpP2mpLspIpv4Attribute();
final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
providerContext.getAttributeRegistry().serializeAttribute(expectedIpv4Att, actualIpv4);
assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV4, ByteArray.readAllBytes(actualIpv4));
final Attributes actualIpv4Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV4_2), null);
assertEquals(expectedIpv4Att, actualIpv4Attribute);
final Attributes expectedIpv6Att = buildMldpP2mpLspIpv6Attribute();
final ByteBuf actualIpv6 = Unpooled.buffer();
this.handler.serializeAttribute(expectedIpv6Att, actualIpv6);
assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV6, ByteArray.readAllBytes(actualIpv6));
final Attributes actualIpv6Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV6), null);
assertEquals(expectedIpv6Att, actualIpv6Attribute);
final ByteBuf actualL2vpn = Unpooled.buffer();
this.handler.serializeAttribute(buildNoSupportedFamilyAttribute(), actualL2vpn);
assertArrayEquals(new byte[0], ByteArray.readAllBytes(actualIpv4));
final Attributes actualWrongFamily = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY), null);
assertEquals(buildWOTunnelInfAttribute(), actualWrongFamily);
final Attributes expectedL2vpnAtt = buildMldpp2MPLspL2vpnAttribute();
final Attributes actualL2vpnAttribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_L2VPN), null);
assertEquals(expectedL2vpnAtt, actualL2vpnAttribute);
final ByteBuf actualL2vp = Unpooled.buffer();
this.handler.serializeAttribute(expectedL2vpnAtt, actualL2vp);
assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_L2VPN, ByteArray.readAllBytes(actualL2vp));
final ByteBuf actualNonSupportedOpaques = Unpooled.buffer();
this.handler.serializeAttribute(buildNoSupportedOpaqueAttribute(), actualNonSupportedOpaques);
assertArrayEquals(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED, ByteArray.readAllBytes(actualNonSupportedOpaques));
}
use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.
the class BgpIpv6ActivatorTest method testActivator.
@Test
public void testActivator() throws Exception {
final BgpIpv6Activator act = new BgpIpv6Activator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
assertFalse(context.getNlriRegistry().getSerializers().iterator().hasNext());
act.start(context);
assertTrue(context.getNlriRegistry().getSerializers().iterator().next() instanceof VpnIpv6NlriParser);
act.close();
}
use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.
the class PathAttributeParserTest method testSerializingAigpAttribute.
@Test
public void testSerializingAigpAttribute() throws BGPDocumentedException, BGPParsingException {
final byte[] value = new byte[] { 1, 0, 11, 0, 0, 0, 0, 0, 0, 0, 8 };
final ByteBuf inputData = Unpooled.buffer();
final ByteBuf testBuffer = Unpooled.buffer();
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, AigpAttributeParser.TYPE, Unpooled.copiedBuffer(value), inputData);
final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
final Attributes pathAttributes = providerContext.getAttributeRegistry().parseAttributes(inputData, null);
final Aigp aigp = pathAttributes.getAigp();
final AttributesBuilder pathAttributesBuilder = new AttributesBuilder();
pathAttributesBuilder.setAigp(aigp);
final AigpAttributeParser parser = new AigpAttributeParser();
parser.serializeAttribute(pathAttributesBuilder.build(), testBuffer);
final byte[] unparserData = inputData.copy(0, inputData.writerIndex()).array();
final byte[] serializedData = testBuffer.copy(0, inputData.writerIndex()).array();
assertTrue("Buffers should be the same.", Arrays.equals(unparserData, serializedData));
}
use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method setUp.
private void setUp(final byte[] data) throws BGPParsingException {
final LinkstateNlriParser parser = new LinkstateNlriParser();
final MpReachNlriBuilder builder = new MpReachNlriBuilder();
this.registry = SimpleNlriTypeRegistry.getInstance();
final BGPActivator act = new BGPActivator(true, ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
parser.parseNlri(Unpooled.copiedBuffer(data), builder);
final DestinationLinkstate ls = ((DestinationLinkstateCase) builder.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate();
assertEquals(1, ls.getCLinkstateDestination().size());
this.dest = ls.getCLinkstateDestination().get(0);
}
use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.
the class ActivatorTest method testActivator.
@Test
public void testActivator() throws Exception {
final BGPActivator act = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(4));
act.start(context);
assertEquals(LabeledUnicastSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry().classForFamily(4));
act.close();
}
Aggregations