use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder in project bgpcep by opendaylight.
the class LUNlriParserTest method testMpReachNlriIpv4Constraint.
@Test
public void testMpReachNlriIpv4Constraint() throws BGPParsingException {
final LUNlriParser parser = new LUNlriParser();
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
final CLabeledUnicastDestination lu = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID).setPrefix(IPV4_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build()).build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
// test parser
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV4_ADD_PATH), testBuilder, this.constraint);
assertEquals(mpReachExpected, testBuilder.build());
// test serializer
final ByteBuf output = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReachExpected).build()).build(), output);
assertArrayEquals(LU_REACH_NLRI_IPV4_ADD_PATH, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder in project bgpcep by opendaylight.
the class VpnIpv6NlriParserTest method testMpReachNlri.
@Test
public void testMpReachNlri() throws BGPParsingException {
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder().setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(Collections.singletonList(new VpnDestinationBuilder(IPV6_VPN).setPathId(null).build())).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReachExpected).build()).build(), output);
assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder in project bgpcep by opendaylight.
the class VpnIpv4NlriParserTest method testMpReachNlri.
@Test
public void testMpReachNlri() throws BGPParsingException {
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(new VpnDestinationBuilder(IPV4_VPN).setPathId(null).build())).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(MplsLabeledVpnSubsequentAddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder, null);
assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReachExpected).build()).build(), output);
assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method testSerializeAttribute.
@Test
public void testSerializeAttribute() throws BGPParsingException {
final LinkstateNlriParser parser = new LinkstateNlriParser();
setUp(this.prefixNlri);
final List<CLinkstateDestination> dests = Lists.newArrayList(this.dest);
final DestinationLinkstateCase dlc = new DestinationLinkstateCaseBuilder().setDestinationLinkstate(new DestinationLinkstateBuilder().setCLinkstateDestination(dests).build()).build();
final AdvertizedRoutes aroutes = new AdvertizedRoutesBuilder().setDestinationType(dlc).build();
Attributes pa = new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(new MpReachNlriBuilder().setAdvertizedRoutes(aroutes).build()).build()).build();
ByteBuf result = Unpooled.buffer();
parser.serializeAttribute(pa, result);
assertArrayEquals(this.prefixNlri, ByteArray.getAllBytes(result));
setUp(this.nodeNlri);
final List<CLinkstateDestination> destsU = Lists.newArrayList(this.dest);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase dlcU = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(destsU).build()).build();
final WithdrawnRoutes wroutes = new WithdrawnRoutesBuilder().setDestinationType(dlcU).build();
pa = new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(new MpUnreachNlriBuilder().setWithdrawnRoutes(wroutes).build()).build()).build();
result = Unpooled.buffer();
parser.serializeAttribute(pa, result);
assertArrayEquals(this.nodeNlri, ByteArray.getAllBytes(result));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder in project bgpcep by opendaylight.
the class AbstractAddPathTest method addAttributeAugmentation.
private static void addAttributeAugmentation(final AttributesBuilder attBuilder, final Ipv4Prefix prefix, final PathId pathId) {
attBuilder.setUnrecognizedAttributes(Collections.emptyMap());
attBuilder.addAugmentation(new AttributesReachBuilder().setMpReachNlri(new MpReachNlriBuilder().setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(NH1).build()).build()).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(Collections.singletonList(new Ipv4PrefixesBuilder().setPathId(pathId).setPrefix(new Ipv4Prefix(prefix)).build())).build()).build()).build()).build()).build());
}
Aggregations