@Test public void shouldHandleLocalhostLookup() throws Exception { final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?endpoint=localhost:40124"); assertThat(udpChannel.remoteData(), is(new InetSocketAddress("127.0.0.1", 40124))); assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("127.0.0.1", 40124))); }
@Theory public void shouldHandleLocalhostLookupWithAeronUri( @Values({"endpoint"}) final String endpointKey) throws Exception { final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124")); assertThat(udpChannel.remoteData(), is(new InetSocketAddress("127.0.0.1", 40124))); assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("127.0.0.1", 40124))); }
@Test public void shouldHandleImpliedLocalAddressAndPortFormat() throws Exception { final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?endpoint=localhost:40124"); assertThat(udpChannel.localData(), is(new InetSocketAddress("0.0.0.0", 0))); assertThat(udpChannel.localControl(), is(new InetSocketAddress("0.0.0.0", 0))); assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124))); assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124))); }
@Theory public void shouldHandleImpliedLocalAddressAndPortFormatWithAeronUri( @Values({"endpoint"}) final String endpointKey) throws Exception { final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124")); assertThat(udpChannel.localData(), is(new InetSocketAddress("0.0.0.0", 0))); assertThat(udpChannel.localControl(), is(new InetSocketAddress("0.0.0.0", 0))); assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124))); assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124))); }
@Theory public void shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast( @Values({"endpoint"}) final String endpointKey, @Values({"interface"}) final String interfaceKey) throws Exception { final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "[::1]:40124", interfaceKey, "[::]")); assertThat(udpChannel.localData(), is(new InetSocketAddress("::", 0))); assertThat(udpChannel.localControl(), is(new InetSocketAddress("::", 0))); assertThat(udpChannel.remoteData(), is(new InetSocketAddress("::1", 40124))); assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("::1", 40124))); }
@Test public void shouldParseValidMulticastAddress() throws Exception { final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=224.10.9.9:40124"); assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 0))); assertThat(udpChannel.remoteControl(), isMulticastAddress("224.10.9.10", 40124)); assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0))); assertThat(udpChannel.remoteData(), isMulticastAddress("224.10.9.9", 40124)); assertThat( udpChannel.localInterface(), is(NetworkInterface.getByInetAddress(InetAddress.getByName("localhost")))); }
@Theory public void shouldParseValidMulticastAddressWithAeronUri( @Values({"endpoint"}) final String endpointKey, @Values({"interface"}) final String interfaceKey) throws Exception { final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "224.10.9.9:40124", interfaceKey, "localhost")); assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 0))); assertThat(udpChannel.remoteControl(), isMulticastAddress("224.10.9.10", 40124)); assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0))); assertThat(udpChannel.remoteData(), isMulticastAddress("224.10.9.9", 40124)); assertThat( udpChannel.localInterface(), is(NetworkInterface.getByInetAddress(InetAddress.getByName("localhost")))); }