From 1a217e40e75b6dd46dfd7e7e2f7038e5e204c63d Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 27 May 2021 19:14:02 +0200 Subject: [PATCH] Upgrade to junit5 (#295) Motivation: JUnit 5 is more expressive, extensible, and composable in many ways, and it's better able to run tests in parallel. Modifications: Use JUnit 5 in tests Result: Use JUnit 5 --- pom.xml | 32 +++---- .../codec/quic/AbstractQuicTest.java | 4 +- .../codec/quic/FlushStrategyTest.java | 6 +- .../quic/InsecureQuicTokenHandlerTest.java | 8 +- .../codec/quic/QuicChannelConnectTest.java | 22 +++-- .../codec/quic/QuicChannelDatagramTest.java | 17 ++-- .../codec/quic/QuicChannelEchoTest.java | 87 +++++++++---------- .../codec/quic/QuicConnectionAddressTest.java | 15 ++-- .../quic/QuicConnectionIdGeneratorTest.java | 16 ++-- .../codec/quic/QuicConnectionStatsTest.java | 6 +- .../codec/quic/QuicPacketTypeTest.java | 9 +- .../codec/quic/QuicReadableTest.java | 2 +- .../quic/QuicStreamChannelCloseTest.java | 2 +- .../quic/QuicStreamChannelCreationTest.java | 6 +- .../codec/quic/QuicStreamFrameTest.java | 7 +- .../codec/quic/QuicStreamHalfClosureTest.java | 6 +- .../codec/quic/QuicStreamIdGeneratorTest.java | 4 +- .../codec/quic/QuicStreamLimitTest.java | 4 +- .../codec/quic/QuicStreamTypeTest.java | 9 +- .../netty/incubator/codec/quic/QuicTest.java | 8 +- .../codec/quic/QuicWritableTest.java | 13 +-- .../codec/quic/QuicheQuicCodecTest.java | 10 +-- 22 files changed, 150 insertions(+), 143 deletions(-) diff --git a/pom.xml b/pom.xml index 3e52d29b8..696bdc333 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,7 @@ false 4.1.65.Final 29 + 5.7.0 ${os.detected.name}-${os.detected.arch} netty_quiche_${os.detected.name}_${os.detected.arch} ${project.build.directory}/netty-jni-util/ @@ -646,13 +647,6 @@ false ${test.argLine} - - - org.apache.maven.surefire - surefire-junit4 - 2.22.1 - - @@ -882,9 +876,21 @@ test - junit - junit - 4.13.1 + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} test @@ -905,12 +911,6 @@ 1.1.7 test - - org.apache.maven.surefire - surefire-junit4 - 2.22.1 - test - org.bouncycastle diff --git a/src/test/java/io/netty/incubator/codec/quic/AbstractQuicTest.java b/src/test/java/io/netty/incubator/codec/quic/AbstractQuicTest.java index 10e0f0994..db26d0a8b 100644 --- a/src/test/java/io/netty/incubator/codec/quic/AbstractQuicTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/AbstractQuicTest.java @@ -16,8 +16,8 @@ package io.netty.incubator.codec.quic; import org.junit.Assume; -import org.junit.BeforeClass; import org.junit.Rule; +import org.junit.jupiter.api.BeforeAll; import org.junit.rules.Timeout; public abstract class AbstractQuicTest { @@ -28,7 +28,7 @@ public abstract class AbstractQuicTest { @Rule public final Timeout globalTimeout = Timeout.seconds(TEST_GLOBAL_TIMEOUT_VALUE); - @BeforeClass + @BeforeAll public static void assumeTrue() { Quic.ensureAvailability(); Assume.assumeTrue(Quic.isAvailable()); diff --git a/src/test/java/io/netty/incubator/codec/quic/FlushStrategyTest.java b/src/test/java/io/netty/incubator/codec/quic/FlushStrategyTest.java index 37792f41f..e3b2cf2f1 100644 --- a/src/test/java/io/netty/incubator/codec/quic/FlushStrategyTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/FlushStrategyTest.java @@ -15,10 +15,10 @@ */ package io.netty.incubator.codec.quic; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FlushStrategyTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandlerTest.java b/src/test/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandlerTest.java index a18a4b750..14d9408e9 100644 --- a/src/test/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandlerTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandlerTest.java @@ -17,7 +17,8 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -26,8 +27,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.lessThanOrEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class InsecureQuicTokenHandlerTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicChannelConnectTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicChannelConnectTest.java index dd8f24f90..5736a916b 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicChannelConnectTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicChannelConnectTest.java @@ -29,8 +29,9 @@ import io.netty.util.concurrent.Future; import org.hamcrest.CoreMatchers; import org.hamcrest.Matchers; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; @@ -49,17 +50,19 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class QuicChannelConnectTest extends AbstractQuicTest { - @Test(timeout = 5000) + @Test + @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) public void testConnectAndQLog() throws Throwable { Path path = Files.createTempFile("qlog", ".quic"); assertTrue(path.toFile().delete()); @@ -75,7 +78,8 @@ public void testConnectAndQLog() throws Throwable { }); } - @Test(timeout = 5000) + @Test + @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) public void testConnectAndQLogDir() throws Throwable { Path path = Files.createTempDirectory("qlogdir-"); testQLog(path, p -> { @@ -406,7 +410,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType) } } - @Ignore + @Disabled @Test public void testALPNProtocolMissmatch() throws Throwable { CountDownLatch latch = new CountDownLatch(1); diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicChannelDatagramTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicChannelDatagramTest.java index aa8771f6c..de1235e07 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicChannelDatagramTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicChannelDatagramTest.java @@ -23,11 +23,10 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelOption; -import io.netty.channel.socket.DatagramPacket; import io.netty.util.ReferenceCountUtil; import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.InetSocketAddress; import java.util.Random; @@ -35,9 +34,9 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class QuicChannelDatagramTest extends AbstractQuicTest { @@ -257,12 +256,12 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { // Let's add some sleep in between as this is UDP so we may loose some data otherwise. Thread.sleep(50); } - assertTrue("Server received: " + serverReadCount.get() + - ", Client received: " + clientReadCount.get(), serverPromise.await(3000)); + assertTrue(serverPromise.await(3000), "Server received: " + serverReadCount.get() + + ", Client received: " + clientReadCount.get()); serverPromise.sync(); - assertTrue("Server received: " + serverReadCount.get() + - ", Client received: " + clientReadCount.get(), clientPromise.await(3000)); + assertTrue(clientPromise.await(3000), "Server received: " + serverReadCount.get() + + ", Client received: " + clientReadCount.get()); ByteBuf buffer = clientPromise.get(); ByteBuf expected = Unpooled.wrappedBuffer(data); assertEquals(expected, buffer); diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicChannelEchoTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicChannelEchoTest.java index 08e885927..aef38d90f 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicChannelEchoTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicChannelEchoTest.java @@ -30,9 +30,8 @@ import io.netty.channel.ChannelOption; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.util.concurrent.Future; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import java.io.IOException; import java.net.InetSocketAddress; @@ -43,10 +42,9 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicReference; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(Parameterized.class) public class QuicChannelEchoTest extends AbstractQuicTest { private static final Random random = new Random(); @@ -56,12 +54,6 @@ public class QuicChannelEchoTest extends AbstractQuicTest { random.nextBytes(data); } - private final boolean autoRead; - private final ByteBufAllocator allocator; - private final boolean composite; - - @Parameterized.Parameters(name = - "{index}: autoRead = {0}, directBuffer = {1}, composite = {2}") public static Collection data() { List config = new ArrayList<>(); for (int a = 0; a < 2; a++) { @@ -74,13 +66,16 @@ public static Collection data() { return config; } - public QuicChannelEchoTest(boolean autoRead, boolean directBuffer, boolean composite) { - this.autoRead = autoRead; + private void setAllocator(Channel channel, ByteBufAllocator allocator) { + channel.config().setAllocator(allocator); + } + + private ByteBufAllocator getAllocator(boolean directBuffer) { if (directBuffer) { - allocator = new UnpooledByteBufAllocator(true); + return new UnpooledByteBufAllocator(true); } else { // Force usage of heap buffers and also ensure memoryAddress() is not not supported. - allocator = new AbstractByteBufAllocator(false) { + return new AbstractByteBufAllocator(false) { @Override public ByteBuf ioBuffer() { @@ -113,31 +108,25 @@ public boolean isDirectBufferPooled() { } }; } - this.composite = composite; - } - - private ByteBuf allocateBuffer() { - return allocator.buffer(); } - private void setAllocator(Channel channel) { - channel.config().setAllocator(allocator); - } - - @Test - public void testEchoStartedFromServer() throws Throwable { - final EchoHandler sh = new EchoHandler(true, autoRead); - final EchoHandler ch = new EchoHandler(false, autoRead); + @ParameterizedTest(name = + "{index}: autoRead = {0}, directBuffer = {1}, composite = {2}") + @MethodSource("data") + public void testEchoStartedFromServer(boolean autoRead, boolean directBuffer, boolean composite) throws Throwable { + ByteBufAllocator allocator = getAllocator(directBuffer); + final EchoHandler sh = new EchoHandler(true, autoRead, allocator); + final EchoHandler ch = new EchoHandler(false, autoRead, allocator); AtomicReference> writeFutures = new AtomicReference<>(); Channel server = QuicTestUtils.newServer(new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) { - setAllocator(ctx.channel()); + setAllocator(ctx.channel(), allocator); ((QuicChannel) ctx.channel()).createStream(QuicStreamType.BIDIRECTIONAL, sh) .addListener((Future future) -> { QuicStreamChannel stream = future.getNow(); - setAllocator(stream); - List futures = writeAllData(stream); + setAllocator(stream, allocator); + List futures = writeAllData(stream, composite, allocator); writeFutures.set(futures); }); @@ -154,7 +143,7 @@ public void channelReadComplete(ChannelHandlerContext ctx) { } } }, sh); - setAllocator(server); + setAllocator(server, allocator); InetSocketAddress address = (InetSocketAddress) server.localAddress(); Channel channel = QuicTestUtils.newClient(); QuicChannel quicChannel = null; @@ -220,14 +209,18 @@ public void channelReadComplete(ChannelHandlerContext ctx) { } } - @Test - public void testEchoStartedFromClient() throws Throwable { - final EchoHandler sh = new EchoHandler(true, autoRead); - final EchoHandler ch = new EchoHandler(false, autoRead); + @ParameterizedTest(name = + "{index}: autoRead = {0}, directBuffer = {1}, composite = {2}") + @MethodSource("data") + public void testEchoStartedFromClient(boolean autoRead, boolean directBuffer, boolean composite) throws Throwable { + ByteBufAllocator allocator = getAllocator(directBuffer); + + final EchoHandler sh = new EchoHandler(true, autoRead, allocator); + final EchoHandler ch = new EchoHandler(false, autoRead, allocator); Channel server = QuicTestUtils.newServer(new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) { - setAllocator(ctx.channel()); + setAllocator(ctx.channel(), allocator); ctx.channel().config().setAutoRead(autoRead); if (!autoRead) { ctx.read(); @@ -241,7 +234,7 @@ public void channelReadComplete(ChannelHandlerContext ctx) { } } }, sh); - setAllocator(server); + setAllocator(server, allocator); InetSocketAddress address = (InetSocketAddress) server.localAddress(); Channel channel = QuicTestUtils.newClient(); QuicChannel quicChannel = null; @@ -272,7 +265,7 @@ public void channelReadComplete(ChannelHandlerContext ctx) { .get(); QuicStreamChannel stream = quicChannel.createStream(QuicStreamType.BIDIRECTIONAL, ch).sync().getNow(); - setAllocator(stream); + setAllocator(stream, allocator); assertEquals(QuicStreamType.BIDIRECTIONAL, stream.type()); assertEquals(0, stream.streamId()); @@ -281,7 +274,7 @@ public void channelReadComplete(ChannelHandlerContext ctx) { for (int i = 0; i < 5; i++) { ch.counter = 0; sh.counter = 0; - List futures = writeAllData(stream); + List futures = writeAllData(stream, composite, allocator); for (ChannelFuture f : futures) { f.sync(); @@ -307,12 +300,12 @@ public void channelReadComplete(ChannelHandlerContext ctx) { } } - private List writeAllData(Channel channel) { + private List writeAllData(Channel channel, boolean composite, ByteBufAllocator allocator) { if (composite) { CompositeByteBuf compositeByteBuf = allocator.compositeBuffer(); for (int i = 0; i < data.length;) { int length = Math.min(random.nextInt(1024 * 64), data.length - i); - ByteBuf buf = allocateBuffer().writeBytes(data, i, length); + ByteBuf buf = allocator.buffer().writeBytes(data, i, length); compositeByteBuf.addComponent(true, buf); i += length; } @@ -321,7 +314,7 @@ private List writeAllData(Channel channel) { List futures = new ArrayList<>(); for (int i = 0; i < data.length;) { int length = Math.min(random.nextInt(1024 * 64), data.length - i); - ByteBuf buf = allocateBuffer().writeBytes(data, i, length); + ByteBuf buf = allocator.buffer().writeBytes(data, i, length); futures.add(channel.writeAndFlush(buf)); i += length; } @@ -364,19 +357,21 @@ private static void checkForException(EchoHandler h1, EchoHandler h2) throws Thr private class EchoHandler extends SimpleChannelInboundHandler { private final boolean server; private final boolean autoRead; + private final ByteBufAllocator allocator; volatile Channel channel; final AtomicReference exception = new AtomicReference<>(); volatile int counter; - EchoHandler(boolean server, boolean autoRead) { + EchoHandler(boolean server, boolean autoRead, ByteBufAllocator allocator) { this.server = server; this.autoRead = autoRead; + this.allocator = allocator; } @Override public void channelRegistered(ChannelHandlerContext ctx) { ctx.channel().config().setAutoRead(autoRead); - setAllocator(ctx.channel()); + setAllocator(ctx.channel(), allocator); ctx.fireChannelRegistered(); } diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicConnectionAddressTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicConnectionAddressTest.java index c924120dc..49ed10ced 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicConnectionAddressTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicConnectionAddressTest.java @@ -15,24 +15,25 @@ */ package io.netty.incubator.codec.quic; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.concurrent.ThreadLocalRandom; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class QuicConnectionAddressTest extends AbstractQuicTest { - @Test(expected = NullPointerException.class) + @Test public void testNullByteArray() { - new QuicConnectionAddress((byte[]) null); + assertThrows(NullPointerException.class, () -> new QuicConnectionAddress((byte[]) null)); } - @Test(expected = NullPointerException.class) + @Test public void testNullByteBuffer() { - new QuicConnectionAddress((ByteBuffer) null); + assertThrows(NullPointerException.class, () -> new QuicConnectionAddress((ByteBuffer) null)); } @Test diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicConnectionIdGeneratorTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicConnectionIdGeneratorTest.java index 7ce9f8864..52822e253 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicConnectionIdGeneratorTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicConnectionIdGeneratorTest.java @@ -15,15 +15,16 @@ */ package io.netty.incubator.codec.quic; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.concurrent.ThreadLocalRandom; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class QuicConnectionIdGeneratorTest extends AbstractQuicTest { @@ -51,15 +52,16 @@ public void testRandomness() { assertNotEquals(id, id2); } - @Test(expected = IllegalArgumentException.class) + @Test public void testThrowsIfInputTooBig() { QuicConnectionIdGenerator idGenerator = QuicConnectionIdGenerator.randomGenerator(); - idGenerator.newId(Integer.MAX_VALUE); + assertThrows(IllegalArgumentException.class, () -> idGenerator.newId(Integer.MAX_VALUE)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testThrowsIfInputTooBig2() { QuicConnectionIdGenerator idGenerator = QuicConnectionIdGenerator.randomGenerator(); - idGenerator.newId(ByteBuffer.wrap(new byte[8]), Integer.MAX_VALUE); + assertThrows(IllegalArgumentException.class, () -> + idGenerator.newId(ByteBuffer.wrap(new byte[8]), Integer.MAX_VALUE)); } } diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicConnectionStatsTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicConnectionStatsTest.java index 226718a00..1c3737c4b 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicConnectionStatsTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicConnectionStatsTest.java @@ -23,15 +23,15 @@ import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.atomic.AtomicInteger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; public class QuicConnectionStatsTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicPacketTypeTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicPacketTypeTest.java index a21cad4ec..5e72d7e5b 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicPacketTypeTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicPacketTypeTest.java @@ -15,9 +15,10 @@ */ package io.netty.incubator.codec.quic; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class QuicPacketTypeTest extends AbstractQuicTest { @@ -28,8 +29,8 @@ public void testOfValidType() { } } - @Test(expected = IllegalArgumentException.class) + @Test public void testOfInvalidType() { - QuicPacketType.of((byte) -1); + assertThrows(IllegalArgumentException.class, () -> QuicPacketType.of((byte) -1)); } } diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicReadableTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicReadableTest.java index be17f4500..e8a0dd890 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicReadableTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicReadableTest.java @@ -20,7 +20,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCloseTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCloseTest.java index 96366482f..df2f611f6 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCloseTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCloseTest.java @@ -25,7 +25,7 @@ import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.TimeUnit; diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCreationTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCreationTest.java index 938183012..e2c030a17 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCreationTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicStreamChannelCreationTest.java @@ -16,18 +16,16 @@ package io.netty.incubator.codec.quic; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelOption; import io.netty.util.AttributeKey; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.InetSocketAddress; import java.util.concurrent.CountDownLatch; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; public class QuicStreamChannelCreationTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicStreamFrameTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicStreamFrameTest.java index e87c3ea7e..12a38e5ef 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicStreamFrameTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicStreamFrameTest.java @@ -20,13 +20,14 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.socket.ChannelInputShutdownReadComplete; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class QuicStreamFrameTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicStreamHalfClosureTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicStreamHalfClosureTest.java index 8230b2af7..c043b9346 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicStreamHalfClosureTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicStreamHalfClosureTest.java @@ -23,13 +23,13 @@ import io.netty.channel.socket.ChannelInputShutdownEvent; import io.netty.channel.socket.ChannelInputShutdownReadComplete; import io.netty.util.ReferenceCountUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class QuicStreamHalfClosureTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicStreamIdGeneratorTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicStreamIdGeneratorTest.java index ea3602138..97a9fc057 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicStreamIdGeneratorTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicStreamIdGeneratorTest.java @@ -15,9 +15,9 @@ */ package io.netty.incubator.codec.quic; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class QuicStreamIdGeneratorTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicStreamLimitTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicStreamLimitTest.java index 1448b57d5..237fb95f0 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicStreamLimitTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicStreamLimitTest.java @@ -23,14 +23,14 @@ import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.InetSocketAddress; import java.util.concurrent.CountDownLatch; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class QuicStreamLimitTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicStreamTypeTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicStreamTypeTest.java index ec8db064d..cb1d61d03 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicStreamTypeTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicStreamTypeTest.java @@ -23,13 +23,14 @@ import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; import io.netty.util.concurrent.PromiseNotifier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class QuicStreamTypeTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicTest.java index d43463fd3..1d693b5cb 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicTest.java @@ -23,10 +23,10 @@ import java.util.Map; import java.util.UUID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class QuicTest extends AbstractQuicTest { diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicWritableTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicWritableTest.java index 168f14493..4ec510ab2 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicWritableTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicWritableTest.java @@ -23,16 +23,18 @@ import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; import io.netty.util.concurrent.PromiseNotifier; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.net.InetSocketAddress; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class QuicWritableTest extends AbstractQuicTest { @@ -148,7 +150,8 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { } } - @Test(timeout = 5000) + @Test + @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) public void testBytesUntilUnwritable() throws Throwable { Promise writePromise = ImmediateEventExecutor.INSTANCE.newPromise(); final AtomicReference serverErrorRef = new AtomicReference<>(); diff --git a/src/test/java/io/netty/incubator/codec/quic/QuicheQuicCodecTest.java b/src/test/java/io/netty/incubator/codec/quic/QuicheQuicCodecTest.java index 5f8397f11..4f6c9a511 100644 --- a/src/test/java/io/netty/incubator/codec/quic/QuicheQuicCodecTest.java +++ b/src/test/java/io/netty/incubator/codec/quic/QuicheQuicCodecTest.java @@ -21,15 +21,15 @@ import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.channel.socket.DatagramPacket; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.InetSocketAddress; import java.util.concurrent.atomic.AtomicInteger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public abstract class QuicheQuicCodecTest> extends AbstractQuicTest {