import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class LabeledUnicastIpv6RIBSupportTest extends AbstractRIBSupportTest {
+public class LabeledUnicastIpv6RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastRoute> {
private static final IpPrefix IPv6_PREFIX = new IpPrefix(new Ipv6Prefix("102:304:500::/40"));
- private static final LabeledUnicastIpv6RIBSupport RIB_SUPPORT = LabeledUnicastIpv6RIBSupport.getInstance();
private static final LabeledUnicastRoute ROUTE;
private static final LabeledUnicastIpv6Routes ROUTES;
private static final LabeledUnicastRouteKey ROUTE_KEY;
private static final String LABEL_KEY;
private static final PathId PATH_ID = new PathId(1L);
- private static final List<LabelStack> LABEL_STACK = Lists.newArrayList(new LabelStackBuilder().setLabelValue(new MplsLabel(355L)).build());
- private static final List<CLabeledUnicastDestination> LABELED_DESTINATION_LIST = Collections.singletonList(new CLabeledUnicastDestinationBuilder()
- .setPathId(PATH_ID).setLabelStack(LABEL_STACK).setPrefix(IPv6_PREFIX).build());
- private static final DestinationIpv6LabeledUnicastCase REACH_NLRI = new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(LABELED_DESTINATION_LIST).build()).build();
- private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationIpv6LabeledUnicastCase UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
- .ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.
- DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(LABELED_DESTINATION_LIST).build()).build();
+ private static final List<LabelStack> LABEL_STACK = Lists.newArrayList(new LabelStackBuilder()
+ .setLabelValue(new MplsLabel(355L)).build());
+ private static final List<CLabeledUnicastDestination> LABELED_DESTINATION_LIST
+ = Collections.singletonList(new CLabeledUnicastDestinationBuilder()
+ .setPathId(PATH_ID).setLabelStack(LABEL_STACK).setPrefix(IPv6_PREFIX).build());
+ private static final DestinationIpv6LabeledUnicastCase REACH_NLRI
+ = new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
+ new DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(LABELED_DESTINATION_LIST)
+ .build()).build();
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationIpv6LabeledUnicastCase UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params
+ .xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination
+ .type.DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(new org.opendaylight
+ .yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp
+ .unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled.unicast._case.
+ DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(LABELED_DESTINATION_LIST).build())
+ .build();
+ private LabeledUnicastIpv6RIBSupport ribSupport;
static {
final BGPActivator act = new BGPActivator();
LUNlriParser.serializeNlri(LABELED_DESTINATION_LIST, false, buffer);
LABEL_KEY = ByteArray.encodeBase64(buffer);
ROUTE_KEY = new LabeledUnicastRouteKey(PATH_ID, LABEL_KEY);
- ROUTE = new LabeledUnicastRouteBuilder().setKey(ROUTE_KEY).setPrefix(IPv6_PREFIX).setPathId(PATH_ID).setLabelStack(LABEL_STACK)
+ ROUTE = new LabeledUnicastRouteBuilder().setKey(ROUTE_KEY)
+ .setPrefix(IPv6_PREFIX).setPathId(PATH_ID).setLabelStack(LABEL_STACK)
.setAttributes(new AttributesBuilder().build()).build();
ROUTES = new LabeledUnicastIpv6RoutesBuilder().setLabeledUnicastRoute(Collections.singletonList(ROUTE)).build();
}
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = LabeledUnicastIpv6RIBSupport.getInstance(this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<LabeledUnicastRoute> instanceIdentifier = (InstanceIdentifier<LabeledUnicastRoute>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<LabeledUnicastRoute> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(LabeledUnicastRoute.class));
}
@Test
public void testPutRoutes() {
- RIB_SUPPORT.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
final LabeledUnicastRoute route = (LabeledUnicastRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
public void testEmptyRoute() {
final Routes empty = new LabeledUnicastIpv6RoutesCaseBuilder().setLabeledUnicastIpv6Routes(
new LabeledUnicastIpv6RoutesBuilder().setLabeledUnicastRoute(Collections.emptyList()).build()).build();
- final ChoiceNode emptyRoutes = RIB_SUPPORT.emptyRoutes();
+ final ChoiceNode emptyRoutes = this.ribSupport.emptyRoutes();
assertEquals(createRoutes(empty), emptyRoutes);
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = RIB_SUPPORT.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes1.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = RIB_SUPPORT.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
- assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
+ final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri()
+ .getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes2.class));
}
@Test
public void testCacheableNlriObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, RIB_SUPPORT.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ assertEquals(getRoutePath().node(prefixNii),
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(LabeledUnicastIpv6Routes.QNAME,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes.QNAME.getLocalName().intern())),
- RIB_SUPPORT.routeAttributesIdentifier());
+ assertEquals(new NodeIdentifier(QName.create(LabeledUnicastIpv6Routes.QNAME,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables
+ .Attributes.QNAME.getLocalName().intern())),
+ this.ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(LabeledUnicastIpv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(LabeledUnicastIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(LabeledUnicastIpv6Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(LabeledUnicastIpv6Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(LabeledUnicastRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(LabeledUnicastRoute.class, this.ribSupport.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new LabeledUnicastIpv6RoutesCaseBuilder().build();
- DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
+ createRoutes(emptyCase)).getRootNode();
+ Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
- final Routes emptyRoutes = new LabeledUnicastIpv6RoutesCaseBuilder().setLabeledUnicastIpv6Routes(new LabeledUnicastIpv6RoutesBuilder().build()).build();
+ final Routes emptyRoutes = new LabeledUnicastIpv6RoutesCaseBuilder()
+ .setLabeledUnicastIpv6Routes(new LabeledUnicastIpv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new LabeledUnicastIpv6RoutesCaseBuilder().setLabeledUnicastIpv6Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = RIB_SUPPORT.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
Assert.assertFalse(result.isEmpty());
}
}