use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class RetransmitHandlerTest method shouldRetransmitOnMultipleNaks.
@Theory
public void shouldRetransmitOnMultipleNaks(final BiConsumer<RetransmitHandlerTest, Integer> creator) {
createTermBuffer(creator, 5);
handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH, TERM_BUFFER_LENGTH, retransmitSender);
handler.onNak(TERM_ID, offsetOfFrame(1), ALIGNED_FRAME_LENGTH, TERM_BUFFER_LENGTH, retransmitSender);
currentTime = TimeUnit.MILLISECONDS.toNanos(100);
handler.processTimeouts(currentTime, retransmitSender);
final InOrder inOrder = inOrder(retransmitSender);
inOrder.verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
inOrder.verify(retransmitSender).resend(TERM_ID, offsetOfFrame(1), ALIGNED_FRAME_LENGTH);
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class RetransmitHandlerTest method shouldRetransmitOnNakOverMtuLength.
@Theory
public void shouldRetransmitOnNakOverMtuLength(final BiConsumer<RetransmitHandlerTest, Integer> creator) {
final int numFramesPerMtu = MTU_LENGTH / ALIGNED_FRAME_LENGTH;
createTermBuffer(creator, numFramesPerMtu * 5);
handler.onNak(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2, TERM_BUFFER_LENGTH, retransmitSender);
currentTime = TimeUnit.MILLISECONDS.toNanos(100);
handler.processTimeouts(currentTime, retransmitSender);
verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2);
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class BufferClaimMessageTest method shouldReceivePublishedMessageWithInterleavedAbort.
@Theory
@Test(timeout = 10000)
public void shouldReceivePublishedMessageWithInterleavedAbort(final String channel) throws Exception {
final BufferClaim bufferClaim = new BufferClaim();
final UnsafeBuffer srcBuffer = new UnsafeBuffer(ByteBuffer.allocateDirect(MESSAGE_LENGTH));
final MediaDriver.Context ctx = new MediaDriver.Context();
try (MediaDriver ignore = MediaDriver.launch(ctx);
Aeron aeron = Aeron.connect();
Publication publication = aeron.addPublication(channel, STREAM_ID);
Subscription subscription = aeron.addSubscription(channel, STREAM_ID)) {
publishMessage(srcBuffer, publication);
while (publication.tryClaim(MESSAGE_LENGTH, bufferClaim) < 0L) {
Thread.yield();
}
publishMessage(srcBuffer, publication);
bufferClaim.abort();
final int expectedNumberOfFragments = 2;
int numFragments = 0;
do {
numFragments += subscription.poll(mockFragmentHandler, FRAGMENT_COUNT_LIMIT);
} while (numFragments < expectedNumberOfFragments);
verify(mockFragmentHandler, times(expectedNumberOfFragments)).onFragment(any(DirectBuffer.class), anyInt(), eq(MESSAGE_LENGTH), any(Header.class));
} finally {
ctx.deleteAeronDirectory();
}
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class UdpChannelTest method shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri.
@Theory
public void shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost"));
final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.1"));
final UdpChannel udpChannelAllSystems = UdpChannel.parse(uri(endpointKey, "224.0.0.1:40456", interfaceKey, "127.0.0.1"));
final UdpChannel udpChannelDefault = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456"));
final UdpChannel udpChannelSubnet = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost/24"));
final UdpChannel udpChannelSubnetLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.0/24"));
assertThat(udpChannel.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
assertThat(udpChannelLocal.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
assertThat(udpChannelAllSystems.canonicalForm(), is("UDP-7f000001-0-e0000001-40456"));
assertThat(udpChannelSubnet.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
assertThat(udpChannelSubnetLocal.canonicalForm(), is("UDP-7f000001-0-e0000101-40456"));
assertThat(udpChannelDefault.localInterface(), supportsMulticastOrIsLoopback());
}
use of org.junit.experimental.theories.Theory 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"));
}
Aggregations