use of org.junit.experimental.theories.Theory 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)));
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class UdpChannelTest method shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast.
@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)));
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class UdpChannelTest method shouldHandleCanonicalFormForUnicastCorrectlyWithAeronUri.
@Theory
public void shouldHandleCanonicalFormForUnicastCorrectlyWithAeronUri(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "192.168.0.1:40456"));
final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "192.168.0.1:40456", interfaceKey, "127.0.0.1"));
final UdpChannel udpChannelLocalPort = UdpChannel.parse(uri(endpointKey, "192.168.0.1:40456", interfaceKey, "127.0.0.1:40455"));
final UdpChannel udpChannelLocalhost = UdpChannel.parse(uri(endpointKey, "localhost:40456", interfaceKey, "localhost"));
assertThat(udpChannel.canonicalForm(), is("UDP-00000000-0-c0a80001-40456"));
assertThat(udpChannelLocal.canonicalForm(), is("UDP-7f000001-0-c0a80001-40456"));
assertThat(udpChannelLocalPort.canonicalForm(), is("UDP-7f000001-40455-c0a80001-40456"));
assertThat(udpChannelLocalhost.canonicalForm(), is("UDP-7f000001-0-7f000001-40456"));
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class PubAndSubTest method shouldReceivePublishedMessageBatchedWithDataLoss.
@Theory
@Test(timeout = 10000)
public void shouldReceivePublishedMessageBatchedWithDataLoss(final String channel) throws Exception {
final int termBufferLength = 64 * 1024;
final int numMessagesInTermBuffer = 64;
final int messageLength = (termBufferLength / numMessagesInTermBuffer) - HEADER_LENGTH;
final int numMessagesToSend = 2 * numMessagesInTermBuffer;
final int numBatches = 4;
final int numMessagesPerBatch = numMessagesToSend / numBatches;
final LossReport lossReport = mock(LossReport.class);
context.lossReport(lossReport);
final LossGenerator dataLossGenerator = DebugChannelEndpointConfiguration.lossGeneratorSupplier(0.10, 0xcafebabeL);
final LossGenerator noLossGenerator = DebugChannelEndpointConfiguration.lossGeneratorSupplier(0, 0);
context.publicationTermBufferLength(termBufferLength);
context.sendChannelEndpointSupplier((udpChannel, statusIndicator, context) -> new DebugSendChannelEndpoint(udpChannel, statusIndicator, context, noLossGenerator, noLossGenerator));
context.receiveChannelEndpointSupplier((udpChannel, dispatcher, statusIndicator, context) -> new DebugReceiveChannelEndpoint(udpChannel, dispatcher, statusIndicator, context, dataLossGenerator, noLossGenerator));
launch(channel);
Assume.assumeThat(channel, not(IPC_URI));
for (int i = 0; i < numBatches; i++) {
for (int j = 0; j < numMessagesPerBatch; j++) {
while (publication.offer(buffer, 0, messageLength) < 0L) {
Thread.yield();
}
}
final AtomicInteger fragmentsRead = new AtomicInteger();
SystemTestHelper.executeUntil(() -> fragmentsRead.get() >= numMessagesPerBatch, (j) -> {
fragmentsRead.addAndGet(subscription.poll(fragmentHandler, 10));
Thread.yield();
}, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(900));
}
verify(fragmentHandler, times(numMessagesToSend)).onFragment(any(DirectBuffer.class), anyInt(), eq(messageLength), any(Header.class));
verify(lossReport).createEntry(anyLong(), anyLong(), anyInt(), eq(STREAM_ID), anyString(), anyString());
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class PubAndSubTest method shouldContinueAfterBufferRolloverWithPaddingBatched.
@Theory
@Test(timeout = 10000)
public void shouldContinueAfterBufferRolloverWithPaddingBatched(final String channel) throws Exception {
/*
* 65536 bytes in the buffer
* 63 * 1032 = 65016
* 65536 - 65016 = 520 bytes padding at the end
* so, sending 64 messages causes last to overflow
*/
final int termBufferLength = 64 * 1024;
final int messageLength = 1032 - HEADER_LENGTH;
final int numMessagesToSend = 64;
final int numBatchesPerTerm = 4;
final int numMessagesPerBatch = numMessagesToSend / numBatchesPerTerm;
context.publicationTermBufferLength(termBufferLength);
launch(channel);
for (int i = 0; i < numBatchesPerTerm; i++) {
for (int j = 0; j < numMessagesPerBatch; j++) {
while (publication.offer(buffer, 0, messageLength) < 0L) {
Thread.yield();
}
}
final AtomicInteger fragmentsRead = new AtomicInteger();
SystemTestHelper.executeUntil(() -> fragmentsRead.get() >= numMessagesPerBatch, (j) -> {
fragmentsRead.addAndGet(subscription.poll(fragmentHandler, 10));
Thread.yield();
}, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(900));
}
verify(fragmentHandler, times(numMessagesToSend)).onFragment(any(DirectBuffer.class), anyInt(), eq(messageLength), any(Header.class));
}
Aggregations