You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/02/09 04:29:38 UTC
[james-project] 10/33: [REFACTORING] Get rid of some JUNIT 4 usages
in mailetcontainer-camel tests
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ecee174e344836c92505de58ee90e25a730a244c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 12:27:02 2021 +0700
[REFACTORING] Get rid of some JUNIT 4 usages in mailetcontainer-camel tests
---
.../AutomaticallySentMailDetectorImplTest.java | 57 ++++++------
.../impl/JamesMailetContextTest.java | 102 ++++++++++-----------
.../mailetcontainer/impl/MailetConfigImplTest.java | 20 ++--
.../mailetcontainer/impl/matchers/AndTest.java | 21 ++---
.../mailetcontainer/impl/matchers/NotTest.java | 21 ++---
.../mailetcontainer/impl/matchers/OrTest.java | 21 ++---
.../mailetcontainer/impl/matchers/XorTest.java | 24 +++--
.../lib/AbstractStateCompositeProcessorTest.java | 8 +-
.../lib/AbstractStateMailetProcessorTest.java | 2 +-
9 files changed, 130 insertions(+), 146 deletions(-)
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java
index 52d0071..8996565 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/AutomaticallySentMailDetectorImplTest.java
@@ -36,14 +36,13 @@ import org.apache.james.core.builder.MimeMessageBuilder;
import org.apache.james.util.MimeMessageUtil;
import org.apache.mailet.base.MailAddressFixture;
import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.google.common.base.Joiner;
-public class AutomaticallySentMailDetectorImplTest {
-
+class AutomaticallySentMailDetectorImplTest {
@Test
- public void nullSenderMailsShouldBeConsideredAsAutomaticMails() throws Exception {
+ void nullSenderMailsShouldBeConsideredAsAutomaticMails() throws Exception {
assertThat(
new AutomaticallySentMailDetectorImpl()
.isAutomaticallySent(FakeMail.builder()
@@ -53,7 +52,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void nonNullSenderMailsShouldNotBeConsideredAsAutomaticMails() throws Exception {
+ void nonNullSenderMailsShouldNotBeConsideredAsAutomaticMails() throws Exception {
assertThat(
new AutomaticallySentMailDetectorImpl()
.isAutomaticallySent(FakeMail.builder()
@@ -66,7 +65,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void ownerIsAMailingListPrefix() throws Exception {
+ void ownerIsAMailingListPrefix() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("owner-list@any.com")
@@ -76,7 +75,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void requestIsAMailingListPrefix() throws Exception {
+ void requestIsAMailingListPrefix() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("list-request@any.com")
@@ -86,7 +85,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void mailerDaemonIsReserved() throws Exception {
+ void mailerDaemonIsReserved() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("MAILER-DAEMON@any.com")
@@ -96,7 +95,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listservIsReserved() throws Exception {
+ void listservIsReserved() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("LISTSERV@any.com")
@@ -106,7 +105,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void majordomoIsReserved() throws Exception {
+ void majordomoIsReserved() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("majordomo@any.com")
@@ -116,7 +115,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listIdShouldBeDetected() throws Exception {
+ void listIdShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -128,7 +127,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listHelpShouldBeDetected() throws Exception {
+ void listHelpShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -140,7 +139,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listSubscribeShouldBeDetected() throws Exception {
+ void listSubscribeShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -152,7 +151,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listUnsubscribeShouldBeDetected() throws Exception {
+ void listUnsubscribeShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -164,7 +163,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listPostShouldBeDetected() throws Exception {
+ void listPostShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -176,7 +175,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listOwnerShouldBeDetected() throws Exception {
+ void listOwnerShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -189,7 +188,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void listArchiveShouldBeDetected() throws Exception {
+ void listArchiveShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -202,7 +201,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void normalMailShouldNotBeIdentifiedAsMailingList() throws Exception {
+ void normalMailShouldNotBeIdentifiedAsMailingList() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -213,7 +212,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isAutoSubmittedShouldNotMatchNonAutoSubmittedMails() throws Exception {
+ void isAutoSubmittedShouldNotMatchNonAutoSubmittedMails() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
@@ -223,7 +222,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isAutoSubmittedShouldBeDetected() throws Exception {
+ void isAutoSubmittedShouldBeDetected() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -235,7 +234,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isAutoSubmittedShouldBeDetectedWhenAutoGenerated() throws Exception {
+ void isAutoSubmittedShouldBeDetectedWhenAutoGenerated() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -247,7 +246,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isAutoSubmittedShouldBeDetectedWhenAutoNotified() throws Exception {
+ void isAutoSubmittedShouldBeDetectedWhenAutoNotified() throws Exception {
FakeMail fakeMail = FakeMail.builder()
.name("mail")
.sender("any@any.com")
@@ -259,7 +258,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isMdnSentAutomaticallyShouldBeDetected() throws Exception {
+ void isMdnSentAutomaticallyShouldBeDetected() throws Exception {
MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
MimeMultipart multipart = new MimeMultipart();
MimeBodyPart scriptPart = new MimeBodyPart();
@@ -287,7 +286,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isMdnSentAutomaticallyShouldNotFilterManuallySentMdn() throws Exception {
+ void isMdnSentAutomaticallyShouldNotFilterManuallySentMdn() throws Exception {
MimeMessage message = MimeMessageUtil.defaultMimeMessage();
MimeMultipart multipart = new MimeMultipart();
MimeBodyPart scriptPart = new MimeBodyPart();
@@ -315,7 +314,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isMdnSentAutomaticallyShouldManageItsMimeType() throws Exception {
+ void isMdnSentAutomaticallyShouldManageItsMimeType() throws Exception {
MimeMessage message = MimeMessageUtil.defaultMimeMessage();
MimeMultipart multipart = new MimeMultipart();
MimeBodyPart scriptPart = new MimeBodyPart();
@@ -340,7 +339,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isMdnSentAutomaticallyShouldNotThrowOnBodyPartsWithManyLines() throws Exception {
+ void isMdnSentAutomaticallyShouldNotThrowOnBodyPartsWithManyLines() throws Exception {
int mime4jDefaultMaxHeaderCount = 1000;
int headerCount = mime4jDefaultMaxHeaderCount + 10;
MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
@@ -359,7 +358,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isMdnSentAutomaticallyShouldNotThrowWhenBiggerThan1MB() throws Exception {
+ void isMdnSentAutomaticallyShouldNotThrowWhenBiggerThan1MB() throws Exception {
MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
.addHeaders()
.setMultipartWithBodyParts(
@@ -378,8 +377,7 @@ public class AutomaticallySentMailDetectorImplTest {
}
@Test
- public void isMdnSentAutomaticallyShouldDetectBigMDN() throws Exception {
-
+ void isMdnSentAutomaticallyShouldDetectBigMDN() throws Exception {
MimeMessage message = MimeMessageUtil.defaultMimeMessage();
MimeMultipart multipart = new MimeMultipart();
MimeBodyPart scriptPart = new MimeBodyPart();
@@ -409,5 +407,4 @@ public class AutomaticallySentMailDetectorImplTest {
assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isTrue();
}
-
}
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
index 22e14fb..c0a0d1b 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/JamesMailetContextTest.java
@@ -54,23 +54,19 @@ import org.apache.james.util.MimeMessageUtil;
import org.apache.mailet.Mail;
import org.apache.mailet.base.MailAddressFixture;
import org.apache.mailet.base.test.FakeMail;
-import org.assertj.core.api.JUnitSoftAssertions;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import com.google.common.collect.ImmutableList;
-public class JamesMailetContextTest {
+class JamesMailetContextTest {
private static final Domain DOMAIN_COM = Domain.of("domain.com");
private static final String USERNAME = "user";
private static final Username USERMAIL = Username.of(USERNAME + "@" + DOMAIN_COM.name());
private static final String PASSWORD = "password";
private static final DNSService DNS_SERVICE = null;
-
- @Rule
- public final JUnitSoftAssertions softly = new JUnitSoftAssertions();
private MemoryDomainList domainList;
private MemoryUsersRepository usersRepository;
@@ -79,9 +75,9 @@ public class JamesMailetContextTest {
private MailQueue spoolMailQueue;
private MemoryRecipientRewriteTable recipientRewriteTable;
- @Before
+ @BeforeEach
@SuppressWarnings("unchecked")
- public void setUp() throws Exception {
+ void setUp() throws Exception {
domainList = spy(new MemoryDomainList(DNS_SERVICE));
domainList.configure(DomainListConfiguration.DEFAULT);
@@ -99,17 +95,17 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalUserShouldBeFalseOnNullUser() {
+ void isLocalUserShouldBeFalseOnNullUser() {
assertThat(testee.isLocalUser(null)).isFalse();
}
@Test
- public void isLocalServerShouldBeFalseWhenDomainDoNotExist() {
+ void isLocalServerShouldBeFalseWhenDomainDoNotExist() {
assertThat(testee.isLocalServer(DOMAIN_COM)).isFalse();
}
@Test
- public void isLocalServerShouldPropagateDomainExceptions() throws Exception {
+ void isLocalServerShouldPropagateDomainExceptions() throws Exception {
when(domainList.getDomains()).thenThrow(new DomainListException("fail!"));
assertThatThrownBy(() -> testee.isLocalServer(DOMAIN_COM))
@@ -117,7 +113,7 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalUserShouldPropagateDomainExceptions() throws Exception {
+ void isLocalUserShouldPropagateDomainExceptions() throws Exception {
when(domainList.getDefaultDomain()).thenThrow(new DomainListException("fail!"));
assertThatThrownBy(() -> testee.isLocalUser("user"))
@@ -125,7 +121,7 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalUserShouldPropagateUserExceptions() throws Exception {
+ void isLocalUserShouldPropagateUserExceptions() throws Exception {
domainList.configure(DomainListConfiguration.builder()
.defaultDomain(Domain.of("any"))
.build());
@@ -138,7 +134,7 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalUserShouldPropagateRrtExceptions() throws Exception {
+ void isLocalUserShouldPropagateRrtExceptions() throws Exception {
domainList.configure(DomainListConfiguration.builder()
.defaultDomain(Domain.of("any"))
.build());
@@ -151,14 +147,14 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalServerShouldBeTrueWhenDomainExist() throws Exception {
+ void isLocalServerShouldBeTrueWhenDomainExist() throws Exception {
domainList.addDomain(DOMAIN_COM);
assertThat(testee.isLocalServer(DOMAIN_COM)).isTrue();
}
@Test
- public void isLocalUserShouldBeTrueWhenUsernameExist() throws Exception {
+ void isLocalUserShouldBeTrueWhenUsernameExist() throws Exception {
domainList.addDomain(DOMAIN_COM);
usersRepository.addUser(USERMAIL, PASSWORD);
@@ -166,7 +162,7 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalUserShouldReturnTrueWhenUsedWithLocalPartAndUserExistOnDefaultDomain() throws Exception {
+ void isLocalUserShouldReturnTrueWhenUsedWithLocalPartAndUserExistOnDefaultDomain() throws Exception {
domainList.configure(DomainListConfiguration.builder()
.defaultDomain(DOMAIN_COM)
.build());
@@ -177,7 +173,7 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalUserShouldReturnFalseWhenUsedWithLocalPartAndUserDoNotExistOnDefaultDomain() throws Exception {
+ void isLocalUserShouldReturnFalseWhenUsedWithLocalPartAndUserDoNotExistOnDefaultDomain() throws Exception {
domainList.configure(DomainListConfiguration.builder()
.defaultDomain(Domain.of("any"))
.build());
@@ -189,24 +185,24 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalUserShouldBeFalseWhenUsernameDoNotExist() {
+ void isLocalUserShouldBeFalseWhenUsernameDoNotExist() {
assertThat(testee.isLocalUser(USERMAIL.asString())).isFalse();
}
@Test
- public void isLocalEmailShouldBeFalseWhenUsernameDoNotExist() {
+ void isLocalEmailShouldBeFalseWhenUsernameDoNotExist() {
assertThat(testee.isLocalEmail(mailAddress)).isFalse();
}
@Test
- public void isLocalEmailShouldBeFalseWhenUsernameDoNotExistButDomainExists() throws Exception {
+ void isLocalEmailShouldBeFalseWhenUsernameDoNotExistButDomainExists() throws Exception {
domainList.addDomain(DOMAIN_COM);
assertThat(testee.isLocalEmail(mailAddress)).isFalse();
}
@Test
- public void isLocalEmailShouldBeTrueWhenUsernameExists() throws Exception {
+ void isLocalEmailShouldBeTrueWhenUsernameExists() throws Exception {
domainList.addDomain(DOMAIN_COM);
usersRepository.addUser(USERMAIL, PASSWORD);
@@ -214,7 +210,7 @@ public class JamesMailetContextTest {
}
@Test
- public void localRecipientsShouldReturnAddressWhenUserExists() throws Exception {
+ void localRecipientsShouldReturnAddressWhenUserExists() throws Exception {
domainList.addDomain(DOMAIN_COM);
usersRepository.addUser(USERMAIL, PASSWORD);
@@ -222,7 +218,7 @@ public class JamesMailetContextTest {
}
@Test
- public void localRecipientsShouldReturnOnlyExistingUsers() throws Exception {
+ void localRecipientsShouldReturnOnlyExistingUsers() throws Exception {
domainList.addDomain(DOMAIN_COM);
usersRepository.addUser(USERMAIL, PASSWORD);
@@ -233,24 +229,24 @@ public class JamesMailetContextTest {
}
@Test
- public void localRecipientsShouldNotReturnAddressWhenUserDoNotExists() throws Exception {
+ void localRecipientsShouldNotReturnAddressWhenUserDoNotExists() throws Exception {
domainList.addDomain(DOMAIN_COM);
assertThat(testee.localRecipients(ImmutableList.of(mailAddress))).isEmpty();
}
@Test
- public void localRecipientsShouldNotReturnAddressWhenDomainDoNotExists() throws Exception {
+ void localRecipientsShouldNotReturnAddressWhenDomainDoNotExists() throws Exception {
assertThat(testee.localRecipients(ImmutableList.of(mailAddress))).isEmpty();
}
@Test
- public void isLocalEmailShouldBeFalseWhenMailIsNull() {
+ void isLocalEmailShouldBeFalseWhenMailIsNull() {
assertThat(testee.isLocalEmail(null)).isFalse();
}
@Test
- public void isLocalEmailShouldPropagateDomainExceptions() throws Exception {
+ void isLocalEmailShouldPropagateDomainExceptions() throws Exception {
when(domainList.getDomains()).thenThrow(new DomainListException("fail!"));
assertThatThrownBy(() -> testee.isLocalEmail(mailAddress))
@@ -258,7 +254,7 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalEmailShouldPropagateUserExceptions() throws Exception {
+ void isLocalEmailShouldPropagateUserExceptions() throws Exception {
domainList.configure(DomainListConfiguration.builder()
.defaultDomain(Domain.of("any"))
.build());
@@ -271,7 +267,7 @@ public class JamesMailetContextTest {
}
@Test
- public void isLocalEmailShouldPropagateRrtExceptions() throws Exception {
+ void isLocalEmailShouldPropagateRrtExceptions() throws Exception {
domainList.configure(DomainListConfiguration.builder()
.defaultDomain(Domain.of("any"))
.build());
@@ -284,7 +280,7 @@ public class JamesMailetContextTest {
}
@Test
- public void bounceShouldNotFailWhenNonConfiguredPostmaster() throws Exception {
+ void bounceShouldNotFailWhenNonConfiguredPostmaster() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.sender(mailAddress)
@@ -295,7 +291,7 @@ public class JamesMailetContextTest {
}
@Test
- public void bouncingToNullSenderShouldBeANoop() throws Exception {
+ void bouncingToNullSenderShouldBeANoop() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.sender(MailAddress.nullSender())
@@ -309,7 +305,7 @@ public class JamesMailetContextTest {
}
@Test
- public void bouncingToNoSenderShouldBeANoop() throws Exception {
+ void bouncingToNoSenderShouldBeANoop() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.addRecipient(mailAddress)
@@ -322,7 +318,7 @@ public class JamesMailetContextTest {
}
@Test
- public void bounceShouldEnqueueEmailWithRootState() throws Exception {
+ void bounceShouldEnqueueEmailWithRootState() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.sender(mailAddress)
@@ -340,7 +336,7 @@ public class JamesMailetContextTest {
}
@Test
- public void sendMailShouldEnqueueEmailWithRootState() throws Exception {
+ void sendMailShouldEnqueueEmailWithRootState() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.sender(mailAddress)
@@ -357,7 +353,7 @@ public class JamesMailetContextTest {
}
@Test
- public void sendMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
+ void sendMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.sender(mailAddress)
@@ -375,7 +371,7 @@ public class JamesMailetContextTest {
}
@Test
- public void sendMailShouldEnqueueEmailWithRootStateAndDelayWhenSpecified() throws Exception {
+ void sendMailShouldEnqueueEmailWithRootStateAndDelayWhenSpecified() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.sender(mailAddress)
@@ -390,13 +386,15 @@ public class JamesMailetContextTest {
verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture(), delayArgumentCaptor.capture(), timeUnitArgumentCaptor.capture());
verifyNoMoreInteractions(spoolMailQueue);
- softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(Mail.DEFAULT);
- softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
- softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+ SoftAssertions.assertSoftly(softly -> {
+ softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(Mail.DEFAULT);
+ softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
+ softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+ });
}
@Test
- public void sendMailShouldEnqueueEmailWithOtherStateAndDelayWhenSpecified() throws Exception {
+ void sendMailShouldEnqueueEmailWithOtherStateAndDelayWhenSpecified() throws Exception {
MailImpl mail = MailImpl.builder()
.name("mail1")
.sender(mailAddress)
@@ -412,13 +410,15 @@ public class JamesMailetContextTest {
verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture(), delayArgumentCaptor.capture(), timeUnitArgumentCaptor.capture());
verifyNoMoreInteractions(spoolMailQueue);
- softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(other);
- softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
- softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+ SoftAssertions.assertSoftly(softly -> {
+ softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(other);
+ softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L);
+ softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES);
+ });
}
@Test
- public void sendMailForMessageShouldEnqueueEmailWithRootState() throws Exception {
+ void sendMailForMessageShouldEnqueueEmailWithRootState() throws Exception {
MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
.addFrom(mailAddress.asString())
.addToRecipient(mailAddress.asString())
@@ -435,7 +435,7 @@ public class JamesMailetContextTest {
}
@Test
- public void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithRootState() throws Exception {
+ void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithRootState() throws Exception {
MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
.addFrom(mailAddress.asString())
.addToRecipient(mailAddress.asString())
@@ -454,7 +454,7 @@ public class JamesMailetContextTest {
}
@Test
- public void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
+ void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
.addFrom(mailAddress.asString())
.addToRecipient(mailAddress.asString())
@@ -474,7 +474,7 @@ public class JamesMailetContextTest {
}
@Test
- public void sendMailForMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
+ void sendMailForMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
.addFrom(mailAddress.asString())
.addToRecipient(mailAddress.asString())
@@ -498,7 +498,7 @@ public class JamesMailetContextTest {
}
@Test
- public void sendMailForMailShouldEnqueueEmailWithDefaults() throws Exception {
+ void sendMailForMailShouldEnqueueEmailWithDefaults() throws Exception {
MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
.addFrom(mailAddress.asString())
.addToRecipient(mailAddress.asString())
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
index 1ad3c87..6be2e1c 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
@@ -29,19 +29,17 @@ import org.apache.commons.configuration2.XMLConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
import org.apache.commons.configuration2.convert.DisabledListDelimiterHandler;
-import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.commons.configuration2.io.FileHandler;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MailetConfigImplTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+class MailetConfigImplTest {
private XMLConfiguration xmlConfiguration;
private FileHandler fileHandler;
private MailetConfigImpl config;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(XMLConfiguration.class)
.configure(new Parameters()
.xml()
@@ -53,7 +51,7 @@ public class MailetConfigImplTest {
}
@Test
- public void testDotParamsFromXML() throws Exception {
+ void testDotParamsFromXML() throws Exception {
fileHandler.load(new ByteArrayInputStream("<mailet><mail.debug>true</mail.debug></mailet>".getBytes()));
config.setConfiguration(xmlConfiguration);
@@ -64,7 +62,7 @@ public class MailetConfigImplTest {
}
@Test
- public void testDotParamsFromConfig() throws ConfigurationException {
+ void testDotParamsFromConfig() {
xmlConfiguration.addProperty("mail.debug", "true");
config.setConfiguration(xmlConfiguration);
@@ -76,7 +74,7 @@ public class MailetConfigImplTest {
// See JAMES-1232
@Test
- public void testParamWithComma() throws Exception {
+ void testParamWithComma() throws Exception {
fileHandler.load(new ByteArrayInputStream("<mailet><whatever>value1,value2</whatever></mailet>".getBytes()));
config.setConfiguration(xmlConfiguration);
@@ -87,7 +85,7 @@ public class MailetConfigImplTest {
}
@Test
- public void testParamWithXmlSpace() throws Exception {
+ void testParamWithXmlSpace() throws Exception {
fileHandler.load(new ByteArrayInputStream(
"<mailet><whatever xml:space=\"preserve\"> some text </whatever></mailet>".getBytes()));
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
index c7fa744..e621b90 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
@@ -29,20 +29,19 @@ import org.apache.james.core.MailAddress;
import org.apache.mailet.Mail;
import org.apache.mailet.Matcher;
import org.apache.mailet.base.test.FakeMail;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
-public class AndTest {
-
+class AndTest {
private And testee;
private Matcher matcher1;
private Matcher matcher2;
private Mail mail;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
matcher1 = mock(Matcher.class);
matcher2 = mock(Matcher.class);
@@ -52,12 +51,12 @@ public class AndTest {
}
@Test
- public void shouldNotMatchWhenNoChild() throws Exception {
+ void shouldNotMatchWhenNoChild() throws Exception {
assertThat(testee.match(mail)).isEmpty();
}
@Test
- public void shouldMatchWhenSingleUnderlyingMatcherMatch() throws Exception {
+ void shouldMatchWhenSingleUnderlyingMatcherMatch() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES));
testee.add(matcher1);
@@ -66,7 +65,7 @@ public class AndTest {
}
@Test
- public void shouldMatchWhenTwoUnderlyingMatcherMatch() throws Exception {
+ void shouldMatchWhenTwoUnderlyingMatcherMatch() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
when(matcher2.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
@@ -77,7 +76,7 @@ public class AndTest {
}
@Test
- public void shouldMatchWhenAtLeastOneUnderlyingMatcherDoNotMatch() throws Exception {
+ void shouldMatchWhenAtLeastOneUnderlyingMatcherDoNotMatch() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
@@ -88,7 +87,7 @@ public class AndTest {
}
@Test
- public void shouldSupportNull() throws Exception {
+ void shouldSupportNull() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
when(matcher2.match(mail)).thenReturn(null);
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
index d69bf08..a4b3737 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/NotTest.java
@@ -27,13 +27,12 @@ import org.apache.james.core.MailAddress;
import org.apache.james.server.core.MailImpl;
import org.apache.mailet.Mail;
import org.apache.mailet.Matcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
-public class NotTest {
-
+class NotTest {
private Not testee;
private Matcher matcher1;
private Matcher matcher2;
@@ -43,8 +42,8 @@ public class NotTest {
private MailAddress recipient3;
private MailAddress recipient4;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
matcher1 = mock(Matcher.class);
matcher2 = mock(Matcher.class);
@@ -58,12 +57,12 @@ public class NotTest {
}
@Test
- public void shouldReturnAllAddressesWhenNoMatcherSpecified() throws Exception {
+ void shouldReturnAllAddressesWhenNoMatcherSpecified() throws Exception {
assertThat(testee.match(mail)).containsOnly(recipient1, recipient2, recipient3, recipient4);
}
@Test
- public void shouldNegateWhenOneMatcher() throws Exception {
+ void shouldNegateWhenOneMatcher() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
testee.add(matcher1);
@@ -72,7 +71,7 @@ public class NotTest {
}
@Test
- public void shouldNegateUnionWhenTwoMatchers() throws Exception {
+ void shouldNegateUnionWhenTwoMatchers() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
when(matcher2.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient2));
@@ -83,7 +82,7 @@ public class NotTest {
}
@Test
- public void shouldAcceptEmptyResults() throws Exception {
+ void shouldAcceptEmptyResults() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
@@ -94,7 +93,7 @@ public class NotTest {
}
@Test
- public void shouldAcceptNullResults() throws Exception {
+ void shouldAcceptNullResults() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3));
when(matcher2.match(mail)).thenReturn(null);
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
index 9827fe7..aa0926f 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
@@ -31,20 +31,19 @@ import org.apache.james.core.MailAddress;
import org.apache.james.server.core.MailImpl;
import org.apache.mailet.Mail;
import org.apache.mailet.Matcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
-public class OrTest {
-
+class OrTest {
private Or testee;
private Matcher matcher1;
private Matcher matcher2;
private Mail mail;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
matcher1 = mock(Matcher.class);
matcher2 = mock(Matcher.class);
@@ -54,12 +53,12 @@ public class OrTest {
}
@Test
- public void shouldReturnNoResultWhenNoMatcherSpecified() throws Exception {
+ void shouldReturnNoResultWhenNoMatcherSpecified() throws Exception {
assertThat(testee.match(mail)).isEmpty();
}
@Test
- public void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
+ void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
testee.add(matcher1);
@@ -68,7 +67,7 @@ public class OrTest {
}
@Test
- public void shouldReturnUnionWhenTwoMatchers() throws Exception {
+ void shouldReturnUnionWhenTwoMatchers() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
when(matcher2.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
@@ -79,7 +78,7 @@ public class OrTest {
}
@Test
- public void shouldAcceptEmptyResults() throws Exception {
+ void shouldAcceptEmptyResults() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
@@ -90,7 +89,7 @@ public class OrTest {
}
@Test
- public void shouldAcceptNullResults() throws Exception {
+ void shouldAcceptNullResults() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
when(matcher2.match(mail)).thenReturn(null);
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
index 9d5eb26..9a2dc56 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
@@ -26,24 +26,22 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.apache.james.core.MailAddress;
import org.apache.james.server.core.MailImpl;
import org.apache.mailet.Mail;
import org.apache.mailet.Matcher;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
-public class XorTest {
-
+class XorTest {
private Xor testee;
private Matcher matcher1;
private Matcher matcher2;
private Mail mail;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
matcher1 = mock(Matcher.class);
matcher2 = mock(Matcher.class);
@@ -53,12 +51,12 @@ public class XorTest {
}
@Test
- public void shouldReturnNoResultWhenNoMatcherSpecified() throws Exception {
+ void shouldReturnNoResultWhenNoMatcherSpecified() {
assertThat(testee.match(mail)).isNull();
}
@Test
- public void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
+ void shouldReturnMatchResultWhenOnlyOneMatcher() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
testee.add(matcher1);
@@ -67,7 +65,7 @@ public class XorTest {
}
@Test
- public void shouldPerformXorWhenTwoMatchers() throws Exception {
+ void shouldPerformXorWhenTwoMatchers() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
when(matcher2.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES));
@@ -78,9 +76,9 @@ public class XorTest {
}
@Test
- public void shouldAcceptEmptyResults() throws Exception {
+ void shouldAcceptEmptyResults() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
- when(matcher2.match(mail)).thenReturn(ImmutableList.<MailAddress>of());
+ when(matcher2.match(mail)).thenReturn(ImmutableList.of());
testee.add(matcher1);
testee.add(matcher2);
@@ -89,7 +87,7 @@ public class XorTest {
}
@Test
- public void shouldAcceptNullResults() throws Exception {
+ void shouldAcceptNullResults() throws Exception {
when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2));
when(matcher2.match(mail)).thenReturn(null);
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
index ffa1258..e1d9306 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
@@ -34,15 +34,9 @@ import org.apache.james.mailetcontainer.api.mock.MockMailProcessor;
import org.apache.james.server.core.MailImpl;
import org.apache.james.server.core.configuration.FileConfigurationProvider;
import org.apache.mailet.Mail;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
public abstract class AbstractStateCompositeProcessorTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void testChooseRightProcessor() throws Exception {
AbstractStateCompositeProcessor processor = new AbstractStateCompositeProcessor() {
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
index 8cea067..bb5f33a 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
@@ -41,7 +41,7 @@ import org.apache.james.server.core.configuration.FileConfigurationProvider;
import org.apache.mailet.Mail;
import org.apache.mailet.Mailet;
import org.apache.mailet.Matcher;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public abstract class AbstractStateMailetProcessorTest {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org