@Test public void testParseCompleteWithTwoRoute() throws Exception { AddressFamilyRoutingConfiguration result = parser.parseConfiguration(config.configurationAt("AddressFamily(1)")); Assert.assertEquals(AddressFamily.IPv4, result.getKey().getAddressFamily()); Assert.assertEquals( SubsequentAddressFamily.NLRI_UNICAST_FORWARDING, result.getKey().getSubsequentAddressFamily()); Iterator<RouteConfiguration> it = result.getRoutes().iterator(); Assert.assertTrue(it.hasNext()); RouteConfiguration route = it.next(); Assert.assertEquals( new NetworkLayerReachabilityInformation( 24, new byte[] {(byte) 0xc0, (byte) 0xa8, (byte) 0x01}), route.getNlri()); Assert.assertTrue(it.hasNext()); route = it.next(); Assert.assertEquals( new NetworkLayerReachabilityInformation( 24, new byte[] {(byte) 0xc0, (byte) 0xa8, (byte) 0x02}), route.getNlri()); Assert.assertFalse(it.hasNext()); }
public RoutingConfiguration parseConfiguration(HierarchicalConfiguration config) throws ConfigurationException { RoutingConfigurationImpl result = new RoutingConfigurationImpl(); Set<AddressFamilyKey> keys = new HashSet<AddressFamilyKey>(); for (HierarchicalConfiguration afConfig : config.configurationsAt("AddressFamily")) { AddressFamilyRoutingConfiguration afRouting = afParser.parseConfiguration(afConfig); if (keys.contains(afRouting.getKey())) throw new ConfigurationException("Duplicate address family: " + afRouting.getKey()); result.getRoutingConfigurations().add(afRouting); keys.add(afRouting.getKey()); } return result; }