You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/01/12 11:02:17 UTC

[james-project] 18/20: JAMES-2543 Junit 4 -> 5 migration for server/protocols/smtp

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit dd12ea90b025d6e152e53e887734940ccc93fd4c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Dec 31 09:19:21 2020 +0700

    JAMES-2543 Junit 4 -> 5 migration for server/protocols/smtp
---
 .../java/org/apache/james/smtpserver/DSNTest.java  | 30 +++++++++++-----------
 .../smtpserver/POP3BeforeSMTPHandlerTest.java      | 12 ++++-----
 .../apache/james/smtpserver/SMTPServerTest.java    | 16 ++++++------
 .../apache/james/smtpserver/SPFHandlerTest.java    |  6 ++---
 .../apache/james/smtpserver/URIRBLHandlerTest.java |  2 +-
 .../james/smtpserver/ValidRcptHandlerTest.java     |  6 ++---
 .../apache/james/smtpserver/ValidRcptMXTest.java   |  6 ++---
 7 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
index 3c38d88..f3f13cb 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
@@ -75,14 +75,14 @@ import org.apache.mailet.DsnParameters;
 import org.apache.mailet.Mail;
 import org.assertj.core.api.SoftAssertions;
 import org.jboss.netty.util.HashedWheelTimer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 import com.google.inject.TypeLiteral;
 
-public class DSNTest {
+class DSNTest {
     public static final String LOCAL_DOMAIN = "example.local";
     public static final Username BOB = Username.of("bob@localhost");
     public static final String PASSWORD = "bobpwd";
@@ -100,8 +100,8 @@ public class DSNTest {
 
     private SMTPServer smtpServer;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         domainList = new MemoryDomainList(new InMemoryDNSService()
             .registerMxRecord(Domain.LOCALHOST.asString(), "127.0.0.1")
             .registerMxRecord(Domain.LOCALHOST.asString(), "127.0.0.1")
@@ -178,14 +178,14 @@ public class DSNTest {
             .build();
     }
 
-    @After
-    public void tearDown() {
+    @AfterEach
+    void tearDown() {
         smtpServer.destroy();
         hashedWheelTimer.stop();
     }
 
     @Test
-    public void ehloShouldAdvertiseDsnExtension() throws Exception {
+    void ehloShouldAdvertiseDsnExtension() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
             ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
         smtpServer.init();
@@ -211,7 +211,7 @@ public class DSNTest {
     }
 
     @Test
-    public void dsnParametersShouldBeSetOnTheFinalEmail() throws Exception {
+    void dsnParametersShouldBeSetOnTheFinalEmail() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
             ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
         smtpServer.init();
@@ -238,7 +238,7 @@ public class DSNTest {
     }
 
     @Test
-    public void multipleRecipientsShouldBeSupported() throws Exception {
+    void multipleRecipientsShouldBeSupported() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
             ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
         smtpServer.init();
@@ -270,7 +270,7 @@ public class DSNTest {
     }
 
     @Test
-    public void notifyCanBeOmitted() throws Exception {
+    void notifyCanBeOmitted() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
             ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
         smtpServer.init();
@@ -296,7 +296,7 @@ public class DSNTest {
     }
 
     @Test
-    public void orcptCanBeOmitted() throws Exception {
+    void orcptCanBeOmitted() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
             ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
         smtpServer.init();
@@ -322,7 +322,7 @@ public class DSNTest {
     }
 
     @Test
-    public void retCanBeOmitted() throws Exception {
+    void retCanBeOmitted() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
             ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
         smtpServer.init();
@@ -348,7 +348,7 @@ public class DSNTest {
     }
 
     @Test
-    public void envIdCanBeOmitted() throws Exception {
+    void envIdCanBeOmitted() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
             ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
         smtpServer.init();
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java
index 66970a2..dd07d9a 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/POP3BeforeSMTPHandlerTest.java
@@ -26,9 +26,9 @@ import java.time.Duration;
 import org.apache.james.protocols.lib.POP3BeforeSMTPHelper;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class POP3BeforeSMTPHandlerTest {
+class POP3BeforeSMTPHandlerTest {
 
     private SMTPSession mockedSession;
 
@@ -59,7 +59,7 @@ public class POP3BeforeSMTPHandlerTest {
     }
 
     @Test
-    public void testAuthWorks() {
+    void testAuthWorks() {
 
         POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
@@ -72,7 +72,7 @@ public class POP3BeforeSMTPHandlerTest {
     }
 
     @Test
-    public void testIPGetRemoved() {
+    void testIPGetRemoved() {
         long sleepTime = 100;
         POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
@@ -92,7 +92,7 @@ public class POP3BeforeSMTPHandlerTest {
     }
 
     @Test
-    public void testThrowExceptionOnIllegalExpireTime() {
+    void testThrowExceptionOnIllegalExpireTime() {
         boolean exception = false;
         POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
@@ -107,7 +107,7 @@ public class POP3BeforeSMTPHandlerTest {
     }
 
     @Test
-    public void testValidExpireTime() {
+    void testValidExpireTime() {
         boolean exception = false;
         POP3BeforeSMTPHandler handler = new POP3BeforeSMTPHandler();
 
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index 9d99f15..953068b 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -87,10 +87,10 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.memory.MemoryUsersRepository;
 import org.apache.mailet.Mail;
 import org.jboss.netty.util.HashedWheelTimer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -207,7 +207,7 @@ public class SMTPServerTest {
 
     private SMTPServer smtpServer;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
 
         domainList = new MemoryDomainList(new InMemoryDNSService()
@@ -369,8 +369,8 @@ public class SMTPServerTest {
         }
     }
 
-    @After
-    public void tearDown() throws Exception {
+    @AfterEach
+    public void tearDown() {
         smtpServer.destroy();
         hashedWheelTimer.stop();
     }
@@ -640,7 +640,7 @@ public class SMTPServerTest {
     }
 
     // FIXME
-    @Ignore
+    @Disabled
     @Test
     public void testEmptyMessageReceivedHeader() throws Exception {
         init(smtpConfiguration);
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
index 9349d6d..613906a 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
@@ -34,8 +34,8 @@ import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
 import org.apache.james.smtpserver.fastfail.SPFHandler;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.base.Preconditions;
 
@@ -46,7 +46,7 @@ public class SPFHandlerTest {
 
     private boolean relaying = false;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         setupMockedDnsService();
         setRelayingAllowed(false);
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/URIRBLHandlerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/URIRBLHandlerTest.java
index af14370..acda4bb 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/URIRBLHandlerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/URIRBLHandlerTest.java
@@ -45,7 +45,7 @@ import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
 import org.apache.james.smtpserver.fastfail.URIRBLHandler;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.base.Preconditions;
 
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
index 5065bc6..8bbb2a0 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
@@ -41,8 +41,8 @@ import org.apache.james.rrt.memory.MemoryRecipientRewriteTable;
 import org.apache.james.smtpserver.fastfail.ValidRcptHandler;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.memory.MemoryUsersRepository;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeEach;
 
 import com.google.common.base.Preconditions;
 
@@ -62,7 +62,7 @@ public class ValidRcptHandlerTest {
     private MailAddress user1mail;
     private MailAddress invalidUserEmail;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         MemoryDomainList memoryDomainList = new MemoryDomainList(mock(DNSService.class));
         memoryDomainList.configure(DomainListConfiguration.builder()
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
index ee29e3f..0a6da3c 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
@@ -31,12 +31,12 @@ import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.utils.BaseFakeSMTPSession;
 import org.apache.james.smtpserver.fastfail.ValidRcptMX;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
-public class ValidRcptMXTest {
+class ValidRcptMXTest {
 
     private static final String INVALID_HOST = "invalid.host.de";
 
@@ -81,7 +81,7 @@ public class ValidRcptMXTest {
     }
 
     @Test
-    public void testRejectLoopbackMX() throws Exception {
+    void testRejectLoopbackMX() throws Exception {
         String bannedAddress = "172.53.64.2";
 
         DNSService dns = new InMemoryDNSService()


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org