diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java index 77514ffd63..888502b187 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexCodecBuilderTest.java @@ -32,7 +32,7 @@ import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalChannel; import io.netty.channel.local.LocalHandler; import io.netty.channel.local.LocalServerChannel; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -124,7 +124,7 @@ public class Http2MultiplexCodecBuilderTest { assertTrue(serverChannelLatch.await(5, SECONDS)); } - @AfterClass + @AfterAll public static void shutdown() { group.shutdownGracefully(0, 5, SECONDS); } diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java index eb0150006d..05602fcb5c 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2TestUtil.java @@ -43,8 +43,8 @@ import static io.netty.handler.codec.http2.Http2CodecUtil.MAX_HEADER_LIST_SIZE; import static io.netty.handler.codec.http2.Http2CodecUtil.MAX_HEADER_TABLE_SIZE; import static io.netty.util.ReferenceCountUtil.release; import static java.lang.Math.min; -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; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyByte; diff --git a/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttTestUtils.java b/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttTestUtils.java index 0d530e83f8..cf470aea5f 100644 --- a/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttTestUtils.java +++ b/codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttTestUtils.java @@ -22,10 +22,10 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; public final class MqttTestUtils { private MqttTestUtils() { @@ -48,7 +48,7 @@ public final class MqttTestUtils { case SHARED_SUBSCRIPTION_AVAILABLE: { final Integer expectedValue = ((MqttProperties.IntegerProperty) expectedProperty).value; final Integer actualValue = ((MqttProperties.IntegerProperty) actualProperty).value; - assertEquals("one byte property doesn't match", expectedValue, actualValue); + assertEquals(expectedValue, actualValue, "one byte property doesn't match"); break; } // two byte value integer property @@ -58,7 +58,7 @@ public final class MqttTestUtils { case TOPIC_ALIAS: { final Integer expectedValue = ((MqttProperties.IntegerProperty) expectedProperty).value; final Integer actualValue = ((MqttProperties.IntegerProperty) actualProperty).value; - assertEquals("two byte property doesn't match", expectedValue, actualValue); + assertEquals(expectedValue, actualValue, "two byte property doesn't match"); break; } // four byte value integer property @@ -68,7 +68,7 @@ public final class MqttTestUtils { case MAXIMUM_PACKET_SIZE: { final Integer expectedValue = ((MqttProperties.IntegerProperty) expectedProperty).value; final Integer actualValue = ((MqttProperties.IntegerProperty) actualProperty).value; - assertEquals("four byte property doesn't match", expectedValue, actualValue); + assertEquals(expectedValue, actualValue, "four byte property doesn't match"); break; } // four byte value integer property @@ -87,7 +87,7 @@ public final class MqttTestUtils { case REASON_STRING: { final String expectedValue = ((MqttProperties.StringProperty) expectedProperty).value; final String actualValue = ((MqttProperties.StringProperty) actualProperty).value; - assertEquals("String property doesn't match", expectedValue, actualValue); + assertEquals(expectedValue, actualValue, "String property doesn't match"); break; } // User property @@ -96,9 +96,9 @@ public final class MqttTestUtils { ((MqttProperties.UserProperties) expectedProperty).value; final List actualPairs = ((MqttProperties.UserProperties) actualProperty).value; - assertEquals("User properties count doesn't match", expectedPairs, actualPairs); + assertEquals(expectedPairs, actualPairs, "User properties count doesn't match"); for (int i = 0; i < expectedPairs.size(); i++) { - assertEquals("User property mismatch", expectedPairs.get(i), actualPairs.get(i)); + assertEquals(expectedPairs.get(i), actualPairs.get(i), "User property mismatch"); } break; } @@ -109,7 +109,7 @@ public final class MqttTestUtils { final byte[] actualValue = ((MqttProperties.BinaryProperty) actualProperty).value; final String expectedHexDump = ByteBufUtil.hexDump(expectedValue); final String actualHexDump = ByteBufUtil.hexDump(actualValue); - assertEquals("byte[] property doesn't match", expectedHexDump, actualHexDump); + assertEquals(expectedHexDump, actualHexDump, "byte[] property doesn't match"); break; } default: @@ -118,7 +118,7 @@ public final class MqttTestUtils { } for (MqttProperties.MqttProperty actualProperty : actual.listAll()) { MqttProperties.MqttProperty expectedProperty = expected.getProperty(actualProperty.propertyId); - assertNotNull("Property " + actualProperty.propertyId + " not expected", expectedProperty); + assertNotNull(expectedProperty, "Property " + actualProperty.propertyId + " not expected"); } } @@ -139,9 +139,9 @@ public final class MqttTestUtils { List actualTopicSubscriptions = actual.topicSubscriptions(); assertEquals( - "MqttSubscribePayload TopicSubscriptionList size mismatch ", expectedTopicSubscriptions.size(), - actualTopicSubscriptions.size()); + actualTopicSubscriptions.size(), + "MqttSubscribePayload TopicSubscriptionList size mismatch"); for (int i = 0; i < expectedTopicSubscriptions.size(); i++) { validateTopicSubscription(expectedTopicSubscriptions.get(i), actualTopicSubscriptions.get(i)); } @@ -150,21 +150,21 @@ public final class MqttTestUtils { public static void validateTopicSubscription( MqttTopicSubscription expected, MqttTopicSubscription actual) { - assertEquals("MqttTopicSubscription TopicName mismatch ", expected.topicName(), actual.topicName()); + assertEquals(expected.topicName(), actual.topicName(), "MqttTopicSubscription TopicName mismatch"); assertEquals( - "MqttTopicSubscription Qos mismatch ", expected.qualityOfService(), - actual.qualityOfService()); + actual.qualityOfService(), + "MqttTopicSubscription Qos mismatch"); assertEquals( - "MqttTopicSubscription options mismatch ", expected.option(), - actual.option()); + actual.option(), + "MqttTopicSubscription options mismatch"); } public static void validateUnsubscribePayload(MqttUnsubscribePayload expected, MqttUnsubscribePayload actual) { assertArrayEquals( - "MqttUnsubscribePayload TopicList mismatch ", expected.topics().toArray(), - actual.topics().toArray()); + actual.topics().toArray(), + "MqttUnsubscribePayload TopicList mismatch"); } } diff --git a/microbench/src/main/java/io/netty/microbench/handler/ssl/AbstractSslHandlerBenchmark.java b/microbench/src/main/java/io/netty/microbench/handler/ssl/AbstractSslHandlerBenchmark.java index e9eea75df2..974899831c 100644 --- a/microbench/src/main/java/io/netty/microbench/handler/ssl/AbstractSslHandlerBenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/handler/ssl/AbstractSslHandlerBenchmark.java @@ -34,7 +34,6 @@ import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; import static io.netty.handler.codec.ByteToMessageDecoder.COMPOSITE_CUMULATOR; -import static org.junit.Assert.assertNull; public class AbstractSslHandlerBenchmark extends AbstractMicrobenchmark { private static final String PROTOCOL_TLS_V1_2 = "TLSv1.2"; @@ -176,6 +175,8 @@ public class AbstractSslHandlerBenchmark extends AbstractMicrobenchmark { } public static void handleUnexpectedException(Throwable t) { - assertNull(t); + if (t != null) { + throw new IllegalStateException(t); + } } } diff --git a/microbench/src/main/java/io/netty/microbench/util/AbstractSharedExecutorMicrobenchmark.java b/microbench/src/main/java/io/netty/microbench/util/AbstractSharedExecutorMicrobenchmark.java index a86eec88c1..40d7c6db1a 100644 --- a/microbench/src/main/java/io/netty/microbench/util/AbstractSharedExecutorMicrobenchmark.java +++ b/microbench/src/main/java/io/netty/microbench/util/AbstractSharedExecutorMicrobenchmark.java @@ -15,7 +15,6 @@ */ package io.netty.microbench.util; -import static org.junit.Assert.assertNull; import io.netty.channel.EventLoop; import io.netty.util.concurrent.AbstractEventExecutor; import io.netty.util.concurrent.Future; @@ -166,6 +165,8 @@ public class AbstractSharedExecutorMicrobenchmark extends AbstractMicrobenchmark } public static void handleUnexpectedException(Throwable t) { - assertNull(t); + if (t != null) { + throw new IllegalStateException(t); + } } } diff --git a/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastIPv6Test.java b/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastIPv6Test.java index 5ffa6e72c0..2ab4b6b97e 100644 --- a/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastIPv6Test.java +++ b/testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramUnicastIPv6Test.java @@ -16,7 +16,7 @@ package io.netty.testsuite.transport.socket; import io.netty.channel.socket.InternetProtocolFamily; -import org.junit.Assume; +import org.junit.AssumptionViolatedException; import org.junit.jupiter.api.BeforeAll; import java.io.IOException; @@ -32,7 +32,7 @@ public class DatagramUnicastIPv6Test extends DatagramUnicastInetTest { Channel channel = SelectorProvider.provider().openDatagramChannel(StandardProtocolFamily.INET6); channel.close(); } catch (UnsupportedOperationException e) { - Assume.assumeNoException("IPv6 not supported", e); + throw new AssumptionViolatedException("IPv6 not supported", e); } catch (IOException ignore) { // Ignore }