Search in sources :

Example 61 with UdpChannel

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

the class UdpChannelTest method shouldHandleExplicitLocalAddressAndPortFormatWithAeronUri.

@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleExplicitLocalAddressAndPortFormatWithAeronUri(final String endpointKey, final String interfaceKey) {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124", interfaceKey, "localhost:40123"));
    assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 40123)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 40123)));
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 62 with UdpChannel

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

the class UdpChannelTest method shouldHandleCanonicalFormForUnicastCorrectly.

@Test
public void shouldHandleCanonicalFormForUnicastCorrectly() {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?endpoint=192.168.0.1:40456");
    final UdpChannel udpChannelLocal = UdpChannel.parse("aeron:udp?interface=127.0.0.1|endpoint=192.168.0.1:40456");
    final UdpChannel udpChannelLocalPort = UdpChannel.parse("aeron:udp?interface=127.0.0.1:40455|endpoint=192.168.0.1:40456");
    final UdpChannel udpChannelLocalhost = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=localhost:40456");
    assertThat(udpChannel.canonicalForm(), is("UDP-0.0.0.0:0-192.168.0.1:40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-127.0.0.1:0-192.168.0.1:40456"));
    assertThat(udpChannelLocalPort.canonicalForm(), is("UDP-127.0.0.1:40455-192.168.0.1:40456"));
    assertThat(udpChannelLocalhost.canonicalForm(), is("UDP-127.0.0.1:0-localhost:40456"));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 63 with UdpChannel

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

the class UdpChannelTest method shouldHandleImpliedLocalAddressAndPortFormatWithAeronUri.

@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleImpliedLocalAddressAndPortFormatWithAeronUri(final String endpointKey) {
    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)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 64 with UdpChannel

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

the class UdpChannelTest method shouldHandleCanonicalFormForMulticastCorrectly.

@Test
public void shouldHandleCanonicalFormForMulticastCorrectly() {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=224.0.1.1:40456");
    final UdpChannel udpChannelLocal = UdpChannel.parse("aeron:udp?interface=127.0.0.1|endpoint=224.0.1.1:40456");
    final UdpChannel udpChannelAllSystems = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=224.0.1.1:40456");
    final UdpChannel udpChannelDefault = UdpChannel.parse("aeron:udp?endpoint=224.0.1.1:40456");
    final UdpChannel udpChannelSubnet = UdpChannel.parse("aeron:udp?interface=localhost/29|endpoint=224.0.1.1:40456");
    final UdpChannel udpChannelSubnetLocal = UdpChannel.parse("aeron:udp?interface=127.0.0.0/29|endpoint=224.0.1.1:40456");
    assertThat(udpChannel.canonicalForm(), is("UDP-127.0.0.1:0-224.0.1.1:40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-127.0.0.1:0-224.0.1.1:40456"));
    final Pattern canonicalFormPattern = Pattern.compile("UDP-127\\.0\\.0\\.[1-7]:0-224\\.0\\.1\\.1:40456");
    assertThat(udpChannelAllSystems.canonicalForm(), matchesPattern(canonicalFormPattern));
    assertThat(udpChannelSubnet.canonicalForm(), matchesPattern(canonicalFormPattern));
    assertThat(udpChannelSubnetLocal.canonicalForm(), matchesPattern(canonicalFormPattern));
    assertThat(udpChannelDefault.localInterface(), supportsMulticastOrIsLoopback());
}
Also used : Pattern(java.util.regex.Pattern) UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 65 with UdpChannel

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

the class UdpChannelTest method shouldHandleIPv4AnyAddressAsInterfaceAddressForUnicast.

@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleIPv4AnyAddressAsInterfaceAddressForUnicast(final String endpointKey, final String interfaceKey) {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124", interfaceKey, "0.0.0.0"));
    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)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

UdpChannel (io.aeron.driver.media.UdpChannel)78 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)35 Test (org.junit.jupiter.api.Test)26 Test (org.junit.Test)18 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)12 Theory (org.junit.experimental.theories.Theory)11 CsvSource (org.junit.jupiter.params.provider.CsvSource)11 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)7 ChannelUri (io.aeron.ChannelUri)3 PublicationParams (io.aeron.driver.PublicationParams)3 ControlProtocolException (io.aeron.exceptions.ControlProtocolException)3 RawLog (io.aeron.driver.buffer.RawLog)2 ReceiveDestinationTransport (io.aeron.driver.media.ReceiveDestinationTransport)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Pattern (java.util.regex.Pattern)2 Aeron (io.aeron.Aeron)1 SPY_QUALIFIER (io.aeron.ChannelUri.SPY_QUALIFIER)1 ChannelUriStringBuilder (io.aeron.ChannelUriStringBuilder)1 CommonContext (io.aeron.CommonContext)1