AS4OctetPeerConfigurationDecorator extends PeerConfigurationDecorator { @Override public Capabilities getCapabilities() { if(getLocalAS() > 65535 || getRemoteAS() > 65535) return new AS4OctetRequiredCapabiltiesDecorator(super.getCapabilities(), getLocalAS()); else return super.getCapabilities(); } AS4OctetPeerConfigurationDecorator(PeerConfiguration decorated); @Override Capabilities getCapabilities();  }
@Test public void test2OctetASNumber() throws Exception { PeerConfiguration peer = new AS4OctetPeerConfigurationDecorator(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()); AutonomousSystem4Capability as4cap = findRequiredCapability(peer.getCapabilities(), AutonomousSystem4Capability.class); Assert.assertNull(as4cap); }
@Test public void test2OctetASNumberAS4Cap() throws Exception { PeerConfiguration peer = new AS4OctetPeerConfigurationDecorator(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 AutonomousSystem4Capability(10241024)}))); Assert.assertEquals(10, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); AutonomousSystem4Capability as4cap = findRequiredCapability(peer.getCapabilities(), AutonomousSystem4Capability.class); Assert.assertNotNull(as4cap); Assert.assertEquals(10241024L, as4cap.getAutonomousSystem()); }
@Test public void test4OctetASNumber() throws Exception { PeerConfiguration peer = new AS4OctetPeerConfigurationDecorator(new PeerConfigurationImpl("peer1", new ClientConfigurationImpl(InetAddress.getLocalHost(), 17179), 131072, 11, 1024, 2048, 15, 15, false, 30, true, true, 60, false, false, false, 0, false, null)); Assert.assertEquals(131072, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); AutonomousSystem4Capability as4cap = findRequiredCapability(peer.getCapabilities(), AutonomousSystem4Capability.class); Assert.assertNotNull(as4cap); Assert.assertEquals(131072, as4cap.getAutonomousSystem()); }
@Test public void test4OctetASNumberAS4Cap() throws Exception { PeerConfiguration peer = new AS4OctetPeerConfigurationDecorator(new PeerConfigurationImpl("peer1", new ClientConfigurationImpl(InetAddress.getLocalHost(), 17179), 131072, 11, 1024, 2048, 15, 15, false, 30, true, true, 60, false, false, false, 0, false, new CapabilitiesImpl(new Capability[] { new AutonomousSystem4Capability(262144)}))); Assert.assertEquals(131072, peer.getLocalAS()); Assert.assertEquals(11, peer.getRemoteAS()); AutonomousSystem4Capability as4cap = findRequiredCapability(peer.getCapabilities(), AutonomousSystem4Capability.class); Assert.assertNotNull(as4cap); Assert.assertEquals(262144, as4cap.getAutonomousSystem()); }