Search in sources :

Example 6 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.

the class UdpChannelTest method shouldHandleCanonicalFormWithNsLookup.

@Test
public void shouldHandleCanonicalFormWithNsLookup() throws Exception {
    final String localhostIpAsHex = resolveToHexAddress("localhost");
    final UdpChannel udpChannelExampleCom = UdpChannel.parse("aeron:udp?endpoint=localhost:40456");
    assertThat(udpChannelExampleCom.canonicalForm(), is("UDP-00000000-0-" + localhostIpAsHex + "-40456"));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.Test)

Example 7 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.

the class UdpChannelTest method shouldHandleImpliedLocalPortFormat.

@Test
public void shouldHandleImpliedLocalPortFormat() throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=localhost:40124");
    assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 0)));
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.Test)

Example 8 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.

the class UdpChannelTest method shouldHandleIpV6CanonicalFormForMulticastCorrectly.

@Theory
public void shouldHandleIpV6CanonicalFormForMulticastCorrectly(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    Assume.assumeTrue(System.getProperty("java.net.preferIPv4Stack") == null);
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "[FF01::FD]:40456", interfaceKey, "localhost"));
    final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "[::1]:54321/64"));
    assertThat(udpChannel.canonicalForm(), is("UDP-7f000001-0-ff0100000000000000000000000000fd-40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-00000000000000000000000000000001-54321-e0000101-40456"));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Example 9 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.

the class UdpChannelTest method shouldParseValidMulticastAddressWithAeronUri.

@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"))));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Example 10 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.

the class UdpChannelTest method shouldHandleImpliedLocalPortFormatWithAeronUri.

@Theory
public void shouldHandleImpliedLocalPortFormatWithAeronUri(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124", interfaceKey, "localhost"));
    assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 0)));
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Aggregations

UdpChannel (io.aeron.driver.media.UdpChannel)31 Test (org.junit.Test)16 Theory (org.junit.experimental.theories.Theory)11 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)6 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)4 RawLog (io.aeron.driver.buffer.RawLog)1 AeronUri (io.aeron.driver.uri.AeronUri)1 HashMap (java.util.HashMap)1