RouteTransportListener implements RoutingEventListener { public void configure(Set<RoutingFilterConfiguration> localRoutingFilters, PathAttributeConfiguration localDefaultPathAttributes) { injector.configure(localDefaultPathAttributes); for(RoutingFilterConfiguration filterConfig : localRoutingFilters) { if(filterConfig instanceof PrefixRoutingFilterConfiguration) { PrefixRoutingFilter filter = prefixFilterProvider.get(); filter.configure((PrefixRoutingFilterConfiguration)filterConfig); filters.add(filter); } } }  @Override void routeAdded(RouteAdded event); @Override void routeWithdrawn(RouteWithdrawn event); void configure(Set<RoutingFilterConfiguration> localRoutingFilters,	PathAttributeConfiguration localDefaultPathAttributes);  }
@Test public void testPrefixFilter() throws Exception { RouteChecker firstChecker = new RouteChecker(sourceRib.getRibID(), firstRoute); RouteChecker secondChecker = new RouteChecker(sourceRib.getRibID(), secondRoute); filterConfigs.add(new PrefixRoutingFilterConfiguration() { @Override public int compareTo(RoutingFilterConfiguration o) { return 0; } @Override public String getName() { return null; } @Override public Set<NetworkLayerReachabilityInformation> getFilterPrefixes() { Set<NetworkLayerReachabilityInformation> filteredRoutes = new HashSet<NetworkLayerReachabilityInformation>(); filteredRoutes.add(secondRoute.getNlri()); return filteredRoutes; } }); listener.configure(filterConfigs, new PathAttributeConfiguration() { @Override public int compareTo(PathAttributeConfiguration o) { return 0; } @Override public Set<PathAttribute> getAttributes() { return injectedPathAttributes; } }); sourceRib.addRoute(firstRoute); sourceRib.addRoute(secondRoute); targetRib.visitRoutingNodes(firstChecker); targetRib.visitRoutingNodes(secondChecker); Assert.assertTrue(firstChecker.isFound()); Assert.assertFalse(secondChecker.isFound()); sourceRib.withdrawRoute(firstRoute); sourceRib.withdrawRoute(secondRoute); firstChecker.resetFound(); secondChecker.resetFound(); targetRib.visitRoutingNodes(firstChecker); targetRib.visitRoutingNodes(secondChecker); Assert.assertFalse(firstChecker.isFound()); Assert.assertFalse(secondChecker.isFound()); }
@Test public void testInjectAttributes() throws Exception { RouteChecker firstChecker = new RouteChecker(sourceRib.getRibID(), firstRouteFull); RouteChecker secondChecker = new RouteChecker(sourceRib.getRibID(), secondRouteFull); injectedPathAttributes.add(new MultiExitDiscPathAttribute(1)); injectedPathAttributes.add(new OriginPathAttribute(Origin.INCOMPLETE)); listener.configure(filterConfigs, new PathAttributeConfiguration() { @Override public int compareTo(PathAttributeConfiguration o) { return 0; } @Override public Set<PathAttribute> getAttributes() { return injectedPathAttributes; } }); sourceRib.addRoute(firstRoute); sourceRib.addRoute(secondRoute); targetRib.visitRoutingNodes(firstChecker); targetRib.visitRoutingNodes(secondChecker); Assert.assertTrue(firstChecker.isFound()); Assert.assertTrue(secondChecker.isFound()); sourceRib.withdrawRoute(firstRoute); sourceRib.withdrawRoute(secondRoute); firstChecker.resetFound(); secondChecker.resetFound(); targetRib.visitRoutingNodes(firstChecker); targetRib.visitRoutingNodes(secondChecker); Assert.assertFalse(firstChecker.isFound()); Assert.assertFalse(secondChecker.isFound()); }
@Test public void testPathAttributesInjectAttributes() throws Exception { RouteChecker firstChecker = new RouteChecker(sourceRib.getRibID(), firstRouteFull); RouteChecker secondChecker = new RouteChecker(sourceRib.getRibID(), secondRouteFull); RouteChecker thirdChecker = new RouteChecker(sourceRib.getRibID(), firstRoute); RouteChecker fourthChecker = new RouteChecker(sourceRib.getRibID(), secondRoute); injectedPathAttributes.add(new MultiExitDiscPathAttribute(1)); injectedPathAttributes.add(new OriginPathAttribute(Origin.INCOMPLETE)); filterConfigs.add(new PrefixRoutingFilterConfiguration() { @Override public int compareTo(RoutingFilterConfiguration o) { return 0; } @Override public String getName() { return null; } @Override public Set<NetworkLayerReachabilityInformation> getFilterPrefixes() { Set<NetworkLayerReachabilityInformation> filteredRoutes = new HashSet<NetworkLayerReachabilityInformation>(); filteredRoutes.add(secondRoute.getNlri()); return filteredRoutes; } }); listener.configure(filterConfigs, new PathAttributeConfiguration() { @Override public int compareTo(PathAttributeConfiguration o) { return 0; } @Override public Set<PathAttribute> getAttributes() { return injectedPathAttributes; } }); sourceRib.addRoute(firstRoute); sourceRib.addRoute(secondRoute); targetRib.visitRoutingNodes(firstChecker); targetRib.visitRoutingNodes(secondChecker); targetRib.visitRoutingNodes(thirdChecker); targetRib.visitRoutingNodes(fourthChecker); Assert.assertTrue(firstChecker.isFound()); Assert.assertFalse(secondChecker.isFound()); Assert.assertFalse(thirdChecker.isFound()); Assert.assertFalse(fourthChecker.isFound()); sourceRib.withdrawRoute(firstRoute); sourceRib.withdrawRoute(secondRoute); firstChecker.resetFound(); secondChecker.resetFound(); targetRib.visitRoutingNodes(firstChecker); targetRib.visitRoutingNodes(secondChecker); targetRib.visitRoutingNodes(thirdChecker); targetRib.visitRoutingNodes(fourthChecker); Assert.assertFalse(firstChecker.isFound()); Assert.assertFalse(secondChecker.isFound()); }