IPv4RequiredCapabilityPeerConfigurationDecorator extends PeerConfigurationDecorator { @Override public Capabilities getCapabilities() { return ipv4decorator; } IPv4RequiredCapabilityPeerConfigurationDecorator(PeerConfiguration decorated); @Override Capabilities getCapabilities();  }
@Test public void testNoCapabiltiesSet() throws Exception { PeerConfiguration peer = new IPv4RequiredCapabilityPeerConfigurationDecorator(new PeerConfigurationImpl("peer1", new ClientConfigurationImpl(InetAddress.getLocalHost(), 17179), 10, 11, 1024, 2048, 15, 15, false, 30, true, true, 60, false, false, false, 0, false, null)); Assert.assertEquals(10, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); MultiProtocolCapability ipv4Cap = new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); Assert.assertTrue(peer.getCapabilities().getRequiredCapabilities().contains(ipv4Cap)); Assert.assertFalse(peer.getCapabilities().getOptionalCapabilities().contains(ipv4Cap)); }
@Test public void testIPv4OptionalCapabiltiesSet() throws Exception { PeerConfiguration peer = new IPv4RequiredCapabilityPeerConfigurationDecorator(new PeerConfigurationImpl("peer1", new ClientConfigurationImpl(InetAddress.getLocalHost(), 17179), 10, 11, 1024, 2048, 15, 15, false, 30, true, true, 60, false, false, false, 0, false, new CapabilitiesImpl(null, new Capability[] { new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING), new MultiProtocolCapability(AddressFamily.IPv6, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING) }))); Assert.assertEquals(10, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); MultiProtocolCapability ipv4Cap = new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); MultiProtocolCapability ipv6Cap = new MultiProtocolCapability(AddressFamily.IPv6, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); Assert.assertTrue(peer.getCapabilities().getRequiredCapabilities().contains(ipv4Cap)); Assert.assertFalse(peer.getCapabilities().getOptionalCapabilities().contains(ipv4Cap)); Assert.assertFalse(peer.getCapabilities().getRequiredCapabilities().contains(ipv6Cap)); Assert.assertTrue(peer.getCapabilities().getOptionalCapabilities().contains(ipv6Cap)); }
@Test public void testIPv4AnycastOptionalCapabiltiesSet() throws Exception { PeerConfiguration peer = new IPv4RequiredCapabilityPeerConfigurationDecorator(new PeerConfigurationImpl("peer1", new ClientConfigurationImpl(InetAddress.getLocalHost(), 17179), 10, 11, 1024, 2048, 15, 15, false, 30, true, true, 60, false, false, false, 0, false, new CapabilitiesImpl(null, new Capability[] { new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_MULTICAST_FORWARDING), new MultiProtocolCapability(AddressFamily.IPv6, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING) }))); Assert.assertEquals(10, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); MultiProtocolCapability ipv4UnicastCap = new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); MultiProtocolCapability ipv4MulticastCap = new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_MULTICAST_FORWARDING); MultiProtocolCapability ipv6Cap = new MultiProtocolCapability(AddressFamily.IPv6, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); Assert.assertTrue(peer.getCapabilities().getRequiredCapabilities().contains(ipv4UnicastCap)); Assert.assertFalse(peer.getCapabilities().getOptionalCapabilities().contains(ipv4UnicastCap)); Assert.assertFalse(peer.getCapabilities().getRequiredCapabilities().contains(ipv6Cap)); Assert.assertTrue(peer.getCapabilities().getOptionalCapabilities().contains(ipv6Cap)); Assert.assertFalse(peer.getCapabilities().getRequiredCapabilities().contains(ipv4MulticastCap)); Assert.assertTrue(peer.getCapabilities().getOptionalCapabilities().contains(ipv4MulticastCap)); }
@Test public void testIPv4RequiredCapabiltiesSet() throws Exception { PeerConfiguration peer = new IPv4RequiredCapabilityPeerConfigurationDecorator(new PeerConfigurationImpl("peer1", new ClientConfigurationImpl(InetAddress.getLocalHost(), 17179), 10, 11, 1024, 2048, 15, 15, false, 30, true, true, 60, false, false, false, 0, false, new CapabilitiesImpl(new Capability[] { new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING) }))); Assert.assertEquals(10, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); MultiProtocolCapability ipv4Cap = new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); Assert.assertTrue(peer.getCapabilities().getRequiredCapabilities().contains(ipv4Cap)); Assert.assertFalse(peer.getCapabilities().getOptionalCapabilities().contains(ipv4Cap)); }
@Test public void testIPv4AnycastRequiredCapabiltiesSet() throws Exception { PeerConfiguration peer = new IPv4RequiredCapabilityPeerConfigurationDecorator(new PeerConfigurationImpl("peer1", new ClientConfigurationImpl(InetAddress.getLocalHost(), 17179), 10, 11, 1024, 2048, 15, 15, false, 30, true, true, 60, false, false, false, 0, false, new CapabilitiesImpl(new Capability[] { new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_MULTICAST_FORWARDING) }))); Assert.assertEquals(10, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); MultiProtocolCapability ipv4UnicastCap = new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); MultiProtocolCapability ipv4MulticastCap = new MultiProtocolCapability(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_MULTICAST_FORWARDING); Assert.assertTrue(peer.getCapabilities().getRequiredCapabilities().contains(ipv4UnicastCap)); Assert.assertFalse(peer.getCapabilities().getOptionalCapabilities().contains(ipv4UnicastCap)); Assert.assertTrue(peer.getCapabilities().getRequiredCapabilities().contains(ipv4MulticastCap)); Assert.assertFalse(peer.getCapabilities().getOptionalCapabilities().contains(ipv4MulticastCap)); }