<artifactId>bgp-parser-impl</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
</dependencies>
<scm>
import java.util.Optional;
import java.util.stream.Collectors;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.evpn.impl.nlri.EvpnNlriParser;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EvpnSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.L2vpnAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.bgp.rib.rib.loc.rib.tables.routes.EvpnRoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.EvpnRoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.bgp.rib.rib.loc.rib.tables.routes.EvpnRoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.destination.EvpnDestination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.routes.EvpnRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.routes.EvpnRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class EvpnRibSupport extends AbstractRIBSupport<EvpnRoute, EvpnRouteKey> {
- private static final EvpnRibSupport SINGLETON = new EvpnRibSupport();
+final class EvpnRibSupport extends AbstractRIBSupport<EvpnRoutesCase, EvpnRoutes, EvpnRoute, EvpnRouteKey> {
private static final Logger LOG = LoggerFactory.getLogger(EvpnRibSupport.class);
+
private static final NodeIdentifier NLRI_ROUTES_LIST = NodeIdentifier.create(EvpnDestination.QNAME);
+ private static final EvpnRoutes EMPTY_CONTAINER
+ = new EvpnRoutesBuilder().setEvpnRoute(Collections.emptyList()).build();
+ private static final EvpnRoutesCase EMPTY_CASE =
+ new EvpnRoutesCaseBuilder().setEvpnRoutes(EMPTY_CONTAINER).build();
+ private static EvpnRibSupport SINGLETON;
- private EvpnRibSupport() {
- super(EvpnRoutesCase.class, EvpnRoutes.class, EvpnRoute.class, L2vpnAddressFamily.class,
- EvpnSubsequentAddressFamily.class, DestinationEvpn.QNAME);
+ private EvpnRibSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(mappingService,
+ EvpnRoutesCase.class,
+ EvpnRoutes.class,
+ EvpnRoute.class,
+ L2vpnAddressFamily.class,
+ EvpnSubsequentAddressFamily.class,
+ DestinationEvpn.QNAME);
}
- static EvpnRibSupport getInstance() {
+ static synchronized EvpnRibSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new EvpnRibSupport(mappingService);
+ }
return SINGLETON;
}
} else {
builder = new EvpnRouteBuilder();
}
- return builder.setKey(new EvpnRouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
+ return builder.setKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes).build();
+ }
+
+ @Override
+ public EvpnRoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
}
@Override
- public Routes emptyRoutesContainer() {
- return new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().build()).build();
+ public EvpnRoutes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
@Override
import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EvpnSubsequentAddressFamily;
public final class RIBActivator extends AbstractRIBExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
return Collections.singletonList(context.registerRIBSupport(L2vpnAddressFamily.class,
EvpnSubsequentAddressFamily.class,
- EvpnRibSupport.getInstance()));
+ EvpnRibSupport.getInstance(mappingService)));
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public final class EvpnRibSupportTest extends AbstractRIBSupportTest {
- private static final EvpnRibSupport RIB_SUPPORT = EvpnRibSupport.getInstance();
+public final class EvpnRibSupportTest extends AbstractRIBSupportTest<EvpnRoute> {
+ private EvpnRibSupport ribSupport;
private static final EvpnRoute ROUTE;
private static final EvpnRouteKey ROUTE_KEY;
private static final EvpnDestination EVPN_DESTINATION = new EvpnDestinationBuilder()
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = EvpnRibSupport.getInstance(this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- @SuppressWarnings("unchecked") final InstanceIdentifier<EvpnRoute> instanceIdentifier =
- (InstanceIdentifier<EvpnRoute>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<EvpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(EvpnRoute.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 EvpnRoute route = (EvpnRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
public void testEmptyRoute() {
final Routes empty = new EvpnRoutesCaseBuilder().setEvpnRoutes(
new EvpnRoutesBuilder().setEvpnRoute(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(EVPN_ROUTES), ATTRIBUTES);
+ final Update update = this.ribSupport.buildUpdate(Collections.emptyList(),
+ createRoutes(EVPN_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(EVPN_ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = this.ribSupport.buildUpdate(
+ createRoutes(EVPN_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() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
- assertEquals(ROUTE_KEY, RIB_SUPPORT.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
+ assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
ROUTE_KEY.getRouteKey()));
}
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(EVPN_ROUTES);
assertEquals(getRoutePath().node(prefixNii),
- RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(EvpnRoutes.QNAME,
- Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(EvpnRoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(EvpnRoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(EvpnRoutes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(EvpnRoutes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(EvpnRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(EvpnRoute.class, this.ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new EvpnRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().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 EvpnRoutesCaseBuilder().setEvpnRoutes(EVPN_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());
}
}
\ No newline at end of file
import static org.junit.Assert.assertNull;
import org.junit.Test;
+import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBActivatorTest;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EvpnSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.L2vpnAddressFamily;
-public class RIBActivatorTest {
+public class RIBActivatorTest extends AbstractRIBActivatorTest {
@Test
public void testRIBActivator() {
final RIBActivator ribAct = new RIBActivator();
final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
assertNull(context.getRIBSupport(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class));
- ribAct.startRIBExtensionProvider(context);
+ ribAct.startRIBExtensionProvider(context, this.mappingService);
assertNotNull(context.getRIBSupport(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class));
ribAct.close();
}
<artifactId>mdsal-binding-dom-adapter</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
import java.util.Collection;
import java.util.Optional;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@Beta
-public abstract class AbstractFlowspecRIBSupport<T extends AbstractFlowspecNlriParser,
- R extends Route, S extends Identifier> extends AbstractRIBSupport<R, S> {
+public abstract class AbstractFlowspecRIBSupport<
+ T extends AbstractFlowspecNlriParser,
+ C extends Routes & DataObject,
+ S extends DataObject,
+ R extends Route,
+ I extends Identifier> extends AbstractRIBSupport<C, S, R, I> {
protected final T nlriParser;
protected AbstractFlowspecRIBSupport(
- final Class<? extends Routes> cazeClass,
- final Class<? extends DataObject> containerClass,
- final Class<? extends Route> listClass,
- final Class<? extends AddressFamily> afiClass,
- final Class<? extends SubsequentAddressFamily> safiClass,
- final QName dstContainerClassQName,
- final T nlriParser
+ final BindingNormalizedNodeSerializer mappingService,
+ final Class<C> cazeClass,
+ final Class<S> containerClass,
+ final Class<R> listClass,
+ final Class<? extends AddressFamily> afiClass,
+ final Class<? extends SubsequentAddressFamily> safiClass,
+ final QName dstContainerClassQName,
+ final T nlriParser
) {
- super(cazeClass, containerClass, listClass, afiClass, safiClass, dstContainerClassQName);
+ super(mappingService, cazeClass, containerClass, listClass, afiClass, safiClass, dstContainerClassQName);
this.nlriParser = requireNonNull(nlriParser);
}
*/
package org.opendaylight.protocol.bgp.flowspec;
+import java.util.Collections;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecRoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.FlowspecRoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecRoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv4.DestinationFlowspec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv4.route.FlowspecRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv4.route.FlowspecRouteBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.routes.FlowspecRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
-public final class FlowspecIpv4RIBSupport extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv4NlriParser,
- FlowspecRoute, FlowspecRouteKey> {
+public final class FlowspecIpv4RIBSupport
+ extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv4NlriParser,
+ FlowspecRoutesCase,
+ FlowspecRoutes,
+ FlowspecRoute,
+ FlowspecRouteKey> {
+ private static final FlowspecRoutes EMPTY_CONTAINER
+ = new FlowspecRoutesBuilder().setFlowspecRoute(Collections.emptyList()).build();
+ private static final FlowspecRoutesCase EMPTY_CASE
+ = new FlowspecRoutesCaseBuilder().setFlowspecRoutes(EMPTY_CONTAINER).build();
+ private static FlowspecIpv4RIBSupport SINGLETON;
- public FlowspecIpv4RIBSupport(SimpleFlowspecExtensionProviderContext context) {
+ private FlowspecIpv4RIBSupport(
+ SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
super(
+ mappingService,
FlowspecRoutesCase.class,
FlowspecRoutes.class,
FlowspecRoute.class,
);
}
- static FlowspecIpv4RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
- return new FlowspecIpv4RIBSupport(context);
- }
+ static synchronized FlowspecIpv4RIBSupport getInstance(
+ SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+ if(SINGLETON == null){
+ SINGLETON = new FlowspecIpv4RIBSupport(context, mappingService);
+ }
+ return SINGLETON; }
@Override
public FlowspecRoute createRoute(final FlowspecRoute route, final String routeKey, final long pathId,
}
@Override
- public Routes emptyRoutesContainer() {
- return new FlowspecRoutesCaseBuilder().setFlowspecRoutes(new FlowspecRoutesBuilder().build()).build();
+ public FlowspecRoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public FlowspecRoutes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
@Override
*/
package org.opendaylight.protocol.bgp.flowspec;
+import java.util.Collections;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecIpv6RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.FlowspecIpv6RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecIpv6RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv6.DestinationFlowspec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.route.FlowspecRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.route.FlowspecRouteBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.ipv6.routes.FlowspecIpv6RoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
-public final class FlowspecIpv6RIBSupport extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv6NlriParser,
- FlowspecRoute, FlowspecRouteKey> {
+public final class FlowspecIpv6RIBSupport
+ extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv6NlriParser,
+ FlowspecIpv6RoutesCase,
+ FlowspecIpv6Routes,
+ FlowspecRoute,
+ FlowspecRouteKey> {
+ private static final FlowspecIpv6Routes EMPTY_CONTAINER
+ = new FlowspecIpv6RoutesBuilder().setFlowspecRoute(Collections.emptyList()).build();
+ private static final FlowspecIpv6RoutesCase EMPTY_CASE = new FlowspecIpv6RoutesCaseBuilder()
+ .setFlowspecIpv6Routes(EMPTY_CONTAINER).build();
+ private static FlowspecIpv6RIBSupport SINGLETON;
- public FlowspecIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
+ private FlowspecIpv6RIBSupport(
+ SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
super(
+ mappingService,
FlowspecIpv6RoutesCase.class,
FlowspecIpv6Routes.class,
FlowspecRoute.class,
);
}
- static FlowspecIpv6RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
- return new FlowspecIpv6RIBSupport(context);
+ static synchronized FlowspecIpv6RIBSupport getInstance(
+ SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+ if(SINGLETON == null){
+ SINGLETON = new FlowspecIpv6RIBSupport(context, mappingService);
+ }
+ return SINGLETON;
}
@Override
}
@Override
- public Routes emptyRoutesContainer() {
- return new FlowspecIpv6RoutesCaseBuilder()
- .setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder().build()).build();
+ public FlowspecIpv6RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public FlowspecIpv6Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
@Override
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4.FlowspecL3vpnIpv4RIBSupport;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6.FlowspecL3vpnIpv6RIBSupport;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
}
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
- final List<AutoCloseable> regs = new ArrayList<>();
- regs.add(context.registerRIBSupport(Ipv4AddressFamily.class,
- FlowspecSubsequentAddressFamily.class, FlowspecIpv4RIBSupport.getInstance(this.fsContext)));
- regs.add(context.registerRIBSupport(Ipv6AddressFamily.class,
- FlowspecSubsequentAddressFamily.class, FlowspecIpv6RIBSupport.getInstance(this.fsContext)));
- regs.add(context.registerRIBSupport(Ipv4AddressFamily.class,
- FlowspecL3vpnSubsequentAddressFamily.class, FlowspecL3vpnIpv4RIBSupport.getInstance(this.fsContext)));
- regs.add(context.registerRIBSupport(Ipv6AddressFamily.class,
- FlowspecL3vpnSubsequentAddressFamily.class, FlowspecL3vpnIpv6RIBSupport.getInstance(this.fsContext)));
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+ final List<AutoCloseable> regs = new ArrayList<>(4);
+ regs.add(context.registerRIBSupport(Ipv4AddressFamily.class, FlowspecSubsequentAddressFamily.class,
+ FlowspecIpv4RIBSupport.getInstance(this.fsContext, mappingService)));
+ regs.add(context.registerRIBSupport(Ipv6AddressFamily.class, FlowspecSubsequentAddressFamily.class,
+ FlowspecIpv6RIBSupport.getInstance(this.fsContext, mappingService)));
+ regs.add(context.registerRIBSupport(Ipv4AddressFamily.class, FlowspecL3vpnSubsequentAddressFamily.class,
+ FlowspecL3vpnIpv4RIBSupport.getInstance(this.fsContext, mappingService)));
+ regs.add(context.registerRIBSupport(Ipv6AddressFamily.class, FlowspecL3vpnSubsequentAddressFamily.class,
+ FlowspecL3vpnIpv6RIBSupport.getInstance(this.fsContext, mappingService)));
return regs;
}
}
import com.google.common.collect.Iterables;
import java.util.Collection;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.flowspec.AbstractFlowspecRIBSupport;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecL3vpnSubsequentAddressFamily;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
public abstract class AbstractFlowspecL3vpnRIBSupport
- <T extends AbstractFlowspecL3vpnNlriParser, R extends Route, S extends Identifier>
- extends AbstractFlowspecRIBSupport<T, R, S> {
+ <T extends AbstractFlowspecL3vpnNlriParser,
+ C extends Routes & DataObject,
+ S extends DataObject,
+ R extends Route,
+ I extends Identifier>
+ extends AbstractFlowspecRIBSupport<T, C, S, R, I> {
protected AbstractFlowspecL3vpnRIBSupport(
- final Class<? extends Routes> cazeClass,
- final Class<? extends DataObject> containerClass,
- final Class<? extends Route> listClass,
+ final BindingNormalizedNodeSerializer mappingService,
+ final Class<C> cazeClass,
+ final Class<S> containerClass,
+ final Class<R> listClass,
final QName dstContainerClassQName,
final Class<? extends AddressFamily> afiClass,
final T flowspecNlriParser
) {
- super(cazeClass, containerClass, listClass, afiClass, FlowspecL3vpnSubsequentAddressFamily.class,
+ super(mappingService, cazeClass, containerClass, listClass, afiClass, FlowspecL3vpnSubsequentAddressFamily.class,
dstContainerClassQName, flowspecNlriParser);
}
*/
package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4;
+import java.util.Collections;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.FlowspecL3vpnIpv4RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRouteBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4RoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
-public final class FlowspecL3vpnIpv4RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv4NlriParser,
- FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
+public final class FlowspecL3vpnIpv4RIBSupport
+ extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv4NlriParser,
+ FlowspecL3vpnIpv4RoutesCase,
+ FlowspecL3vpnIpv4Routes,
+ FlowspecL3vpnRoute,
+ FlowspecL3vpnRouteKey> {
+ private static final FlowspecL3vpnIpv4Routes EMPTY_CONTAINER
+ = new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(Collections.emptyList()).build();
+ private static final FlowspecL3vpnIpv4RoutesCase EMPTY_CASE = new FlowspecL3vpnIpv4RoutesCaseBuilder()
+ .setFlowspecL3vpnIpv4Routes(EMPTY_CONTAINER).build();
+ private static FlowspecL3vpnIpv4RIBSupport SINGLETON;
- public FlowspecL3vpnIpv4RIBSupport(final SimpleFlowspecExtensionProviderContext context) {
+ private FlowspecL3vpnIpv4RIBSupport(
+ final SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
super(
+ mappingService,
FlowspecL3vpnIpv4RoutesCase.class,
FlowspecL3vpnIpv4Routes.class,
FlowspecL3vpnRoute.class,
);
}
- public static FlowspecL3vpnIpv4RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
- return new FlowspecL3vpnIpv4RIBSupport(context);
+ public static synchronized FlowspecL3vpnIpv4RIBSupport getInstance(
+ final SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+ if(SINGLETON == null){
+ SINGLETON = new FlowspecL3vpnIpv4RIBSupport(context, mappingService);
+ }
+ return SINGLETON;
}
@Override
}
@Override
- public Routes emptyRoutesContainer() {
- return new FlowspecL3vpnIpv4RoutesCaseBuilder()
- .setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder().build()).build();
+ public FlowspecL3vpnIpv4RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public FlowspecL3vpnIpv4Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
}
*/
package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6;
+import java.util.Collections;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6RoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
-public final class FlowspecL3vpnIpv6RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser,
- FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
- private FlowspecL3vpnIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
+public final class FlowspecL3vpnIpv6RIBSupport
+ extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser,
+ FlowspecL3vpnIpv6RoutesCase,
+ FlowspecL3vpnIpv6Routes,
+ FlowspecL3vpnRoute,
+ FlowspecL3vpnRouteKey> {
+ private static final FlowspecL3vpnIpv6Routes EMPTY_CONTAINER
+ = new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.emptyList()).build();
+ private static final FlowspecL3vpnIpv6RoutesCase EMPTY_CASE = new FlowspecL3vpnIpv6RoutesCaseBuilder()
+ .setFlowspecL3vpnIpv6Routes(EMPTY_CONTAINER).build();
+ private static FlowspecL3vpnIpv6RIBSupport SINGLETON;
+
+ private FlowspecL3vpnIpv6RIBSupport(
+ final SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
super(
+ mappingService,
FlowspecL3vpnIpv6RoutesCase.class,
FlowspecL3vpnIpv6Routes.class,
FlowspecL3vpnRoute.class,
);
}
- public static FlowspecL3vpnIpv6RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
- return new FlowspecL3vpnIpv6RIBSupport(context);
+ public static synchronized FlowspecL3vpnIpv6RIBSupport getInstance(
+ final SimpleFlowspecExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new FlowspecL3vpnIpv6RIBSupport(context, mappingService);
+ }
+ return SINGLETON;
}
@Override
}
@Override
- public Routes emptyRoutesContainer() {
- return new FlowspecL3vpnIpv6RoutesCaseBuilder()
- .setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder().build()).build();
+ public FlowspecL3vpnIpv6RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public FlowspecL3vpnIpv6Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest {
+public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecRoute> {
- private static final FlowspecIpv4RIBSupport RIB_SUPPORT;
- private static final FlowspecRoute ROUTE;
- private static final FlowspecRoutes ROUTES;
- private static final FlowspecRouteKey ROUTE_KEY;
+ private FlowspecIpv4RIBSupport ribSupport;
+ private FlowspecRoute route;
+ private FlowspecRoutes routes;
+ private FlowspecRouteKey routeKey;
private static final PathId PATH_ID = new PathId(1L);
- private static final DestinationPrefixCase DEST_PREFIX = new DestinationPrefixCaseBuilder().setDestinationPrefix(new Ipv4Prefix("10.0.1.0/32")).build();
- private static final List<Flowspec> FLOW_LIST = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
- private static final DestinationFlowspec DEST_FLOW = new DestinationFlowspecBuilder().setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
- private static final DestinationFlowspecCase REACH_NLRI = new DestinationFlowspecCaseBuilder().setDestinationFlowspec(DEST_FLOW).build();
+ private static final DestinationPrefixCase DEST_PREFIX = new DestinationPrefixCaseBuilder()
+ .setDestinationPrefix(new Ipv4Prefix("10.0.1.0/32")).build();
+ private static final List<Flowspec> FLOW_LIST
+ = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
+ private static final DestinationFlowspec DEST_FLOW = new DestinationFlowspecBuilder()
+ .setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
+ private static final DestinationFlowspecCase REACH_NLRI
+ = new DestinationFlowspecCaseBuilder().setDestinationFlowspec(DEST_FLOW).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCase UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder().setDestinationFlowspec(DEST_FLOW).build();
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCase UNREACH_NLRI
+ = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
+ .setDestinationFlowspec(DEST_FLOW).build();
- static {
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
final SimpleFlowspecExtensionProviderContext fsContext = new SimpleFlowspecExtensionProviderContext();
final FlowspecActivator activator = new FlowspecActivator(fsContext);
final BGPActivator act = new BGPActivator(activator);
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
- RIB_SUPPORT = FlowspecIpv4RIBSupport.getInstance(fsContext);
+ this.ribSupport = FlowspecIpv4RIBSupport.getInstance(fsContext, this.mappingService);
final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(
- fsContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
-
- ROUTE_KEY = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
- ROUTE = new FlowspecRouteBuilder().setKey(ROUTE_KEY).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
- .setAttributes(new AttributesBuilder().build()).build();
- ROUTES = new FlowspecRoutesBuilder().setFlowspecRoute(Collections.singletonList(ROUTE)).build();
- }
+ fsContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
+ SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
- @Override
- public void setUp() throws Exception {
- super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
+ this.route = new FlowspecRouteBuilder().setKey(this.routeKey).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
+ .setAttributes(new AttributesBuilder().build()).build();
+ this.routes = new FlowspecRoutesBuilder().setFlowspecRoute(Collections.singletonList(this.route)).build();
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecRoute> instanceIdentifier = (InstanceIdentifier<FlowspecRoute>) this.deletedRoutes.get(0);
- assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(FlowspecRoute.class));
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ assertEquals(this.routeKey, instanceIdentifier.firstKeyOf(FlowspecRoute.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 FlowspecRoute route = (FlowspecRoute) this.insertedRoutes.get(0).getValue();
- assertEquals(ROUTE, route);
+ assertEquals(this.route, route);
}
@Test
- public void testEmptyRoute() throws Exception {
+ public void testEmptyRoute() {
final Routes empty = new FlowspecRoutesCaseBuilder().setFlowspecRoutes(
new FlowspecRoutesBuilder().setFlowspecRoute(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(this.routeKey, this.ribSupport.createRouteListKey(1L, this.routeKey.getRouteKey()));
}
@Test
public void testRoutePath() {
- final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(this.routes);
+ assertEquals(getRoutePath().node(prefixNii),
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(FlowspecRoutes.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(FlowspecRoutes.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(FlowspecRoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(FlowspecRoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(FlowspecRoutes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(FlowspecRoutes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(FlowspecRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(FlowspecRoute.class, this.ribSupport.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new FlowspecRoutesCaseBuilder().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 FlowspecRoutesCaseBuilder().setFlowspecRoutes(new FlowspecRoutesBuilder().build()).build();
+ final Routes emptyRoutes
+ = new FlowspecRoutesCaseBuilder().setFlowspecRoutes(new FlowspecRoutesBuilder().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 FlowspecRoutesCaseBuilder().setFlowspecRoutes(new FlowspecRoutesBuilder()
- .setFlowspecRoute(Collections.singletonList(ROUTE)).build()).build();
+ .setFlowspecRoute(Collections.singletonList(this.route)).build()).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());
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class FlowspecIpv6RIBSupportTest extends AbstractRIBSupportTest {
+public class FlowspecIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecRoute> {
- private static final FlowspecIpv6RIBSupport RIB_SUPPORT;
- private static final FlowspecRoute ROUTE;
- private static final FlowspecRouteKey ROUTE_KEY;
private static final PathId PATH_ID = new PathId(1L);
-
- private static final DestinationIpv6PrefixCase DEST_PREFIX = new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix(new Ipv6Prefix("2001:db8:1:2::/64")).build();
- private static final List<Flowspec> FLOW_LIST = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
- private static final DestinationFlowspec DEST_FLOW = new DestinationFlowspecBuilder().setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
- private static final DestinationFlowspecIpv6Case REACH_NLRI = new DestinationFlowspecIpv6CaseBuilder().setDestinationFlowspec(DEST_FLOW).build();
+ private static final DestinationIpv6PrefixCase DEST_PREFIX = new DestinationIpv6PrefixCaseBuilder()
+ .setDestinationPrefix(new Ipv6Prefix("2001:db8:1:2::/64")).build();
+ private static final List<Flowspec> FLOW_LIST = Collections.singletonList(new FlowspecBuilder()
+ .setFlowspecType(DEST_PREFIX).build());
+ private static final DestinationFlowspec DEST_FLOW = new DestinationFlowspecBuilder()
+ .setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
+ private static final DestinationFlowspecIpv6Case REACH_NLRI = new DestinationFlowspecIpv6CaseBuilder()
+ .setDestinationFlowspec(DEST_FLOW).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6Case UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
- .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder().setDestinationFlowspec(DEST_FLOW).build();
- private static final FlowspecIpv6Routes ROUTES;
- static {
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6Case UNREACH_NLRI
+ = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
+ .setDestinationFlowspec(DEST_FLOW).build();
+ private FlowspecRoute route;
+ private FlowspecRouteKey routeKey;
+ private FlowspecIpv6Routes routes;
+ private FlowspecIpv6RIBSupport ribSupport;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
final SimpleFlowspecExtensionProviderContext fsContext = new SimpleFlowspecExtensionProviderContext();
final FlowspecActivator activator = new FlowspecActivator(fsContext);
final BGPActivator act = new BGPActivator(activator);
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
- RIB_SUPPORT = FlowspecIpv6RIBSupport.getInstance(fsContext);
final SimpleFlowspecIpv6NlriParser parser = new SimpleFlowspecIpv6NlriParser(
- fsContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
-
- ROUTE_KEY = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
- ROUTE = new FlowspecRouteBuilder().setKey(ROUTE_KEY).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
- .setAttributes(new AttributesBuilder().build()).build();
- ROUTES = new FlowspecIpv6RoutesBuilder().setFlowspecRoute(Collections.singletonList(ROUTE)).build();
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ fsContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
+ SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
+ this.routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
+ this.route = new FlowspecRouteBuilder().setKey(this.routeKey).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
+ .setAttributes(new AttributesBuilder().build()).build();
+ this.routes = new FlowspecIpv6RoutesBuilder().setFlowspecRoute(Collections.singletonList(this.route)).build();
+ this.ribSupport = FlowspecIpv6RIBSupport.getInstance(fsContext, this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecRoute> instanceIdentifier = (InstanceIdentifier<FlowspecRoute>) this.deletedRoutes.get(0);
- assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(FlowspecRoute.class));
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ assertEquals(this.routeKey, instanceIdentifier.firstKeyOf(FlowspecRoute.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 FlowspecRoute route = (FlowspecRoute) this.insertedRoutes.get(0).getValue();
- assertEquals(ROUTE, route);
+ assertEquals(this.route, route);
}
@Test
- public void testEmptyRoute() throws Exception {
+ public void testEmptyRoute() {
final Routes empty = new FlowspecIpv6RoutesCaseBuilder().setFlowspecIpv6Routes(
new FlowspecIpv6RoutesBuilder().setFlowspecRoute(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(this.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(this.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(this.routeKey, this.ribSupport.createRouteListKey(1L, this.routeKey.getRouteKey()));
}
@Test
public void testRoutePath() {
- final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(this.routes);
+ assertEquals(getRoutePath().node(prefixNii),
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(FlowspecIpv6Routes.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(FlowspecIpv6Routes.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(FlowspecIpv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(FlowspecIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(FlowspecIpv6Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(FlowspecIpv6Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(FlowspecRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(FlowspecRoute.class, this.ribSupport.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new FlowspecIpv6RoutesCaseBuilder().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 FlowspecIpv6RoutesCaseBuilder().setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder().build()).build();
+ final Routes emptyRoutes = new FlowspecIpv6RoutesCaseBuilder()
+ .setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder().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 FlowspecIpv6RoutesCaseBuilder().setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder()
- .setFlowspecRoute(Collections.singletonList(ROUTE)).build()).build();
+ final Routes routes = new FlowspecIpv6RoutesCaseBuilder()
+ .setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder()
+ .setFlowspecRoute(Collections.singletonList(this.route)).build()).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());
}
}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class FlowspecL3vpnIpv4RIBSupportTest extends AbstractRIBSupportTest {
+public class FlowspecL3vpnIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnRoute> {
- private static final FlowspecL3vpnIpv4RIBSupport RIB_SUPPORT;
private static final FlowspecL3vpnRoute ROUTE;
private static final FlowspecL3vpnRouteKey ROUTE_KEY;
private static final PathId PATH_ID = new PathId(1L);
private static final RouteDistinguisher RD = new RouteDistinguisher(new RdTwoOctetAs("0:5:3"));
-
private static final DestinationPrefixCase DEST_PREFIX = new DestinationPrefixCaseBuilder()
- .setDestinationPrefix(new Ipv4Prefix("172.17.1.0/24")).build();
- private static final List<Flowspec> FLOW_LIST = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
- private static final DestinationFlowspecL3vpnIpv4 DEST_FLOW = new DestinationFlowspecL3vpnIpv4Builder().setRouteDistinguisher(RD)
- .setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
- private static final DestinationFlowspecL3vpnIpv4Case REACH_NLRI = new DestinationFlowspecL3vpnIpv4CaseBuilder().setDestinationFlowspecL3vpnIpv4(DEST_FLOW).build();
- private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationFlowspecL3vpnIpv4Case UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationFlowspecL3vpnIpv4CaseBuilder().setDestinationFlowspecL3vpnIpv4(DEST_FLOW).build();
+ .setDestinationPrefix(new Ipv4Prefix("172.17.1.0/24")).build();
+ private static final List<Flowspec> FLOW_LIST
+ = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
+ private static final DestinationFlowspecL3vpnIpv4 DEST_FLOW
+ = new DestinationFlowspecL3vpnIpv4Builder().setRouteDistinguisher(RD)
+ .setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
+ private static final DestinationFlowspecL3vpnIpv4Case REACH_NLRI
+ = new DestinationFlowspecL3vpnIpv4CaseBuilder().setDestinationFlowspecL3vpnIpv4(DEST_FLOW).build();
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4Case UNREACH_NLRI
+ = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
+ DestinationFlowspecL3vpnIpv4CaseBuilder().setDestinationFlowspecL3vpnIpv4(DEST_FLOW).build();
+ private FlowspecL3vpnIpv4RIBSupport ribSupport;
static {
- final SimpleFlowspecExtensionProviderContext providerContext = new SimpleFlowspecExtensionProviderContext();
- RIB_SUPPORT = FlowspecL3vpnIpv4RIBSupport.getInstance(providerContext);
- ROUTE_KEY = new FlowspecL3vpnRouteKey(PATH_ID, "[l3vpn with route-distinguisher 0:5:3] all packets to 172.17.1.0/24");
+ ROUTE_KEY = new FlowspecL3vpnRouteKey(PATH_ID,
+ "[l3vpn with route-distinguisher 0:5:3] all packets to 172.17.1.0/24");
ROUTE = new FlowspecL3vpnRouteBuilder().setKey(ROUTE_KEY).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
.setAttributes(new AttributesBuilder().build()).setRouteDistinguisher(RD).build();
}
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = FlowspecL3vpnIpv4RIBSupport
+ .getInstance(new SimpleFlowspecExtensionProviderContext(), this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = (InstanceIdentifier<FlowspecL3vpnRoute>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(FlowspecL3vpnRoute.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 FlowspecL3vpnRoute route = (FlowspecL3vpnRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
public void testEmptyRoute() throws Exception {
final Routes empty = new FlowspecL3vpnIpv4RoutesCaseBuilder().setFlowspecL3vpnIpv4Routes(
new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(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(
+ final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(
new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = RIB_SUPPORT.buildUpdate(createRoutes(
+ final Update update = this.ribSupport.buildUpdate(createRoutes(
new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()), Collections.emptyList(), ATTRIBUTES);
final AdvertizedRoutes advertised = update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes();
assertEquals(REACH_NLRI, advertised.getDestinationType());
@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 YangInstanceIdentifier.NodeIdentifierWithPredicates prefixNii = createRouteNIWP(new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build());
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ final NodeIdentifierWithPredicates prefixNii
+ = createRouteNIWP(new FlowspecL3vpnIpv4RoutesBuilder()
+ .setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build());
+ assertEquals(getRoutePath().node(prefixNii),
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new YangInstanceIdentifier.NodeIdentifier(QName.create(FlowspecL3vpnIpv4Routes.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(FlowspecL3vpnIpv4Routes.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(FlowspecL3vpnIpv4RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(FlowspecL3vpnIpv4RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(FlowspecL3vpnIpv4Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(FlowspecL3vpnIpv4Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(FlowspecL3vpnRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(FlowspecL3vpnRoute.class, this.ribSupport.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new FlowspecL3vpnIpv4RoutesCaseBuilder().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 FlowspecL3vpnIpv4RoutesCaseBuilder().setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder().build()).build();
+ final Routes emptyRoutes = new FlowspecL3vpnIpv4RoutesCaseBuilder()
+ .setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder().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 FlowspecL3vpnIpv4RoutesCaseBuilder().setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder()
+ final Routes routes = new FlowspecL3vpnIpv4RoutesCaseBuilder()
+ .setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder()
.setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()).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());
}
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class FlowspecL3vpnIpv6RIBSupportTest extends AbstractRIBSupportTest {
+public class FlowspecL3vpnIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnRoute> {
- private static final FlowspecL3vpnIpv6RIBSupport RIB_SUPPORT;
private static final FlowspecL3vpnRoute ROUTE;
private static final FlowspecL3vpnRouteKey ROUTE_KEY;
private static final PathId PATH_ID = new PathId(1L);
private static final RouteDistinguisher RD = new RouteDistinguisher(new RdTwoOctetAs("0:5:3"));
-
private static final DestinationIpv6PrefixCase DEST_PREFIX = new DestinationIpv6PrefixCaseBuilder()
- .setDestinationPrefix(new Ipv6Prefix("2001:db8:1:2::/64")).build();
- private static final List<Flowspec> FLOW_LIST = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
- private static final DestinationFlowspecL3vpnIpv6 DEST_FLOW = new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(RD)
- .setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
- private static final DestinationFlowspecL3vpnIpv6Case REACH_NLRI = new DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(DEST_FLOW).build();
- private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationFlowspecL3vpnIpv6Case UNREACH_NLRI = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(DEST_FLOW).build();
+ .setDestinationPrefix(new Ipv6Prefix("2001:db8:1:2::/64")).build();
+ private static final List<Flowspec> FLOW_LIST
+ = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
+ private static final DestinationFlowspecL3vpnIpv6 DEST_FLOW
+ = new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(RD)
+ .setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
+ private static final DestinationFlowspecL3vpnIpv6Case REACH_NLRI
+ = new DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(DEST_FLOW).build();
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case UNREACH_NLRI
+ = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
+ .setDestinationFlowspecL3vpnIpv6(DEST_FLOW).build();
static {
- final SimpleFlowspecExtensionProviderContext providerContext = new SimpleFlowspecExtensionProviderContext();
- RIB_SUPPORT = FlowspecL3vpnIpv6RIBSupport.getInstance(providerContext);
- ROUTE_KEY = new FlowspecL3vpnRouteKey(PATH_ID, "[l3vpn with route-distinguisher 0:5:3] all packets to 2001:db8:1:2::/64");
+ ROUTE_KEY = new FlowspecL3vpnRouteKey(PATH_ID,
+ "[l3vpn with route-distinguisher 0:5:3] all packets to 2001:db8:1:2::/64");
ROUTE = new FlowspecL3vpnRouteBuilder().setKey(ROUTE_KEY).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
- .setAttributes(new AttributesBuilder().build()).setRouteDistinguisher(RD).build();
+ .setAttributes(new AttributesBuilder().build()).setRouteDistinguisher(RD).build();
}
+ private FlowspecL3vpnIpv6RIBSupport ribSupport;
+
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = FlowspecL3vpnIpv6RIBSupport
+ .getInstance(new SimpleFlowspecExtensionProviderContext(), this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = (InstanceIdentifier<FlowspecL3vpnRoute>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(FlowspecL3vpnRoute.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 FlowspecL3vpnRoute route = (FlowspecL3vpnRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
public void testEmptyRoute() {
final Routes empty = new FlowspecL3vpnIpv6RoutesCaseBuilder().setFlowspecL3vpnIpv6Routes(
new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(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(
- new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()), ATTRIBUTES);
+ final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(
+ new FlowspecL3vpnIpv6RoutesBuilder()
+ .setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()), 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(
- new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()), Collections.emptyList(), ATTRIBUTES);
- final AdvertizedRoutes advertised = update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes();
+ final Update update = this.ribSupport.buildUpdate(createRoutes(
+ new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()),
+ Collections.emptyList(), ATTRIBUTES);
+ final AdvertizedRoutes advertised
+ = update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes();
assertEquals(REACH_NLRI, advertised.getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes2.class));
}
@Test
public void testCacheableNlriObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ Assert.assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ Assert.assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, RIB_SUPPORT.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(1L, ROUTE_KEY.getRouteKey()));
}
@Test
public void testRoutePath() {
- final YangInstanceIdentifier.NodeIdentifierWithPredicates prefixNii = createRouteNIWP(new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build());
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ final YangInstanceIdentifier.NodeIdentifierWithPredicates prefixNii
+ = createRouteNIWP(new FlowspecL3vpnIpv6RoutesBuilder()
+ .setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build());
+ Assert.assertEquals(getRoutePath().node(prefixNii),
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
Assert.assertEquals(new YangInstanceIdentifier.NodeIdentifier(QName.create(FlowspecL3vpnIpv6Routes.QNAME,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes.QNAME.getLocalName().intern())),
- RIB_SUPPORT.routeAttributesIdentifier());
+ 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(FlowspecL3vpnIpv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ Assert.assertEquals(FlowspecL3vpnIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(FlowspecL3vpnIpv6Routes.class, RIB_SUPPORT.routesContainerClass());
+ Assert.assertEquals(FlowspecL3vpnIpv6Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(FlowspecL3vpnRoute.class, RIB_SUPPORT.routesListClass());
+ Assert.assertEquals(FlowspecL3vpnRoute.class, this.ribSupport.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new FlowspecL3vpnIpv6RoutesCaseBuilder().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 FlowspecL3vpnIpv6RoutesCaseBuilder().setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder().build()).build();
+ final Routes emptyRoutes = new FlowspecL3vpnIpv6RoutesCaseBuilder()
+ .setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder().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 FlowspecL3vpnIpv6RoutesCaseBuilder().setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder()
- .setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()).build();
+ final Routes routes = new FlowspecL3vpnIpv6RoutesCaseBuilder()
+ .setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder()
+ .setFlowspecL3vpnRoute(Collections.singletonList(ROUTE)).build()).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());
}
}
\ No newline at end of file
<artifactId>bgp-parser-impl</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
</dependencies>
<scm>
import com.google.common.collect.ImmutableSet;
import java.util.Optional;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
/**
* Common {@link org.opendaylight.protocol.bgp.rib.spi.RIBSupport} class for IPv4 and IPv6 addresses.
*/
-abstract class AbstractIPRibSupport<R extends Route, N extends Identifier>
- extends AbstractRIBSupport<R,N> {
+abstract class AbstractIPRibSupport<
+ C extends Routes & DataObject,
+ S extends DataObject,
+ R extends Route,
+ N extends Identifier>
+ extends AbstractRIBSupport<C, S, R, N> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractIPRibSupport.class);
private final NodeIdentifier prefixNid;
private final NodeIdentifier nlriRoutesList;
private final ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects;
- AbstractIPRibSupport(final Class<? extends DataObject> prefixClass,
+ AbstractIPRibSupport(
+ final BindingNormalizedNodeSerializer mappingService,
+ final Class<? extends DataObject> prefixClass,
final Class<? extends AddressFamily> addressFamilyClass,
- final Class<? extends Routes> cazeClass,
- final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass,
+ final Class<C> cazeClass,
+ final Class<S> containerClass,
+ final Class<R> listClass,
final QName destinationQname, final QName prefixesQname) {
- super(cazeClass, containerClass, listClass, addressFamilyClass,
+ super(mappingService, cazeClass, containerClass, listClass, addressFamilyClass,
UnicastSubsequentAddressFamily.class, destinationQname);
this.nlriRoutesList = new NodeIdentifier(prefixesQname);
this.cacheableNlriObjects = ImmutableSet.of(prefixClass);
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.Ipv4RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.DestinationIpv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.DestinationIpv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
/**
* Class supporting IPv4 unicast RIBs.
*/
-final class IPv4RIBSupport extends AbstractIPRibSupport<Ipv4Route, Ipv4RouteKey> {
+final class IPv4RIBSupport extends AbstractIPRibSupport<Ipv4RoutesCase, Ipv4Routes, Ipv4Route, Ipv4RouteKey> {
- private static final IPv4RIBSupport SINGLETON = new IPv4RIBSupport();
+ private static final Ipv4Routes EMPTY_CONTAINER
+ = new Ipv4RoutesBuilder().setIpv4Route(Collections.emptyList()).build();
+ private static final Ipv4RoutesCase EMPTY_CASE = new Ipv4RoutesCaseBuilder().setIpv4Routes(EMPTY_CONTAINER).build();
+ private static IPv4RIBSupport SINGLETON = null;
- private IPv4RIBSupport() {
- super(Ipv4PrefixAndPathId.class, Ipv4AddressFamily.class,
- Ipv4RoutesCase.class, Ipv4Routes.class, Ipv4Route.class, DestinationIpv4.QNAME, Ipv4Prefixes.QNAME);
+ private IPv4RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(
+ mappingService,
+ Ipv4PrefixAndPathId.class,
+ Ipv4AddressFamily.class,
+ Ipv4RoutesCase.class,
+ Ipv4Routes.class,
+ Ipv4Route.class,
+ DestinationIpv4.QNAME,
+ Ipv4Prefixes.QNAME);
}
- static IPv4RIBSupport getInstance() {
+ static synchronized IPv4RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new IPv4RIBSupport(mappingService);
+ }
return SINGLETON;
}
} else {
builder = new Ipv4RouteBuilder();
}
- builder.setKey(new Ipv4RouteKey(new PathId(pathId), routeKey)).setAttributes(attributes);
+ builder.setKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes);
return builder.build();
}
@Override
- public Routes emptyRoutesContainer() {
- return new Ipv4RoutesCaseBuilder().setIpv4Routes(new Ipv4RoutesBuilder().build()).build();
+ public Ipv4RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public Ipv4Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
@Override
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv6RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.Ipv6RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv6RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.DestinationIpv6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.DestinationIpv6Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.destination.ipv6.Ipv6Prefixes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
/**
* Class supporting IPv6 unicast RIBs.
*/
-final class IPv6RIBSupport extends AbstractIPRibSupport<Ipv6Route, Ipv6RouteKey> {
+final class IPv6RIBSupport extends AbstractIPRibSupport<Ipv6RoutesCase, Ipv6Routes, Ipv6Route, Ipv6RouteKey> {
- private static final IPv6RIBSupport SINGLETON = new IPv6RIBSupport();
+ private static final Ipv6Routes EMPTY_CONTAINER
+ = new Ipv6RoutesBuilder().setIpv6Route(Collections.emptyList()).build();
+ private static final Ipv6RoutesCase EMPTY_CASE = new Ipv6RoutesCaseBuilder().setIpv6Routes(EMPTY_CONTAINER).build();
+ private static IPv6RIBSupport SINGLETON;
- private IPv6RIBSupport() {
- super(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.Ipv6Prefix.class,
- Ipv6AddressFamily.class, Ipv6RoutesCase.class, Ipv6Routes.class, Ipv6Route.class,
- DestinationIpv6.QNAME, Ipv6Prefixes.QNAME);
+ private IPv6RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(mappingService,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.Ipv6Prefix.class,
+ Ipv6AddressFamily.class,
+ Ipv6RoutesCase.class,
+ Ipv6Routes.class,
+ Ipv6Route.class,
+ DestinationIpv6.QNAME,
+ Ipv6Prefixes.QNAME);
}
- static IPv6RIBSupport getInstance() {
+ static synchronized IPv6RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new IPv6RIBSupport(mappingService);
+ }
return SINGLETON;
}
}
@Override
- public Routes emptyRoutesContainer() {
- return new Ipv6RoutesCaseBuilder().setIpv6Routes(new Ipv6RoutesBuilder().build()).build();
+ public Ipv6RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public Ipv6Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
@Override
import com.google.common.collect.Lists;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
public final class RIBActivator extends AbstractRIBExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
return Lists.newArrayList(
context.registerRIBSupport(Ipv4AddressFamily.class,
- UnicastSubsequentAddressFamily.class, IPv4RIBSupport.getInstance()),
+ UnicastSubsequentAddressFamily.class, IPv4RIBSupport.getInstance(mappingService)),
context.registerRIBSupport(Ipv6AddressFamily.class,
- UnicastSubsequentAddressFamily.class, IPv6RIBSupport.getInstance()));
+ UnicastSubsequentAddressFamily.class, IPv6RIBSupport.getInstance(mappingService)));
}
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public final class IPv4RIBSupportTest extends AbstractRIBSupportTest {
- private static final IPv4RIBSupport RIB_SUPPORT = IPv4RIBSupport.getInstance();
+public final class IPv4RIBSupportTest extends AbstractRIBSupportTest<Ipv4Route> {
+ private IPv4RIBSupport ribSupport;
private static final PathId PATH_ID = new PathId(1L);
private static final Ipv4Prefix PREFIX = new Ipv4Prefix("1.2.3.4/32");
private static final Ipv4RouteKey ROUTE_KEY = new Ipv4RouteKey(PATH_ID, PREFIX.getValue());
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = IPv4RIBSupport.getInstance(this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- @SuppressWarnings("unchecked") final InstanceIdentifier<Ipv4Route> instanceIdentifier =
- (InstanceIdentifier<Ipv4Route>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<Ipv4Route> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(Ipv4Route.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 Ipv4Route route = (Ipv4Route) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
final Routes empty = new Ipv4RoutesCaseBuilder().setIpv4Routes(EMPTY_ROUTES).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);
+ 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() {
assertEquals(ImmutableSet.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
- .message.rev180329.Ipv4PrefixAndPathId.class), RIB_SUPPORT.cacheableNlriObjects());
+ .message.rev180329.Ipv4PrefixAndPathId.class), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
final Ipv4RouteKey expected = new Ipv4RouteKey(new PathId(1L), PREFIX.getValue());
- assertEquals(expected, RIB_SUPPORT.createRouteListKey(expected.getPathId().getValue(), PREFIX.getValue()));
+ assertEquals(expected, this.ribSupport.createRouteListKey(expected.getPathId().getValue(), PREFIX.getValue()));
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath()
+ assertEquals(getRoutePath().node(prefixNii), this.ribSupport.routePath(getTablePath()
.node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME.getLocalName().intern())),
- RIB_SUPPORT.routeAttributesIdentifier());
+ this.ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(Ipv4RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(Ipv4RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(Ipv4Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(Ipv4Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(Ipv4Route.class, RIB_SUPPORT.routesListClass());
+ assertEquals(Ipv4Route.class, this.ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new Ipv4RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new Ipv4RoutesCaseBuilder().setIpv4Routes(new Ipv4RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new Ipv4RoutesCaseBuilder().setIpv4Routes(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());
}
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public final class IPv6RIBSupportTest extends AbstractRIBSupportTest {
- private static final IPv6RIBSupport RIB_SUPPORT = IPv6RIBSupport.getInstance();
+public final class IPv6RIBSupportTest extends AbstractRIBSupportTest<Ipv6Route> {
+ private IPv6RIBSupport ribSupport;
private static final PathId PATH_ID = new PathId(1L);
private static final Ipv6Prefix PREFIX = new Ipv6Prefix("2001:db8:1:2::/64");
private static final Ipv6RouteKey ROUTE_KEY = new Ipv6RouteKey(PATH_ID, PREFIX.getValue());
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = IPv6RIBSupport.getInstance(this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- @SuppressWarnings("unchecked") final InstanceIdentifier<Ipv6Route> instanceIdentifier =
- (InstanceIdentifier<Ipv6Route>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<Ipv6Route> instanceIdentifier =
+ this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(Ipv6Route.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 Ipv6Route route = (Ipv6Route) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
final Routes empty = new Ipv6RoutesCaseBuilder().setIpv6Routes(EMPTY_ROUTES).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);
+ 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() {
assertEquals(ImmutableSet.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
- .rev180329.Ipv6Prefix.class), RIB_SUPPORT.cacheableNlriObjects());
+ .rev180329.Ipv6Prefix.class), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
final Ipv6RouteKey expected = new Ipv6RouteKey(new PathId(1L), PREFIX.getValue());
- assertEquals(expected, RIB_SUPPORT.createRouteListKey(expected.getPathId().getValue(), PREFIX.getValue()));
+ assertEquals(expected, this.ribSupport.createRouteListKey(expected.getPathId().getValue(), PREFIX.getValue()));
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
assertEquals(getRoutePath().node(prefixNii),
- RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(Ipv6Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(Ipv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(Ipv6RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(Ipv6Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(Ipv6Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(Ipv6Route.class, RIB_SUPPORT.routesListClass());
+ assertEquals(Ipv6Route.class, this.ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new Ipv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new Ipv6RoutesCaseBuilder().setIpv6Routes(new Ipv6RoutesBuilder().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 Ipv6RoutesCaseBuilder().setIpv6Routes(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());
}
}
<artifactId>mdsal-binding-dom-adapter</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
</dependencies>
<scm>
import java.util.stream.Collectors;
import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.labeled.unicast.LUNlriParser;
import org.opendaylight.protocol.bgp.labeled.unicast.LabeledUnicastIpv4RIBSupport;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.MplsLabeledVpnSubsequentAddressFamily;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractVpnRIBSupport extends AbstractRIBSupport<VpnRoute, VpnRouteKey> {
+public abstract class AbstractVpnRIBSupport<C extends Routes & DataObject, S extends DataObject>
+ extends AbstractRIBSupport<C, S, VpnRoute, VpnRouteKey> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractVpnRIBSupport.class);
private final NodeIdentifier nlriRoutesListNid;
private final NodeIdentifier labelStackNid;
*
* @param cazeClass Binding class of the AFI/SAFI-specific case statement, must not be null
* @param containerClass Binding class of the container in routes choice, must not be null.
- * @param listClass Binding class of the route list, nust not be null;
*/
- protected AbstractVpnRIBSupport(final Class<? extends Routes> cazeClass,
- final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass,
- final Class<? extends AddressFamily> afiClass, final QName vpnDstContainerClassQname) {
- super(cazeClass, containerClass, listClass, afiClass,
+ protected AbstractVpnRIBSupport(
+ final BindingNormalizedNodeSerializer mappingService,
+ final Class<C> cazeClass,
+ final Class<S> containerClass,
+ final Class<? extends AddressFamily> afiClass,
+ final QName vpnDstContainerClassQname) {
+ super(mappingService, cazeClass, containerClass, VpnRoute.class, afiClass,
MplsLabeledVpnSubsequentAddressFamily.class, vpnDstContainerClassQname);
final QName classQname = BindingReflections.findQName(containerClass).intern();
final QName vpnDstClassQname = QName.create(classQname, VpnDestination.QNAME.getLocalName());
*/
package org.opendaylight.protocol.bgp.l3vpn.ipv4;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
public class RibIpv4Activator extends AbstractRIBExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
- final List<AutoCloseable> regs = new ArrayList<>();
- regs.add(context.registerRIBSupport(Ipv4AddressFamily.class,
- MplsLabeledVpnSubsequentAddressFamily.class, new VpnIpv4RIBSupport()));
- return regs;
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+
+ return Collections.singletonList(context.registerRIBSupport(Ipv4AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class, VpnIpv4RIBSupport.getInstance(mappingService)));
}
}
*/
package org.opendaylight.protocol.bgp.l3vpn.ipv4;
+import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.l3vpn.AbstractVpnRIBSupport;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv4RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.VpnIpv4RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv4RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.destination.VpnIpv4Destination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.destination.VpnIpv4DestinationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.routes.VpnIpv4Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.l3vpn.ipv4.routes.VpnIpv4RoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestination;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.route.VpnRoute;
-final class VpnIpv4RIBSupport extends AbstractVpnRIBSupport {
+final class VpnIpv4RIBSupport extends AbstractVpnRIBSupport<VpnIpv4RoutesCase, VpnIpv4Routes> {
+ private static final VpnIpv4Routes EMPTY_CONTAINER
+ = new VpnIpv4RoutesBuilder().setVpnRoute(Collections.emptyList()).build();
+ private static final VpnIpv4RoutesCase EMPTY_CASE
+ = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(EMPTY_CONTAINER).build();
+ private static VpnIpv4RIBSupport SINGLETON;
+
/**
* Default constructor. Requires the QName of the container augmented under the routes choice
* node in instantiations of the rib grouping. It is assumed that this container is defined by
* the same model which populates it with route grouping instantiation, and by extension with
* the route attributes container.
*/
- VpnIpv4RIBSupport() {
- super(VpnIpv4RoutesCase.class, VpnIpv4Routes.class, VpnRoute.class,
- Ipv4AddressFamily.class, VpnIpv4Destination.QNAME);
+ private VpnIpv4RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(mappingService,
+ VpnIpv4RoutesCase.class,
+ VpnIpv4Routes.class,
+ Ipv4AddressFamily.class,
+ VpnIpv4Destination.QNAME);
+ }
+
+ public static synchronized VpnIpv4RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new VpnIpv4RIBSupport(mappingService);
+ }
+ return SINGLETON;
}
@Override
}
@Override
- public Routes emptyRoutesContainer() {
- return new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(new VpnIpv4RoutesBuilder().build()).build();
+ public VpnIpv4RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public VpnIpv4Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
}
*/
package org.opendaylight.protocol.bgp.l3vpn.ipv6;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
public class RibIpv6Activator extends AbstractRIBExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
- final List<AutoCloseable> regs = new ArrayList<>();
- regs.add(context.registerRIBSupport(Ipv6AddressFamily.class,
- MplsLabeledVpnSubsequentAddressFamily.class, new VpnIpv6RIBSupport()));
- return regs;
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+ return Collections.singletonList((context.registerRIBSupport(Ipv6AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class, VpnIpv6RIBSupport.getInstance(mappingService))));
}
-
}
*/
package org.opendaylight.protocol.bgp.l3vpn.ipv6;
+import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.l3vpn.AbstractVpnRIBSupport;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv6RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.VpnIpv6RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv6RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.destination.VpnIpv6Destination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.destination.VpnIpv6DestinationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.routes.VpnIpv6Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.routes.VpnIpv6RoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestination;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.route.VpnRoute;
-final class VpnIpv6RIBSupport extends AbstractVpnRIBSupport {
+final class VpnIpv6RIBSupport extends AbstractVpnRIBSupport<VpnIpv6RoutesCase, VpnIpv6Routes> {
+ private static final VpnIpv6Routes EMPTY_CONTAINER
+ = new VpnIpv6RoutesBuilder().setVpnRoute(Collections.emptyList()).build();
+ private static final VpnIpv6RoutesCase EMPTY_CASE
+ = new VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(EMPTY_CONTAINER).build();
+ private static VpnIpv6RIBSupport SINGLETON;
/**
* Default constructor. Requires the QName of the container augmented under the routes choice
* the same model which populates it with route grouping instantiation, and by extension with
* the route attributes container.
*/
- VpnIpv6RIBSupport() {
- super(VpnIpv6RoutesCase.class, VpnIpv6Routes.class, VpnRoute.class,
- Ipv6AddressFamily.class, VpnIpv6Destination.QNAME);
+ private VpnIpv6RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(mappingService,
+ VpnIpv6RoutesCase.class,
+ VpnIpv6Routes.class,
+ Ipv6AddressFamily.class,
+ VpnIpv6Destination.QNAME);
+ }
+
+ public static synchronized VpnIpv6RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new VpnIpv6RIBSupport(mappingService);
+ }
+ return SINGLETON;
}
@Override
}
@Override
- public Routes emptyRoutesContainer() {
- return new VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(new VpnIpv6RoutesBuilder().build()).build();
+ public VpnIpv6RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public VpnIpv6Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class VpnIpv4RIBSupportTest extends AbstractRIBSupportTest {
- private static final VpnIpv4RIBSupport RIB_SUPPORT = new VpnIpv4RIBSupport();
+public class VpnIpv4RIBSupportTest extends AbstractRIBSupportTest<VpnRoute> {
+ private VpnIpv4RIBSupport ribSupport;
private static final DestinationVpnIpv4Case REACH_NLRI = new DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build();
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = VpnIpv4RIBSupport.getInstance(this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- @SuppressWarnings("unchecked")
- final InstanceIdentifier<VpnRoute> instanceIdentifier =
- (InstanceIdentifier<VpnRoute>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<VpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(VpnRoute.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 VpnRoute route = (VpnRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
public void testEmptyRoute() {
final Routes empty = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(new VpnIpv4RoutesBuilder()
.setVpnRoute(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);
+ 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() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, RIB_SUPPORT.createRouteListKey(0L, ROUTE_KEY.getRouteKey()));
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(0L, ROUTE_KEY.getRouteKey()));
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT
+ assertEquals(getRoutePath().node(prefixNii), ribSupport
.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(VpnIpv4Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(VpnIpv4RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(VpnIpv4RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(VpnIpv4Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(VpnIpv4Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(VpnRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(VpnRoute.class, this.ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new VpnIpv4RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(
new VpnIpv4RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(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());
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class VpnIpv6RIBSupportTest extends AbstractRIBSupportTest {
- private static final VpnIpv6RIBSupport RIB_SUPPORT = new VpnIpv6RIBSupport();
+public class VpnIpv6RIBSupportTest extends AbstractRIBSupportTest<VpnRoute> {
+ private VpnIpv6RIBSupport ribSupport;
private static final DestinationVpnIpv6Case REACH_NLRI = new DestinationVpnIpv6CaseBuilder()
.setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = VpnIpv6RIBSupport.getInstance(this.mappingService);
+ setUpTestCustomizer(this.ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- @SuppressWarnings("unchecked") final InstanceIdentifier<VpnRoute> instanceIdentifier =
- (InstanceIdentifier<VpnRoute>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<VpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(VpnRoute.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 VpnRoute route = (VpnRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
public void testEmptyRoute() {
final Routes empty = new VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(new VpnIpv6RoutesBuilder()
.setVpnRoute(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);
+ 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() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, RIB_SUPPORT.createRouteListKey(0L, ROUTE_KEY.getRouteKey()));
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(0L, ROUTE_KEY.getRouteKey()));
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
assertEquals(getRoutePath().node(prefixNii),
- RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(VpnIpv6Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(VpnIpv6RoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(VpnIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(VpnIpv6Routes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(VpnIpv6Routes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(VpnRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(VpnRoute.class, this.ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new VpnIpv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new VpnIpv6RoutesCaseBuilder()
.setVpnIpv6Routes(new VpnIpv6RoutesBuilder().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 VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(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());
}
}
\ No newline at end of file
<artifactId>sal-binding-api</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-broker-impl</artifactId>
import java.util.Optional;
import java.util.stream.Collectors;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupport;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.LabeledUnicastSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStack;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStackBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.destination.CLabeledUnicastDestination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.routes.list.LabeledUnicastRouteKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.common.QName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-abstract class AbstractLabeledUnicastRIBSupport
- extends AbstractRIBSupport<LabeledUnicastRoute, LabeledUnicastRouteKey> {
+abstract class AbstractLabeledUnicastRIBSupport<
+ C extends Routes & DataObject,
+ S extends DataObject>
+ extends AbstractRIBSupport<C, S, LabeledUnicastRoute, LabeledUnicastRouteKey> {
private static final NodeIdentifier LABEL_STACK_NID
= NodeIdentifier.create(QName.create(CLabeledUnicastDestination.QNAME, "label-stack").intern());
private static final NodeIdentifier LV_NID
* node in instantiations of the rib grouping. It is assumed that this container is defined by
* the same model which populates it with route grouping instantiation, and by extension with
* the route attributes container.
- * @param cazeClass Binding class of the AFI/SAFI-specific case statement, must not be null
+ * @param mappingService Binding Normalized Node Serializer
+ * @param cazeClass Binding class of the AFI/SAFI-specific case statement, must not be null
* @param containerClass Binding class of the container in routes choice, must not be null.
- * @param listClass Binding class of the route list, nust not be null;
* @param addressFamilyClass address Family Class
- * @param safiClass SubsequentAddressFamily
* @param destinationQname destination Qname
*/
- AbstractLabeledUnicastRIBSupport(final Class<? extends Routes> cazeClass,
- final Class<? extends DataObject> containerClass,
- final Class<? extends Route> listClass,
+ AbstractLabeledUnicastRIBSupport(
+ final BindingNormalizedNodeSerializer mappingService,
+ final Class<C> cazeClass,
+ final Class<S> containerClass,
final Class<? extends AddressFamily> addressFamilyClass,
- final Class<? extends SubsequentAddressFamily> safiClass,
final QName destinationQname) {
- super(cazeClass, containerClass, listClass, addressFamilyClass, safiClass, destinationQname);
+ super(mappingService,
+ cazeClass,
+ containerClass,
+ LabeledUnicastRoute.class,
+ addressFamilyClass,
+ LabeledUnicastSubsequentAddressFamily.class,
+ destinationQname);
}
@Override
package org.opendaylight.protocol.bgp.labeled.unicast;
import java.util.Collection;
+import java.util.Collections;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.LabeledUnicastSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.bgp.rib.rib.loc.rib.tables.routes.LabeledUnicastRoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.LabeledUnicastRoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.bgp.rib.rib.loc.rib.tables.routes.LabeledUnicastRoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.routes.LabeledUnicastRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.routes.LabeledUnicastRoutesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.routes.list.LabeledUnicastRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLabeledUnicastCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicast;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-public final class LabeledUnicastIpv4RIBSupport extends AbstractLabeledUnicastRIBSupport {
- private static final LabeledUnicastIpv4RIBSupport SINGLETON = new LabeledUnicastIpv4RIBSupport();
+public final class LabeledUnicastIpv4RIBSupport
+ extends AbstractLabeledUnicastRIBSupport<LabeledUnicastRoutesCase, LabeledUnicastRoutes> {
+ private static final LabeledUnicastRoutes EMPTY_CONTAINER
+ = new LabeledUnicastRoutesBuilder().setLabeledUnicastRoute(Collections.emptyList()).build();
+ private static final LabeledUnicastRoutesCase EMPTY_CASE
+ = new LabeledUnicastRoutesCaseBuilder().setLabeledUnicastRoutes(EMPTY_CONTAINER).build();
+ private static LabeledUnicastIpv4RIBSupport SINGLETON;
- private LabeledUnicastIpv4RIBSupport() {
- super(LabeledUnicastRoutesCase.class, LabeledUnicastRoutes.class, LabeledUnicastRoute.class,
- Ipv4AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class, DestinationLabeledUnicast.QNAME);
+ private LabeledUnicastIpv4RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(mappingService,
+ LabeledUnicastRoutesCase.class,
+ LabeledUnicastRoutes.class,
+ Ipv4AddressFamily.class,
+ DestinationLabeledUnicast.QNAME);
}
- static LabeledUnicastIpv4RIBSupport getInstance() {
+ static synchronized LabeledUnicastIpv4RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new LabeledUnicastIpv4RIBSupport(mappingService);
+ }
return SINGLETON;
}
@Override
protected DestinationType buildDestination(final Collection<MapEntryNode> routes) {
return new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(extractRoutes(routes)).build()).build();
+ new DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(extractRoutes(routes)).build()).build();
}
@Override
protected DestinationType buildWithdrawnDestination(final Collection<MapEntryNode> routes) {
- return 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.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- 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.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(
- extractRoutes(routes)).build()).build();
+ return 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
+ .DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(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.labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(extractRoutes(routes)).build()).build();
}
@Override
- public IpPrefix extractPrefix(final DataContainerNode<? extends PathArgument> route, final NodeIdentifier prefixTypeNid) {
+ public IpPrefix extractPrefix(
+ final DataContainerNode<? extends PathArgument> route,
+ final NodeIdentifier prefixTypeNid) {
if (route.getChild(prefixTypeNid).isPresent()) {
final String prefixType = (String) route.getChild(prefixTypeNid).get().getValue();
return new IpPrefix(new Ipv4Prefix(prefixType));
}
@Override
- public Routes emptyRoutesContainer() {
- return new LabeledUnicastRoutesCaseBuilder()
- .setLabeledUnicastRoutes(new LabeledUnicastRoutesBuilder().build()).build();
+ public LabeledUnicastRoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public LabeledUnicastRoutes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
}
package org.opendaylight.protocol.bgp.labeled.unicast;
import java.util.Collection;
+import java.util.Collections;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.LabeledUnicastSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.bgp.rib.rib.loc.rib.tables.routes.LabeledUnicastIpv6RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.LabeledUnicastIpv6RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.bgp.rib.rib.loc.rib.tables.routes.LabeledUnicastIpv6RoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.ipv6.routes.LabeledUnicastIpv6Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.ipv6.routes.LabeledUnicastIpv6RoutesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.routes.list.LabeledUnicastRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6LabeledUnicastCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicast;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-final class LabeledUnicastIpv6RIBSupport extends AbstractLabeledUnicastRIBSupport {
- private static final LabeledUnicastIpv6RIBSupport SINGLETON = new LabeledUnicastIpv6RIBSupport();
+final class LabeledUnicastIpv6RIBSupport
+ extends AbstractLabeledUnicastRIBSupport<LabeledUnicastIpv6RoutesCase, LabeledUnicastIpv6Routes> {
- private LabeledUnicastIpv6RIBSupport() {
- super(LabeledUnicastIpv6RoutesCase.class, LabeledUnicastIpv6Routes.class, LabeledUnicastRoute.class,
- Ipv4AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class, DestinationIpv6LabeledUnicast.QNAME);
+ private static final LabeledUnicastIpv6Routes EMPTY_CONTAINER
+ = new LabeledUnicastIpv6RoutesBuilder().setLabeledUnicastRoute(Collections.emptyList()).build();
+ private static final LabeledUnicastIpv6RoutesCase EMPTY_CASE
+ = new LabeledUnicastIpv6RoutesCaseBuilder().setLabeledUnicastIpv6Routes(EMPTY_CONTAINER).build();
+ private static LabeledUnicastIpv6RIBSupport SINGLETON;
+
+ private LabeledUnicastIpv6RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(mappingService,
+ LabeledUnicastIpv6RoutesCase.class,
+ LabeledUnicastIpv6Routes.class,
+ Ipv6AddressFamily.class,
+ DestinationIpv6LabeledUnicast.QNAME);
}
- static LabeledUnicastIpv6RIBSupport getInstance() {
+ static synchronized LabeledUnicastIpv6RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
+ SINGLETON = new LabeledUnicastIpv6RIBSupport(mappingService);
+ }
return SINGLETON;
}
@Override
protected DestinationType buildDestination(final Collection<MapEntryNode> routes) {
return new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
- new DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(extractRoutes(routes)).build()).build();
+ new DestinationIpv6LabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(extractRoutes(routes)).build()).build();
}
@Override
protected DestinationType buildWithdrawnDestination(final Collection<MapEntryNode> routes) {
- return 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()
+ return 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(extractRoutes(routes)).build()).build();
}
}
@Override
- public Routes emptyRoutesContainer() {
- return new LabeledUnicastIpv6RoutesCaseBuilder()
- .setLabeledUnicastIpv6Routes(new LabeledUnicastIpv6RoutesBuilder().build()).build();
+ public LabeledUnicastIpv6RoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
+ }
+
+ @Override
+ public LabeledUnicastIpv6Routes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
}
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.LabeledUnicastSubsequentAddressFamily;
@Override
protected List<AutoCloseable> startRIBExtensionProviderImpl(
- final RIBExtensionProviderContext context) {
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService
+ ) {
final List<AutoCloseable> regs = new ArrayList<>(2);
- regs.add(context.registerRIBSupport(Ipv4AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class, LabeledUnicastIpv4RIBSupport.getInstance()));
- regs.add(context.registerRIBSupport(Ipv6AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class, LabeledUnicastIpv6RIBSupport.getInstance()));
+ regs.add(context.registerRIBSupport(Ipv4AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class,
+ LabeledUnicastIpv4RIBSupport.getInstance(mappingService)));
+ regs.add(context.registerRIBSupport(Ipv6AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class,
+ LabeledUnicastIpv6RIBSupport.getInstance(mappingService)));
return regs;
}
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public class LabeledUnicastIpv4RIBSupportTest extends AbstractRIBSupportTest {
+public class LabeledUnicastIpv4RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastRoute> {
private static final IpPrefix IPv4_PREFIX = new IpPrefix(new Ipv4Prefix("34.1.22.0/24"));
- private static final LabeledUnicastIpv4RIBSupport RIB_SUPPORT = LabeledUnicastIpv4RIBSupport.getInstance();
private static final LabeledUnicastRoute ROUTE;
private static final LabeledUnicastRoutes 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(IPv4_PREFIX).build());
- private static final DestinationLabeledUnicastCase REACH_NLRI = new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new DestinationLabeledUnicastBuilder().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.
- DestinationLabeledUnicastCase 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.
- DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(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.labeled.unicast._case.DestinationLabeledUnicastBuilder().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(IPv4_PREFIX).build());
+ private static final DestinationLabeledUnicastCase REACH_NLRI = new DestinationLabeledUnicastCaseBuilder()
+ .setDestinationLabeledUnicast(new DestinationLabeledUnicastBuilder()
+ .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
+ .DestinationLabeledUnicastCase 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
+ .DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(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.labeled.unicast._case.DestinationLabeledUnicastBuilder()
+ .setCLabeledUnicastDestination(LABELED_DESTINATION_LIST).build()).build();
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(IPv4_PREFIX).setPathId(PATH_ID).setLabelStack(LABEL_STACK)
- .setAttributes(new AttributesBuilder().build()).build();
+ ROUTE = new LabeledUnicastRouteBuilder()
+ .setKey(ROUTE_KEY)
+ .setPrefix(IPv4_PREFIX)
+ .setPathId(PATH_ID)
+ .setLabelStack(LABEL_STACK)
+ .setAttributes(new AttributesBuilder().build()).build();
ROUTES = new LabeledUnicastRoutesBuilder().setLabeledUnicastRoute(Collections.singletonList(ROUTE)).build();
}
+ private LabeledUnicastIpv4RIBSupport ribSupport;
+
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = LabeledUnicastIpv4RIBSupport.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);
}
@Test
- public void testEmptyRoute() throws Exception {
+ public void testEmptyRoute() {
final Routes empty = new LabeledUnicastRoutesCaseBuilder().setLabeledUnicastRoutes(
new LabeledUnicastRoutesBuilder().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(LabeledUnicastRoutes.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(LabeledUnicastRoutes.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(LabeledUnicastRoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(LabeledUnicastRoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(LabeledUnicastRoutes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(LabeledUnicastRoutes.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 LabeledUnicastRoutesCaseBuilder().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 LabeledUnicastRoutesCaseBuilder().setLabeledUnicastRoutes(new LabeledUnicastRoutesBuilder().build()).build();
+ final Routes emptyRoutes = new LabeledUnicastRoutesCaseBuilder()
+ .setLabeledUnicastRoutes(new LabeledUnicastRoutesBuilder().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 LabeledUnicastRoutesCaseBuilder().setLabeledUnicastRoutes(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());
}
}
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());
}
}
<artifactId>mdsal-binding-dom-adapter</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
import io.netty.buffer.Unpooled;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser;
import org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkstateSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.bgp.rib.rib.loc.rib.tables.routes.LinkstateRoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.bgp.rib.rib.peer.effective.rib.in.tables.routes.LinkstateRoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.bgp.rib.rib.loc.rib.tables.routes.LinkstateRoutesCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.destination.CLinkstateDestination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.routes.LinkstateRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.routes.LinkstateRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class LinkstateRIBSupport extends AbstractRIBSupport<LinkstateRoute, LinkstateRouteKey> {
+public final class LinkstateRIBSupport
+ extends AbstractRIBSupport<LinkstateRoutesCase, LinkstateRoutes, LinkstateRoute, LinkstateRouteKey> {
private static final Logger LOG = LoggerFactory.getLogger(LinkstateRIBSupport.class);
- private static final LinkstateRIBSupport SINGLETON = new LinkstateRIBSupport();
+
+ private static final LinkstateRoutes EMPTY_CONTAINER
+ = new LinkstateRoutesBuilder().setLinkstateRoute(Collections.emptyList()).build();
+ private static final LinkstateRoutesCase EMPTY_CASE
+ = new LinkstateRoutesCaseBuilder().setLinkstateRoutes(EMPTY_CONTAINER).build();
+ private static LinkstateRIBSupport SINGLETON;
private final YangInstanceIdentifier.NodeIdentifier nlriRoutesList
= new YangInstanceIdentifier.NodeIdentifier(CLinkstateDestination.QNAME);
- private LinkstateRIBSupport() {
- super(LinkstateRoutesCase.class, LinkstateRoutes.class, LinkstateRoute.class, LinkstateAddressFamily.class,
- LinkstateSubsequentAddressFamily.class, DestinationLinkstate.QNAME);
+ private LinkstateRIBSupport(final BindingNormalizedNodeSerializer mappingService) {
+ super(
+ mappingService,
+ LinkstateRoutesCase.class,
+ LinkstateRoutes.class,
+ LinkstateRoute.class,
+ LinkstateAddressFamily.class,
+ LinkstateSubsequentAddressFamily.class,
+ DestinationLinkstate.QNAME);
}
- public static LinkstateRIBSupport getInstance() {
+ public synchronized static LinkstateRIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if(SINGLETON == null){
+ SINGLETON = new LinkstateRIBSupport(mappingService);
+ }
return SINGLETON;
}
} else {
builder = new LinkstateRouteBuilder();
}
- return builder.setKey(new LinkstateRouteKey(new PathId(pathId), routeKey)).setAttributes(attributes).build();
+ return builder.setKey(createRouteListKey(pathId, routeKey)).setAttributes(attributes).build();
+ }
+
+ @Override
+ public LinkstateRoutesCase emptyRoutesCase() {
+ return EMPTY_CASE;
}
@Override
- public Routes emptyRoutesContainer() {
- return new LinkstateRoutesCaseBuilder().setLinkstateRoutes(new LinkstateRoutesBuilder().build()).build();
+ public LinkstateRoutes emptyRoutesContainer() {
+ return EMPTY_CONTAINER;
}
@Override
*/
package org.opendaylight.protocol.bgp.linkstate.impl;
-import com.google.common.collect.Lists;
+import java.util.Collections;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkstateAddressFamily;
*/
public final class RIBActivator extends AbstractRIBExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
- return Lists.newArrayList((AutoCloseable) context.registerRIBSupport(LinkstateAddressFamily.class,
- LinkstateSubsequentAddressFamily.class, LinkstateRIBSupport.getInstance()));
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
+ return Collections.singletonList(context.registerRIBSupport(LinkstateAddressFamily.class,
+ LinkstateSubsequentAddressFamily.class, LinkstateRIBSupport.getInstance(mappingService)));
}
}
import org.opendaylight.protocol.bgp.linkstate.impl.RIBActivator;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
+import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBActivatorTest;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
import org.opendaylight.protocol.rsvp.parser.spi.pojo.ServiceLoaderRSVPExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkstateSubsequentAddressFamily;
-public class ActivatorTest {
-
+public class ActivatorTest extends AbstractRIBActivatorTest {
@Test
- public void testActivator() throws Exception {
- final BGPActivator act = new BGPActivator(true, ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
+ public void testActivator() {
+ final BGPActivator act = new BGPActivator(true,
+ ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
assertNull(context.getAddressFamilyRegistry().classForFamily(16388));
assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(71));
act.start(context);
assertEquals(LinkstateAddressFamily.class, context.getAddressFamilyRegistry().classForFamily(16388));
- assertEquals(LinkstateSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry().classForFamily(71));
+ assertEquals(LinkstateSubsequentAddressFamily.class,
+ context.getSubsequentAddressFamilyRegistry().classForFamily(71));
act.close();
}
assertNull(context.getRIBSupport(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
- ribAct.startRIBExtensionProvider(context);
+ ribAct.startRIBExtensionProvider(context, this.mappingService);
assertNotNull(context.getRIBSupport(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-public final class LinkstateRIBSupportTest extends AbstractRIBSupportTest {
+public final class LinkstateRIBSupportTest extends AbstractRIBSupportTest<LinkstateRoute> {
- private static final LinkstateRIBSupport RIB_SUPPORT = LinkstateRIBSupport.getInstance();
+ private LinkstateRIBSupport ribSupport;
private static final LinkstateRoute ROUTE;
private static final LinkstateRoutes ROUTES;
private static final LinkstateRouteKey ROUTE_KEY;
@Override
public void setUp() throws Exception {
super.setUp();
- setUpTestCustomizer(RIB_SUPPORT);
+ this.ribSupport = LinkstateRIBSupport.getInstance(this.mappingService);
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<LinkstateRoute> instanceIdentifier
- = (InstanceIdentifier<LinkstateRoute>) this.deletedRoutes.get(0);
+ this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<LinkstateRoute> instanceIdentifier = this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(LinkstateRoute.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 LinkstateRoute route = (LinkstateRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
public void testEmptyRoute() {
final Routes empty = new LinkstateRoutesCaseBuilder().setLinkstateRoutes(
new LinkstateRoutesBuilder().setLinkstateRoute(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);
+ 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());
+ Assert.assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ Assert.assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
@Test
public void testRouteIdAddPath() {
- Assert.assertEquals(ROUTE_KEY, RIB_SUPPORT.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
+ Assert.assertEquals(ROUTE_KEY, this.ribSupport.createRouteListKey(ROUTE_KEY.getPathId().getValue(),
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));
+ Assert.assertEquals(getRoutePath().node(prefixNii), this.ribSupport.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
Assert.assertEquals(new NodeIdentifier(QName.create(LinkstateRoutes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes.QNAME.getLocalName().intern())),
- RIB_SUPPORT.routeAttributesIdentifier());
+ this.ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(LinkstateRoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ Assert.assertEquals(LinkstateRoutesCase.class, this.ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(LinkstateRoutes.class, RIB_SUPPORT.routesContainerClass());
+ Assert.assertEquals(LinkstateRoutes.class, this.ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(LinkstateRoute.class, RIB_SUPPORT.routesListClass());
+ Assert.assertEquals(LinkstateRoute.class, this.ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new LinkstateRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
+ Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new LinkstateRoutesCaseBuilder()
.setLinkstateRoutes(new LinkstateRoutesBuilder().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 LinkstateRoutesCaseBuilder().setLinkstateRoutes(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());
}
}
\ No newline at end of file
if (table.getDataBefore() == null) {
tx.put(LogicalDatastoreType.OPERATIONAL, tablePath, new TablesBuilder()
.setAfi(tableKey.getAfi()).setSafi(tableKey.getSafi())
- .setRoutes(this.registry.getRIBSupport(tableKey).emptyRoutesContainer())
+ .setRoutes(this.registry.getRIBSupport(tableKey).emptyRoutesCase())
.setAttributes(newTable.getAttributes()).build());
}
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import javassist.ClassPool;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
-import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.DestinationIpv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.NotifyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.SendReceive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.AddPathCapabilityBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapabilityBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamiliesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public abstract class AbstractAddPathTest extends DefaultRibPoliciesMockTest {
private static final int RETRY_TIMER = 10;
static final Set<TablesKey> AFI_SAFIS_ADVERTIZED = Collections.singleton(TABLES_KEY);
private BGPExtensionProviderContext context;
private static final InstanceIdentifier<BgpRib> BGP_IID = InstanceIdentifier.create(BgpRib.class);
- protected SchemaContext schemaContext;
@Mock
protected ClusterSingletonServiceProvider clusterSingletonServiceProvider;
- BindingToNormalizedNodeCodec mappingService;
BGPDispatcherImpl serverDispatcher;
RIBExtensionProviderContext ribExtension;
private RIBActivator ribActivator;
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
- this.ribActivator.startRIBExtensionProvider(this.ribExtension);
+ this.ribActivator.startRIBExtensionProvider(this.ribExtension, this.mappingService);
this.bgpActivator = new BGPActivator();
this.inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
this.context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(this.context);
this.inetActivator.start(this.context);
-
- this.mappingService = new BindingToNormalizedNodeCodec(
- GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
- new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(
- JavassistUtils.forClassPool(ClassPool.getDefault()))));
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpRib.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Attributes1.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
- this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
- this.schemaContext = moduleInfoBackedContext.getSchemaContext();
if (!Epoll.isAvailable()) {
this.worker = new NioEventLoopGroup();
this.boss = new NioEventLoopGroup();
localTables.add(new BgpTableTypeImpl(AFI, SAFI));
this.a1 = new RIBActivator();
- this.a1.startRIBExtensionProvider(context);
+ this.a1.startRIBExtensionProvider(context, this.mappingService);
final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(this.codecFactory,
GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
getDomBroker(), getDataBroker(), this.policies, this.peerTracker, TABLES_TYPE, pathTables);
this.ribImpl.instantiateServiceInstance();
- this.ribImpl.onGlobalContextUpdated(this.schemaContext);
+ this.ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
waitFutureSuccess(channelFuture);
this.serverChannel = channelFuture.channel();
this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
this.peerTracker, TABLES_TYPE, pathTables);
this.ribImpl.instantiateServiceInstance();
- this.ribImpl.onGlobalContextUpdated(this.schemaContext);
+ this.ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
waitFutureSuccess(channelFuture);
this.serverChannel = channelFuture.channel();
this.peerTracker, TABLES_TYPE, pathTables);
this.ribImpl.instantiateServiceInstance();
- this.ribImpl.onGlobalContextUpdated(this.schemaContext);
+ this.ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
waitFutureSuccess(channelFuture);
this.serverChannel = channelFuture.channel();
this.baseact = new RIBActivator();
this.lsact = new org.opendaylight.protocol.bgp.linkstate.impl.RIBActivator();
- this.baseact.startRIBExtensionProvider(this.ext1);
- this.lsact.startRIBExtensionProvider(this.ext2);
+ this.baseact.startRIBExtensionProvider(this.ext1, this.mappingService);
+ this.lsact.startRIBExtensionProvider(this.ext2, this.mappingService);
this.codecsRegistry = CodecsRegistryImpl.create(this.bindingCodecTreeFactory,
GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
}
this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
this.peerTracker, ImmutableList.of(this.ipv4tt), pathTables);
ribImpl.instantiateServiceInstance();
- ribImpl.onGlobalContextUpdated(this.schemaContext);
+ ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
Collections.emptySet());
this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
this.peerTracker, ImmutableList.of(this.ipv4tt), pathTables);
ribImpl.instantiateServiceInstance();
- ribImpl.onGlobalContextUpdated(this.schemaContext);
+ ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
Collections.emptySet());
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>bgpcep-parent</artifactId>
+ <artifactId>binding-parent</artifactId>
<version>0.10.0-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
+ <relativePath>../../binding-parent</relativePath>
</parent>
<artifactId>bgp-rib-spi</artifactId>
<artifactId>mdsal-binding-dom-adapter</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
</dependencies>
<build>
import com.google.common.base.Preconditions;
import java.util.List;
import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private List<AutoCloseable> registrations;
@GuardedBy("this")
- protected abstract List<AutoCloseable> startRIBExtensionProviderImpl(RIBExtensionProviderContext context);
+ protected abstract List<AutoCloseable> startRIBExtensionProviderImpl(
+ RIBExtensionProviderContext context,
+ BindingNormalizedNodeSerializer mappingService);
@Override
- public final synchronized void startRIBExtensionProvider(final RIBExtensionProviderContext context) {
+ public final synchronized void startRIBExtensionProvider(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
Preconditions.checkState(this.registrations == null);
- this.registrations = requireNonNull(startRIBExtensionProviderImpl(context));
+ this.registrations = requireNonNull(startRIBExtensionProviderImpl(context, mappingService));
}
@Override
import java.util.Optional;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.UpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.LocRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
import org.slf4j.LoggerFactory;
@Beta
-public abstract class AbstractRIBSupport<R extends Route, N extends Identifier>
- implements RIBSupport<R, N> {
+public abstract class AbstractRIBSupport<
+ C extends Routes & DataObject,
+ S extends DataObject,
+ R extends Route,
+ I extends Identifier>
+ implements RIBSupport<C, S, R, I> {
public static final String ROUTE_KEY = "route-key";
private static final Logger LOG = LoggerFactory.getLogger(AbstractRIBSupport.class);
private static final NodeIdentifier ADVERTISED_ROUTES = new NodeIdentifier(AdvertizedRoutes.QNAME);
private final NodeIdentifier routesContainerIdentifier;
private final NodeIdentifier routesListIdentifier;
private final NodeIdentifier routeAttributesIdentifier;
- private final Class<? extends Routes> cazeClass;
- private final Class<? extends DataObject> containerClass;
- private final Class<? extends Route> listClass;
+ private final Class<C> cazeClass;
+ private final Class<S> containerClass;
+ private final Class<R> listClass;
private final ApplyRoute putRoute = new PutRoute();
private final ChoiceNode emptyRoutes;
private final QName routeQname;
private final QName routeKeyQname;
private final NodeIdentifier prefixTypeNid;
private final NodeIdentifier rdNid;
+ private final BindingNormalizedNodeSerializer mappingService;
/**
* Default constructor. Requires the QName of the container augmented under the routes choice
* node in instantiations of the rib grouping. It is assumed that this container is defined by
* the same model which populates it with route grouping instantiation, and by extension with
* the route attributes container.
- * @param cazeClass Binding class of the AFI/SAFI-specific case statement, must not be null
+ * @param cazeClass Binding class of the AFI/SAFI-specific case statement, must not be null
* @param containerClass Binding class of the container in routes choice, must not be null.
* @param listClass Binding class of the route list, nust not be null;
* @param afiClass address Family Class
* @param destinationQname destination Qname
*/
protected AbstractRIBSupport(
- final Class<? extends Routes> cazeClass,
- final Class<? extends DataObject> containerClass,
- final Class<? extends Route> listClass,
+ final BindingNormalizedNodeSerializer mappingService,
+ final Class<C> cazeClass,
+ final Class<S> containerClass,
+ final Class<R> listClass,
final Class<? extends AddressFamily> afiClass,
final Class<? extends SubsequentAddressFamily> safiClass,
final QName destinationQname) {
this.routeAttributesIdentifier = new NodeIdentifier(QName.create(qname,
Attributes.QNAME.getLocalName().intern()));
this.cazeClass = requireNonNull(cazeClass);
+ this.mappingService = requireNonNull(mappingService);
this.containerClass = requireNonNull(containerClass);
this.listClass = requireNonNull(listClass);
this.routeQname = QName.create(qname, BindingReflections.findQName(listClass).intern().getLocalName());
this.routesListIdentifier = new NodeIdentifier(this.routeQname);
- this.emptyRoutes = Builders.choiceBuilder().withNodeIdentifier(ROUTES)
- .addChild(Builders.containerBuilder()
- .withNodeIdentifier(routesContainerIdentifier())
- .withChild(ImmutableNodes.mapNodeBuilder(this.routeQname).build()).build()).build();
+
+ final TablesKey tk = new TablesKey(afiClass, safiClass);
+ //FIXME Use Route Iid instead of Tables.
+ final InstanceIdentifier<Tables> routeIID = InstanceIdentifier.create(BgpRib.class)
+ .child(Rib.class, new RibKey(requireNonNull(new RibId("rib"))))
+ .child(LocRib.class)
+ .child(Tables.class, tk);
+ this.emptyRoutes = (ChoiceNode) ((MapEntryNode) this.mappingService
+ .toNormalizedNode(routeIID, new TablesBuilder().setKey(tk)
+ .setRoutes(emptyRoutesCase()).build()).getValue())
+ .getChild(new NodeIdentifier(BindingReflections.findQName(Routes.class))).get();
this.afiClass = afiClass;
this.safiClass = safiClass;
this.destinationNid = new NodeIdentifier(destinationQname);
}
@Override
- public final Class<? extends Routes> routesCaseClass() {
+ public final Class<C> routesCaseClass() {
return this.cazeClass;
}
@Override
- public final Class<? extends DataObject> routesContainerClass() {
+ public final Class<S> routesContainerClass() {
return this.containerClass;
}
@Override
- public final Class<? extends Route> routesListClass() {
+ public final Class<R> routesListClass() {
return this.listClass;
}
@Override
public final InstanceIdentifier<R> createRouteIdentifier(
- final KeyedInstanceIdentifier<Tables, TablesKey> tableIId, final N key) {
+ final KeyedInstanceIdentifier<Tables, TablesKey> tableIId, final I key) {
return tableIId.child((Class) routesContainerClass()).child(routesListClass(), key);
}
}
protected final RouteDistinguisher extractRouteDistinguisher(
- final DataContainerNode<? extends YangInstanceIdentifier.PathArgument> route) {
+ final DataContainerNode<? extends PathArgument> route) {
if (route.getChild(this.rdNid).isPresent()) {
return RouteDistinguisherBuilder.getDefaultInstance((String) route.getChild(this.rdNid).get().getValue());
}
package org.opendaylight.protocol.bgp.rib.spi;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
public interface RIBExtensionProviderActivator {
- void startRIBExtensionProvider(@Nonnull RIBExtensionProviderContext context);
+ void startRIBExtensionProvider(
+ @Nonnull RIBExtensionProviderContext context,
+ @Nonnull BindingNormalizedNodeSerializer mappingService);
void stopRIBExtensionProvider();
}
* to register an implementation of this class and the RIB core then calls into it
* to inquire about details specific to that particular model.
*/
-public interface RIBSupport<R extends Route, N extends Identifier> extends AddPathRibSupport {
+public interface RIBSupport<
+ C extends Routes & DataObject,
+ S extends DataObject,
+ R extends Route,
+ I extends Identifier> {
/**
* Return the table-type-specific empty routes container, as augmented into the
* bgp-rib model under /rib/tables/routes choice node. This needs to include all
* @return Class
*/
@Nonnull
- Class<? extends Routes> routesCaseClass();
+ Class<C> routesCaseClass();
/**
* Return class object of the Routes Container statement.
* @return Class
*/
@Nonnull
- Class<? extends DataObject> routesContainerClass();
+ Class<S> routesContainerClass();
/**
* Return class object of the Routes List statement.
* @return Class
*/
@Nonnull
- Class<? extends Route> routesListClass();
+ Class<R> routesListClass();
@Nonnull
default ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects() {
@Nonnull
InstanceIdentifier<R> createRouteIdentifier(
@Nonnull KeyedInstanceIdentifier<Tables, TablesKey> tableKey,
- @Nonnull N newRouteKey);
+ @Nonnull I newRouteKey);
/**
* Creates a route with new path Id and attributes.
* @return Protocol-specific case in the routes choice, may not be null.
*/
@Nonnull
- Routes emptyRoutesContainer();
+ C emptyRoutesCase();
+
+ /**
+ * Return the table-type-specific empty routes container, as augmented into the
+ * bgp-peer model under /peer/effect-rib-in/tables/routes choice node/routes container. This needs to include all
+ * the skeleton nodes under which the individual routes will be stored.
+ *
+ * @return Protocol-specific container in the routes, may not be null.
+ */
+ @Nonnull
+ S emptyRoutesContainer();
+
/**
* @return route list Key (RouteKey + pathId)
*/
@Nonnull
- N createRouteListKey(@Nonnull long pathId, @Nonnull String routeKey);
+ I createRouteListKey(@Nonnull long pathId, @Nonnull String routeKey);
}
import com.google.common.annotations.VisibleForTesting;
import java.util.ServiceLoader;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(ServiceLoaderRIBExtensionConsumerContext.class);
private final ServiceLoader<RIBExtensionProviderActivator> loader;
- private ServiceLoaderRIBExtensionConsumerContext(final ServiceLoader<RIBExtensionProviderActivator> loader) {
+ private ServiceLoaderRIBExtensionConsumerContext(final ServiceLoader<RIBExtensionProviderActivator> loader,
+ final BindingNormalizedNodeSerializer mappingService) {
this.loader = requireNonNull(loader);
for (RIBExtensionProviderActivator a : loader) {
- a.startRIBExtensionProvider(this);
+ a.startRIBExtensionProvider(this, mappingService);
}
}
@VisibleForTesting
- static ServiceLoaderRIBExtensionConsumerContext createConsumerContext() {
+ static ServiceLoaderRIBExtensionConsumerContext createConsumerContext(
+ final BindingNormalizedNodeSerializer mappingService) {
final ServiceLoader<RIBExtensionProviderActivator> loader =
ServiceLoader.load(RIBExtensionProviderActivator.class);
- return new ServiceLoaderRIBExtensionConsumerContext(loader);
+ return new ServiceLoaderRIBExtensionConsumerContext(loader, mappingService);
}
@Override
import static java.util.Objects.requireNonNull;
import java.util.List;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final RIBExtensionProviderContext providerContext;
private final List<RIBExtensionProviderActivator> extensionActivators;
+ private final BindingNormalizedNodeSerializer mappingService;
public SimpleRIBExtensionProviderContextActivator(final RIBExtensionProviderContext providerContext,
- final List<RIBExtensionProviderActivator> extensionActivators) {
+ final List<RIBExtensionProviderActivator> extensionActivators,
+ final BindingNormalizedNodeSerializer mappingService) {
this.providerContext = requireNonNull(providerContext);
this.extensionActivators = requireNonNull(extensionActivators);
+ this.mappingService = requireNonNull(mappingService);
}
public void start() {
LOG.info("Starting {} RIBExtensionProviderActivator instances", this.extensionActivators.size());
for (final RIBExtensionProviderActivator e : this.extensionActivators) {
- e.startRIBExtensionProvider(this.providerContext);
+ e.startRIBExtensionProvider(this.providerContext, this.mappingService);
}
}
META-INF/services/org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator resources.
-->
<odl:specific-reference-list id="extensionActivators" interface="org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator"/>
-
+ <odl:static-reference id="mappingCodec"
+ interface="org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer"/>
<bean id="extensionProviderContext" class="org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext"/>
<bean id="extensionProviderContextActivator" class="org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContextActivator"
init-method="start" destroy-method="close">
<argument ref="extensionProviderContext"/>
<argument ref="extensionActivators"/>
+ <argument ref="mappingCodec"/>
</bean>
<service ref="extensionProviderContext">
--- /dev/null
+module bgp-test {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:bgp:test";
+ prefix "bgp-inet";
+
+ import bgp-rib { prefix bgp-rib; revision-date 2018-03-29; }
+ import bgp-multiprotocol { prefix bgp-mp; revision-date 2018-03-29; }
+ import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
+ import bgp-message { prefix bgp-msg; revision-date 2018-03-29; }
+
+ organization "AT&T Services, Inc.";
+ contact "Claudio D. Gasparini <claudio.gasparini@pantheon.tech>";
+
+ description
+ "This module contains the base data model for test .
+
+ Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+
+ This program and the accompanying materials are made available
+ under the terms of the Eclipse Public License v1.0 which
+ accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html";
+
+ revision "2018-05-15" {
+ description "Initial test model";
+ }
+
+ grouping ipv4-prefixes {
+ container destination-ipv4 {
+ list ipv4-prefixes {
+ uses bgp-msg:ipv4-prefix-and-path-id;
+ }
+ }
+ }
+
+ grouping ipv4-routes {
+ container ipv4-routes {
+ list ipv4-route {
+ key "route-key path-id";
+ uses bgp-rib:route;
+ leaf prefix {
+ type inet:ipv4-prefix;
+ }
+ }
+ }
+ }
+
+ augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
+ case destination-ipv4-case {
+ when "../../afi = ipv4";
+ uses ipv4-prefixes;
+ }
+ }
+
+ augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
+ case destination-ipv4-case {
+ when "../../afi = ipv4";
+ uses ipv4-prefixes;
+ }
+ }
+
+ augment "/bgp-rib:application-rib/bgp-rib:tables/bgp-rib:routes" {
+ case ipv4-routes-case {
+ uses ipv4-routes;
+ }
+ }
+
+ augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
+ case ipv4-routes-case {
+ uses ipv4-routes;
+ }
+ }
+
+ augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-in/bgp-rib:tables/bgp-rib:routes" {
+ case ipv4-routes-case {
+ uses ipv4-routes;
+ }
+ }
+
+ augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:effective-rib-in/bgp-rib:tables/bgp-rib:routes" {
+ case ipv4-routes-case {
+ uses ipv4-routes;
+ }
+ }
+
+ augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-out/bgp-rib:tables/bgp-rib:routes" {
+ case ipv4-routes-case {
+ uses ipv4-routes;
+ }
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.rib.spi;
+
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+
+public abstract class AbstractRIBActivatorTest extends AbstractConcurrentDataBrokerTest {
+ protected BindingNormalizedNodeSerializer mappingService;
+
+ @Override
+ protected final AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer();
+ this.mappingService = customizer.getBindingToNormalized();
+ return customizer;
+ }
+}
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import javassist.ClassPool;
-import org.junit.After;
import org.junit.Before;
import org.mockito.Mock;
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
-import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.LocRib;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-public abstract class AbstractRIBSupportTest {
+public abstract class AbstractRIBSupportTest<R extends Route> extends AbstractConcurrentDataBrokerTest {
protected static final PathId PATH_ID = new PathId(1L);
protected static final Attributes ATTRIBUTES = new AttributesBuilder().build();
private static final InstanceIdentifier<LocRib> RIB = InstanceIdentifier.builder(BgpRib.class)
.augmentation(Attributes2.class).child(MpUnreachNlri.class);
private static final InstanceIdentifier<MpReachNlri> MP_REACH_IID = ATTRIBUTES_IID.augmentation(Attributes1.class)
.child(MpReachNlri.class);
-
@Mock
protected DOMDataWriteTransaction tx;
- protected List<InstanceIdentifier<?>> deletedRoutes;
+ protected List<InstanceIdentifier<R>> deletedRoutes;
protected List<Map.Entry<InstanceIdentifier<?>, DataObject>> insertedRoutes;
- private BindingToNormalizedNodeCodec mappingService;
+ protected BindingNormalizedNodeSerializer mappingService;
private AbstractRIBSupport abstractRIBSupport;
private ModuleInfoBackedContext moduleInfoBackedContext;
protected final void setUpTestCustomizer(final AbstractRIBSupport ribSupport) throws Exception {
this.abstractRIBSupport = ribSupport;
- this.moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(this.abstractRIBSupport
- .routesContainerClass()));
- this.mappingService.onGlobalContextUpdated(this.moduleInfoBackedContext.tryToCreateSchemaContext().get());
+ this.moduleInfoBackedContext
+ .registerModuleInfo(BindingReflections.getModuleInfo(this.abstractRIBSupport.routesContainerClass()));
+ this.moduleInfoBackedContext
+ .registerModuleInfo(BindingReflections.getModuleInfo(this.abstractRIBSupport.routesCaseClass()));
+ this.moduleInfoBackedContext
+ .registerModuleInfo(BindingReflections.getModuleInfo(this.abstractRIBSupport.routesListClass()));
}
@Before
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
- AbstractRIBSupportTest.this.deletedRoutes.add(AbstractRIBSupportTest.this.mappingService
- .fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
+ AbstractRIBSupportTest.this.deletedRoutes.add((InstanceIdentifier<R>)
+ this.mappingService.fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
return args[1];
}).when(this.tx).delete(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
this.deletedRoutes = new ArrayList<>();
this.insertedRoutes = new ArrayList<>();
-
- this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy
- .getTCCLClassLoadingStrategy(),
- new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator
- .create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
this.moduleInfoBackedContext = ModuleInfoBackedContext.create();
}
+ @Override
+ protected final AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer();
+ this.mappingService = customizer.getBindingToNormalized();
+ return customizer;
+ }
+
protected final ContainerNode createNlriWithDrawnRoute(final DestinationType destUnreach) {
final MpUnreachNlri mpReach = new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder()
.setDestinationType(destUnreach).build()).build();
final Collection<MapEntryNode> map = createRoutes(routes);
return Iterables.getOnlyElement(map).getIdentifier();
}
-
- @After
- public final void tearDown() {
- this.mappingService.close();
- }
}
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Prefixes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Routes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.RIBSupportTestImp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.UpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.Ipv4Prefixes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.ipv4.routes.Ipv4Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.ipv4.routes.ipv4.routes.Ipv4Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-public class RIBSupportTest {
+public class RIBSupportTest extends AbstractConcurrentDataBrokerTest {
private static final String ROUTE_KEY = "prefix";
private static final String PREFIX = "1.2.3.4/32";
private static final QName PATH_ID_QNAME = QName.create(Ipv4Route.QNAME, "path-id").intern();
private static final NodeIdentifierWithPredicates PREFIX_NII = new NodeIdentifierWithPredicates(Ipv4Route.QNAME,
ImmutableMap.of(QName.create(Ipv4Route.QNAME, ROUTE_KEY).intern(), PREFIX));
- private static final RIBSupportTestImp ABSTRACT_RIB_SUPP_TEST = new RIBSupportTestImp();
+ private RIBSupportTestImp ribSupportTestImp;
private static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class,
UnicastSubsequentAddressFamily.class);
private static final YangInstanceIdentifier LOC_RIB_TARGET = YangInstanceIdentifier
private DataTreeCandidateNode subTree;
private DOMDataWriteTransaction tx;
private ContainerNode nlri;
- private Map<YangInstanceIdentifier, NormalizedNode<?, ?>> routesMap;
+ private Map<YangInstanceIdentifier, NormalizedNode<?, ?>> routesMap = new HashMap<>();
private ContainerNode attributes;
private MapEntryNode mapEntryNode;
+ private BindingToNormalizedNodeCodec mappingService;
@Before
- public void setUp() {
- this.routesMap = new HashMap<>();
+ public void setUp() throws Exception {
+ super.setup();
MockitoAnnotations.initMocks(this);
+ this.ribSupportTestImp = new RIBSupportTestImp(this.mappingService);
this.emptyTree = Mockito.mock(DataTreeCandidateNode.class);
this.emptySubTree = Mockito.mock(DataTreeCandidateNode.class);
this.subTree = Mockito.mock(DataTreeCandidateNode.class);
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
- RIBSupportTest.this.routesMap.remove(args[1]);
+ this.routesMap.remove(args[1]);
return args[1];
}).when(this.tx).delete(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
final NormalizedNode<?, ?> node1 = (NormalizedNode<?, ?>) args[2];
- RIBSupportTest.this.routesMap.put((YangInstanceIdentifier) args[1], node1);
+ this.routesMap.put((YangInstanceIdentifier) args[1], node1);
return args[1];
}).when(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class),
any(NormalizedNode.class));
this.mapEntryNode = Mockito.mock(MapEntryNode.class);
}
+ @Override
+ protected final AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer();
+ this.mappingService = customizer.getBindingToNormalized();
+ return customizer;
+ }
+
@Test
public void pathIdQName() {
- assertEquals(PATH_ID_QNAME, ABSTRACT_RIB_SUPP_TEST.pathIdQName());
+ assertEquals(PATH_ID_QNAME,this.ribSupportTestImp.pathIdQName());
}
@Test
public void routesCaseClass() {
- assertEquals(Ipv4RoutesCase.class, ABSTRACT_RIB_SUPP_TEST.routesCaseClass());
+ assertEquals(Ipv4RoutesCase.class,this.ribSupportTestImp.routesCaseClass());
}
@Test
public void routesContainerClass() {
- assertEquals(Ipv4Routes.class, ABSTRACT_RIB_SUPP_TEST.routesContainerClass());
+ assertEquals(Ipv4Routes.class,this.ribSupportTestImp.routesContainerClass());
}
@Test
public void routesListClass() {
- assertEquals(Ipv4Route.class, ABSTRACT_RIB_SUPP_TEST.routesListClass());
+ assertEquals(Ipv4Route.class,this.ribSupportTestImp.routesListClass());
}
@Test
public void routeQName() {
- assertEquals(Ipv4Route.QNAME, ABSTRACT_RIB_SUPP_TEST.routeQName());
+ assertEquals(Ipv4Route.QNAME,this.ribSupportTestImp.routeQName());
}
@Test
public void emptyRoutes() {
final ChoiceNode emptyRoutes = Builders.choiceBuilder().withNodeIdentifier(ROUTES_IDENTIFIER)
.addChild(Builders.containerBuilder().withNodeIdentifier(IPV4_ROUTES_IDENTIFIER)
- .withChild(ImmutableNodes.mapNodeBuilder(ABSTRACT_RIB_SUPP_TEST.routeQName())
+ .withChild(ImmutableNodes.mapNodeBuilder(ribSupportTestImp.routeQName())
.build()).build()).build();
- assertEquals(emptyRoutes, ABSTRACT_RIB_SUPP_TEST.emptyRoutes());
+ assertEquals(emptyRoutes,this.ribSupportTestImp.emptyRoutes());
}
@Test
public void routeNid() {
- assertEquals(new NodeIdentifier(Ipv4Route.QNAME), ABSTRACT_RIB_SUPP_TEST.routeNid());
+ assertEquals(new NodeIdentifier(Ipv4Route.QNAME),this.ribSupportTestImp.routeNid());
}
@Test
public void getAfi() {
- assertEquals(Ipv4AddressFamily.class, ABSTRACT_RIB_SUPP_TEST.getAfi());
+ assertEquals(Ipv4AddressFamily.class,this.ribSupportTestImp.getAfi());
}
@Test
public void getSafi() {
- assertEquals(UnicastSubsequentAddressFamily.class, ABSTRACT_RIB_SUPP_TEST.getSafi());
+ assertEquals(UnicastSubsequentAddressFamily.class,this.ribSupportTestImp.getSafi());
}
@Test
public void routesContainerIdentifier() {
- assertEquals(IPV4_ROUTES_IDENTIFIER, ABSTRACT_RIB_SUPP_TEST.routesContainerIdentifier());
+ assertEquals(IPV4_ROUTES_IDENTIFIER,this.ribSupportTestImp.routesContainerIdentifier());
}
@Test
public void routeAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())), ABSTRACT_RIB_SUPP_TEST.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())),this.ribSupportTestImp.routeAttributesIdentifier());
}
@Test
public void routePath() {
- Assert.assertEquals(LOC_RIB_TARGET.node(ROUTES_IDENTIFIER)
+ assertEquals(LOC_RIB_TARGET.node(ROUTES_IDENTIFIER)
.node(Ipv4Routes.QNAME).node(Ipv4Route.QNAME).node(PREFIX_NII),
- ABSTRACT_RIB_SUPP_TEST.routePath(LOC_RIB_TARGET.node(Routes.QNAME), PREFIX_NII));
+ this.ribSupportTestImp.routePath(LOC_RIB_TARGET.node(Routes.QNAME), PREFIX_NII));
}
@Test
public void changedRoutes() {
- Assert.assertTrue(ABSTRACT_RIB_SUPP_TEST.changedRoutes(this.emptyTree).isEmpty());
- Assert.assertTrue(ABSTRACT_RIB_SUPP_TEST.changedRoutes(this.emptySubTree).isEmpty());
- Assert.assertNotNull(ABSTRACT_RIB_SUPP_TEST.changedRoutes(this.subTree));
+ assertTrue(ribSupportTestImp.changedRoutes(this.emptyTree).isEmpty());
+ assertTrue(ribSupportTestImp.changedRoutes(this.emptySubTree).isEmpty());
+ assertNotNull(ribSupportTestImp.changedRoutes(this.subTree));
}
@Test
public void putRoutes() {
- ABSTRACT_RIB_SUPP_TEST.putRoutes(this.tx, LOC_RIB_TARGET, this.nlri, this.attributes);
+ this.ribSupportTestImp.putRoutes(this.tx, LOC_RIB_TARGET, this.nlri, this.attributes);
assertFalse(this.routesMap.isEmpty());
}
@Test
public void deleteRoutes() {
- ABSTRACT_RIB_SUPP_TEST.deleteRoutes(this.tx, LOC_RIB_TARGET, this.nlri);
+ this.ribSupportTestImp.deleteRoutes(this.tx, LOC_RIB_TARGET, this.nlri);
assertTrue(this.routesMap.isEmpty());
}
final Collection<MapEntryNode> routes = new HashSet<>();
assertEquals(new UpdateBuilder().setAttributes(new AttributesBuilder().build()).build(),
- ABSTRACT_RIB_SUPP_TEST.buildUpdate(routes, routes, attr));
+ this.ribSupportTestImp.buildUpdate(routes, routes, attr));
routes.add(this.mapEntryNode);
final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class)
final Attributes attMpR = new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(mpReach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpR).build(),
- ABSTRACT_RIB_SUPP_TEST.buildUpdate(routes, Collections.emptySet(), attr));
+ this.ribSupportTestImp.buildUpdate(routes, Collections.emptySet(), attr));
final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class)
.setSafi(UnicastSubsequentAddressFamily.class)
final Attributes attMpU = new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(mpUnreach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpU).build(),
- ABSTRACT_RIB_SUPP_TEST.buildUpdate(Collections.emptySet(), routes, attr));
+ this.ribSupportTestImp.buildUpdate(Collections.emptySet(), routes, attr));
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.rib.spi;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Collection;
+import java.util.Collections;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.Ipv4Prefixes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.ipv4.routes.Ipv4Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.ipv4.routes.Ipv4RoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.ipv4.routes.ipv4.routes.Ipv4Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.test.rev180515.ipv4.routes.ipv4.routes.Ipv4RouteKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+
+public final class RIBSupportTestImp extends AbstractRIBSupport<Ipv4RoutesCase, Ipv4Routes, Ipv4Route, Ipv4RouteKey> {
+ private static final String ROUTE_KEY = "prefix";
+ private static final String PREFIX = "1.2.3.4/32";
+
+ private static final NodeIdentifierWithPredicates PREFIX_NII = new NodeIdentifierWithPredicates(Ipv4Route.QNAME,
+ ImmutableMap.of(QName.create(Ipv4Route.QNAME, ROUTE_KEY).intern(), PREFIX));
+
+ public RIBSupportTestImp(final BindingNormalizedNodeSerializer mappingService) {
+ super(mappingService, Ipv4RoutesCase.class, Ipv4Routes.class, Ipv4Route.class, Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, Ipv4Prefixes.QNAME);
+ }
+
+ @Override
+ protected DestinationType buildDestination(final Collection routes) {
+ return null;
+ }
+
+ @Override
+ protected DestinationType buildWithdrawnDestination(final Collection routes) {
+ return null;
+ }
+
+ @Override
+ protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath,
+ final ContainerNode destination, final ContainerNode attributes, final ApplyRoute applyFunction) {
+ applyFunction.apply(tx, routesPath.node(Ipv4Route.QNAME), PREFIX_NII, destination, attributes);
+ }
+
+ @Override
+ public Ipv4Route createRoute(final Ipv4Route route, final String routeKey, final long pathId,
+ final Attributes attributes) {
+ return null;
+ }
+
+ @Override
+ public Ipv4RoutesCase emptyRoutesCase() {
+ return new Ipv4RoutesCaseBuilder().setIpv4Routes(emptyRoutesContainer()).build();
+ }
+
+ @Override
+ public Ipv4Routes emptyRoutesContainer() {
+ return new Ipv4RoutesBuilder().setIpv4Route(Collections.emptyList()).build();
+ }
+
+ @Override
+ public Ipv4RouteKey createRouteListKey(final long pathId, final String routeKey) {
+ return new Ipv4RouteKey(new PathId(pathId), routeKey);
+ }
+}
\ No newline at end of file
import java.util.Collections;
import java.util.List;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-public class SimpleRIBExtensionProviderContextActivatorTest {
+public class SimpleRIBExtensionProviderContextActivatorTest extends AbstractRIBActivatorTest {
private static boolean RIBACTIVATED;
@Test
- public void test() throws Exception {
+ public void test() {
final List<RIBExtensionProviderActivator> extensionActivators = Collections.singletonList(new RibActivator());
final SimpleRIBExtensionProviderContextActivator activator =
new SimpleRIBExtensionProviderContextActivator(new SimpleRIBExtensionProviderContext(),
- extensionActivators);
+ extensionActivators, this.mappingService);
activator.start();
assertTrue(RIBACTIVATED);
activator.close();
private static class RibActivator extends AbstractRIBExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
RIBACTIVATED = true;
return Collections.singletonList(() -> RIBACTIVATED = false);
}
*/
package org.opendaylight.protocol.bgp.rib.spi;
-import com.google.common.collect.Lists;
+import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
import org.opendaylight.yangtools.yang.binding.DataObject;
-public class SimpleRIBExtensionTest {
+public class SimpleRIBExtensionTest extends AbstractConcurrentDataBrokerTest {
+ private BindingToNormalizedNodeCodec codec;
+
+ @Override
+ protected final AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer();
+ this.codec = customizer.getBindingToNormalized();
+ return customizer;
+ }
@Test
public void testExtensionProvider() {
final ServiceLoaderRIBExtensionConsumerContext ctx =
- ServiceLoaderRIBExtensionConsumerContext.createConsumerContext();
+ ServiceLoaderRIBExtensionConsumerContext.createConsumerContext(this.codec);
Assert.assertNull(ctx.getRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
final TestActivator act = new TestActivator();
- act.startRIBExtensionProvider(ctx);
+ act.startRIBExtensionProvider(ctx, this.codec);
Assert.assertNotNull(ctx.getRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
act.close();
Assert.assertNull(ctx.getRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
private final class TestActivator extends AbstractRIBExtensionProviderActivator {
@Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(
+ final RIBExtensionProviderContext context,
+ final BindingNormalizedNodeSerializer mappingService) {
final RIBSupport support = Mockito.mock(RIBSupport.class);
Mockito.doReturn(Route.class).when(support).routesListClass();
Mockito.doReturn(DataObject.class).when(support).routesContainerClass();
Mockito.doReturn(DataObject.class).when(support).routesCaseClass();
- return Lists.newArrayList((AutoCloseable)context.registerRIBSupport(Ipv4AddressFamily.class,
+ return Collections.singletonList((AutoCloseable) context.registerRIBSupport(Ipv4AddressFamily.class,
UnicastSubsequentAddressFamily.class, support));
}
}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes;
-
-import org.opendaylight.yangtools.yang.common.QName;
-
-public interface Ipv4Prefixes {
- QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
- "2015-03-05", "ipv4-prefixes").intern();
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
-import org.opendaylight.yangtools.yang.common.QName;
-
-public interface Ipv4Route extends Route {
- QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
- "2015-03-05", "ipv4-route").intern();
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.common.QName;
-
-public interface Ipv4Routes extends DataObject {
- QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
- "2015-03-05", "ipv4-routes").intern();
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes;
-
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
-import org.opendaylight.yangtools.yang.common.QName;
-
-public interface Ipv4RoutesCase extends Routes {
- QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
- "2015-03-05", "ipv4-routes-case").intern();
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.Collection;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupport;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-
-public final class RIBSupportTestImp extends AbstractRIBSupport {
- private static final String ROUTE_KEY = "prefix";
- private static final String PREFIX = "1.2.3.4/32";
-
- private static final NodeIdentifierWithPredicates PREFIX_NII = new NodeIdentifierWithPredicates(org.opendaylight
- .yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route.QNAME,
- ImmutableMap.of(QName.create(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
- .rev180329.ipv4.routes.ipv4.routes.Ipv4Route.QNAME, ROUTE_KEY).intern(), PREFIX));
-
- public RIBSupportTestImp() {
- super(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4
- .routes.Ipv4RoutesCase.class,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.
- routes.Ipv4Routes.class, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
- .inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route.class, Ipv4AddressFamily.class,
- UnicastSubsequentAddressFamily.class, org.opendaylight.yang.gen.v1.urn.opendaylight.params
- .xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Prefixes.QNAME);
- }
-
- @Override
- protected DestinationType buildDestination(final Collection routes) {
- return null;
- }
-
- @Override
- protected DestinationType buildWithdrawnDestination(final Collection routes) {
- return null;
- }
-
- @Override
- protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath,
- final ContainerNode destination, final ContainerNode attributes, final ApplyRoute applyFunction) {
- applyFunction.apply(tx, routesPath.node(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
- .bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route.QNAME), PREFIX_NII, destination, attributes);
- }
-
- @Override
- public Route createRoute(final Route route, final String routeKey, final long pathId, final Attributes attributes) {
- return null;
- }
-
- @Override
- public Routes emptyRoutesContainer() {
- return null;
- }
-
- @Override
- public Identifier createRouteListKey(final long pathId, final String routeKey) {
- return null;
- }
-}
\ No newline at end of file
import io.netty.channel.socket.nio.NioSocketChannel;
import java.net.InetSocketAddress;
import java.util.List;
-import javassist.ClassPool;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
-import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bmp.monitor.monitor.router.peer.pre.policy.rib.tables.routes.Ipv4RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.AdjRibInType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.InitiationMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.PeerType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.RouteMirroringMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.StatsReportsMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.peer.up.ReceivedOpen;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.peer.up.SentOpen;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev180329.BmpMonitor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev180329.MonitorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev180329.routers.RouterKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@Before
public void setUp() throws Exception {
+ super.setup();
+
MockitoAnnotations.initMocks(this);
doAnswer(invocationOnMock -> {
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService2.closeServiceInstance())
.when(this.singletonServiceRegistration2).close();
- this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy
- .getTCCLClassLoadingStrategy(),
- new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator
- .create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
- final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(InitiationMessage.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(CParameters1.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(SentOpen.class));
- moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(ReceivedOpen.class));
- this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
+ this.mappingService.onGlobalContextUpdated(getSchemaContext());
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
- this.ribActivator.startRIBExtensionProvider(this.ribExtension);
+ this.ribActivator.startRIBExtensionProvider(this.ribExtension, this.mappingService);
this.bgpActivator = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
new NodeIdentifier(BmpMonitor.QNAME))
.addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build()).build();
wTx.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(BmpMonitor.QNAME), parentNode);
- wTx.submit();
+ wTx.commit().get();
final BmpDeployerDependencies bmpDependecies = new BmpDeployerDependencies(getDataBroker(), getDomBroker(),
this.ribExtension, this.mappingService.getCodecFactory(), getSchemaContext(), this.clusterSSProv);
});
}
+ @Override
+ protected final AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer();
+ this.mappingService = customizer.getBindingToNormalized();
+ return customizer;
+ }
+
@After
public void tearDown() throws Exception {
this.ribActivator.close();
b.option(ChannelOption.SO_KEEPALIVE, true);
b.handler(new ChannelInitializer<SocketChannel>() {
@Override
- protected void initChannel(final SocketChannel ch) throws Exception {
+ protected void initChannel(final SocketChannel ch) {
ch.pipeline().addLast(hf.getDecoders());
ch.pipeline().addLast(hf.getEncoders());
}