* 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.flowspec;
import static org.junit.Assert.assertEquals;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
+import org.opendaylight.protocol.bgp.flowspec.FlowspecTypeRegistries.SAFI;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
public class FlowspecIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecIpv6RoutesCase, FlowspecIpv6Routes,
- FlowspecRoute, FlowspecRouteKey> {
+ FlowspecRoute> {
private static final PathId PATH_ID = new PathId(Uint32.ONE);
private static final DestinationIpv6PrefixCase DEST_PREFIX = new DestinationIpv6PrefixCaseBuilder()
@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 BGPActivator act = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
- final SimpleFlowspecIpv6NlriParser parser = new SimpleFlowspecIpv6NlriParser(
- fsContext.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4,
- SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
+ final SimpleFlowspecIpv6NlriParser parser = new SimpleFlowspecIpv6NlriParser(SAFI.FLOWSPEC);
this.routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
this.route = new FlowspecRouteBuilder().withKey(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.adapter.currentSerializer());
+ this.routes = new FlowspecIpv6RoutesBuilder().setFlowspecRoute(Map.of(this.route.key(), this.route)).build();
+ this.ribSupport = new FlowspecIpv6RIBSupport(this.adapter.currentSerializer());
setUpTestCustomizer(this.ribSupport);
}
public void testBuildMpUnreachNlriUpdate() {
final Update update = this.ribSupport.buildUpdate(Collections.emptyList(),
createRoutes(this.routes), ATTRIBUTES);
- assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(Attributes2.class)
+ assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
- assertNull(update.getAttributes().augmentation(Attributes1.class));
+ assertNull(update.getAttributes().augmentation(AttributesReach.class));
}
@Test
public void testBuildMpReachNlriUpdate() {
final Update update = this.ribSupport.buildUpdate(createRoutes(this.routes),
Collections.emptyList(), ATTRIBUTES);
- assertEquals(REACH_NLRI, update.getAttributes().augmentation(Attributes1.class).getMpReachNlri()
+ assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
- assertNull(update.getAttributes().augmentation(Attributes2.class));
+ assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
}
@Test
assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
}
- @Test
- public void testRouteIdAddPath() {
- assertEquals(this.routeKey, this.ribSupport.createRouteListKey(routeKey.getPathId(), routeKey.getRouteKey()));
- }
-
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(this.routes);
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(new FlowspecIpv6RoutesCaseBuilder()
.setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder()
- .setFlowspecRoute(Collections.singletonList(this.route)).build()).build())).getRootNode();
+ .setFlowspecRoute(Map.of(this.route.key(), this.route)).build()).build())).getRootNode();
final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
Assert.assertFalse(result.isEmpty());
}