diff --git a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpCommandTest.java b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpCommandTest.java index 3458a78e9d..c53b9d1158 100644 --- a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpCommandTest.java +++ b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpCommandTest.java @@ -15,9 +15,13 @@ */ package io.netty.handler.codec.smtp; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SmtpCommandTest { @Test diff --git a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java index dab4dd5309..7c9e056fbc 100644 --- a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java +++ b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java @@ -20,11 +20,13 @@ import io.netty.buffer.Unpooled; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.EncoderException; import io.netty.util.CharsetUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SmtpRequestEncoderTest { @@ -106,12 +108,17 @@ public class SmtpRequestEncoderTest { assertEquals("DATA\r\nSubject: Test\r\n\r\nTest\r\n.\r\n", getWrittenString(channel)); } - @Test(expected = EncoderException.class) + @Test public void testThrowsIfContentExpected() { - EmbeddedChannel channel = new EmbeddedChannel(new SmtpRequestEncoder()); + final EmbeddedChannel channel = new EmbeddedChannel(new SmtpRequestEncoder()); try { assertTrue(channel.writeOutbound(SmtpRequests.data())); - channel.writeOutbound(SmtpRequests.noop()); + assertThrows(EncoderException.class, new Executable() { + @Override + public void execute() { + channel.writeOutbound(SmtpRequests.noop()); + } + }); } finally { channel.finishAndReleaseAll(); } diff --git a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpResponseDecoderTest.java b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpResponseDecoderTest.java index 50846d8de0..5f5918d57c 100644 --- a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpResponseDecoderTest.java +++ b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpResponseDecoderTest.java @@ -20,11 +20,16 @@ import io.netty.buffer.Unpooled; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.DecoderException; import io.netty.util.CharsetUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SmtpResponseDecoderTest { @@ -106,22 +111,37 @@ public class SmtpResponseDecoderTest { assertNull(channel.readInbound()); } - @Test(expected = DecoderException.class) + @Test public void testDecodeInvalidSeparator() { - EmbeddedChannel channel = newChannel(); - assertTrue(channel.writeInbound(newBuffer("200:Ok\r\n"))); + final EmbeddedChannel channel = newChannel(); + assertThrows(DecoderException.class, new Executable() { + @Override + public void execute() { + channel.writeInbound(newBuffer("200:Ok\r\n")); + } + }); } - @Test(expected = DecoderException.class) + @Test public void testDecodeInvalidCode() { - EmbeddedChannel channel = newChannel(); - assertTrue(channel.writeInbound(newBuffer("xyz Ok\r\n"))); + final EmbeddedChannel channel = newChannel(); + assertThrows(DecoderException.class, new Executable() { + @Override + public void execute() { + channel.writeInbound(newBuffer("xyz Ok\r\n")); + } + }); } - @Test(expected = DecoderException.class) + @Test public void testDecodeInvalidLine() { - EmbeddedChannel channel = newChannel(); - assertTrue(channel.writeInbound(newBuffer("Ok\r\n"))); + final EmbeddedChannel channel = newChannel(); + assertThrows(DecoderException.class, new Executable() { + @Override + public void execute() { + channel.writeInbound(newBuffer("Ok\r\n")); + } + }); } private static EmbeddedChannel newChannel() {