You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2018/03/26 13:04:37 UTC

[01/10] james-project git commit: JAMES-2361 Don't rely on method name, use instead a class

Repository: james-project
Updated Branches:
  refs/heads/master 336d1f94b -> 0d416804a


JAMES-2361 Don't rely on method name, use instead a class


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0dbf48c5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0dbf48c5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0dbf48c5

Branch: refs/heads/master
Commit: 0dbf48c58b11089e5e37fcdc13beb0938f1ed00d
Parents: 1e365b3
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Fri Mar 23 11:36:19 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:23 2018 +0200

----------------------------------------------------------------------
 .../james/transport/mailets/AddFooterTest.java  | 57 +++++++++++---------
 1 file changed, 31 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0dbf48c5/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
index b5e0abb..0c3b75a 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
@@ -37,9 +37,11 @@ import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.Lists;
@@ -51,30 +53,33 @@ class AddFooterTest {
     private Mailet mailet;
     
 
-    private static Stream<Arguments> charsetTuples() {
-        //javamail has its own charset handling logic, it needs to be exercised
-        List<String> charsetNamesToTest = Lists.newArrayList(
-                "ANSI_X3.4-1968", 
-                "iso-ir-6", 
-                "ANSI_X3.4-1986", 
-                "ISO_646.irv:1991", 
-                "ASCII", 
-                "ISO646-US", 
-                "US-ASCII",
-                "us", 
-                "IBM367", 
-                "cp367",
-                "csASCII");
-        return charsetNamesToTest.stream().flatMap(from -> charsetNamesToTest.stream().map(to -> Arguments.of(from, to)));
+    static class CharsetTuples implements ArgumentsProvider {
+        @Override
+        public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+            //javamail has its own charset handling logic, it needs to be exercised
+            List<String> charsetNamesToTest = Lists.newArrayList(
+                    "ANSI_X3.4-1968", 
+                    "iso-ir-6", 
+                    "ANSI_X3.4-1986", 
+                    "ISO_646.irv:1991", 
+                    "ASCII", 
+                    "ISO646-US", 
+                    "US-ASCII",
+                    "us", 
+                    "IBM367", 
+                    "cp367",
+                    "csASCII");
+            return charsetNamesToTest.stream().flatMap(from -> charsetNamesToTest.stream().map(to -> Arguments.of(from, to)));
+        }
     }
-    
+
     @BeforeEach
     void setup() {
         mailet = new AddFooter();
     }
 
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldAddFooterWhenQuotedPrintableTextPlainMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -100,7 +105,7 @@ class AddFooterTest {
     }
 
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldEnsureCarriageReturnWhenAddFooterWithTextPlainMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -126,7 +131,7 @@ class AddFooterTest {
     }
 
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldNotAddFooterWhenUnsupportedEncoding(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -150,7 +155,7 @@ class AddFooterTest {
     }
 
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldNotAddFooterWhenUnsupportedTextContentType(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -178,7 +183,7 @@ class AddFooterTest {
      * This should not add the header and should leave the multipart/mixed Content-Type intact
      */
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldNotAddFooterWhenNestedUnsupportedMultipart(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -215,7 +220,7 @@ class AddFooterTest {
      * Test for JAMES-368
      */
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldAddFooterWhenMultipartRelatedHtmlMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -268,7 +273,7 @@ class AddFooterTest {
     }
 
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldAddFooterWhenMultipartAlternivateMessage(String javaCharset, String javaMailCharset) throws MessagingException,
             IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
@@ -306,7 +311,7 @@ class AddFooterTest {
     }
 
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldAddFooterWhenHtmlMessageWithMixedCaseBodyTag(String javaCharset, String javaMailCharset) throws MessagingException,
             IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
@@ -334,7 +339,7 @@ class AddFooterTest {
     }
 
     @ParameterizedTest
-    @MethodSource("charsetTuples")
+    @ArgumentsSource(CharsetTuples.class)
     void shouldAddFooterWhenHtmlMessageWithNoBodyTag(String javaCharset, String javaMailCharset) throws MessagingException,
             IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()


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


[05/10] james-project git commit: JAMES-2361 rename utility method to make it clear what it does

Posted by ma...@apache.org.
JAMES-2361 rename utility method to make it clear what it does


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dcf7934a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dcf7934a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dcf7934a

Branch: refs/heads/master
Commit: dcf7934a8b42dd3f3ac736915198a8f28e5edd24
Parents: 02ed3ab
Author: Matthieu Baechler <ma...@apache.org>
Authored: Tue Mar 20 16:36:38 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:23 2018 +0200

----------------------------------------------------------------------
 .../jmap/methods/integration/SendMDNMethodTest.java     | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/dcf7934a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
index 8d595eb..ac5a42e 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
@@ -105,7 +105,7 @@ public abstract class SendMDNMethodTest {
         bartAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), BART, BOB_PASSWORD);
     }
 
-    private void sendAnInitialMessage() {
+    private void bartSendMessageToHomer() {
         String messageCreationId = "creationId";
         String outboxId = getOutboxId(bartAccessToken);
         String requestBody = "[" +
@@ -186,7 +186,7 @@ public abstract class SendMDNMethodTest {
 
     @Test
     public void sendMDNShouldReturnCreatedMessageId() {
-        sendAnInitialMessage();
+        bartSendMessageToHomer();
 
         List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
@@ -217,7 +217,7 @@ public abstract class SendMDNMethodTest {
 
     @Test
     public void sendMDNShouldFailOnUnknownMessageId() {
-        sendAnInitialMessage();
+        bartSendMessageToHomer();
 
         String creationId = "creation-1";
         String randomMessageId = randomMessageId().serialize();
@@ -290,7 +290,7 @@ public abstract class SendMDNMethodTest {
 
     @Test
     public void sendMDNShouldSendAMDNBackToTheOriginalMessageAuthor() {
-        sendAnInitialMessage();
+        bartSendMessageToHomer();
 
         List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
@@ -335,7 +335,7 @@ public abstract class SendMDNMethodTest {
 
     @Test
     public void sendMDNShouldPositionTheReportAsAnAttachment() {
-        sendAnInitialMessage();
+        bartSendMessageToHomer();
 
         List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
@@ -413,7 +413,7 @@ public abstract class SendMDNMethodTest {
 
     @Test
     public void sendMDNShouldReturnMaxQuotaReachedWhenUserReachedHisQuota() throws MailboxException {
-        sendAnInitialMessage();
+        bartSendMessageToHomer();
 
         List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 


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


[10/10] james-project git commit: JAMES-2361 Create an extension to replace TemporaryFolder rule

Posted by ma...@apache.org.
JAMES-2361 Create an extension to replace TemporaryFolder rule


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0d416804
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0d416804
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0d416804

Branch: refs/heads/master
Commit: 0d416804ae35879e8545d297aceb0cc331502269
Parents: 0dbf48c
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Fri Mar 23 15:08:00 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:24 2018 +0200

----------------------------------------------------------------------
 mailet/standard/pom.xml                         |  5 ++
 .../transport/mailets/StripAttachmentTest.java  | 85 ++++++++------------
 .../james/junit/TemporaryFolderExtension.java   | 75 +++++++++++++++++
 3 files changed, 115 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0d416804/mailet/standard/pom.xml
----------------------------------------------------------------------
diff --git a/mailet/standard/pom.xml b/mailet/standard/pom.xml
index 944dafa..21e505d 100644
--- a/mailet/standard/pom.xml
+++ b/mailet/standard/pom.xml
@@ -58,6 +58,11 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-testing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>javax-mail-extension</artifactId>
             <type>test-jar</type>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/0d416804/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
index afeb363..71ec927 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
@@ -39,21 +39,20 @@ import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.james.core.builder.MimeMessageBuilder;
+import org.apache.james.junit.TemporaryFolderExtension;
+import org.apache.james.junit.TemporaryFolderExtension.TemporaryFolder;
 import org.apache.james.transport.mailets.StripAttachment.OutputFileName;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetException;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
-import com.google.common.io.Files;
-
+@ExtendWith(TemporaryFolderExtension.class)
 class StripAttachmentTest {
 
     private static final String EXPECTED_ATTACHMENT_CONTENT = "#¤ãàé";
@@ -81,23 +80,9 @@ class StripAttachmentTest {
         new MimeMessageBuilder.Header(CONTENT_TYPE, TEXT_CALENDAR_CHARSET_UTF_8)
     };
 
-    private String folderPath;
-    private File tempDir;
-
-    @BeforeEach
-    void setUp() {
-        tempDir = Files.createTempDir();
-        folderPath = tempDir.getPath() + "/";
-    }
-
-    @AfterEach
-    void tearDown() throws IOException {
-        FileUtils.deleteDirectory(tempDir);
-    }
-
     @Test
-    void serviceShouldNotModifyMailWhenNotMultipart() throws MessagingException, IOException {
-        Mailet mailet = initMailet();
+    void serviceShouldNotModifyMailWhenNotMultipart(TemporaryFolder temporaryFolder) throws MessagingException, IOException {
+        Mailet mailet = initMailet(temporaryFolder);
         MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
             .setSubject("test")
             .setText("simple text");
@@ -116,8 +101,8 @@ class StripAttachmentTest {
     }
     
     @Test
-    void serviceShouldSaveAttachmentInAFolderWhenPatternMatch() throws MessagingException {
-        Mailet mailet = initMailet();
+    void serviceShouldSaveAttachmentInAFolderWhenPatternMatch(TemporaryFolder temporaryFolder) throws MessagingException {
+        Mailet mailet = initMailet(temporaryFolder);
 
         String expectedAttachmentContent = EXPECTED_ATTACHMENT_CONTENT;
         MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
@@ -138,7 +123,7 @@ class StripAttachmentTest {
 
         String attachmentFilename = savedAttachments.iterator().next();
 
-        assertThat(new File(folderPath + attachmentFilename)).hasContent(expectedAttachmentContent);
+        assertThat(new File(temporaryFolder.getFolderPath() + attachmentFilename)).hasContent(expectedAttachmentContent);
     }
 
     @Test
@@ -179,12 +164,12 @@ class StripAttachmentTest {
     }
 
     @Test
-    void serviceShouldSaveAttachmentInAFolderWhenNotPatternDoesntMatch() throws MessagingException {
+    void serviceShouldSaveAttachmentInAFolderWhenNotPatternDoesntMatch(TemporaryFolder temporaryFolder) throws MessagingException {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("remove", "all")
                 .setProperty("notpattern", "^(winmail\\.dat$)")
                 .build();
@@ -209,7 +194,7 @@ class StripAttachmentTest {
 
         String attachmentFilename = retrieveFilenameStartingWith(savedAttachments, "temp_filname");
         assertThat(attachmentFilename).isNotNull();
-        assertThat(new File(folderPath + attachmentFilename)).hasContent(expectedAttachmentContent);
+        assertThat(new File(temporaryFolder.getFolderPath() + attachmentFilename)).hasContent(expectedAttachmentContent);
     }
 
     private String retrieveFilenameStartingWith(Collection<String> savedAttachments, String filename) {
@@ -220,8 +205,8 @@ class StripAttachmentTest {
     }
 
     @Test
-    void serviceShouldDecodeFilenameAndSaveAttachmentInAFolderWhenPatternMatchAndDecodeFilenameTrue() throws MessagingException {
-        Mailet mailet = initMailet();
+    void serviceShouldDecodeFilenameAndSaveAttachmentInAFolderWhenPatternMatchAndDecodeFilenameTrue(TemporaryFolder temporaryFolder) throws MessagingException {
+        Mailet mailet = initMailet(temporaryFolder);
 
         String expectedAttachmentContent = EXPECTED_ATTACHMENT_CONTENT;
         MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
@@ -245,18 +230,18 @@ class StripAttachmentTest {
 
         assertThat(name.startsWith("e_Pubblicita_e_vietata_Milano9052")).isTrue();
         
-        assertThat(new File(folderPath + name)).hasContent(expectedAttachmentContent);
+        assertThat(new File(temporaryFolder.getFolderPath() + name)).hasContent(expectedAttachmentContent);
     }
 
     @Test
-    void serviceShouldSaveFilenameAttachmentAndFileContentInCustomAttribute() throws MessagingException, IOException {
+    void serviceShouldSaveFilenameAttachmentAndFileContentInCustomAttribute(TemporaryFolder temporaryFolder) throws MessagingException, IOException {
         StripAttachment mailet = new StripAttachment();
 
         String customAttribute = "my.custom.attribute";
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("remove", "matched")
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("pattern", ".*\\.tmp")
                 .setProperty("attribute", customAttribute)
                 .build();
@@ -477,8 +462,8 @@ class StripAttachmentTest {
     }
 
     @Test
-    void serviceShouldThrowWhenUnretrievableMessage() throws MessagingException {
-        Mailet mailet = initMailet();
+    void serviceShouldThrowWhenUnretrievableMessage(TemporaryFolder temporaryFolder) throws MessagingException {
+        Mailet mailet = initMailet(temporaryFolder);
         
         Mail mail = mock(Mail.class);
         when(mail.getMessage())
@@ -490,8 +475,8 @@ class StripAttachmentTest {
     }
 
     @Test
-    void serviceShouldThrowWhenUnretrievableContentTypeMessage() throws MessagingException {
-        Mailet mailet = initMailet();
+    void serviceShouldThrowWhenUnretrievableContentTypeMessage(TemporaryFolder temporaryFolder) throws MessagingException {
+        Mailet mailet = initMailet(temporaryFolder);
 
         MimeMessage message = mock(MimeMessage.class);
         Mail mail = mock(Mail.class);
@@ -572,14 +557,14 @@ class StripAttachmentTest {
     }
 
     @Test
-    void processMultipartPartMessageShouldPutTwoPartsInDefaultAttributeWhenTwoPartsMatch() throws Exception {
+    void processMultipartPartMessageShouldPutTwoPartsInDefaultAttributeWhenTwoPartsMatch(TemporaryFolder temporaryFolder) throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("remove", "matched")
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("pattern", ".*")
                 .build();
         mailet.init(mci);
@@ -603,7 +588,7 @@ class StripAttachmentTest {
     }
 
     @Test
-    void processMultipartPartMessageShouldPutTwoPartsInCustomAttributeWhenTwoPartsMatch() throws Exception {
+    void processMultipartPartMessageShouldPutTwoPartsInCustomAttributeWhenTwoPartsMatch(TemporaryFolder temporaryFolder) throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -611,7 +596,7 @@ class StripAttachmentTest {
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("remove", "matched")
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("pattern", ".*")
                 .setProperty("attribute", customAttribute)
                 .build();
@@ -717,14 +702,14 @@ class StripAttachmentTest {
     }
 
     @Test
-    void processMultipartPartMessageShouldSetFilenameToMatchingAttachmentsWhenAttachmentWithoutFilename() throws Exception {
+    void processMultipartPartMessageShouldSetFilenameToMatchingAttachmentsWhenAttachmentWithoutFilename(TemporaryFolder temporaryFolder) throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("remove", "matched")
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("pattern", ".*")
                 .build();
         mailet.init(mci);
@@ -746,11 +731,11 @@ class StripAttachmentTest {
     }
 
     @Test
-    void saveAttachmentShouldUsePartNameIfNoFilename() throws Exception {
+    void saveAttachmentShouldUsePartNameIfNoFilename(TemporaryFolder temporaryFolder) throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("pattern", ".*\\.tmp")
                 .build();
         mailet.init(mci);
@@ -768,10 +753,10 @@ class StripAttachmentTest {
     }
     
     @Test
-    void saveAttachmentShouldReturnAbsentWhenNoFilenameAtAll() throws Exception {
+    void saveAttachmentShouldReturnAbsentWhenNoFilenameAtAll(TemporaryFolder temporaryFolder) throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("pattern", ".*\\.tmp")
                 .build();
         mailet.init(mci);
@@ -782,11 +767,11 @@ class StripAttachmentTest {
     }
     
     @Test
-    void saveAttachmentShouldAddBinExtensionWhenNoFileNameExtension() throws Exception {
+    void saveAttachmentShouldAddBinExtensionWhenNoFileNameExtension(TemporaryFolder temporaryFolder) throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("pattern", ".*")
                 .build();
         mailet.init(mci);
@@ -801,12 +786,12 @@ class StripAttachmentTest {
         assertThat(filename).endsWith(".bin");
     }
     
-    private Mailet initMailet() throws MessagingException {
+    private Mailet initMailet(TemporaryFolder temporaryFolder) throws MessagingException {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
-                .setProperty("directory", folderPath)
+                .setProperty("directory", temporaryFolder.getFolderPath())
                 .setProperty("remove", "all")
                 .setProperty("pattern", ".*\\.tmp")
                 .setProperty("decodeFilename", "true")

http://git-wip-us.apache.org/repos/asf/james-project/blob/0d416804/server/testing/src/main/java/org/apache/james/junit/TemporaryFolderExtension.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/junit/TemporaryFolderExtension.java b/server/testing/src/main/java/org/apache/james/junit/TemporaryFolderExtension.java
new file mode 100644
index 0000000..b5ed368
--- /dev/null
+++ b/server/testing/src/main/java/org/apache/james/junit/TemporaryFolderExtension.java
@@ -0,0 +1,75 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.junit;
+
+import java.io.File;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+import com.google.common.io.Files;
+
+public class TemporaryFolderExtension implements ParameterResolver, BeforeEachCallback, AfterEachCallback {
+
+    private TemporaryFolder temporaryFolder;
+
+    @Override
+    public void beforeEach(ExtensionContext context) throws Exception {
+        temporaryFolder = new TemporaryFolder(Files.createTempDir());
+    }
+
+    @Override
+    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return (parameterContext.getParameter().getType() == TemporaryFolder.class);
+    }
+
+    @Override
+    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return temporaryFolder;
+    }
+
+    @Override
+    public void afterEach(ExtensionContext context) throws Exception {
+        FileUtils.deleteDirectory(temporaryFolder.getTempDir());
+    }
+
+    public static class TemporaryFolder {
+        private final File tempDir;
+        private final String folderPath;
+
+        public TemporaryFolder(File tempDir) {
+            this.tempDir = tempDir;
+            this.folderPath = tempDir.getPath() + "/";
+        }
+
+        public File getTempDir() {
+            return tempDir;
+        }
+
+        public String getFolderPath() {
+            return folderPath;
+        }
+    }
+}


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


[06/10] james-project git commit: JAMES-2361 pass AccessToken instead of String and serialize when needed

Posted by ma...@apache.org.
JAMES-2361 pass AccessToken instead of String and serialize when needed


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d16c5340
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d16c5340
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d16c5340

Branch: refs/heads/master
Commit: d16c5340795baee78b46efac68c1e39daa2f2da6
Parents: dcf7934
Author: Matthieu Baechler <ma...@apache.org>
Authored: Tue Mar 20 17:20:01 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:23 2018 +0200

----------------------------------------------------------------------
 .../methods/integration/SendMDNMethodTest.java    | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/d16c5340/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
index ac5a42e..a33b64a 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
@@ -135,7 +135,7 @@ public abstract class SendMDNMethodTest {
             .body()
             .path(ARGUMENTS + ".created." + messageCreationId + ".id");
 
-        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken.serialize()).isEmpty());
+        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken).isEmpty());
     }
 
     private void sendAWrongInitialMessage() {
@@ -167,7 +167,7 @@ public abstract class SendMDNMethodTest {
             .body()
             .path(ARGUMENTS + ".created." + messageCreationId + ".id");
 
-        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken.serialize()).isEmpty());
+        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken).isEmpty());
     }
 
     private URIBuilder baseUri() {
@@ -188,7 +188,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldReturnCreatedMessageId() {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
 
         String creationId = "creation-1";
         given()
@@ -253,7 +253,7 @@ public abstract class SendMDNMethodTest {
     @Test
     public void sendMDNShouldFailOnInvalidMessages() {
         sendAWrongInitialMessage();
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
 
         String creationId = "creation-1";
 
@@ -292,7 +292,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldSendAMDNBackToTheOriginalMessageAuthor() {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
 
         // HOMER sends a MDN back to BART
         String creationId = "creation-1";
@@ -337,7 +337,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldPositionTheReportAsAnAttachment() {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
 
         // USER sends a MDN back to BART
         String creationId = "creation-1";
@@ -415,7 +415,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldReturnMaxQuotaReachedWhenUserReachedHisQuota() throws MailboxException {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
 
         QuotaProbe quotaProbe = jmapServer.getProbe(QuotaProbesImpl.class);
         String inboxQuotaRoot = quotaProbe.getQuotaRoot("#private", HOMER, DefaultMailboxes.INBOX);
@@ -532,9 +532,9 @@ public abstract class SendMDNMethodTest {
             .getList(ARGUMENTS + ".list");
     }
 
-    private List<String> getMessageIdListForAccount(String accessToken) {
+    private List<String> getMessageIdListForAccount(AccessToken accessToken) {
         return with()
-            .header("Authorization", accessToken)
+            .header("Authorization", accessToken.serialize())
             .body("[[\"getMessageList\", {}, \"#0\"]]")
             .post("/jmap")
         .then()


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


[08/10] james-project git commit: Rename people in tests to make it easier to read

Posted by ma...@apache.org.
Rename people in tests to make it easier to read


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/02ed3ab8
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/02ed3ab8
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/02ed3ab8

Branch: refs/heads/master
Commit: 02ed3ab83ec5afb11ffb530b25b803078b7e2cdc
Parents: 336d1f9
Author: Matthieu Baechler <ma...@apache.org>
Authored: Tue Mar 20 16:35:19 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:23 2018 +0200

----------------------------------------------------------------------
 .../methods/integration/SendMDNMethodTest.java  | 100 +++++++++----------
 1 file changed, 50 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/02ed3ab8/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
index c1a586b..8d595eb 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
@@ -69,8 +69,8 @@ public abstract class SendMDNMethodTest {
     private static final String NAME = "[0][0]";
     private static final String ARGUMENTS = "[0][1]";
     private static final String USERS_DOMAIN = "domain.tld";
-    private static final String USERNAME = "username@" + USERS_DOMAIN;
-    private static final String BOB = "bob@" + USERS_DOMAIN;
+    private static final String HOMER = "homer@" + USERS_DOMAIN;
+    private static final String BART = "bart@" + USERS_DOMAIN;
     private static final String PASSWORD = "password";
     private static final String BOB_PASSWORD = "bobPassword";
 
@@ -78,8 +78,8 @@ public abstract class SendMDNMethodTest {
 
     protected abstract MessageId randomMessageId();
 
-    private AccessToken accessToken;
-    private AccessToken bobAccessToken;
+    private AccessToken homerAccessToken;
+    private AccessToken bartAccessToken;
     private GuiceJamesServer jmapServer;
 
     @Before
@@ -98,24 +98,24 @@ public abstract class SendMDNMethodTest {
         RestAssured.defaultParser = Parser.JSON;
 
         dataProbe.addDomain(USERS_DOMAIN);
-        dataProbe.addUser(USERNAME, PASSWORD);
-        dataProbe.addUser(BOB, BOB_PASSWORD);
-        mailboxProbe.createMailbox("#private", USERNAME, DefaultMailboxes.INBOX);
-        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USERNAME, PASSWORD);
-        bobAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), BOB, BOB_PASSWORD);
+        dataProbe.addUser(HOMER, PASSWORD);
+        dataProbe.addUser(BART, BOB_PASSWORD);
+        mailboxProbe.createMailbox("#private", HOMER, DefaultMailboxes.INBOX);
+        homerAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), HOMER, PASSWORD);
+        bartAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), BART, BOB_PASSWORD);
     }
 
     private void sendAnInitialMessage() {
         String messageCreationId = "creationId";
-        String outboxId = getOutboxId(bobAccessToken);
+        String outboxId = getOutboxId(bartAccessToken);
         String requestBody = "[" +
             "  [" +
             "    \"setMessages\"," +
             "    {" +
             "      \"create\": { \"" + messageCreationId  + "\" : {" +
-            "        \"headers\":{\"Disposition-Notification-To\":\"" + BOB + "\"}," +
-            "        \"from\": { \"name\": \"Bob\", \"email\": \"" + BOB + "\"}," +
-            "        \"to\": [{ \"name\": \"User\", \"email\": \"" + USERNAME + "\"}]," +
+            "        \"headers\":{\"Disposition-Notification-To\":\"" + BART + "\"}," +
+            "        \"from\": { \"name\": \"Bob\", \"email\": \"" + BART + "\"}," +
+            "        \"to\": [{ \"name\": \"User\", \"email\": \"" + HOMER + "\"}]," +
             "        \"subject\": \"Message with an attachment\"," +
             "        \"textBody\": \"Test body, plain text version\"," +
             "        \"htmlBody\": \"Test <b>body</b>, HTML version\"," +
@@ -127,7 +127,7 @@ public abstract class SendMDNMethodTest {
             "]";
 
         with()
-            .header("Authorization", bobAccessToken.serialize())
+            .header("Authorization", bartAccessToken.serialize())
             .body(requestBody)
             .post("/jmap")
         .then()
@@ -135,19 +135,19 @@ public abstract class SendMDNMethodTest {
             .body()
             .path(ARGUMENTS + ".created." + messageCreationId + ".id");
 
-        calmlyAwait.until(() -> !getMessageIdListForAccount(accessToken.serialize()).isEmpty());
+        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken.serialize()).isEmpty());
     }
 
     private void sendAWrongInitialMessage() {
         String messageCreationId = "creationId";
-        String outboxId = getOutboxId(bobAccessToken);
+        String outboxId = getOutboxId(bartAccessToken);
         String requestBody = "[" +
             "  [" +
             "    \"setMessages\"," +
             "    {" +
             "      \"create\": { \"" + messageCreationId  + "\" : {" +
-            "        \"from\": { \"name\": \"Bob\", \"email\": \"" + BOB + "\"}," +
-            "        \"to\": [{ \"name\": \"User\", \"email\": \"" + USERNAME + "\"}]," +
+            "        \"from\": { \"name\": \"Bob\", \"email\": \"" + BART + "\"}," +
+            "        \"to\": [{ \"name\": \"User\", \"email\": \"" + HOMER + "\"}]," +
             "        \"subject\": \"Message with an attachment\"," +
             "        \"textBody\": \"Test body, plain text version\"," +
             "        \"htmlBody\": \"Test <b>body</b>, HTML version\"," +
@@ -159,7 +159,7 @@ public abstract class SendMDNMethodTest {
             "]";
 
         with()
-            .header("Authorization", bobAccessToken.serialize())
+            .header("Authorization", bartAccessToken.serialize())
             .body(requestBody)
             .post("/jmap")
         .then()
@@ -167,7 +167,7 @@ public abstract class SendMDNMethodTest {
             .body()
             .path(ARGUMENTS + ".created." + messageCreationId + ".id");
 
-        calmlyAwait.until(() -> !getMessageIdListForAccount(accessToken.serialize()).isEmpty());
+        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken.serialize()).isEmpty());
     }
 
     private URIBuilder baseUri() {
@@ -188,11 +188,11 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldReturnCreatedMessageId() {
         sendAnInitialMessage();
 
-        List<String> messageIds = getMessageIdListForAccount(accessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
         String creationId = "creation-1";
         given()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                     "    \"messageId\":\"" + messageIds.get(0) + "\"," +
@@ -222,7 +222,7 @@ public abstract class SendMDNMethodTest {
         String creationId = "creation-1";
         String randomMessageId = randomMessageId().serialize();
         given()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                     "    \"messageId\":\"" + randomMessageId + "\"," +
@@ -253,12 +253,12 @@ public abstract class SendMDNMethodTest {
     @Test
     public void sendMDNShouldFailOnInvalidMessages() {
         sendAWrongInitialMessage();
-        List<String> messageIds = getMessageIdListForAccount(accessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
         String creationId = "creation-1";
 
         given()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                     "    \"messageId\":\"" + messageIds.get(0) + "\"," +
@@ -292,12 +292,12 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldSendAMDNBackToTheOriginalMessageAuthor() {
         sendAnInitialMessage();
 
-        List<String> messageIds = getMessageIdListForAccount(accessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
-        // USER sends a MDN back to BOB
+        // HOMER sends a MDN back to BART
         String creationId = "creation-1";
         with()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                 "    \"messageId\":\"" + messageIds.get(0) + "\"," +
@@ -313,19 +313,19 @@ public abstract class SendMDNMethodTest {
                 "}}, \"#0\"]]")
             .post("/jmap");
 
-        // BOB should have received it
-        calmlyAwait.until(() -> !listMessagesInMailbox(bobAccessToken, getInboxId(bobAccessToken)).isEmpty());
-        List<String> bobInboxMessageIds = listMessagesInMailbox(bobAccessToken, getInboxId(bobAccessToken));
+        // BART should have received it
+        calmlyAwait.until(() -> !listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken)).isEmpty());
+        List<String> bobInboxMessageIds = listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken));
 
         given()
-            .header("Authorization", bobAccessToken.serialize())
+            .header("Authorization", bartAccessToken.serialize())
             .body("[[\"getMessages\", {\"ids\": [\"" + bobInboxMessageIds.get(0) + "\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body(ARGUMENTS + ".list[0].from.email", is(USERNAME))
-            .body(ARGUMENTS + ".list[0].to.email", contains(BOB))
+            .body(ARGUMENTS + ".list[0].from.email", is(HOMER))
+            .body(ARGUMENTS + ".list[0].to.email", contains(BART))
             .body(ARGUMENTS + ".list[0].hasAttachment", is(true))
             .body(ARGUMENTS + ".list[0].textBody", is("Read confirmation"))
             .body(ARGUMENTS + ".list[0].subject", is("subject"))
@@ -337,12 +337,12 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldPositionTheReportAsAnAttachment() {
         sendAnInitialMessage();
 
-        List<String> messageIds = getMessageIdListForAccount(accessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
-        // USER sends a MDN back to BOB
+        // USER sends a MDN back to BART
         String creationId = "creation-1";
         with()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                 "    \"messageId\":\"" + messageIds.get(0) + "\"," +
@@ -358,12 +358,12 @@ public abstract class SendMDNMethodTest {
                 "}}, \"#0\"]]")
             .post("/jmap");
 
-        // BOB should have received it
-        calmlyAwait.until(() -> !listMessagesInMailbox(bobAccessToken, getInboxId(bobAccessToken)).isEmpty());
-        List<String> bobInboxMessageIds = listMessagesInMailbox(bobAccessToken, getInboxId(bobAccessToken));
+        // BART should have received it
+        calmlyAwait.until(() -> !listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken)).isEmpty());
+        List<String> bobInboxMessageIds = listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken));
 
         String blobId = with()
-            .header("Authorization", bobAccessToken.serialize())
+            .header("Authorization", bartAccessToken.serialize())
             .body("[[\"getMessages\", {\"ids\": [\"" + bobInboxMessageIds.get(0) + "\"]}, \"#0\"]]")
             .post("/jmap")
         .then()
@@ -372,13 +372,13 @@ public abstract class SendMDNMethodTest {
             .path(ARGUMENTS + ".list[0].attachments[0].blobId");
 
         given()
-            .header("Authorization", bobAccessToken.serialize())
+            .header("Authorization", bartAccessToken.serialize())
         .when()
             .get("/download/" + blobId)
         .then()
             .statusCode(200)
             .body(containsString("Reporting-UA: reportingUA;"))
-            .body(containsString("Final-Recipient: rfc822; username@domain.tld"))
+            .body(containsString("Final-Recipient: rfc822; homer@domain.tld"))
             .body(containsString("Original-Message-ID: "))
             .body(containsString("Disposition: automatic-action/MDN-sent-automatically;processed"));
     }
@@ -388,7 +388,7 @@ public abstract class SendMDNMethodTest {
         String creationId = "creation-1";
         // Missing subject
         given()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                     "    \"messageId\":\"" + randomMessageId().serialize() + "\"," +
@@ -415,17 +415,17 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldReturnMaxQuotaReachedWhenUserReachedHisQuota() throws MailboxException {
         sendAnInitialMessage();
 
-        List<String> messageIds = getMessageIdListForAccount(accessToken.serialize());
+        List<String> messageIds = getMessageIdListForAccount(homerAccessToken.serialize());
 
         QuotaProbe quotaProbe = jmapServer.getProbe(QuotaProbesImpl.class);
-        String inboxQuotaRoot = quotaProbe.getQuotaRoot("#private", USERNAME, DefaultMailboxes.INBOX);
+        String inboxQuotaRoot = quotaProbe.getQuotaRoot("#private", HOMER, DefaultMailboxes.INBOX);
         quotaProbe.setMaxStorage(inboxQuotaRoot, SerializableQuotaValue.valueOf(Optional.of(QuotaSize.size(100))));
 
-        MessageAppender.fillMailbox(jmapServer.getProbe(MailboxProbeImpl.class), USERNAME, MailboxConstants.INBOX);
+        MessageAppender.fillMailbox(jmapServer.getProbe(MailboxProbeImpl.class), HOMER, MailboxConstants.INBOX);
 
         String creationId = "creation-1";
         given()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                 "    \"messageId\":\"" + messageIds.get(0) + "\"," +
@@ -455,7 +455,7 @@ public abstract class SendMDNMethodTest {
         String creationId = "creation-1";
         // Missing actionMode
         given()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                 "    \"messageId\":\"" + randomMessageId().serialize() + "\"," +
@@ -482,7 +482,7 @@ public abstract class SendMDNMethodTest {
     public void invalidEnumValuesInMDNShouldBeReported() {
         String creationId = "creation-1";
         given()
-            .header("Authorization", accessToken.serialize())
+            .header("Authorization", homerAccessToken.serialize())
             .body("[[\"setMessages\", {\"sendMDN\": {" +
                 "\"" + creationId + "\":{" +
                 "    \"messageId\":\"" + randomMessageId().serialize() + "\"," +


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


[04/10] james-project git commit: JAMES-2361 migrate mailet/standard to junit 5

Posted by ma...@apache.org.
JAMES-2361 migrate mailet/standard to junit 5


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1e365b3e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1e365b3e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1e365b3e

Branch: refs/heads/master
Commit: 1e365b3edc2f8c53726621fb2c049017435a205c
Parents: a4c9f2e
Author: Matthieu Baechler <ma...@apache.org>
Authored: Wed Mar 21 12:02:33 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:23 2018 +0200

----------------------------------------------------------------------
 mailet/standard/pom.xml                         |  20 +-
 .../mailets/AddDeliveredToHeaderTest.java       |   6 +-
 .../james/transport/mailets/AddFooterTest.java  | 105 +++++-----
 .../transport/mailets/AddSubjectPrefixTest.java |  30 ++-
 .../mailets/AmqpForwardAttributeTest.java       |  52 +++--
 .../transport/mailets/ContactExtractorTest.java |   6 +-
 .../transport/mailets/ContentReplacerTest.java  |   2 +-
 .../james/transport/mailets/LogMessageTest.java |  37 ++--
 .../MailAttributesListToMimeHeadersTest.java    |  66 +++----
 .../MailAttributesToMimeHeadersTest.java        |  53 +++--
 .../transport/mailets/MappingArgumentTest.java  |  42 ++--
 .../mailets/MimeDecodingMailetTest.java         |  39 ++--
 .../james/transport/mailets/NullTest.java       |   6 +-
 .../james/transport/mailets/OnlyTextTest.java   |  14 +-
 .../transport/mailets/PatternExtractorTest.java |  44 ++---
 .../transport/mailets/PostmasterAliasTest.java  |   6 +-
 .../mailets/RecipientToLowerCaseTest.java       |   6 +-
 .../mailets/RemoveAllMailAttributesTest.java    |   6 +-
 .../mailets/RemoveMailAttributeTest.java        |  33 ++--
 .../mailets/RemoveMimeHeaderByPrefixTest.java   |  36 ++--
 .../transport/mailets/RemoveMimeHeaderTest.java |  32 ++--
 .../transport/mailets/ReplaceContentTest.java   |  31 ++-
 .../transport/mailets/SetMailAttributeTest.java |  20 +-
 .../transport/mailets/SetMimeHeaderTest.java    |  45 ++---
 .../transport/mailets/StripAttachmentTest.java  | 191 +++++++++----------
 .../transport/mailets/ToProcessorTest.java      |  34 ++--
 .../james/transport/mailets/UnwrapTextTest.java |  28 +--
 .../mailets/UseHeaderRecipientsTest.java        |  42 ++--
 .../mailets/utils/MimeMessageModifierTest.java  |   2 +-
 .../mailets/utils/MimeMessageUtilsTest.java     |   2 +-
 .../matchers/AbstractHasMailAttributeTest.java  |  36 ++--
 .../james/transport/matchers/AllTest.java       |   6 +-
 .../transport/matchers/FetchedFromTest.java     |   6 +-
 .../transport/matchers/HasAttachmentTest.java   |   6 +-
 .../transport/matchers/HasExceptionTest.java    |   6 +-
 .../james/transport/matchers/HasHeaderTest.java |   6 +-
 .../matchers/HasHeaderWithPrefixTest.java       |  50 +++--
 .../matchers/HasMailAttributeTest.java          |   4 -
 .../HasMailAttributeWithValueRegexTest.java     |  25 ++-
 .../matchers/HasMailAttributeWithValueTest.java |  11 +-
 .../transport/matchers/HasMimeTypeTest.java     |   6 +-
 .../transport/matchers/HostIsLocalTest.java     |   6 +-
 .../james/transport/matchers/HostIsTest.java    |   6 +-
 .../matchers/IsSingleRecipientTest.java         |   6 +-
 .../transport/matchers/NESSpamCheckTest.java    |   6 +-
 .../matchers/RecipientIsLocalTest.java          |   6 +-
 .../matchers/RecipientIsRegexTest.java          |  51 +++--
 .../transport/matchers/RecipientIsTest.java     |  42 ++--
 .../transport/matchers/RelayLimitTest.java      |  59 +++---
 .../matchers/SMTPAuthSuccessfulTest.java        |   6 +-
 .../transport/matchers/SMTPAuthUserIsTest.java  |   5 +-
 .../matchers/SMTPIsAuthNetworkTest.java         |   6 +-
 .../matchers/SenderHostIsLocalTest.java         |   6 +-
 .../transport/matchers/SenderHostIsTest.java    |  40 ++--
 .../transport/matchers/SenderIsLocalTest.java   |   6 +-
 .../transport/matchers/SenderIsNullTest.java    |  19 +-
 .../transport/matchers/SenderIsRegexTest.java   |  53 +++--
 .../james/transport/matchers/SenderIsTest.java  |  42 ++--
 .../transport/matchers/SentByMailetTest.java    |   6 +-
 .../transport/matchers/SizeGreaterThanTest.java |  48 +++--
 .../james/transport/matchers/SubjectIsTest.java |   6 +-
 .../matchers/SubjectStartsWithTest.java         |   6 +-
 .../transport/matchers/TooManyLinesTest.java    |  88 ++++-----
 .../matchers/TooManyRecipientsTest.java         |  92 +++++----
 .../james/transport/matchers/UserIsTest.java    |  42 ++--
 .../util/MailAddressCollectionReaderTest.java   |  46 ++---
 pom.xml                                         |   5 +
 67 files changed, 898 insertions(+), 1004 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/pom.xml
----------------------------------------------------------------------
diff --git a/mailet/standard/pom.xml b/mailet/standard/pom.xml
index 8aab675..944dafa 100644
--- a/mailet/standard/pom.xml
+++ b/mailet/standard/pom.xml
@@ -87,11 +87,6 @@
             <artifactId>commons-io</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>net.javacrumbs.json-unit</groupId>
             <artifactId>json-unit-fluent</artifactId>
             <scope>test</scope>
@@ -115,6 +110,21 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddDeliveredToHeaderTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddDeliveredToHeaderTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddDeliveredToHeaderTest.java
index 4e95400..168df21 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddDeliveredToHeaderTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddDeliveredToHeaderTest.java
@@ -26,14 +26,14 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class AddDeliveredToHeaderTest {
 
     private AddDeliveredToHeader testee;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         testee = new AddDeliveredToHeader();
         testee.init(FakeMailetConfig.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
index 9949b48..b5e0abb 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddFooterTest.java
@@ -20,13 +20,13 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
-import java.util.Collection;
 import java.util.List;
-import java.util.Set;
+import java.util.stream.Stream;
 
 import javax.mail.MessagingException;
 
@@ -35,34 +35,25 @@ import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
 
-@RunWith(Parameterized.class)
-public class AddFooterTest {
+class AddFooterTest {
 
     private static final String MY_FOOTER = "my footer";
-    @Rule public ExpectedException exception = ExpectedException.none();
-    
-    private final String javaCharset;
-    private final String javaMailCharset;
+
     private Mailet mailet;
     
-    @Parameters
-    public static Collection<String[]> data() {
+
+    private static Stream<Arguments> charsetTuples() {
         //javamail has its own charset handling logic, it needs to be exercised
-        List<String[]> charsets = Lists.newArrayList();
-        Set<String> charsetNamesToTest = Sets.newHashSet(
+        List<String> charsetNamesToTest = Lists.newArrayList(
                 "ANSI_X3.4-1968", 
                 "iso-ir-6", 
                 "ANSI_X3.4-1986", 
@@ -74,25 +65,17 @@ public class AddFooterTest {
                 "IBM367", 
                 "cp367",
                 "csASCII");
-        Set<List<String>> cartesianProduct = Sets.cartesianProduct(ImmutableList.of(charsetNamesToTest, charsetNamesToTest));
-        for (List<String> pair: cartesianProduct) {
-            charsets.add(new String[]{pair.get(0), pair.get(1)});
-        }
-        return charsets;
+        return charsetNamesToTest.stream().flatMap(from -> charsetNamesToTest.stream().map(to -> Arguments.of(from, to)));
     }
     
-    public AddFooterTest(String javaCharset, String javaMailCharset) {
-        this.javaCharset = javaCharset;
-        this.javaMailCharset = javaMailCharset;
-    }
-    
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new AddFooter();
     }
-    
-    @Test
-    public void shouldAddFooterWhenQuotedPrintableTextPlainMessage() throws MessagingException, IOException {
+
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldAddFooterWhenQuotedPrintableTextPlainMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("text", "------ " + MY_FOOTER + " à/€ ------")
@@ -116,8 +99,9 @@ public class AddFooterTest {
         assertThat(MailUtil.toString(mail, javaCharset)).endsWith(expectedFooter);
     }
 
-    @Test
-    public void shouldEnsureCarriageReturnWhenAddFooterWithTextPlainMessage() throws MessagingException, IOException {
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldEnsureCarriageReturnWhenAddFooterWithTextPlainMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("text", "------ " + MY_FOOTER + " à/€ ------")
@@ -140,9 +124,10 @@ public class AddFooterTest {
 
         assertThat(MailUtil.toString(mail, javaCharset)).endsWith("\r\n" + expectedFooter);
     }
-    
-    @Test
-    public void shouldNotAddFooterWhenUnsupportedEncoding() throws MessagingException, IOException {
+
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldNotAddFooterWhenUnsupportedEncoding(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("text", "------ " + MY_FOOTER + " à/€ ------")
@@ -164,8 +149,9 @@ public class AddFooterTest {
         assertThat(MailUtil.toString(mail, javaCharset)).doesNotContain(MY_FOOTER);
     }
 
-    @Test
-    public void shouldNotAddFooterWhenUnsupportedTextContentType() throws MessagingException, IOException {
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldNotAddFooterWhenUnsupportedTextContentType(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("text", "------ " + MY_FOOTER + " à/€ ------")
@@ -191,8 +177,9 @@ public class AddFooterTest {
      * Test for JAMES-443
      * This should not add the header and should leave the multipart/mixed Content-Type intact
      */
-    @Test
-    public void shouldNotAddFooterWhenNestedUnsupportedMultipart() throws MessagingException, IOException {
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldNotAddFooterWhenNestedUnsupportedMultipart(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("text", "------ " + MY_FOOTER + " à/€ ------")
@@ -227,8 +214,9 @@ public class AddFooterTest {
     /*
      * Test for JAMES-368
      */
-    @Test
-    public void shouldAddFooterWhenMultipartRelatedHtmlMessage() throws MessagingException, IOException {
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldAddFooterWhenMultipartRelatedHtmlMessage(String javaCharset, String javaMailCharset) throws MessagingException, IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("text", "------ " + MY_FOOTER + " à/€ ------")
@@ -278,9 +266,10 @@ public class AddFooterTest {
 
         assertThat(MailUtil.toString(mail, javaCharset)).contains(expectedFooter);
     }
-    
-    @Test
-    public void shouldAddFooterWhenMultipartAlternivateMessage() throws MessagingException,
+
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldAddFooterWhenMultipartAlternivateMessage(String javaCharset, String javaMailCharset) throws MessagingException,
             IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -316,8 +305,9 @@ public class AddFooterTest {
         assertThat(MailUtil.toString(mail, javaCharset)).matches("(.|\n|\r)*" + MY_FOOTER + "(.|\n|\r)*" + MY_FOOTER + "(.|\n|\r)*");
     }
 
-    @Test
-    public void shouldAddFooterWhenHtmlMessageWithMixedCaseBodyTag() throws MessagingException,
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldAddFooterWhenHtmlMessageWithMixedCaseBodyTag(String javaCharset, String javaMailCharset) throws MessagingException,
             IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -343,8 +333,9 @@ public class AddFooterTest {
         assertThat(MailUtil.toString(mail, javaCharset)).contains(htmlContent);
     }
 
-    @Test
-    public void shouldAddFooterWhenHtmlMessageWithNoBodyTag() throws MessagingException,
+    @ParameterizedTest
+    @MethodSource("charsetTuples")
+    void shouldAddFooterWhenHtmlMessageWithNoBodyTag(String javaCharset, String javaMailCharset) throws MessagingException,
             IOException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -373,7 +364,7 @@ public class AddFooterTest {
     
     @SuppressWarnings("unchecked")
     @Test
-    public void shouldThrowMessagingExceptionWhenIOExceptionReadingMessage() throws MessagingException {
+    void shouldThrowMessagingExceptionWhenIOExceptionReadingMessage() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("text", "------ " + MY_FOOTER + " à/€ ------")
@@ -382,8 +373,6 @@ public class AddFooterTest {
         
         Mail mail = mock(Mail.class);
         when(mail.getMessage()).thenThrow(IOException.class);
-        exception.expect(MessagingException.class);
-        
-        mailet.service(mail);
+        assertThatThrownBy(() -> mailet.service(mail)).isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddSubjectPrefixTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddSubjectPrefixTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddSubjectPrefixTest.java
index 5799c42..b351544 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddSubjectPrefixTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AddSubjectPrefixTest.java
@@ -21,6 +21,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
@@ -29,24 +30,20 @@ import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class AddSubjectPrefixTest {
+class AddSubjectPrefixTest {
 
-    @Rule public ExpectedException expectedException = ExpectedException.none();
-    
     private Mailet mailet;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new AddSubjectPrefix();
     }
     
     @Test
-    public void shouldAddPrefixToSubject() throws MessagingException {
+    void shouldAddPrefixToSubject() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPrefix", "JUNIT")
@@ -63,7 +60,7 @@ public class AddSubjectPrefixTest {
 
     
     @Test
-    public void shouldAddPrefixToEncodedSubject() throws MessagingException {
+    void shouldAddPrefixToEncodedSubject() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPrefix", "Русский")
@@ -82,7 +79,7 @@ public class AddSubjectPrefixTest {
 
     
     @Test
-    public void shouldDefinePrefixAsSubjectWhenNoSubject() throws MessagingException {
+    void shouldDefinePrefixAsSubjectWhenNoSubject() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPrefix", "JUNIT")
@@ -99,7 +96,7 @@ public class AddSubjectPrefixTest {
     }
 
     @Test
-    public void shouldDefinePrefixAsSubjectWhenEmptySubject() throws MessagingException {
+    void shouldDefinePrefixAsSubjectWhenEmptySubject() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPrefix", "JUNIT")
@@ -115,14 +112,13 @@ public class AddSubjectPrefixTest {
     }
     
     @Test
-    public void shouldThrowWhenEmptyPrefix() throws MessagingException {
+    void shouldThrowWhenEmptyPrefix() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPrefix", "")
                 .build();
 
-        expectedException.expect(MessagingException.class);
-
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttributeTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttributeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttributeTest.java
index 29f873b..4b549d2 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttributeTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttributeTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -37,10 +38,8 @@ import org.apache.mailet.MailetContext;
 import org.apache.mailet.MailetException;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.slf4j.Logger;
 
@@ -55,7 +54,7 @@ import com.rabbitmq.client.Connection;
 import com.rabbitmq.client.ConnectionFactory;
 import com.rabbitmq.client.ShutdownSignalException;
 
-public class AmqpForwardAttributeTest {
+class AmqpForwardAttributeTest {
 
     private static final String MAIL_ATTRIBUTE = "ampq.attachments";
     private static final String EXCHANGE_NAME = "exchangeName";
@@ -64,18 +63,14 @@ public class AmqpForwardAttributeTest {
     private static final byte[] ATTACHMENT_CONTENT = "Attachment content".getBytes(StandardCharsets.UTF_8);
     private static final ImmutableMap<String, byte[]> ATTRIBUTE_CONTENT = ImmutableMap.of("attachment1.txt", ATTACHMENT_CONTENT);
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     private AmqpForwardAttribute mailet;
-    private Logger logger;
     private MailetContext mailetContext;
     private FakeMailetConfig mailetConfig;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         mailet = new AmqpForwardAttribute();
-        logger = mock(Logger.class);
+        Logger logger = mock(Logger.class);
         mailetContext = FakeMailContext.builder()
                 .logger(logger)
                 .build();
@@ -90,40 +85,40 @@ public class AmqpForwardAttributeTest {
     }
 
     @Test
-    public void initShouldThrowWhenNoUriParameter() throws MessagingException {
+    void initShouldThrowWhenNoUriParameter() {
         FakeMailetConfig customMailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
                 .build();
-        expectedException.expect(MailetException.class);
-        mailet.init(customMailetConfig);
+        assertThatThrownBy(() -> mailet.init(customMailetConfig))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void initShouldThrowWhenNoExchangeParameter() throws MessagingException {
+    void initShouldThrowWhenNoExchangeParameter() {
         FakeMailetConfig customMailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
                 .setProperty("uri", AMQP_URI)
                 .build();
-        expectedException.expect(MailetException.class);
-        mailet.init(customMailetConfig);
+        assertThatThrownBy(() -> mailet.init(customMailetConfig))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void initShouldThrowWhenNoAttributeParameter() throws MessagingException {
+    void initShouldThrowWhenNoAttributeParameter() {
         FakeMailetConfig customMailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
                 .setProperty("uri", AMQP_URI)
                 .setProperty("exchange", EXCHANGE_NAME)
                 .build();
-        expectedException.expect(MailetException.class);
-        mailet.init(customMailetConfig);
+        assertThatThrownBy(() -> mailet.init(customMailetConfig))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void initShouldThrowWhenInvalidUri() throws MessagingException {
+    void initShouldThrowWhenInvalidUri() {
         FakeMailetConfig customMailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
@@ -131,17 +126,17 @@ public class AmqpForwardAttributeTest {
                 .setProperty("exchange", EXCHANGE_NAME)
                 .setProperty("attribute", MAIL_ATTRIBUTE)
                 .build();
-        expectedException.expect(MailetException.class);
-        mailet.init(customMailetConfig);
+        assertThatThrownBy(() -> mailet.init(customMailetConfig))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void getMailetInfoShouldReturnInfo() {
+    void getMailetInfoShouldReturnInfo() {
         assertThat(mailet.getMailetInfo()).isEqualTo("AmqpForwardAttribute");
     }
 
     @Test
-    public void initShouldIntializeEmptyRoutingKeyWhenAllParametersButRoutingKey() throws MessagingException {
+    void initShouldIntializeEmptyRoutingKeyWhenAllParametersButRoutingKey() throws MessagingException {
         FakeMailetConfig customMailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
@@ -155,7 +150,7 @@ public class AmqpForwardAttributeTest {
     }
 
     @Test
-    public void initShouldNotThrowWithAllParameters() throws MessagingException {
+    void initShouldNotThrowWithAllParameters() throws MessagingException {
         mailet.init(mailetConfig);
     }
 
@@ -180,9 +175,8 @@ public class AmqpForwardAttributeTest {
         Mail mail = mock(Mail.class);
         when(mail.getAttribute(MAIL_ATTRIBUTE)).thenReturn(2);
 
-        expectedException.expect(MailetException.class);
-
-        mailet.service(mail);
+        assertThatThrownBy(() -> mailet.service(mail))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
index af54793..dc33e0b 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
@@ -35,8 +35,8 @@ import org.apache.mailet.MailetException;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.fasterxml.jackson.core.JsonGenerationException;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -51,7 +51,7 @@ public class ContactExtractorTest {
     private MailetContext mailetContext;
     private FakeMailetConfig mailetConfig;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         mailet = new ContactExtractor();
         mailetContext = FakeMailContext.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContentReplacerTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContentReplacerTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContentReplacerTest.java
index 6413786..c9dc99b 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContentReplacerTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ContentReplacerTest.java
@@ -31,7 +31,7 @@ import java.util.regex.Pattern;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
index 920b5c5..ef03a8f 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/LogMessageTest.java
@@ -37,24 +37,19 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 
-public class LogMessageTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class LogMessageTest {
 
     private LogMessage mailet;
     private FakeMailContext mailContext;
     private Logger logger;
 
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         logger = mock(Logger.class);
         when(logger.isInfoEnabled()).thenReturn(true);
         mailContext = FakeMailContext.builder()
@@ -64,12 +59,12 @@ public class LogMessageTest {
     }
 
     @Test
-    public void getMailetInfoShouldReturnValue() {
+    void getMailetInfoShouldReturnValue() {
         assertThat(mailet.getMailetInfo()).isEqualTo("LogHeaders Mailet");
     }
 
     @Test
-    public void initShouldIgnoreExceptions() throws Exception {
+    void initShouldIgnoreExceptions() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -79,7 +74,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldFailWhenMailHasNoStream() throws Exception {
+    void serviceShouldFailWhenMailHasNoStream() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -101,7 +96,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldLog() throws Exception {
+    void serviceShouldLog() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -120,7 +115,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldLogWhenExceptionOccured() throws Exception {
+    void serviceShouldLogWhenExceptionOccured() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -142,7 +137,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldSetTheMailStateWhenPassThroughIsFalse() throws Exception {
+    void serviceShouldSetTheMailStateWhenPassThroughIsFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -157,7 +152,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldNotChangeTheMailStateWhenPassThroughIsTrue() throws Exception {
+    void serviceShouldNotChangeTheMailStateWhenPassThroughIsTrue() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -173,7 +168,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldNotLogHeadersWhenFalse() throws Exception {
+    void serviceShouldNotLogHeadersWhenFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -190,7 +185,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldNotLogBodyWhenFalse() throws Exception {
+    void serviceShouldNotLogBodyWhenFalse() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -209,7 +204,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldNotLogFullBodyWhenBodyMaxIsSet() throws Exception {
+    void serviceShouldNotLogFullBodyWhenBodyMaxIsSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)
@@ -229,7 +224,7 @@ public class LogMessageTest {
     }
 
     @Test
-    public void serviceShouldLogAdditionalCommentWhenCommentIsSet() throws Exception {
+    void serviceShouldLogAdditionalCommentWhenCommentIsSet() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("LogContext")
                 .mailetContext(mailContext)

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesListToMimeHeadersTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesListToMimeHeadersTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesListToMimeHeadersTest.java
index 1dad2bb..1849155 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesListToMimeHeadersTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesListToMimeHeadersTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.ArrayList;
 
@@ -30,14 +31,12 @@ import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class MailAttributesListToMimeHeadersTest {
+class MailAttributesListToMimeHeadersTest {
 
     private static final String VALUE_1_1 = "test1.1";
     private static final String VALUE_1_2 = "test1.2";
@@ -51,40 +50,36 @@ public class MailAttributesListToMimeHeadersTest {
     private static final String HEADER_NAME1 = "JUNIT";
     private static final String HEADER_NAME2 = "JUNIT2";
 
-    @Rule public ExpectedException expectedException = ExpectedException.none();
-
     private Mailet mailet;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new MailAttributesListToMimeHeaders();
     }
 
     @Test
-    public void shouldThrowMessagingExceptionIfMappingIsNotGiven() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-
+    void shouldThrowMessagingExceptionIfMappingIsNotGiven() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .build();
 
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void shouldThrowMessagingExceptionIfMappingIsEmpty() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-
+    void shouldThrowMessagingExceptionIfMappingIsEmpty() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemmapping", "")
             .build();
 
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void shouldIgnoreAttributeOfMappingThatDoesNotExistOnTheMessage() throws MessagingException {
+    void shouldIgnoreAttributeOfMappingThatDoesNotExistOnTheMessage() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemapping",
@@ -106,7 +101,7 @@ public class MailAttributesListToMimeHeadersTest {
     }
 
     @Test
-    public void shouldWorkWithMappingWithASingleBinding() throws MessagingException {
+    void shouldWorkWithMappingWithASingleBinding() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemapping",
@@ -127,7 +122,7 @@ public class MailAttributesListToMimeHeadersTest {
     }
 
     @Test
-    public void shouldIgnoreNullValueInsideList() throws MessagingException {
+    void shouldIgnoreNullValueInsideList() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemapping",
@@ -136,7 +131,7 @@ public class MailAttributesListToMimeHeadersTest {
 
         mailet.init(mailetConfig);
 
-        ArrayList<String> listWithNull = new ArrayList<String>();
+        ArrayList<String> listWithNull = new ArrayList<>();
         listWithNull.add("1");
         listWithNull.add(null);
         listWithNull.add("2");
@@ -152,7 +147,7 @@ public class MailAttributesListToMimeHeadersTest {
     }
 
     @Test
-    public void shouldPutAttributesIntoHeadersWhenMappingDefined() throws MessagingException {
+    void shouldPutAttributesIntoHeadersWhenMappingDefined() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping",
@@ -179,7 +174,7 @@ public class MailAttributesListToMimeHeadersTest {
     }
 
     @Test
-    public void shouldNotRemovePreviousAttributeValueWhenAttributeAlreadyPresent() throws MessagingException {
+    void shouldNotRemovePreviousAttributeValueWhenAttributeAlreadyPresent() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping", MAIL_ATTRIBUTE_NAME1 + "; " + HEADER_NAME1)
@@ -200,7 +195,7 @@ public class MailAttributesListToMimeHeadersTest {
     }
 
     @Test
-    public void shouldFilterAttributeOfWrongClass() throws MessagingException {
+    void shouldFilterAttributeOfWrongClass() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemapping",
@@ -224,7 +219,7 @@ public class MailAttributesListToMimeHeadersTest {
 
 
     @Test
-    public void shouldFilterAttributeElementsOfWrongClass() throws MessagingException {
+    void shouldFilterAttributeElementsOfWrongClass() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemapping", MAIL_ATTRIBUTE_NAME1 + "; " + HEADER_NAME1)
@@ -244,37 +239,34 @@ public class MailAttributesListToMimeHeadersTest {
 
 
     @Test
-    public void shouldThrowAtInitWhenNoSemicolumnInConfigurationEntry() throws MessagingException {
-        expectedException.expect(IllegalArgumentException.class);
-
+    void shouldThrowAtInitWhenNoSemicolumnInConfigurationEntry() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping", "invalidConfigEntry")
                 .build();
 
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void shouldThrowAtInitWhenTwoSemicolumnsInConfigurationEntry() throws MessagingException {
-        expectedException.expect(IllegalArgumentException.class);
-
+    void shouldThrowAtInitWhenTwoSemicolumnsInConfigurationEntry() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping", "first;second;third")
                 .build();
 
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void shouldThrowAtInitWhenNoConfigurationEntry() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-
+    void shouldThrowAtInitWhenNoConfigurationEntry() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
 
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesToMimeHeadersTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesToMimeHeadersTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesToMimeHeadersTest.java
index b02fedf..3b9e845 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesToMimeHeadersTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MailAttributesToMimeHeadersTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
@@ -28,15 +29,11 @@ import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class MailAttributesToMimeHeadersTest {
+class MailAttributesToMimeHeadersTest {
 
-    @Rule public ExpectedException expectedException = ExpectedException.none();
-    
     private Mailet mailet;
 
     private static final String HEADER_NAME1 = "JUNIT";
@@ -48,34 +45,34 @@ public class MailAttributesToMimeHeadersTest {
     private static final String MAIL_ATTRIBUTE_NAME1 = "org.apache.james.test";
     private static final String MAIL_ATTRIBUTE_NAME2 = "org.apache.james.test2";
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new MailAttributesToMimeHeaders();
     }
 
     @Test
-    public void shouldThrowMessagingExceptionIfMappingIsNotGiven() throws MessagingException {
-        expectedException.expect(MessagingException.class);
+    void shouldThrowMessagingExceptionIfMappingIsNotGiven() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .build();
 
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void shouldThrowMessagingExceptionIfMappingIsEmpty() throws MessagingException {
-        expectedException.expect(MessagingException.class);
+    void shouldThrowMessagingExceptionIfMappingIsEmpty() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemmapping", "")
             .build();
 
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void shouldIgnoreAttributeOfMappingThatDoesNotExistOnTheMessage() throws MessagingException {
+    void shouldIgnoreAttributeOfMappingThatDoesNotExistOnTheMessage() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemapping",
@@ -95,7 +92,7 @@ public class MailAttributesToMimeHeadersTest {
     }
 
     @Test
-    public void shouldWorkWithMappingWithASingleBinding() throws MessagingException {
+    void shouldWorkWithMappingWithASingleBinding() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("simplemapping",
@@ -112,7 +109,7 @@ public class MailAttributesToMimeHeadersTest {
     }
 
     @Test
-    public void shouldPutAttributesIntoHeadersWhenMappingDefined() throws MessagingException {
+    void shouldPutAttributesIntoHeadersWhenMappingDefined() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping", 
@@ -134,7 +131,7 @@ public class MailAttributesToMimeHeadersTest {
     }
 
     @Test
-    public void shouldAddAttributeIntoHeadersWhenHeaderAlreadyPresent() throws MessagingException {
+    void shouldAddAttributeIntoHeadersWhenHeaderAlreadyPresent() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping", MAIL_ATTRIBUTE_NAME1 + "; " + HEADER_NAME1)
@@ -153,31 +150,31 @@ public class MailAttributesToMimeHeadersTest {
 
     
     @Test
-    public void shouldThrowAtInitWhenNoSemicolumnInConfigurationEntry() throws MessagingException {
+    void shouldThrowAtInitWhenNoSemicolumnInConfigurationEntry() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping", "invalidConfigEntry")
                 .build();
-        expectedException.expect(IllegalArgumentException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void shouldThrowAtInitWhenTwoSemicolumnsInConfigurationEntry() throws MessagingException {
+    void shouldThrowAtInitWhenTwoSemicolumnsInConfigurationEntry() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("simplemapping", "first;second;third")
                 .build();
-        expectedException.expect(IllegalArgumentException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void shouldThrowAtInitWhenNoConfigurationEntry() throws MessagingException {
+    void shouldThrowAtInitWhenNoConfigurationEntry() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
-        expectedException.expect(MessagingException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/MappingArgumentTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MappingArgumentTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MappingArgumentTest.java
index 4199b4a..19faac6 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MappingArgumentTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MappingArgumentTest.java
@@ -20,75 +20,71 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
 import org.assertj.core.data.MapEntry;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
-public class MappingArgumentTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class MappingArgumentTest {
 
     @Test
-    public void parseShouldFailIfCalledWithNull() throws MessagingException {
-        expectedException.expect(IllegalArgumentException.class);
-        MappingArgument.parse(null);
+    void parseShouldFailIfCalledWithNull() {
+        assertThatThrownBy(() -> MappingArgument.parse(null))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void parseShouldFailIfCalledWhenMissingMappingParts() throws MessagingException {
-        expectedException.expect(IllegalArgumentException.class);
-        MappingArgument.parse("key1;value1,key2");
+    void parseShouldFailIfCalledWhenMissingMappingParts() {
+        assertThatThrownBy(() -> MappingArgument.parse("key1;value1,key2"))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void parseShouldFailIfCalledWhenExtraMappingParts() throws MessagingException {
-        expectedException.expect(IllegalArgumentException.class);
-        MappingArgument.parse("key1;value1,key2;value1;value3");
+    void parseShouldFailIfCalledWhenExtraMappingParts() {
+        assertThatThrownBy(() -> MappingArgument.parse("key1;value1,key2;value1;value3"))
+           .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void parseShouldWorkForEmptyMapping() throws MessagingException {
+    void parseShouldWorkForEmptyMapping() throws MessagingException {
         assertThat(MappingArgument.parse(""))
             .isEmpty();
     }
 
     @Test
-    public void parseShouldWorkForEmptyMappingWithSpace() throws MessagingException {
+    void parseShouldWorkForEmptyMappingWithSpace() throws MessagingException {
         assertThat(MappingArgument.parse("  "))
             .isEmpty();
     }
 
     @Test
-    public void parseShouldWorkForValidParsingWithOnlyOneKey() throws MessagingException {
+    void parseShouldWorkForValidParsingWithOnlyOneKey() throws MessagingException {
         assertThat(MappingArgument.parse("key1;value1"))
             .containsExactly(MapEntry.entry("key1", "value1"));
     }
 
     @Test
-    public void parseShouldWorkForValidParsingWithMoreThanOneKey() throws MessagingException {
+    void parseShouldWorkForValidParsingWithMoreThanOneKey() throws MessagingException {
         assertThat(MappingArgument.parse("key1;value1,key2;value2"))
             .containsExactly(MapEntry.entry("key1", "value1"), MapEntry.entry("key2", "value2"));
     }
 
     @Test
-    public void parserShouldTrimSpacesAroundSemiColon() throws MessagingException {
+    void parserShouldTrimSpacesAroundSemiColon() throws MessagingException {
         assertThat(MappingArgument.parse("key1;    value1"))
             .containsExactly(MapEntry.entry("key1", "value1"));
     }
 
     @Test
-    public void parserShouldTrimSpacesAroundComa() throws MessagingException {
+    void parserShouldTrimSpacesAroundComa() throws MessagingException {
         assertThat(MappingArgument.parse("key1;value1,  key2;value2"))
             .containsExactly(MapEntry.entry("key1", "value1"), MapEntry.entry("key2", "value2"));
     }
 
     @Test
-    public void parserShouldNotFailWhenExtraComa() throws MessagingException {
+    void parserShouldNotFailWhenExtraComa() throws MessagingException {
         assertThat(MappingArgument.parse("key1;value1,"))
             .containsExactly(MapEntry.entry("key1", "value1"));
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/MimeDecodingMailetTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MimeDecodingMailetTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MimeDecodingMailetTest.java
index c8d1a7e..dc62744 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/MimeDecodingMailetTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/MimeDecodingMailetTest.java
@@ -19,6 +19,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
 import java.nio.charset.StandardCharsets;
@@ -32,58 +33,52 @@ import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.assertj.core.data.MapEntry;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
-public class MimeDecodingMailetTest {
+class MimeDecodingMailetTest {
 
     private static final String MAIL_ATTRIBUTE = "mime.attachments";
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    private Logger logger;
     private MailetContext mailetContext;
     private MimeDecodingMailet testee;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         testee = new MimeDecodingMailet();
-        logger = mock(Logger.class);
+        Logger logger = mock(Logger.class);
         mailetContext = FakeMailContext.builder()
                 .logger(logger)
                 .build();
     }
 
     @Test
-    public void initShouldThrowWhenNoAttributeParameter() throws MessagingException {
+    void initShouldThrowWhenNoAttributeParameter() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
                 .build();
-        expectedException.expect(MailetException.class);
-        testee.init(mailetConfig);
+        assertThatThrownBy(() -> testee.init(mailetConfig))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void initShouldThrowWhenAttributeParameterIsEmpty() throws MessagingException {
+    void initShouldThrowWhenAttributeParameterIsEmpty() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
                 .setProperty(MimeDecodingMailet.ATTRIBUTE_PARAMETER_NAME, "")
                 .build();
-        expectedException.expect(MailetException.class);
-        testee.init(mailetConfig);
+        assertThatThrownBy(() -> testee.init(mailetConfig))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void serviceShouldNotThrowWhenAttributeContentIsNotAMap() throws MessagingException {
+    void serviceShouldNotThrowWhenAttributeContentIsNotAMap() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
@@ -98,7 +93,7 @@ public class MimeDecodingMailetTest {
     }
 
     @Test
-    public void serviceShouldNotThrowWhenAttributeContentIsAMapOfWrongTypes() throws MessagingException {
+    void serviceShouldNotThrowWhenAttributeContentIsAMapOfWrongTypes() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
@@ -113,7 +108,7 @@ public class MimeDecodingMailetTest {
     }
 
     @Test
-    public void serviceShouldNotSetAttributeWhenNone() throws MessagingException {
+    void serviceShouldNotSetAttributeWhenNone() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)
@@ -129,7 +124,7 @@ public class MimeDecodingMailetTest {
 
     @Test
     @SuppressWarnings("unchecked")
-    public void serviceShouldChangeAttributeWhenDefined() throws MessagingException {
+    void serviceShouldChangeAttributeWhenDefined() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailetContext)

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
index 9bd6ec6..270000d 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
@@ -26,14 +26,14 @@ import javax.mail.MessagingException;
 
 import org.apache.mailet.Mailet;
 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;
 
 public class NullTest {
 
     private Mailet mailet;
 
-    @Before
+    @BeforeEach
     public void setup() {
         mailet = new Null();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/OnlyTextTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/OnlyTextTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/OnlyTextTest.java
index 4ce817f..16c7325 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/OnlyTextTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/OnlyTextTest.java
@@ -19,6 +19,9 @@
 
 package org.apache.james.transport.mailets;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.io.IOException;
 import java.util.Properties;
 
@@ -32,10 +35,9 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
+import org.junit.jupiter.api.Test;
 
-import junit.framework.TestCase;
-
-public class OnlyTextTest extends TestCase {
+class OnlyTextTest {
 
     /**
      * Test method for
@@ -45,7 +47,8 @@ public class OnlyTextTest extends TestCase {
      * @throws MessagingException
      * @throws IOException
      */
-    public void testService() throws MessagingException, IOException {
+    @Test
+    void testService() throws MessagingException, IOException {
         Mailet mailet;
         FakeMailetConfig mci;
         MimeMessage message;
@@ -177,7 +180,8 @@ public class OnlyTextTest extends TestCase {
         assertTrue(mail.getMessage().isMimeType("text/plain"));
     }
 
-    public void testHtml2Text() throws MessagingException {
+    @Test
+    void testHtml2Text() throws MessagingException {
         OnlyText mailet = new OnlyText();
         mailet.init(FakeMailetConfig.builder()
                 .mailetName("Test")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/PatternExtractorTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/PatternExtractorTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/PatternExtractorTest.java
index 72ab701..d502b40 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/PatternExtractorTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/PatternExtractorTest.java
@@ -20,30 +20,26 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.List;
 import java.util.regex.Pattern;
 
 import org.apache.mailet.MailetException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class PatternExtractorTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class PatternExtractorTest {
 
     private PatternExtractor testee;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         testee = new PatternExtractor();
     }
 
     @Test
-    public void getPatternsFromStringShouldReturnValuesWhenMultiplePatterns() throws Exception {
+    void getPatternsFromStringShouldReturnValuesWhenMultiplePatterns() throws Exception {
         List<ReplacingPattern> patternsFromString = testee.getPatternsFromString("/test/TEST/i/,/a/e//,/o/o/ir/");
 
         assertThat(patternsFromString).containsOnly(
@@ -53,7 +49,7 @@ public class PatternExtractorTest {
     }
 
     @Test
-    public void getPatternsFromFileListShouldReturnValuesWhenMultiplePatterns() throws Exception {
+    void getPatternsFromFileListShouldReturnValuesWhenMultiplePatterns() throws Exception {
         List<ReplacingPattern> patternsFromFileList = testee.getPatternsFromFileList("#/org/apache/james/mailet/standard/mailets/replaceSubject.patterns");
 
         assertThat(patternsFromFileList).containsOnly(
@@ -63,40 +59,34 @@ public class PatternExtractorTest {
     }
 
     @Test
-    public void getPatternsFromStringShouldThrowWhenPatternIsLessThanTwoCharacters() throws Exception {
-        expectedException.expect(MailetException.class);
-
-        testee.getPatternsFromString("a");
+    void getPatternsFromStringShouldThrowWhenPatternIsLessThanTwoCharacters() {
+        assertThatThrownBy(() -> testee.getPatternsFromString("a")).isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void getPatternsFromStringShouldThrowWhenPatternDoesNotStartWithSlash() throws Exception {
-        expectedException.expect(MailetException.class);
-
-        testee.getPatternsFromString("abc/");
+    void getPatternsFromStringShouldThrowWhenPatternDoesNotStartWithSlash() {
+        assertThatThrownBy(() -> testee.getPatternsFromString("abc/")).isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void getPatternsFromStringShouldThrowWhenPatternDoesNotEndWithSlash() throws Exception {
-        expectedException.expect(MailetException.class);
-
-        testee.getPatternsFromString("/abc");
+    void getPatternsFromStringShouldThrowWhenPatternDoesNotEndWithSlash() {
+        assertThatThrownBy(() -> testee.getPatternsFromString("/abc")).isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void serviceShouldUnescapeCarriageReturn() throws Exception {
+    void serviceShouldUnescapeCarriageReturn() throws Exception {
         List<ReplacingPattern> patternsFromString = testee.getPatternsFromString("/a/\\\\r/i/");
         assertThat(patternsFromString).containsOnly(new ReplacingPattern(Pattern.compile("a"), false, "\\\r"));
     }
 
     @Test
-    public void serviceShouldUnescapeLineBreak() throws Exception {
+    void serviceShouldUnescapeLineBreak() throws Exception {
         List<ReplacingPattern> patternsFromString = testee.getPatternsFromString("/a/\\\\n/i/");
         assertThat(patternsFromString).containsOnly(new ReplacingPattern(Pattern.compile("a"), false, "\\\n"));
     }
 
     @Test
-    public void serviceShouldUnescapeTabReturn() throws Exception {
+    void serviceShouldUnescapeTabReturn() throws Exception {
         List<ReplacingPattern> patternsFromString = testee.getPatternsFromString("/a/\\\\t/i/");
         assertThat(patternsFromString).containsOnly(new ReplacingPattern(Pattern.compile("a"), false, "\\\t"));
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/PostmasterAliasTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/PostmasterAliasTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/PostmasterAliasTest.java
index f485158..56ac5a1 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/PostmasterAliasTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/PostmasterAliasTest.java
@@ -27,15 +27,15 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class PostmasterAliasTest {
     private PostmasterAlias testee;
     private MailAddress postmaster;
     private MailAddress postmasterAlias;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         postmaster = new MailAddress("admin@localhost");
         postmasterAlias = new MailAddress("postmaster@localhost");

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
index 49762c6..f59761f 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RecipientToLowerCaseTest.java
@@ -25,14 +25,14 @@ import java.util.Collection;
 
 import org.apache.james.core.MailAddress;
 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;
 
 public class RecipientToLowerCaseTest {
 
     private RecipientToLowerCase testee;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         testee = new RecipientToLowerCase();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveAllMailAttributesTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveAllMailAttributesTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveAllMailAttributesTest.java
index 7f2c0e3..0dba54c 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveAllMailAttributesTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveAllMailAttributesTest.java
@@ -28,15 +28,15 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class RemoveAllMailAttributesTest {
 
     private Mail mail;
     private Mailet mailet;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMailAttributeTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMailAttributeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMailAttributeTest.java
index fd9bb39..1881dd3 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMailAttributeTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMailAttributeTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
@@ -28,10 +29,10 @@ import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetException;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class RemoveMailAttributeTest {
+class RemoveMailAttributeTest {
 
     private static final String ATTRIBUTE_1 = "attribute1";
     private static final String ATTRIBUTE_2 = "attribute2";
@@ -42,31 +43,31 @@ public class RemoveMailAttributeTest {
     private static final String ATTRIBUTE1_ATTRIBUTE2 = "attribute1, attribute2";
     private Mailet removeMailet;
 
-    @Before
-    public void setup() throws Exception {
+    @BeforeEach
+    void setup() {
         removeMailet = new RemoveMailAttribute();
     }
 
     @Test
-    public void getMailetInfoShouldReturnCorrectInformation() throws Exception {
+    void getMailetInfoShouldReturnCorrectInformation() {
         assertThat(removeMailet.getMailetInfo()).isEqualTo("Remove Mail Attribute Mailet");
     }
 
-    @Test(expected = MailetException.class)
-    public void initShouldThrowExceptionIfMailetConfigDoesNotContainAttribute() throws MessagingException {
+    @Test
+    void initShouldThrowExceptionIfMailetConfigDoesNotContainAttribute() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
-        removeMailet.init(mailetConfig);
+        assertThatThrownBy(() -> removeMailet.init(mailetConfig)).isInstanceOf(MailetException.class);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void serviceShouldThrowExceptionWithMailNull() throws MessagingException {
-        removeMailet.service(null);
+    @Test
+    void serviceShouldThrowExceptionWithMailNull() {
+        assertThatThrownBy(() -> removeMailet.service(null)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void serviceShouldDoNothingWhenMailHasEmptyAttribute() throws MessagingException {
+    void serviceShouldDoNothingWhenMailHasEmptyAttribute() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty(RemoveMailAttribute.MAILET_NAME_PARAMETER, ATTRIBUTE1_ATTRIBUTE2)
@@ -80,7 +81,7 @@ public class RemoveMailAttributeTest {
     }
 
     @Test
-    public void serviceShouldDoNothingWhenMailDoNotMatchAttribute() throws MessagingException {
+    void serviceShouldDoNothingWhenMailDoNotMatchAttribute() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty(RemoveMailAttribute.MAILET_NAME_PARAMETER, ATTRIBUTE1_ATTRIBUTE2)
@@ -96,7 +97,7 @@ public class RemoveMailAttributeTest {
     }
 
     @Test
-    public void serviceShouldRemoveSpecifiedAttribute() throws MessagingException {
+    void serviceShouldRemoveSpecifiedAttribute() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty(RemoveMailAttribute.MAILET_NAME_PARAMETER, ATTRIBUTE_1)
@@ -114,7 +115,7 @@ public class RemoveMailAttributeTest {
     }
 
     @Test
-    public void serviceShouldRemoveSpecifiedAttributes() throws MessagingException {
+    void serviceShouldRemoveSpecifiedAttributes() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty(RemoveMailAttribute.MAILET_NAME_PARAMETER, ATTRIBUTE1_ATTRIBUTE2)

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderByPrefixTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderByPrefixTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderByPrefixTest.java
index 5008d8e..51143c4 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderByPrefixTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderByPrefixTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
@@ -29,35 +30,30 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class RemoveMimeHeaderByPrefixTest {
+class RemoveMimeHeaderByPrefixTest {
 
     private static final String PREFIX = "X-OPENPAAS-";
     private static final String HEADER_NAME_PREFIX_1 = "X-OPENPAAS-FEATURE-A";
     private static final String HEADER_NAME_PREFIX_2 = "X-OPENPAAS-FEATURE-B";
     private static final String HEADER_NAME_NO_PREFIX = "X-OTHER-BUSINESS";
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     private GenericMailet mailet;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new RemoveMimeHeaderByPrefix();
     }
 
     @Test
-    public void getMailetInfoShouldReturnValue() {
+    void getMailetInfoShouldReturnValue() {
         assertThat(mailet.getMailetInfo()).isEqualTo("RemoveMimeHeaderByPrefix Mailet");
     }
 
     @Test
-    public void serviceShouldRemoveHeaderWhenPrefixed() throws MessagingException {
+    void serviceShouldRemoveHeaderWhenPrefixed() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("prefix", PREFIX)
@@ -75,7 +71,7 @@ public class RemoveMimeHeaderByPrefixTest {
     }
 
     @Test
-    public void serviceShouldRemoveAllPrefixedHeaders() throws MessagingException {
+    void serviceShouldRemoveAllPrefixedHeaders() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("prefix", PREFIX)
@@ -94,7 +90,7 @@ public class RemoveMimeHeaderByPrefixTest {
     }
 
     @Test
-    public void serviceShouldNotRemoveNonPrefixedHeaders() throws MessagingException {
+    void serviceShouldNotRemoveNonPrefixedHeaders() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("prefix", PREFIX)
@@ -114,7 +110,7 @@ public class RemoveMimeHeaderByPrefixTest {
     }
 
     @Test
-    public void exactMatchOfPrefixShouldBeAllowed() throws MessagingException {
+    void exactMatchOfPrefixShouldBeAllowed() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty("prefix", PREFIX)
@@ -135,21 +131,19 @@ public class RemoveMimeHeaderByPrefixTest {
 
 
     @Test
-    public void initShouldThrowWhenInvalidConfig() throws MessagingException {
-        expectedException.expect(MessagingException.class);
+    void initShouldThrowWhenInvalidConfig() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowWhenPrefixEmpty() throws MessagingException {
-        expectedException.expect(MessagingException.class);
+    void initShouldThrowWhenPrefixEmpty() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
             .mailetName("Test")
             .setProperty(RemoveMimeHeaderByPrefix.PREFIX, "")
             .build();
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderTest.java
index cfce358..7e97007 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/RemoveMimeHeaderTest.java
@@ -32,33 +32,28 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class RemoveMimeHeaderTest {
+class RemoveMimeHeaderTest {
 
     private static final String HEADER1 = "header1";
     private static final String HEADER2 = "header2";
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     private GenericMailet mailet;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new RemoveMimeHeader();
     }
 
     @Test
-    public void getMailetInfoShouldReturnValue() {
+    void getMailetInfoShouldReturnValue() {
         assertThat(mailet.getMailetInfo()).isEqualTo("RemoveMimeHeader Mailet");
     }
 
     @Test
-    public void serviceShouldRemoveHeaderWhenOneMatching() throws MessagingException {
+    void serviceShouldRemoveHeaderWhenOneMatching() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", HEADER1)
@@ -76,7 +71,7 @@ public class RemoveMimeHeaderTest {
     }
 
     @Test
-    public void serviceShouldRemoveHeadersWhenTwoMatching() throws MessagingException {
+    void serviceShouldRemoveHeadersWhenTwoMatching() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", HEADER1 + "," + HEADER2)
@@ -94,7 +89,7 @@ public class RemoveMimeHeaderTest {
     }
 
     @Test
-    public void serviceShouldNotRemoveHeaderWhenNoneMatching() throws MessagingException {
+    void serviceShouldNotRemoveHeaderWhenNoneMatching() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "other1")
@@ -113,7 +108,7 @@ public class RemoveMimeHeaderTest {
     }
 
     @Test
-    public void serviceShouldNotRemoveHeaderWhenEmptyConfig() throws MessagingException {
+    void serviceShouldNotRemoveHeaderWhenEmptyConfig() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "")
@@ -131,17 +126,16 @@ public class RemoveMimeHeaderTest {
     }
 
     @Test
-    public void initShouldThrowWhenInvalidConfig() throws MessagingException {
-        expectedException.expect(MessagingException.class);
+    void initShouldThrowWhenInvalidConfig() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void serviceShouldThrowWhenExceptionOccured() throws MessagingException {
+    void serviceShouldThrowWhenExceptionOccured() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/ReplaceContentTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ReplaceContentTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ReplaceContentTest.java
index cb9d9db..508c4c1 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ReplaceContentTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ReplaceContentTest.java
@@ -30,30 +30,25 @@ import org.apache.james.util.MimeMessageUtil;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class ReplaceContentTest {
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     private ReplaceContent mailet;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new ReplaceContent();
     }
 
     @Test
-    public void getMailetInfoShouldReturnValue() {
+    void getMailetInfoShouldReturnValue() {
         assertThat(mailet.getMailetInfo()).isEqualTo("ReplaceContent");
     }
 
     @Test
-    public void serviceShouldReplaceSubjectWhenMatching() throws Exception {
+    void serviceShouldReplaceSubjectWhenMatching() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPattern", "/test/TEST/i/,/o/a//,/s/s/i/")
@@ -70,7 +65,7 @@ public class ReplaceContentTest {
     }
 
     @Test
-    public void serviceShouldReplaceBodyWhenMatching() throws Exception {
+    void serviceShouldReplaceBodyWhenMatching() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("bodyPattern", 
@@ -95,7 +90,7 @@ public class ReplaceContentTest {
     }
 
     @Test
-    public void serviceShouldNotLoopWhenCaseInsensitiveAndRepeat() throws Exception {
+    void serviceShouldNotLoopWhenCaseInsensitiveAndRepeat() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("bodyPattern", "/a/a/ir/")
@@ -112,7 +107,7 @@ public class ReplaceContentTest {
     }
 
     @Test
-    public void serviceShouldReplaceSubjectWhenConfigurationFromFile() throws Exception {
+    void serviceShouldReplaceSubjectWhenConfigurationFromFile() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPatternFile", "#/org/apache/james/mailet/standard/mailets/replaceSubject.patterns")
@@ -129,7 +124,7 @@ public class ReplaceContentTest {
     }
 
     @Test
-    public void serviceShouldRemoveOrAddTextInBody() throws Exception {
+    void serviceShouldRemoveOrAddTextInBody() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("bodyPattern", "/--original message--/<quote>/i/,"
@@ -153,7 +148,7 @@ public class ReplaceContentTest {
 
 
     @Test
-    public void serviceShouldReplaceBodyWhenMatchingASCIICharacter() throws Exception {
+    void serviceShouldReplaceBodyWhenMatchingASCIICharacter() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("bodyPattern", "/\\u2026/.../r/")
@@ -171,7 +166,7 @@ public class ReplaceContentTest {
     }
 
     @Test
-    public void serviceShouldReplaceBodyWhenMatchingCharset() throws Exception {
+    void serviceShouldReplaceBodyWhenMatchingCharset() throws Exception {
         String messageSource = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
                 + "Content-Transfer-Encoding: quoted-printable\r\n"
                 + "\r\n"
@@ -197,7 +192,7 @@ public class ReplaceContentTest {
     }
 
     @Test
-    public void serviceShouldSetContenTypeWhenInitialized() throws Exception {
+    void serviceShouldSetContenTypeWhenInitialized() throws Exception {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("subjectPattern", "/test/TEST/i/,/o/a//,/s/s/i/")


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


[03/10] james-project git commit: JAMES-2361 migrate mailet/standard to junit 5

Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMailAttributeTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMailAttributeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMailAttributeTest.java
index d5a7b98..e5614a1 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMailAttributeTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMailAttributeTest.java
@@ -29,24 +29,20 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SetMailAttributeTest {
+class SetMailAttributeTest {
 
-    @Rule public ExpectedException expectedException = ExpectedException.none();
-    
     private Mailet mailet;
 
-    @Before
-    public void setupMailet() throws MessagingException {
+    @BeforeEach
+    void setupMailet() {
         mailet = new SetMailAttribute();
     }
 
     @Test
-    public void shouldAddConfiguredAttributes() throws MessagingException {
+    void shouldAddConfiguredAttributes() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("org.apache.james.junit1", "true")
@@ -64,7 +60,7 @@ public class SetMailAttributeTest {
     }
     
     @Test
-    public void shouldAddNothingWhenNoConfiguredAttribute() throws MessagingException {
+    void shouldAddNothingWhenNoConfiguredAttribute() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
@@ -79,7 +75,7 @@ public class SetMailAttributeTest {
     }
     
     @Test
-    public void shouldOverwriteAttributeWhenAttributeAlreadyPresent() throws MessagingException {
+    void shouldOverwriteAttributeWhenAttributeAlreadyPresent() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("org.apache.james.junit1", "bar")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMimeHeaderTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMimeHeaderTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMimeHeaderTest.java
index 8d122e4..6154897 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMimeHeaderTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/SetMimeHeaderTest.java
@@ -32,24 +32,20 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SetMimeHeaderTest {
+class SetMimeHeaderTest {
 
-    @Rule public ExpectedException expectedException = ExpectedException.none();
-    
     private Mailet mailet;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         mailet = new SetMimeHeader();
     }
 
     @Test
-    public void shouldAddHeaderToMime() throws MessagingException {
+    void shouldAddHeaderToMime() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "header-name")
@@ -66,7 +62,7 @@ public class SetMimeHeaderTest {
     }
 
     @Test
-    public void shouldAddHeaderWhenAlreadyPresent() throws MessagingException {
+    void shouldAddHeaderWhenAlreadyPresent() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "header-name")
@@ -84,7 +80,7 @@ public class SetMimeHeaderTest {
     }
 
     @Test
-    public void shouldThrowOnMessagingException() throws MessagingException {
+    void shouldThrowOnMessagingException() throws MessagingException {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "header-name")
@@ -100,53 +96,48 @@ public class SetMimeHeaderTest {
     }
     
     @Test
-    public void shouldThrowWhenNoConfiguration() throws MessagingException {
+    void shouldThrowWhenNoConfiguration() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
-        expectedException.expect(MessagingException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
     
     @Test
-    public void shouldThrowWhenNoValue() throws MessagingException {
+    void shouldThrowWhenNoValue() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "correct")
                 .build();
-        expectedException.expect(MessagingException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
     
     @Test
-    public void shouldThrowWhenNoHeader() throws MessagingException {
+    void shouldThrowWhenNoHeader() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("value", "correct")
                 .build();
-        expectedException.expect(MessagingException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
     
     @Test
-    public void shouldThrowWhenEmptyValue() throws MessagingException {
+    void shouldThrowWhenEmptyValue() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("value", "")
                 .setProperty("name", "correct")
                 .build();
-        expectedException.expect(MessagingException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
     
     @Test
-    public void shouldThrowWhenEmptyHeader() throws MessagingException {
+    void shouldThrowWhenEmptyHeader() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("name", "")
                 .setProperty("value", "correct")
                 .build();
-        expectedException.expect(MessagingException.class);
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig)).isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
index 537a1d3..afeb363 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -38,6 +39,7 @@ import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.transport.mailets.StripAttachment.OutputFileName;
@@ -46,59 +48,55 @@ import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetException;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class StripAttachmentTest {
+import com.google.common.io.Files;
+
+class StripAttachmentTest {
 
     private static final String EXPECTED_ATTACHMENT_CONTENT = "#¤ãàé";
     private static final Optional<String> ABSENT_MIME_TYPE = Optional.empty();
     private static final String CONTENT_TRANSFER_ENCODING_VALUE = "8bit";
 
-    public static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
-    public static final String CONTENT_TYPE = "Content-Type";
-    public static final String CONTENT_TYPE_DEFAULT = "application/octet-stream; charset=utf-8";
-    public static final String TEXT_CALENDAR_CHARSET_UTF_8 = "text/calendar; charset=utf-8";
-    public static final String TEXT_HTML_CHARSET_UTF_8 = "text/html; charset=utf-8";
+    private static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
+    private static final String CONTENT_TYPE = "Content-Type";
+    private static final String CONTENT_TYPE_DEFAULT = "application/octet-stream; charset=utf-8";
+    private static final String TEXT_CALENDAR_CHARSET_UTF_8 = "text/calendar; charset=utf-8";
+    private static final String TEXT_HTML_CHARSET_UTF_8 = "text/html; charset=utf-8";
 
-    private static MimeMessageBuilder.Header[] TEXT_HEADERS = {
+    private static final MimeMessageBuilder.Header[] TEXT_HEADERS = {
         new MimeMessageBuilder.Header(CONTENT_TRANSFER_ENCODING, CONTENT_TRANSFER_ENCODING_VALUE),
         new MimeMessageBuilder.Header(CONTENT_TYPE, CONTENT_TYPE_DEFAULT)
     };
 
-    private static MimeMessageBuilder.Header[] HTML_HEADERS = {
+    private static final MimeMessageBuilder.Header[] HTML_HEADERS = {
         new MimeMessageBuilder.Header(CONTENT_TRANSFER_ENCODING, CONTENT_TRANSFER_ENCODING_VALUE),
         new MimeMessageBuilder.Header(CONTENT_TYPE, TEXT_HTML_CHARSET_UTF_8)
     };
 
-    private static MimeMessageBuilder.Header[] CALENDAR_HEADERS = {
+    private static final MimeMessageBuilder.Header[] CALENDAR_HEADERS = {
         new MimeMessageBuilder.Header(CONTENT_TRANSFER_ENCODING, CONTENT_TRANSFER_ENCODING_VALUE),
         new MimeMessageBuilder.Header(CONTENT_TYPE, TEXT_CALENDAR_CHARSET_UTF_8)
     };
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-    @Rule
-    public TemporaryFolder folder = new TemporaryFolder();
-
     private String folderPath;
+    private File tempDir;
 
-    @Before
-    public void setUp() throws IOException {
-        folderPath = folder.getRoot().getPath() + "/";
+    @BeforeEach
+    void setUp() {
+        tempDir = Files.createTempDir();
+        folderPath = tempDir.getPath() + "/";
     }
 
-    @After
-    public void tearDown() throws IOException {
-        folder.delete();
+    @AfterEach
+    void tearDown() throws IOException {
+        FileUtils.deleteDirectory(tempDir);
     }
 
     @Test
-    public void serviceShouldNotModifyMailWhenNotMultipart() throws MessagingException, IOException {
+    void serviceShouldNotModifyMailWhenNotMultipart() throws MessagingException, IOException {
         Mailet mailet = initMailet();
         MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
             .setSubject("test")
@@ -118,7 +116,7 @@ public class StripAttachmentTest {
     }
     
     @Test
-    public void serviceShouldSaveAttachmentInAFolderWhenPatternMatch() throws MessagingException, IOException {
+    void serviceShouldSaveAttachmentInAFolderWhenPatternMatch() throws MessagingException {
         Mailet mailet = initMailet();
 
         String expectedAttachmentContent = EXPECTED_ATTACHMENT_CONTENT;
@@ -144,7 +142,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void serviceShouldRemoveWhenMimeTypeMatches() throws MessagingException, IOException {
+    void serviceShouldRemoveWhenMimeTypeMatches() throws MessagingException {
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .setProperty("mimeType", "text/calendar")
@@ -172,7 +170,7 @@ public class StripAttachmentTest {
         assertThat(removedAttachments).containsOnly(expectedFileName);
     }
 
-    private MimeMessageBuilder.BodyPartBuilder createAttachmentBodyPart(String body, String fileName, MimeMessageBuilder.Header... headers) throws MessagingException, IOException {
+    private MimeMessageBuilder.BodyPartBuilder createAttachmentBodyPart(String body, String fileName, MimeMessageBuilder.Header... headers) {
         return MimeMessageBuilder.bodyPartBuilder()
             .data(body)
             .addHeaders(headers)
@@ -181,7 +179,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void serviceShouldSaveAttachmentInAFolderWhenNotPatternDoesntMatch() throws MessagingException, IOException {
+    void serviceShouldSaveAttachmentInAFolderWhenNotPatternDoesntMatch() throws MessagingException {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -214,7 +212,7 @@ public class StripAttachmentTest {
         assertThat(new File(folderPath + attachmentFilename)).hasContent(expectedAttachmentContent);
     }
 
-    private String retrieveFilenameStartingWith(Collection<String> savedAttachments, final String filename) {
+    private String retrieveFilenameStartingWith(Collection<String> savedAttachments, String filename) {
         return savedAttachments.stream()
                 .filter(attachmentFilename -> attachmentFilename.startsWith(filename))
                 .findFirst()
@@ -222,7 +220,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void serviceShouldDecodeFilenameAndSaveAttachmentInAFolderWhenPatternMatchAndDecodeFilenameTrue() throws MessagingException, IOException {
+    void serviceShouldDecodeFilenameAndSaveAttachmentInAFolderWhenPatternMatchAndDecodeFilenameTrue() throws MessagingException {
         Mailet mailet = initMailet();
 
         String expectedAttachmentContent = EXPECTED_ATTACHMENT_CONTENT;
@@ -251,7 +249,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void serviceShouldSaveFilenameAttachmentAndFileContentInCustomAttribute() throws MessagingException, IOException {
+    void serviceShouldSaveFilenameAttachmentAndFileContentInCustomAttribute() throws MessagingException, IOException {
         StripAttachment mailet = new StripAttachment();
 
         String customAttribute = "my.custom.attribute";
@@ -286,7 +284,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void serviceShouldDecodeHeaderFilenames() throws MessagingException, IOException {
+    void serviceShouldDecodeHeaderFilenames() throws MessagingException, IOException {
         StripAttachment mailet = new StripAttachment();
 
         String customAttribute = "my.custom.attribute";
@@ -318,20 +316,20 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void initShouldThrowWhenPatternAndNotPatternAndMimeTypeAreNull() throws MessagingException {
+    void initShouldThrowWhenPatternAndNotPatternAndMimeTypeAreNull() {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .build();
 
-        expectedException.expect(MailetException.class);
-        expectedException.expectMessage("At least one of 'pattern', 'notpattern' or 'mimeType' parameter should be provided.");
-        mailet.init(mci);
+        assertThatThrownBy(() -> mailet.init(mci))
+            .isInstanceOf(MailetException.class)
+            .hasMessage("At least one of 'pattern', 'notpattern' or 'mimeType' parameter should be provided.");
     }
 
     @Test
-    public void initShouldThrowWhenMimeTypeIsEmpty() throws MessagingException {
+    void initShouldThrowWhenMimeTypeIsEmpty() {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -339,13 +337,13 @@ public class StripAttachmentTest {
                 .setProperty("mimeType", "")
                 .build();
 
-        expectedException.expect(MailetException.class);
-        expectedException.expectMessage("At least one of 'pattern', 'notpattern' or 'mimeType' parameter should be provided.");
-        mailet.init(mci);
+        assertThatThrownBy(() -> mailet.init(mci))
+            .isInstanceOf(MailetException.class)
+            .hasMessage("At least one of 'pattern', 'notpattern' or 'mimeType' parameter should be provided.");
     }
 
     @Test
-    public void initShouldWorkWhenPatternIsDefinedAndValid() throws MessagingException {
+    void initShouldWorkWhenPatternIsDefinedAndValid() throws MessagingException {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -357,7 +355,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void initShouldWorkWhenNotPatternIsDefinedAndValid() throws MessagingException {
+    void initShouldWorkWhenNotPatternIsDefinedAndValid() throws MessagingException {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -369,7 +367,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void initShouldWorkWhenMimeTypeIsDefined() throws MessagingException {
+    void initShouldWorkWhenMimeTypeIsDefined() throws MessagingException {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -381,7 +379,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void initShouldThrowWhenWrongPattern() throws MessagingException {
+    void initShouldThrowWhenWrongPattern() {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -389,13 +387,13 @@ public class StripAttachmentTest {
                 .setProperty("pattern", ".****\\.tmp")
                 .build();
 
-        expectedException.expect(MailetException.class);
-        expectedException.expectMessage("Could not compile regex [.****\\.tmp]");
-        mailet.init(mci);
+        assertThatThrownBy(() -> mailet.init(mci))
+            .isInstanceOf(MailetException.class)
+            .hasMessage("Could not compile regex [.****\\.tmp].");
     }
 
     @Test
-    public void initShouldThrowWhenWrongNotPattern() throws MessagingException {
+    void initShouldThrowWhenWrongNotPattern() {
         Mailet mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -403,13 +401,13 @@ public class StripAttachmentTest {
                 .setProperty("notpattern", ".****\\.tmp")
                 .build();
 
-        expectedException.expect(MailetException.class);
-        expectedException.expectMessage("Could not compile regex [.****\\.tmp]");
-        mailet.init(mci);
+        assertThatThrownBy(() -> mailet.init(mci))
+            .isInstanceOf(MailetException.class)
+            .hasMessage("Could not compile regex [.****\\.tmp].");
     }
 
     @Test
-    public void initShouldThrowWhenRemoveParameterIsUnknown() throws MessagingException {
+    void initShouldThrowWhenRemoveParameterIsUnknown() {
         StripAttachment mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -418,13 +416,13 @@ public class StripAttachmentTest {
                 .setProperty("pattern", ".*\\.tmp")
                 .build();
 
-        expectedException.expect(MailetException.class);
-        expectedException.expectMessage("Unknown remove parameter value 'unknown' waiting for 'matched', 'all' or 'no'.");
-        mailet.init(mci);
+        assertThatThrownBy(() -> mailet.init(mci))
+            .isInstanceOf(MailetException.class)
+            .hasMessage("Unknown remove parameter value 'unknown' waiting for 'matched', 'all' or 'no'.");
     }
 
     @Test
-    public void initShouldSetRemoveParameterWhenEqualsMatched() throws MessagingException {
+    void initShouldSetRemoveParameterWhenEqualsMatched() throws MessagingException {
         StripAttachment mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -438,7 +436,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void initShouldSetRemoveParameterWhenEqualsAll() throws MessagingException {
+    void initShouldSetRemoveParameterWhenEqualsAll() throws MessagingException {
         StripAttachment mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -452,7 +450,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void initShouldSetRemoveParameterWhenEqualsNo() throws MessagingException {
+    void initShouldSetRemoveParameterWhenEqualsNo() throws MessagingException {
         StripAttachment mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -466,7 +464,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void initShouldSetRemoveParameterDefaultValueWhenNotGiven() throws MessagingException {
+    void initShouldSetRemoveParameterDefaultValueWhenNotGiven() throws MessagingException {
         StripAttachment mailet = new StripAttachment();
 
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -479,21 +477,20 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void serviceShouldThrowWhenUnretrievableMessage() throws MessagingException {
+    void serviceShouldThrowWhenUnretrievableMessage() throws MessagingException {
         Mailet mailet = initMailet();
         
         Mail mail = mock(Mail.class);
         when(mail.getMessage())
             .thenThrow(new MessagingException("Test exception"));
 
-        expectedException.expect(MailetException.class);
-        expectedException.expectMessage("Could not retrieve message from Mail object");
-        
-        mailet.service(mail);
+        assertThatThrownBy(() -> mailet.service(mail))
+            .isInstanceOf(MailetException.class)
+            .hasMessage("Could not retrieve message from Mail object");
     }
 
     @Test
-    public void serviceShouldThrowWhenUnretrievableContentTypeMessage() throws MessagingException {
+    void serviceShouldThrowWhenUnretrievableContentTypeMessage() throws MessagingException {
         Mailet mailet = initMailet();
 
         MimeMessage message = mock(MimeMessage.class);
@@ -503,21 +500,20 @@ public class StripAttachmentTest {
         when(message.isMimeType("multipart/*"))
             .thenThrow(new MessagingException("Test exception"));
 
-        expectedException.expect(MailetException.class);
-        expectedException.expectMessage("Could not retrieve contenttype of MimePart.");
-        
-        mailet.service(mail);
+        assertThatThrownBy(() -> mailet.service(mail))
+            .isInstanceOf(MailetException.class)
+            .hasMessage("Could not retrieve contenttype of MimePart.");
     }
 
     @Test
-    public void getMailetInfoShouldReturn() throws MessagingException {
+    void getMailetInfoShouldReturn() {
         StripAttachment mailet = new StripAttachment();
 
         assertThat(mailet.getMailetInfo()).isEqualTo("StripAttachment");
     }
 
     @Test
-    public void processMultipartPartMessageShouldReturnFalseWhenPartIsNotMultipart() throws Exception {
+    void processMultipartPartMessageShouldReturnFalseWhenPartIsNotMultipart() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
         Part part = new MimeBodyPart(new ByteArrayInputStream(new byte[0]));
@@ -529,7 +525,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldReturnTrueWhenAtLeastOneMultipartShouldHaveBeenRemoved() throws Exception {
+    void processMultipartPartMessageShouldReturnTrueWhenAtLeastOneMultipartShouldHaveBeenRemoved() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -552,7 +548,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldReturnTrueWhenAtLeastOneMultipartShouldHaveBeenRemovedAndPartialRemove() throws Exception {
+    void processMultipartPartMessageShouldReturnTrueWhenAtLeastOneMultipartShouldHaveBeenRemovedAndPartialRemove() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -576,7 +572,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldPutTwoPartsInDefaultAttributeWhenTwoPartsMatch() throws Exception {
+    void processMultipartPartMessageShouldPutTwoPartsInDefaultAttributeWhenTwoPartsMatch() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -607,7 +603,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldPutTwoPartsInCustomAttributeWhenTwoPartsMatch() throws Exception {
+    void processMultipartPartMessageShouldPutTwoPartsInCustomAttributeWhenTwoPartsMatch() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -642,7 +638,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldReturnTrueWhenAtLeastOneSubMultipartShouldHaveBeenRemoved() throws Exception {
+    void processMultipartPartMessageShouldReturnTrueWhenAtLeastOneSubMultipartShouldHaveBeenRemoved() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -668,7 +664,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldReturnFalseWhenNoPartHasBeenRemovedInSubMultipart() throws Exception {
+    void processMultipartPartMessageShouldReturnFalseWhenNoPartHasBeenRemovedInSubMultipart() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -694,7 +690,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldRemovePartWhenOnePartShouldHaveBeenRemoved() throws Exception {
+    void processMultipartPartMessageShouldRemovePartWhenOnePartShouldHaveBeenRemoved() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -721,7 +717,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void processMultipartPartMessageShouldSetFilenameToMatchingAttachmentsWhenAttachmentWithoutFilename() throws Exception {
+    void processMultipartPartMessageShouldSetFilenameToMatchingAttachmentsWhenAttachmentWithoutFilename() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
 
@@ -750,7 +746,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void saveAttachmentShouldUsePartNameIfNoFilename() throws Exception {
+    void saveAttachmentShouldUsePartNameIfNoFilename() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -772,7 +768,7 @@ public class StripAttachmentTest {
     }
     
     @Test
-    public void saveAttachmentShouldReturnAbsentWhenNoFilenameAtAll() throws Exception {
+    void saveAttachmentShouldReturnAbsentWhenNoFilenameAtAll() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("directory", folderPath)
@@ -786,7 +782,7 @@ public class StripAttachmentTest {
     }
     
     @Test
-    public void saveAttachmentShouldAddBinExtensionWhenNoFileNameExtension() throws Exception {
+    void saveAttachmentShouldAddBinExtensionWhenNoFileNameExtension() throws Exception {
         //Given
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
@@ -836,19 +832,18 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void fileNameMatchesShouldThrowWhenPatternIsNull() throws Exception {
+    void fileNameMatchesShouldThrowWhenPatternIsNull() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("pattern", ".*pattern.*")
                 .build();
         mailet.init(mci);
-        
-        expectedException.expect(NullPointerException.class);
-        mailet.fileNameMatches(null);
+
+        assertThatThrownBy(() -> mailet.fileNameMatches(null)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void fileNameMatchesShouldReturnFalseWhenPatternDoesntMatch() throws Exception {
+    void fileNameMatchesShouldReturnFalseWhenPatternDoesntMatch() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("pattern", ".*pattern.*")
@@ -859,7 +854,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void fileNameMatchesShouldReturnTrueWhenPatternMatches() throws Exception {
+    void fileNameMatchesShouldReturnTrueWhenPatternMatches() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("pattern", ".*pattern.*")
@@ -870,7 +865,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void fileNameMatchesShouldReturnFalseWhenNotPatternMatches() throws Exception {
+    void fileNameMatchesShouldReturnFalseWhenNotPatternMatches() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("notpattern", ".*pattern.*")
@@ -881,7 +876,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void fileNameMatchesShouldReturnTrueWhenNotPatternDoesntMatch() throws Exception {
+    void fileNameMatchesShouldReturnTrueWhenNotPatternDoesntMatch() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("notpattern", ".*pattern.*")
@@ -892,7 +887,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void fileNameMatchesShouldReturnFalseWhenPatternAndNotPatternAreTheSame() throws Exception {
+    void fileNameMatchesShouldReturnFalseWhenPatternAndNotPatternAreTheSame() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("pattern", ".*pattern.*")
@@ -905,7 +900,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void fileNameMatchesShouldReturnTrueWhenPatternMatchesAndNotPatternDoesntMatch() throws Exception {
+    void fileNameMatchesShouldReturnTrueWhenPatternMatchesAndNotPatternDoesntMatch() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("pattern", ".*pattern.*")
@@ -917,7 +912,7 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void fileNameMatchesShouldReturnTrueWhenPatternDoesntMatchesAndNotPatternDoesntMatch() throws Exception {
+    void fileNameMatchesShouldReturnTrueWhenPatternDoesntMatchesAndNotPatternDoesntMatch() throws Exception {
         StripAttachment mailet = new StripAttachment();
         FakeMailetConfig mci = FakeMailetConfig.builder()
                 .setProperty("pattern", ".*pattern.*")
@@ -929,13 +924,13 @@ public class StripAttachmentTest {
     }
 
     @Test
-    public void prependedPrefixShouldAddUnderscoreWhenPrefixIsLessThanThreeCharacters() {
+    void prependedPrefixShouldAddUnderscoreWhenPrefixIsLessThanThreeCharacters() {
         String prefix = OutputFileName.prependedPrefix("a");
         assertThat(prefix).isEqualTo("__a");
     }
 
     @Test
-    public void prependedPrefixShouldReturnPrefixWhenPrefixIsGreaterThanThreeCharacters() {
+    void prependedPrefixShouldReturnPrefixWhenPrefixIsGreaterThanThreeCharacters() {
         String expectedPrefix = "abcd";
         String prefix = OutputFileName.prependedPrefix(expectedPrefix);
         assertThat(prefix).isEqualTo(expectedPrefix);

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
index 6fe84e3..0ef692d 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/ToProcessorTest.java
@@ -21,6 +21,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
 import javax.mail.MessagingException;
@@ -32,47 +33,40 @@ import org.apache.mailet.MailetException;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 
-public class ToProcessorTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class ToProcessorTest {
 
     private Mailet mailet;
-    private Logger logger;
     private FakeMailContext mailContext;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         mailet = new ToProcessor();
-        logger = mock(Logger.class);
+        Logger logger = mock(Logger.class);
         mailContext = FakeMailContext.builder().logger(logger).build();
     }
 
     @Test
-    public void getMailetInfoShouldReturnValue() {
+    void getMailetInfoShouldReturnValue() {
         assertThat(mailet.getMailetInfo()).isEqualTo("ToProcessor Mailet");
     }
 
     @Test
-    public void initShouldThrowWhenProcessorIsNotGiven() throws MessagingException {
+    void initShouldThrowWhenProcessorIsNotGiven() {
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
                 .mailetContext(mailContext)
                 .setProperty("notice", "error in message")
                 .build();
-        expectedException.expect(MailetException.class);
-
-        mailet.init(mailetConfig);
+        assertThatThrownBy(() -> mailet.init(mailetConfig))
+            .isInstanceOf(MailetException.class);
     }
 
     @Test
-    public void serviceShouldSetTheStateOfTheMail() throws MessagingException {
+    void serviceShouldSetTheStateOfTheMail() throws MessagingException {
         String processor = "error";
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
                 .mailetName("Test")
@@ -90,7 +84,7 @@ public class ToProcessorTest {
     }
 
     @Test
-    public void serviceShouldSetTheErrorMessageOfTheMailWhenNotAlreadySet() throws MessagingException {
+    void serviceShouldSetTheErrorMessageOfTheMailWhenNotAlreadySet() throws MessagingException {
         String processor = "error";
         String notice = "error in message";
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()
@@ -110,7 +104,7 @@ public class ToProcessorTest {
     }
 
     @Test
-    public void serviceShouldAppendTheErrorMessageOfTheMailWhenSomeErrorMessageOnMail() throws MessagingException {
+    void serviceShouldAppendTheErrorMessageOfTheMailWhenSomeErrorMessageOnMail() throws MessagingException {
         String processor = "error";
         String notice = "error in message";
         FakeMailetConfig mailetConfig = FakeMailetConfig.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/UnwrapTextTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/UnwrapTextTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/UnwrapTextTest.java
index 7014e41..3fd47c5 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/UnwrapTextTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/UnwrapTextTest.java
@@ -19,8 +19,8 @@
 
 package org.apache.james.transport.mailets;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 public class UnwrapTextTest {
 
@@ -32,8 +32,8 @@ public class UnwrapTextTest {
         String input;
         String output;
 
-        Assert.assertEquals("", UnwrapText.unwrap(""));
-        Assert.assertEquals("a", UnwrapText.unwrap("a"));
+        Assertions.assertEquals("", UnwrapText.unwrap(""));
+        Assertions.assertEquals("a", UnwrapText.unwrap("a"));
 
         input =
                 "Prova per vedere se effettivamente il testo viene wrappato\r\n" +
@@ -46,7 +46,7 @@ public class UnwrapTextTest {
                         "Chissà se funziona davvero\r\n" +
                         "o se va solo come gli pare";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
@@ -59,7 +59,7 @@ public class UnwrapTextTest {
                         "> Chissà se funziona davvero\r\n" +
                         "> o se va solo come gli pare";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
@@ -75,7 +75,7 @@ public class UnwrapTextTest {
                         "> o se va solo come gli pare\r\n" +
                         "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe.\r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "> volevo chiedervi un piccolo aiutino. Una signora con un circolare ha un\r\n" +
@@ -91,7 +91,7 @@ public class UnwrapTextTest {
                         "trucco da  suggerirmi per rimuovere il ponte? Il ponte è in ceramica, per " +
                         "cui  l'utilizzo degli ultrasuoni puo' essere rischioso (?).\r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
@@ -104,7 +104,7 @@ public class UnwrapTextTest {
                 "> Prova per vedere se effettivamente il testo viene wrappato com dovrebbe.\r\n" +
                         "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe.\r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
@@ -118,7 +118,7 @@ public class UnwrapTextTest {
                         "> Prova per vedere se effettivamente il testo viene wrappato come\r\n" +
                         ">> dovrebbe.\r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
@@ -131,7 +131,7 @@ public class UnwrapTextTest {
                         "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
                         "come dovrebbe.\r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "...pero' devo dire che ai congressi vedo moltissimi casi di carico\r\n" +
@@ -147,7 +147,7 @@ public class UnwrapTextTest {
                         "\"parodontosici\" che io terrei li per altri 15 anni...\r\n" +
                         "Non voglio polemizzare ne tantomento accusare nessuno, ma credo che spesso a accada quello che Alessio suggerisce...\r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input));
 
         input =
                 "> mi trovo in difficolta,ho eseguito un lavoro di protesizzazione in\r\n" +
@@ -175,7 +175,7 @@ public class UnwrapTextTest {
                         "a tirar giu il lavoro anche con tutte le cautele del caso rischio la " +
                         "rottura\r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input, 79));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input, 79));
 
         // Controllo spazi
         input =
@@ -193,7 +193,7 @@ public class UnwrapTextTest {
                         "o se va solo come gli pare \r\n" +
                         "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe. \r\n";
 
-        Assert.assertEquals(output, UnwrapText.unwrap(input, 79));
+        Assertions.assertEquals(output, UnwrapText.unwrap(input, 79));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
index f77d57a..d5b294c 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/UseHeaderRecipientsTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.mailets;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.james.core.MailAddress;
 import org.apache.james.core.builder.MimeMessageBuilder;
@@ -29,27 +30,22 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMailetConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class UseHeaderRecipientsTest {
+class UseHeaderRecipientsTest {
 
-    public static final String RECIPIENT1 = "abc1@apache1.org";
-    public static final String RECIPIENT2 = "abc2@apache2.org";
-    public static final String RECIPIENT3 = "abc3@apache3.org";
+    private static final String RECIPIENT1 = "abc1@apache1.org";
+    private static final String RECIPIENT2 = "abc2@apache2.org";
+    private static final String RECIPIENT3 = "abc3@apache3.org";
     private UseHeaderRecipients testee;
     private FakeMailContext mailetContext;
     private MailAddress mailAddress1;
     private MailAddress mailAddress2;
     private MailAddress mailAddress3;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         testee = new UseHeaderRecipients();
         mailetContext = FakeMailContext.defaultContext();
         testee.init(FakeMailetConfig.builder().mailetContext(mailetContext).build());
@@ -60,7 +56,7 @@ public class UseHeaderRecipientsTest {
     }
 
     @Test
-    public void serviceShouldSetMimeMessageRecipients() throws Exception {
+    void serviceShouldSetMimeMessageRecipients() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.ANY_AT_JAMES2)
             .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
@@ -74,7 +70,7 @@ public class UseHeaderRecipientsTest {
     }
 
     @Test
-    public void serviceShouldSetToCcAndBccSpecifiedInTheMimeMessage() throws Exception {
+    void serviceShouldSetToCcAndBccSpecifiedInTheMimeMessage() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipients(MailAddressFixture.ANY_AT_JAMES)
             .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
@@ -90,7 +86,7 @@ public class UseHeaderRecipientsTest {
     }
 
     @Test
-    public void serviceShouldSetEmptyRecipientWhenNoRecipientsInTheMimeMessage() throws Exception {
+    void serviceShouldSetEmptyRecipientWhenNoRecipientsInTheMimeMessage() throws Exception {
 
         FakeMail fakeMail = FakeMail.builder()
             .recipients(MailAddressFixture.ANY_AT_JAMES)
@@ -104,7 +100,7 @@ public class UseHeaderRecipientsTest {
     }
 
     @Test
-    public void serviceShouldGhostEmail() throws Exception {
+    void serviceShouldGhostEmail() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipients(MailAddressFixture.ANY_AT_JAMES)
             .mimeMessage(MimeMessageUtil.defaultMimeMessage())
@@ -117,7 +113,7 @@ public class UseHeaderRecipientsTest {
     }
 
     @Test
-    public void serviceShouldResendTheEmail() throws Exception {
+    void serviceShouldResendTheEmail() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipients(MailAddressFixture.ANY_AT_JAMES)
             .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
@@ -136,20 +132,18 @@ public class UseHeaderRecipientsTest {
     }
 
     @Test
-    public void serviceShouldThrowOnInvalidMailAddress() throws Exception {
-        expectedException.expect(RuntimeException.class);
-
+    void serviceShouldThrowOnInvalidMailAddress() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipients(mailAddress1)
             .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
                 .addToRecipient("invalid"))
             .build();
 
-        testee.service(fakeMail);
+        assertThatThrownBy(() -> testee.service(fakeMail)).isInstanceOf(RuntimeException.class);
     }
 
     @Test
-    public void serviceShouldSupportAddressList() throws Exception {
+    void serviceShouldSupportAddressList() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipients()
             .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
@@ -163,7 +157,7 @@ public class UseHeaderRecipientsTest {
     }
 
     @Test
-    public void serviceShouldSupportMailboxes() throws Exception {
+    void serviceShouldSupportMailboxes() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipients()
             .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
index 081d10f..9b897e1 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
@@ -26,7 +26,7 @@ import java.util.Optional;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.core.builder.MimeMessageBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class MimeMessageModifierTest {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageUtilsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageUtilsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageUtilsTest.java
index de3f003..8d5daa3 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageUtilsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageUtilsTest.java
@@ -29,7 +29,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class MimeMessageUtilsTest {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
index 0bcff15..d6eb21e 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/AbstractHasMailAttributeTest.java
@@ -20,6 +20,10 @@
 
 package org.apache.james.transport.matchers;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 import java.util.Collection;
 
 import javax.mail.MessagingException;
@@ -30,42 +34,38 @@ import org.apache.mailet.base.GenericMatcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;
+import org.junit.jupiter.api.Test;
 
-import junit.framework.TestCase;
 
-public abstract class AbstractHasMailAttributeTest extends TestCase {
+public abstract class AbstractHasMailAttributeTest {
 
-    protected FakeMail mockedMail;
+    FakeMail mockedMail;
 
     protected Matcher matcher;
 
-    protected static final String MAIL_ATTRIBUTE_NAME = "org.apache.james.test.junit";
-
-    protected static final String MAIL_ATTRIBUTE_VALUE = "true";
+    static final String MAIL_ATTRIBUTE_NAME = "org.apache.james.test.junit";
 
-    protected String mailAttributeName = "org.apache.james";
+    static final String MAIL_ATTRIBUTE_VALUE = "true";
 
-    protected String mailAttributeValue = "false";
+    private String mailAttributeName = "org.apache.james";
 
-    public AbstractHasMailAttributeTest() {
-        super(null);
-    }
+    private String mailAttributeValue = "false";
 
-    protected void setMailAttributeName(String mailAttributeName) {
+    void setMailAttributeName(String mailAttributeName) {
         this.mailAttributeName = mailAttributeName;
     }
 
-    protected void setMailAttributeValue(String mailAttributeValue) {
+    void setMailAttributeValue(String mailAttributeValue) {
         this.mailAttributeValue = mailAttributeValue;
     }
 
-    protected void setupMockedMail() throws MessagingException {
+    void setupMockedMail() throws MessagingException {
         mockedMail = MailUtil.createMockMail2Recipients();
         mockedMail.setAttribute(mailAttributeName,
                 mailAttributeValue);
     }
 
-    protected void setupMatcher() throws MessagingException {
+    void setupMatcher() throws MessagingException {
         matcher = createMatcher();
         FakeMatcherConfig mci = FakeMatcherConfig.builder()
                 .matcherName(getMatcherName())
@@ -76,7 +76,7 @@ public abstract class AbstractHasMailAttributeTest extends TestCase {
 
     }
 
-    // test if the mail attribute was matched
+    @Test
     public void testAttributeIsMatched() throws MessagingException {
         init();
 
@@ -94,12 +94,12 @@ public abstract class AbstractHasMailAttributeTest extends TestCase {
         setMailAttributeValue(MAIL_ATTRIBUTE_VALUE);
     }
 
-    protected void setupAll() throws MessagingException {
+    void setupAll() throws MessagingException {
         setupMockedMail();
         setupMatcher();
     }
 
-    // test if the mail attribute was not matched
+    @Test
     public void testAttributeIsNotMatched() throws MessagingException {
         setupAll();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/AllTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/AllTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/AllTest.java
index a699073..63572b8 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/AllTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/AllTest.java
@@ -30,14 +30,14 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class AllTest {
 
     private Matcher matcher;
 
-    @Before
+    @BeforeEach
     public void setupMatcher() throws MessagingException {
         matcher = new All();
         FakeMatcherConfig mci = FakeMatcherConfig.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/FetchedFromTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/FetchedFromTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/FetchedFromTest.java
index d24bcf5..1103040 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/FetchedFromTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/FetchedFromTest.java
@@ -29,8 +29,8 @@ import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class FetchedFromTest {
     private static final String EXPECTED_HEADER_VALUE = "james-user";
@@ -38,7 +38,7 @@ public class FetchedFromTest {
 
     private Matcher matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws MessagingException {
         matcher = new FetchedFrom();
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasAttachmentTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasAttachmentTest.java
index d758b22..56f9fc6 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasAttachmentTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasAttachmentTest.java
@@ -31,8 +31,8 @@ import javax.mail.internet.MimeMultipart;
 import org.apache.james.util.MimeMessageUtil;
 import org.apache.mailet.Mail;
 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;
 
 public class HasAttachmentTest {
 
@@ -40,7 +40,7 @@ public class HasAttachmentTest {
     private MimeMessage mimeMessage;
     private Mail mail;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         testee = new HasAttachment();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasExceptionTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasExceptionTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasExceptionTest.java
index e6e34de..3392e65 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasExceptionTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasExceptionTest.java
@@ -30,15 +30,15 @@ import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class HasExceptionTest {
 
     private FakeMail mockedMail;
     private Matcher testee;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         MimeMessage mimeMessage = MailUtil.createMimeMessage();
         mockedMail = MailUtil.createMockMail2Recipients(mimeMessage);

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderTest.java
index 3afb961..785c266 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderTest.java
@@ -32,8 +32,8 @@ import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class HasHeaderTest {
 
@@ -45,7 +45,7 @@ public class HasHeaderTest {
     private FakeMail mockedMail;
     private Matcher matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         MimeMessage mimeMessage = MailUtil.createMimeMessage(HEADER_NAME_1, HEADER_VALUE_1);
         mockedMail = MailUtil.createMockMail2Recipients(mimeMessage);

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderWithPrefixTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderWithPrefixTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderWithPrefixTest.java
index b3843fa..1e85bfc 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderWithPrefixTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasHeaderWithPrefixTest.java
@@ -21,6 +21,7 @@
 package org.apache.james.transport.matchers;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
@@ -30,28 +31,23 @@ import org.apache.mailet.Matcher;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class HasHeaderWithPrefixTest {
+class HasHeaderWithPrefixTest {
     private static final String PREFIX = "X-OPENPAAS-";
     private static final String HEADER_NAME_PREFIX_1 = "X-OPENPAAS-FEATURE-A";
     private static final String HEADER_NAME_NO_PREFIX = "X-OTHER-BUSINESS";
 
     private Matcher matcher;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         matcher = new HasHeaderWithPrefix();
     }
 
     @Test
-    public void matchShouldReturnAddressesWhenPrefixedHeaderName() throws MessagingException {
+    void matchShouldReturnAddressesWhenPrefixedHeaderName() throws MessagingException {
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
             .matcherName("HasHeader")
             .condition(PREFIX)
@@ -69,7 +65,7 @@ public class HasHeaderWithPrefixTest {
     }
 
     @Test
-    public void matchShouldReturnAddressesWhenExactlyPrefix() throws MessagingException {
+    void matchShouldReturnAddressesWhenExactlyPrefix() throws MessagingException {
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
             .matcherName("HasHeader")
             .condition(PREFIX)
@@ -87,7 +83,7 @@ public class HasHeaderWithPrefixTest {
     }
 
     @Test
-    public void matchShouldReturnEmptyWhenNoPrefixedHeader() throws MessagingException {
+    void matchShouldReturnEmptyWhenNoPrefixedHeader() throws MessagingException {
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
             .matcherName("HasHeader")
             .condition(PREFIX)
@@ -105,7 +101,7 @@ public class HasHeaderWithPrefixTest {
     }
 
     @Test
-    public void matchShouldReturnAddressesWhenAtLeastOneHeaderPrefixed() throws MessagingException {
+    void matchShouldReturnAddressesWhenAtLeastOneHeaderPrefixed() throws MessagingException {
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
             .matcherName("HasHeader")
             .condition(PREFIX)
@@ -124,22 +120,22 @@ public class HasHeaderWithPrefixTest {
     }
 
     @Test
-    public void initShouldRejectEmptyPrefix() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-
-        matcher.init(FakeMatcherConfig.builder()
-            .matcherName("HasHeader")
-            .condition("")
-            .build());
+    void initShouldRejectEmptyPrefix() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
+                .matcherName("HasHeader")
+                .condition("")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldRejectNoCondition() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-
-        matcher.init(FakeMatcherConfig.builder()
-            .matcherName("HasHeader")
-            .build());
+    void initShouldRejectNoCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
+                .matcherName("HasHeader")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeTest.java
index 5d02173..e3d1c87 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeTest.java
@@ -24,10 +24,6 @@ import org.apache.mailet.base.GenericMatcher;
 
 public class HasMailAttributeTest extends AbstractHasMailAttributeTest {
 
-    public HasMailAttributeTest() {
-        super();
-    }
-
     @Override
     protected GenericMatcher createMatcher() {
         return new HasMailAttribute();

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
index cfa7b02..201929e 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueRegexTest.java
@@ -20,24 +20,23 @@
 
 package org.apache.james.transport.matchers;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 import java.util.Collection;
 
 import javax.mail.MessagingException;
 
 import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
+import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
 
-import junit.framework.AssertionFailedError;
-
-public class HasMailAttributeWithValueRegexTest extends
-        AbstractHasMailAttributeTest {
+public class HasMailAttributeWithValueRegexTest extends AbstractHasMailAttributeTest {
 
     private String regex = ".*";
 
-    public HasMailAttributeWithValueRegexTest() {
-        super();
-    }
-
     private void setRegex(String regex) {
         this.regex = regex;
     }
@@ -52,8 +51,8 @@ public class HasMailAttributeWithValueRegexTest extends
         return new HasMailAttributeWithValueRegex();
     }
 
-    // test if the mail attribute was matched
     @Override
+    @Test
     public void testAttributeIsMatched() throws MessagingException {
         init();
         setRegex(".*");
@@ -66,8 +65,8 @@ public class HasMailAttributeWithValueRegexTest extends
                 .size());
     }
 
-    // test if the mail attribute was not matched
-    public void testHeaderIsNotMatched() throws MessagingException {
+    @Test
+    void testHeaderIsNotMatched() throws MessagingException {
         setRegex("\\d");
         setupAll();
 
@@ -76,8 +75,8 @@ public class HasMailAttributeWithValueRegexTest extends
         assertNull(matchedRecipients);
     }
 
-    // test if an exception was thrown cause the regex was invalid
-    public void testHeaderIsNotMatchedCauseValue() throws MessagingException {
+    @Test
+    void testHeaderIsNotMatchedCauseValue() throws MessagingException {
 
         String invalidRegex = "(!(";
         String regexException = null;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
index 1aa1130..9412d88 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMailAttributeWithValueTest.java
@@ -20,19 +20,18 @@
 
 package org.apache.james.transport.matchers;
 
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 import java.util.Collection;
 
 import javax.mail.MessagingException;
 
 import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.GenericMatcher;
+import org.junit.jupiter.api.Test;
 
 public class HasMailAttributeWithValueTest extends AbstractHasMailAttributeTest {
 
-    public HasMailAttributeWithValueTest() {
-        super();
-    }
-
     @Override
     protected String getHasMailAttribute() {
         return MAIL_ATTRIBUTE_NAME + ", " + MAIL_ATTRIBUTE_VALUE;
@@ -43,8 +42,8 @@ public class HasMailAttributeWithValueTest extends AbstractHasMailAttributeTest
         return new HasMailAttributeWithValue();
     }
 
-    // test if the mail attribute was not matched cause diffrent value
-    public void testAttributeIsNotMatchedCauseValue() throws MessagingException {
+    @Test
+    void testAttributeIsNotMatchedCauseValue() throws MessagingException {
         setMailAttributeName(MAIL_ATTRIBUTE_NAME);
         setupMockedMail();
         setupMatcher();

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java
index fbdff6c..a12f187 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java
@@ -25,8 +25,8 @@ import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class HasMimeTypeTest {
 
@@ -37,7 +37,7 @@ public class HasMimeTypeTest {
 
     private HasMimeType matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         matcher = new HasMimeType();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsLocalTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsLocalTest.java
index 1c0b7aa..5d6c41a 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsLocalTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsLocalTest.java
@@ -37,14 +37,14 @@ import org.apache.mailet.MailetContext;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class HostIsLocalTest {
 
     private Matcher matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         MailetContext mailContext = mock(MailetContext.class);
         when(mailContext.isLocalServer(JAMES_APACHE_ORG)).thenReturn(true);

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsTest.java
index 81a5eaf..af342e8 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/HostIsTest.java
@@ -32,14 +32,14 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class HostIsTest {
 
    private Matcher matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         matcher = new HostIs();
         FakeMatcherConfig mci = FakeMatcherConfig.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/IsSingleRecipientTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/IsSingleRecipientTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/IsSingleRecipientTest.java
index 32f342d..87cebd5 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/IsSingleRecipientTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/IsSingleRecipientTest.java
@@ -29,14 +29,14 @@ import javax.mail.MessagingException;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class IsSingleRecipientTest {
 
     private Matcher matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws MessagingException {
         matcher = new IsSingleRecipient();
         FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/NESSpamCheckTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/NESSpamCheckTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/NESSpamCheckTest.java
index da0be46..6186cba 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/NESSpamCheckTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/NESSpamCheckTest.java
@@ -27,14 +27,14 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class NESSpamCheckTest {
 
     private NESSpamCheck matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         matcher = new NESSpamCheck();
         FakeMatcherConfig mci = FakeMatcherConfig.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
index 1825e39..b45ac0a 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsLocalTest.java
@@ -28,8 +28,8 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class RecipientIsLocalTest {
 
@@ -40,7 +40,7 @@ public class RecipientIsLocalTest {
     private MailAddress mailAddress2;
     private Mail mail;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         mailetContext = mock(MailetContext.class);
         testee = new RecipientIsLocal();

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsRegexTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsRegexTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsRegexTest.java
index 89d460e..e0710d9 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsRegexTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsRegexTest.java
@@ -23,30 +23,26 @@ package org.apache.james.transport.matchers;
 import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES;
 import static org.apache.mailet.base.MailAddressFixture.OTHER_AT_JAMES;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class RecipientIsRegexTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class RecipientIsRegexTest {
 
     private RecipientIsRegex matcher;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         matcher = new RecipientIsRegex();
     }
 
     @Test
-    public void shouldMatchOneAddress() throws MessagingException {
+    void shouldMatchOneAddress() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIsRegex")
                 .condition(".*@.*")
@@ -60,7 +56,7 @@ public class RecipientIsRegexTest {
     }
 
     @Test
-    public void shouldNotMatchPartially() throws MessagingException {
+    void shouldNotMatchPartially() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIsRegex")
                 .condition("any")
@@ -74,7 +70,7 @@ public class RecipientIsRegexTest {
     }
 
     @Test
-    public void shouldMatchOnlyMatchingPatterns() throws MessagingException {
+    void shouldMatchOnlyMatchingPatterns() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIsRegex")
                 .condition("^any@.*")
@@ -88,7 +84,7 @@ public class RecipientIsRegexTest {
     }
 
     @Test
-    public void shouldNotMatchNonMatchingPatterns() throws MessagingException {
+    void shouldNotMatchNonMatchingPatterns() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIsRegex")
                 .condition(".*\\+")
@@ -102,27 +98,30 @@ public class RecipientIsRegexTest {
     }
 
     @Test
-    public void testRegexIsNotMatchedCauseError() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void testRegexIsNotMatchedCauseError() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIsRegex")
                 .condition("(.")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void testThrowExceptionWithEmptyPattern() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void testThrowExceptionWithEmptyPattern() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIsRegex")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void testThrowExceptionWithNoCondition() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void testThrowExceptionWithNoCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIsRegex")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsTest.java
index b7e2e04..95f4781 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RecipientIsTest.java
@@ -24,30 +24,26 @@ import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES;
 import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES2;
 import static org.apache.mailet.base.MailAddressFixture.OTHER_AT_JAMES;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class RecipientIsTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class RecipientIsTest {
 
     private RecipientIs matcher;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         matcher = new RecipientIs();
     }
 
     @Test
-    public void shouldMatchCorrespondingAddres() throws Exception {
+    void shouldMatchCorrespondingAddres() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIs")
                 .condition(ANY_AT_JAMES.toString())
@@ -61,7 +57,7 @@ public class RecipientIsTest {
     }
 
     @Test
-    public void shouldOnlyMatchCorrespondingAddress() throws Exception {
+    void shouldOnlyMatchCorrespondingAddress() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIs")
                 .condition(ANY_AT_JAMES.toString())
@@ -75,7 +71,7 @@ public class RecipientIsTest {
     }
 
     @Test
-    public void shouldNotMatchUnrelatedAddresses() throws Exception {
+    void shouldNotMatchUnrelatedAddresses() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIs")
                 .condition(ANY_AT_JAMES.toString())
@@ -89,23 +85,25 @@ public class RecipientIsTest {
     }
 
     @Test
-    public void initShouldThrowOnMissingCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void initShouldThrowOnMissingCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIs")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnEmptyCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void initShouldThrowOnEmptyCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIs")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void shouldBeAbleToMatchSeveralAddresses() throws Exception {
+    void shouldBeAbleToMatchSeveralAddresses() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("RecipientIs")
                 .condition(ANY_AT_JAMES + ", " + ANY_AT_JAMES2)


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


[09/10] james-project git commit: JAMES-2361 rename utility methods for consistency

Posted by ma...@apache.org.
JAMES-2361 rename utility methods for consistency


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/81d5a245
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/81d5a245
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/81d5a245

Branch: refs/heads/master
Commit: 81d5a245512b4d6002e40f8a643f48d076b661d1
Parents: d16c534
Author: Matthieu Baechler <ma...@apache.org>
Authored: Tue Mar 20 17:21:48 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:23 2018 +0200

----------------------------------------------------------------------
 .../methods/integration/SendMDNMethodTest.java  | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/81d5a245/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
index a33b64a..b1144e2 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
@@ -135,7 +135,7 @@ public abstract class SendMDNMethodTest {
             .body()
             .path(ARGUMENTS + ".created." + messageCreationId + ".id");
 
-        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken).isEmpty());
+        calmlyAwait.until(() -> !listMessageIdsForAccount(homerAccessToken).isEmpty());
     }
 
     private void sendAWrongInitialMessage() {
@@ -167,7 +167,7 @@ public abstract class SendMDNMethodTest {
             .body()
             .path(ARGUMENTS + ".created." + messageCreationId + ".id");
 
-        calmlyAwait.until(() -> !getMessageIdListForAccount(homerAccessToken).isEmpty());
+        calmlyAwait.until(() -> !listMessageIdsForAccount(homerAccessToken).isEmpty());
     }
 
     private URIBuilder baseUri() {
@@ -188,7 +188,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldReturnCreatedMessageId() {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
+        List<String> messageIds = listMessageIdsForAccount(homerAccessToken);
 
         String creationId = "creation-1";
         given()
@@ -253,7 +253,7 @@ public abstract class SendMDNMethodTest {
     @Test
     public void sendMDNShouldFailOnInvalidMessages() {
         sendAWrongInitialMessage();
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
+        List<String> messageIds = listMessageIdsForAccount(homerAccessToken);
 
         String creationId = "creation-1";
 
@@ -292,7 +292,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldSendAMDNBackToTheOriginalMessageAuthor() {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
+        List<String> messageIds = listMessageIdsForAccount(homerAccessToken);
 
         // HOMER sends a MDN back to BART
         String creationId = "creation-1";
@@ -314,8 +314,8 @@ public abstract class SendMDNMethodTest {
             .post("/jmap");
 
         // BART should have received it
-        calmlyAwait.until(() -> !listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken)).isEmpty());
-        List<String> bobInboxMessageIds = listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken));
+        calmlyAwait.until(() -> !listMessageIdsInMailbox(bartAccessToken, getInboxId(bartAccessToken)).isEmpty());
+        List<String> bobInboxMessageIds = listMessageIdsInMailbox(bartAccessToken, getInboxId(bartAccessToken));
 
         given()
             .header("Authorization", bartAccessToken.serialize())
@@ -337,7 +337,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldPositionTheReportAsAnAttachment() {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
+        List<String> messageIds = listMessageIdsForAccount(homerAccessToken);
 
         // USER sends a MDN back to BART
         String creationId = "creation-1";
@@ -359,8 +359,8 @@ public abstract class SendMDNMethodTest {
             .post("/jmap");
 
         // BART should have received it
-        calmlyAwait.until(() -> !listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken)).isEmpty());
-        List<String> bobInboxMessageIds = listMessagesInMailbox(bartAccessToken, getInboxId(bartAccessToken));
+        calmlyAwait.until(() -> !listMessageIdsInMailbox(bartAccessToken, getInboxId(bartAccessToken)).isEmpty());
+        List<String> bobInboxMessageIds = listMessageIdsInMailbox(bartAccessToken, getInboxId(bartAccessToken));
 
         String blobId = with()
             .header("Authorization", bartAccessToken.serialize())
@@ -415,7 +415,7 @@ public abstract class SendMDNMethodTest {
     public void sendMDNShouldReturnMaxQuotaReachedWhenUserReachedHisQuota() throws MailboxException {
         bartSendMessageToHomer();
 
-        List<String> messageIds = getMessageIdListForAccount(homerAccessToken);
+        List<String> messageIds = listMessageIdsForAccount(homerAccessToken);
 
         QuotaProbe quotaProbe = jmapServer.getProbe(QuotaProbesImpl.class);
         String inboxQuotaRoot = quotaProbe.getQuotaRoot("#private", HOMER, DefaultMailboxes.INBOX);
@@ -532,7 +532,7 @@ public abstract class SendMDNMethodTest {
             .getList(ARGUMENTS + ".list");
     }
 
-    private List<String> getMessageIdListForAccount(AccessToken accessToken) {
+    private List<String> listMessageIdsForAccount(AccessToken accessToken) {
         return with()
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMessageList\", {}, \"#0\"]]")
@@ -543,7 +543,7 @@ public abstract class SendMDNMethodTest {
             .path(ARGUMENTS + ".messageIds");
     }
 
-    private List<String> listMessagesInMailbox(AccessToken accessToken, String mailboxId) {
+    private List<String> listMessageIdsInMailbox(AccessToken accessToken, String mailboxId) {
         return with()
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]")


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


[02/10] james-project git commit: JAMES-2361 migrate mailet/standard to junit 5

Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java
index 0cc1bae..4025c12 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/RelayLimitTest.java
@@ -21,6 +21,7 @@ package org.apache.james.transport.matchers;
 
 import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
@@ -30,17 +31,17 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class RelayLimitTest {
+class RelayLimitTest {
 
     private RelayLimit testee;
     private Mail mail;
     private MimeMessage mimeMessage;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         testee = new RelayLimit();
         mimeMessage = MimeMessageUtil.defaultMimeMessage();
         mail = FakeMail.builder()
@@ -49,39 +50,47 @@ public class RelayLimitTest {
                 .build();
     }
 
-    @Test(expected = MessagingException.class)
-    public void relayLimitShouldBeANumber() throws Exception {
-        testee.init(FakeMatcherConfig.builder()
+    @Test
+    void relayLimitShouldBeANumber() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
                 .condition("Abc")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
-    @Test(expected = MessagingException.class)
-    public void relayLimitShouldBeSpecified() throws Exception {
-        testee.init(FakeMatcherConfig.builder()
+    @Test
+    void relayLimitShouldBeSpecified() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
-                .build());
+                .build()))
+        .isInstanceOf(MessagingException.class);
     }
 
-    @Test(expected = MessagingException.class)
-    public void relayLimitShouldNotBeNull() throws Exception {
-        testee.init(FakeMatcherConfig.builder()
+    @Test
+    void relayLimitShouldNotBeNull() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
                 .condition("0")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
-    @Test(expected = MessagingException.class)
-    public void relayLimitShouldThrowWhenConditionLessThanZero() throws Exception {
-        testee.init(FakeMatcherConfig.builder()
+    @Test
+    void relayLimitShouldThrowWhenConditionLessThanZero() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
                 .condition("-1")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
     
     @Test
-    public void shouldNotMatchWhenNoReceivedHeader() throws Exception {
+    void shouldNotMatchWhenNoReceivedHeader() throws Exception {
         testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
                 .condition("2")
@@ -92,7 +101,7 @@ public class RelayLimitTest {
 
 
     @Test
-    public void shouldNotMatchWhenNotEnoughReceivedHeader() throws Exception {
+    void shouldNotMatchWhenNotEnoughReceivedHeader() throws Exception {
         testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
                 .condition("2")
@@ -104,7 +113,7 @@ public class RelayLimitTest {
     }
 
     @Test
-    public void shouldMatchWhenEqualToLimit() throws Exception {
+    void shouldMatchWhenEqualToLimit() throws Exception {
         testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
                 .condition("2")
@@ -117,7 +126,7 @@ public class RelayLimitTest {
     }
 
     @Test
-    public void shouldMatchWhenWhenOverLimit() throws Exception {
+    void shouldMatchWhenWhenOverLimit() throws Exception {
         testee.init(FakeMatcherConfig.builder()
                 .matcherName("RelayLimit")
                 .condition("2")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
index 67c7425..7c47bea 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthSuccessfulTest.java
@@ -29,14 +29,14 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SMTPAuthSuccessfulTest {
 
     private SMTPAuthSuccessful testee;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         testee = new SMTPAuthSuccessful();
         testee.init(FakeMatcherConfig.builder().matcherName("matcherName")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
index 4e1908d..ef19a41 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPAuthUserIsTest.java
@@ -20,6 +20,8 @@
 
 package org.apache.james.transport.matchers;
 
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 import java.util.Collection;
 
 import javax.mail.MessagingException;
@@ -27,6 +29,7 @@ import javax.mail.MessagingException;
 import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.GenericMatcher;
+import org.junit.jupiter.api.Test;
 
 public class SMTPAuthUserIsTest extends AbstractHasMailAttributeTest {
 
@@ -53,8 +56,8 @@ public class SMTPAuthUserIsTest extends AbstractHasMailAttributeTest {
     }
     
     
-    // test if the mail attribute was not matched
     @Override
+    @Test
     public void testAttributeIsNotMatched() throws MessagingException {
         setupAll();
         setMailAttributeValue("notmatched@james.apache.org");

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
index 3ce6235..9860001 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SMTPIsAuthNetworkTest.java
@@ -24,15 +24,15 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.james.core.MailAddress;
 import org.apache.mailet.Mail;
 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;
 
 public class SMTPIsAuthNetworkTest {
 
     private SMTPIsAuthNetwork testee;
     private MailAddress recipient;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         testee = new SMTPIsAuthNetwork();
         recipient = new MailAddress("recipient@domain.com");

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
index 86e6e85..5d5982c 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsLocalTest.java
@@ -38,14 +38,14 @@ import org.apache.mailet.MailetContext;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SenderHostIsLocalTest {
 
     private Matcher matcher;
     
-    @Before
+    @BeforeEach
     public void setUp() throws MessagingException {
         MailetContext mailContext = mock(MailetContext.class);
         when(mailContext.isLocalServer(JAMES_APACHE_ORG)).thenReturn(true);

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
index c4f85c0..0be03f0 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderHostIsTest.java
@@ -22,6 +22,7 @@ package org.apache.james.transport.matchers;
 
 import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES2;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
 import java.util.Collection;
@@ -33,23 +34,23 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SenderHostIsTest {
 
     private SenderHostIs matcher;
     private MailetContext mailContext;
 
-    @Before
-    public void setUp() throws MessagingException {
+    @BeforeEach
+    void setUp() {
         mailContext = mock(MailetContext.class);
         matcher = new SenderHostIs();
 
     }
 
     @Test
-    public void shouldMatchWhenSenderHostIsKnown() throws MessagingException {
+    void shouldMatchWhenSenderHostIsKnown() throws MessagingException {
         //Given
         FakeMatcherConfig mci = FakeMatcherConfig.builder()
                 .matcherName("SenderHostIs")
@@ -70,7 +71,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void shouldNotMatchWhenSenderHostIsUnknown() throws MessagingException {
+    void shouldNotMatchWhenSenderHostIsUnknown() throws MessagingException {
         //Given
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderHostIs")
@@ -90,7 +91,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void shouldNotMatchWhenEmptyList() throws MessagingException {
+    void shouldNotMatchWhenEmptyList() throws MessagingException {
         //Given
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderHostIs")
@@ -109,7 +110,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void shouldNotMatchWhenNullSender() throws MessagingException {
+    void shouldNotMatchWhenNullSender() throws MessagingException {
         //Given
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderHostIs")
@@ -126,18 +127,19 @@ public class SenderHostIsTest {
         assertThat(actual).isNull();
     }
 
-    @Test(expected = NullPointerException.class)
-    public void shouldThrowWhenNullCondition() throws Exception {
-        //When
-        matcher.init(FakeMatcherConfig.builder()
+    @Test
+    void shouldThrowWhenNullCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderHostIs")
                 .mailetContext(mailContext)
                 .condition(null)
-                .build());
+                .build()))
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void parseDomainsListShouldParseWhenOnlyOneDomain() {
+    void parseDomainsListShouldParseWhenOnlyOneDomain() {
         //When
         Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org");
         //Then
@@ -145,7 +147,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void parseDomainsListShouldParseWhenCommaSpacePattern() {
+    void parseDomainsListShouldParseWhenCommaSpacePattern() {
         //When
         Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org, james2.apache.org, james3.apache.org, james4.apache.org, james5.apache.org");
         //Then
@@ -153,7 +155,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void parseDomainsListShouldParseWhenCommaPattern() {
+    void parseDomainsListShouldParseWhenCommaPattern() {
         //When
         Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org,james2.apache.org,james3.apache.org,james4.apache.org,james5.apache.org");
         //Then
@@ -161,7 +163,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void parseDomainsListShouldParseWhenSpacePattern() {
+    void parseDomainsListShouldParseWhenSpacePattern() {
         //When
         Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org james2.apache.org james3.apache.org james4.apache.org james5.apache.org");
         //Then
@@ -169,7 +171,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void parseDomainsListShouldParseWhenMixedPatterns() {
+    void parseDomainsListShouldParseWhenMixedPatterns() {
         //When
         Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org james2.apache.org,james3.apache.org, james4.apache.org james5.apache.org");
         //Then
@@ -177,7 +179,7 @@ public class SenderHostIsTest {
     }
 
     @Test
-    public void parseDomainsListShouldIgnoreEmptyDomains() {
+    void parseDomainsListShouldIgnoreEmptyDomains() {
         //When
         Collection<String> senderHosts = matcher.parseDomainsList("james.apache.org   james2.apache.org james3.apache.org , james4.apache.org,,,james5.apache.org");
         //Then

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
index d47bea1..97498a0 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsLocalTest.java
@@ -36,14 +36,14 @@ import org.apache.mailet.MailetContext;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SenderIsLocalTest {
 
     private Matcher matcher;
 
-    @Before
+    @BeforeEach
     public void setUp() throws MessagingException {
         MailetContext mailContext = mock(MailetContext.class);
         when(mailContext.isLocalEmail(ANY_AT_JAMES)).thenReturn(true);

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
index 1c2b429..0b38c45 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsNullTest.java
@@ -25,20 +25,15 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SenderIsNullTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class SenderIsNullTest {
 
     private SenderIsNull matcher;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         matcher = new SenderIsNull();
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsNull")
@@ -46,7 +41,7 @@ public class SenderIsNullTest {
     }
 
     @Test
-    public void shouldMatchWhenNullSender() throws Exception {
+    void shouldMatchWhenNullSender() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipient(ANY_AT_JAMES)
             .build();
@@ -55,7 +50,7 @@ public class SenderIsNullTest {
     }
 
     @Test
-    public void shouldNotMatchWhenSenderIsPresent() throws Exception {
+    void shouldNotMatchWhenSenderIsPresent() throws Exception {
         FakeMail fakeMail = FakeMail.builder()
             .recipient(ANY_AT_JAMES)
             .sender("other@james.apache.org")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
index f5668fb..7bf5c49 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsRegexTest.java
@@ -21,34 +21,30 @@
 package org.apache.james.transport.matchers;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
 import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SenderIsRegexTest {
+class SenderIsRegexTest {
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    public static final String SENDER_NAME = "test@james.apache.org";
+    private static final String SENDER_NAME = "test@james.apache.org";
     private SenderIsRegex matcher;
     private MailAddress recipient;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         matcher = new SenderIsRegex();
         recipient = new MailAddress("recipient@apache.org");
     }
 
     @Test
-    public void shouldMatchOnMatchingPattern() throws Exception {
+    void shouldMatchOnMatchingPattern() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsRegex")
                 .condition(".*@.*")
@@ -63,7 +59,7 @@ public class SenderIsRegexTest {
     }
 
     @Test
-    public void shouldNotMatchSubParts() throws Exception {
+    void shouldNotMatchSubParts() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsRegex")
                 .condition("test")
@@ -78,7 +74,7 @@ public class SenderIsRegexTest {
     }
 
     @Test
-    public void shouldNotMatchWhenNullSender() throws Exception {
+    void shouldNotMatchWhenNullSender() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsRegex")
                 .condition(".*@.*")
@@ -92,7 +88,7 @@ public class SenderIsRegexTest {
     }
 
     @Test
-    public void shouldNotMatchOnNonMatchingPattern() throws Exception {
+    void shouldNotMatchOnNonMatchingPattern() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsRegex")
                 .condition("^\\.")
@@ -107,27 +103,30 @@ public class SenderIsRegexTest {
     }
 
     @Test
-    public void initShouldThrowWhenEmptyCondition() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void initShouldThrowWhenEmptyCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsRegex")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowWhenNoConditions() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void initShouldThrowWhenNoConditions() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsRegex")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowWhenInvalidPattern() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void initShouldThrowWhenInvalidPattern() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIsRegex")
                 .condition("(.")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
index e739959..fbfffa5 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SenderIsTest.java
@@ -21,35 +21,31 @@
 package org.apache.james.transport.matchers;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
 import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SenderIsTest {
+class SenderIsTest {
 
     private static final String SENDER_NAME = "test@james.apache.org";
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     private SenderIs matcher;
     private MailAddress recipient;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         matcher = new SenderIs();
         recipient = new MailAddress("recipient@james.apache.org");
     }
 
     @Test
-    public void shouldMatchWhenGoodSender() throws Exception {
+    void shouldMatchWhenGoodSender() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIs")
                 .condition(SENDER_NAME)
@@ -64,7 +60,7 @@ public class SenderIsTest {
     }
 
     @Test
-    public void shouldNotMatchWhenWrongSender() throws Exception {
+    void shouldNotMatchWhenWrongSender() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIs")
                 .condition(SENDER_NAME)
@@ -79,7 +75,7 @@ public class SenderIsTest {
     }
 
     @Test
-    public void shouldNotMatchWhenNullSender() throws Exception {
+    void shouldNotMatchWhenNullSender() throws Exception {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIs")
                 .condition(SENDER_NAME)
@@ -93,7 +89,7 @@ public class SenderIsTest {
     }
 
     @Test
-    public void senderIsShouldBeConfigurableWithSeveralAddresses() throws Exception {
+    void senderIsShouldBeConfigurableWithSeveralAddresses() throws Exception {
         String mailAddress = "any@apache.org";
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIs")
@@ -104,18 +100,20 @@ public class SenderIsTest {
     }
 
     @Test
-    public void senderIsShouldThrowWhenNoAddressesPassedByConfiguration() throws Exception {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void senderIsShouldThrowWhenNoAddressesPassedByConfiguration() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIs")
-                .build());
+                .build()))
+        .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void senderIsShouldThrowWhenNoConfiguration() throws Exception {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void senderIsShouldThrowWhenNoConfiguration() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("SenderIs")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
index 8d04492..4b5ee71 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SentByMailetTest.java
@@ -29,14 +29,14 @@ import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SentByMailetTest {
 
     private SentByMailet testee;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         testee = new SentByMailet();
         testee.init(FakeMatcherConfig.builder().matcherName("matcherName")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
index 9bfca72..2ef630f 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
@@ -21,6 +21,7 @@ package org.apache.james.transport.matchers;
 
 import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
@@ -28,25 +29,20 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SizeGreaterThanTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class SizeGreaterThanTest {
 
     private Matcher matcher;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         matcher = new SizeGreaterThan();
     }
 
     @Test
-    public void matchShouldMatchWhenMailAboveSize() throws MessagingException {
+    void matchShouldMatchWhenMailAboveSize() throws MessagingException {
         Mail mail = FakeMail.builder()
             .size(2000000)
             .recipient(ANY_AT_JAMES)
@@ -63,7 +59,7 @@ public class SizeGreaterThanTest {
     }
 
     @Test
-    public void matchShouldNotMatchWhenMailUnderSize() throws MessagingException {
+    void matchShouldNotMatchWhenMailUnderSize() throws MessagingException {
         Mail mail = FakeMail.builder()
             .size(200000)
             .recipient(ANY_AT_JAMES)
@@ -80,7 +76,7 @@ public class SizeGreaterThanTest {
     }
 
     @Test
-    public void matchShouldNotMatchMailsWithSpecifiedSize() throws MessagingException {
+    void matchShouldNotMatchMailsWithSpecifiedSize() throws MessagingException {
         Mail mail = FakeMail.builder()
             .size(1024)
             .recipient(ANY_AT_JAMES)
@@ -97,7 +93,7 @@ public class SizeGreaterThanTest {
     }
 
     @Test
-    public void matchShouldMatchMailsWithSizeSuperiorToSpecifiedSize() throws MessagingException {
+    void matchShouldMatchMailsWithSizeSuperiorToSpecifiedSize() throws MessagingException {
         Mail mail = FakeMail.builder()
             .size(1025)
             .recipient(ANY_AT_JAMES)
@@ -114,7 +110,7 @@ public class SizeGreaterThanTest {
     }
 
     @Test
-    public void matchShouldReturnNullWhenUnderLimitNoUnit() throws MessagingException {
+    void matchShouldReturnNullWhenUnderLimitNoUnit() throws MessagingException {
         Mail mail = FakeMail.builder()
             .size(4)
             .recipient(ANY_AT_JAMES)
@@ -131,7 +127,7 @@ public class SizeGreaterThanTest {
     }
 
     @Test
-    public void matchShouldMatchOverLimitWhenNoUnit() throws MessagingException {
+    void matchShouldMatchOverLimitWhenNoUnit() throws MessagingException {
         Mail mail = FakeMail.builder()
             .size(5)
             .recipient(ANY_AT_JAMES)
@@ -148,33 +144,35 @@ public class SizeGreaterThanTest {
     }
 
     @Test
-    public void initShouldThrowOnInvalidUnits() throws Exception {
-        expectedException.expect(MessagingException.class);
+    void initShouldThrowOnInvalidUnits() {
         FakeMatcherConfig matcherConfiguration = FakeMatcherConfig.builder()
                 .matcherName("SizeGreaterThan")
                 .condition("1mb")
                 .build();
 
-        matcher.init(matcherConfiguration);
+        assertThatThrownBy(() -> matcher.init(matcherConfiguration))
+            .isInstanceOf(MessagingException.class);
     }
 
-    @Test(expected = MessagingException.class)
-    public void initShouldThrowOnNullSize() throws Exception {
+    @Test
+    void initShouldThrowOnNullSize() {
         FakeMatcherConfig matcherConfiguration = FakeMatcherConfig.builder()
                 .matcherName("SizeGreaterThan")
                 .condition("0")
                 .build();
 
-        matcher.init(matcherConfiguration);
+        assertThatThrownBy(() -> matcher.init(matcherConfiguration))
+            .isInstanceOf(MessagingException.class);
     }
 
-    @Test(expected = MessagingException.class)
-    public void initShouldThrowOnNegativeSize() throws Exception {
+    @Test
+    void initShouldThrowOnNegativeSize() {
         FakeMatcherConfig matcherConfiguration = FakeMatcherConfig.builder()
                 .matcherName("SizeGreaterThan")
                 .condition("-1")
                 .build();
 
-        matcher.init(matcherConfiguration);
+        assertThatThrownBy(() -> matcher.init(matcherConfiguration))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
index 11193fa..22f5c75 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectIsTest.java
@@ -29,15 +29,15 @@ import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SubjectIsTest {
 
     private SubjectIs matcher;
     private MailAddress roger;
 
-    @Before
+    @BeforeEach
     public void setup() throws AddressException {
         matcher = new SubjectIs();
         roger = new MailAddress("roger@nasa.org");

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
index e927980..a590b9b 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SubjectStartsWithTest.java
@@ -29,15 +29,15 @@ import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
 import org.apache.mailet.base.test.MailUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SubjectStartsWithTest {
 
     private SubjectStartsWith matcher;
     private MailAddress roger;
 
-    @Before
+    @BeforeEach
     public void setup() throws AddressException {
         matcher = new SubjectStartsWith();
         roger = new MailAddress("roger@nasa.org");

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
index bd08510..29a8495 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyLinesTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.matchers;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Collection;
 
@@ -29,73 +30,68 @@ import org.apache.james.core.MailAddress;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class TooManyLinesTest {
+class TooManyLinesTest {
 
     private TooManyLines testee;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         testee = new TooManyLines();
     }
 
     @Test
-    public void initShouldThrowOnAbsentCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder().matcherName("name").build());
+    void initShouldThrowOnAbsentCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder().matcherName("name").build()))
+        .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnInvalidCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(
-            FakeMatcherConfig.builder()
-                .condition("a")
-                .matcherName("name")
-                .build());
+    void initShouldThrowOnInvalidCondition() {
+        assertThatThrownBy(() ->
+            testee.init(
+                FakeMatcherConfig.builder()
+                    .condition("a")
+                    .matcherName("name")
+                    .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnEmptyCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .condition("")
-            .matcherName("name")
-            .build());
+    void initShouldThrowOnEmptyCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .condition("")
+                .matcherName("name")
+                .build()))
+        .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnZeroCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .condition("0")
-            .matcherName("name")
-            .build());
+    void initShouldThrowOnZeroCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .condition("0")
+                .matcherName("name")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnNegativeCondition() throws MessagingException {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .condition("-10")
-            .matcherName("name")
-            .build());
+    void initShouldThrowOnNegativeCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .condition("-10")
+                .matcherName("name")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void matchShouldReturnNoRecipientWhenMailHaveNoMimeMessageAndConditionIs100() throws Exception {
+    void matchShouldReturnNoRecipientWhenMailHaveNoMimeMessageAndConditionIs100() throws Exception {
         testee.init(FakeMatcherConfig.builder()
             .condition("100")
             .matcherName("name")
@@ -108,7 +104,7 @@ public class TooManyLinesTest {
     }
 
     @Test
-    public void matchShouldAcceptMailsUnderLimit() throws Exception {
+    void matchShouldAcceptMailsUnderLimit() throws Exception {
         testee.init(FakeMatcherConfig.builder()
             .condition("100")
             .matcherName("name")
@@ -126,7 +122,7 @@ public class TooManyLinesTest {
     }
 
     @Test
-    public void matchShouldRejectMailsOverLimit() throws Exception {
+    void matchShouldRejectMailsOverLimit() throws Exception {
         testee.init(FakeMatcherConfig.builder().condition("10").matcherName("name").build());
 
         FakeMail fakeMail = FakeMail.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
index 4a6c726..1aa47b8 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/TooManyRecipientsTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.transport.matchers;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Collection;
 
@@ -28,76 +29,71 @@ import javax.mail.MessagingException;
 import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class TooManyRecipientsTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class TooManyRecipientsTest {
 
     private TooManyRecipients testee;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         testee = new TooManyRecipients();
     }
 
     @Test
-    public void initShouldThrowOnAbsentCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .matcherName("matcherName")
-            .build());
+    void initShouldThrowOnAbsentCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .matcherName("matcherName")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnInvalidCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .condition("a")
-            .matcherName("matcherName")
-            .build());
+    void initShouldThrowOnInvalidCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .condition("a")
+                .matcherName("matcherName")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnEmptyCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .condition("")
-            .matcherName("matcherName")
-            .build());
+    void initShouldThrowOnEmptyCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .condition("")
+                .matcherName("matcherName")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnZeroCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .condition("0")
-            .matcherName("matcherName")
-            .build());
+    void initShouldThrowOnZeroCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .condition("0")
+                .matcherName("matcherName")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnNegativeCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-
-        testee.init(FakeMatcherConfig.builder()
-            .condition("-10")
-            .matcherName("matcherName")
-            .build());
+    void initShouldThrowOnNegativeCondition() {
+        assertThatThrownBy(() ->
+            testee.init(FakeMatcherConfig.builder()
+                .condition("-10")
+                .matcherName("matcherName")
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void matchShouldReturnNoRecipientWhenMailHaveNoRecipient() throws Exception {
+    void matchShouldReturnNoRecipientWhenMailHaveNoRecipient() throws Exception {
         testee.init(FakeMatcherConfig.builder()
             .condition("3")
             .matcherName("matcherName")
@@ -109,7 +105,7 @@ public class TooManyRecipientsTest {
     }
 
     @Test
-    public void matchShouldAcceptMailsUnderLimit() throws Exception {
+    void matchShouldAcceptMailsUnderLimit() throws Exception {
         testee.init(FakeMatcherConfig.builder()
             .condition("3")
             .matcherName("matcherName")
@@ -126,7 +122,7 @@ public class TooManyRecipientsTest {
 
 
     @Test
-    public void matchShouldAcceptMailsAtLimit() throws Exception {
+    void matchShouldAcceptMailsAtLimit() throws Exception {
         testee.init(FakeMatcherConfig.builder()
             .condition("3")
             .matcherName("matcherName")
@@ -142,7 +138,7 @@ public class TooManyRecipientsTest {
     }
 
     @Test
-    public void matchShouldRejectMailsOverLimit() throws Exception {
+    void matchShouldRejectMailsOverLimit() throws Exception {
         testee.init(FakeMatcherConfig.builder()
             .condition("3")
             .matcherName("matcherName")

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java
index 348896c..2b89b45 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/UserIsTest.java
@@ -24,30 +24,26 @@ import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES;
 import static org.apache.mailet.base.MailAddressFixture.ANY_AT_JAMES2;
 import static org.apache.mailet.base.MailAddressFixture.OTHER_AT_JAMES;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import javax.mail.MessagingException;
 
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class UserIsTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class UserIsTest {
 
     private UserIs matcher;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         matcher = new UserIs();
     }
 
     @Test
-    public void shouldMatchCorrespondingUser() throws MessagingException {
+    void shouldMatchCorrespondingUser() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("UserIs")
                 .condition("any")
@@ -61,7 +57,7 @@ public class UserIsTest {
     }
 
     @Test
-    public void shouldMatchCorrespondingUserAccrossDomains() throws MessagingException {
+    void shouldMatchCorrespondingUserAccrossDomains() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("UserIs")
                 .condition("any")
@@ -75,7 +71,7 @@ public class UserIsTest {
     }
 
     @Test
-    public void shouldNotMatchNonSpecifiedUsersButPreserveSpecifiedUsers() throws MessagingException {
+    void shouldNotMatchNonSpecifiedUsersButPreserveSpecifiedUsers() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("UserIs")
                 .condition("any")
@@ -89,7 +85,7 @@ public class UserIsTest {
     }
 
     @Test
-    public void shouldNotMatchNonSpecifiedUsers() throws MessagingException {
+    void shouldNotMatchNonSpecifiedUsers() throws MessagingException {
         matcher.init(FakeMatcherConfig.builder()
                 .matcherName("UserIs")
                 .condition("any")
@@ -103,18 +99,20 @@ public class UserIsTest {
     }
 
     @Test
-    public void initShouldThrowOnMissingCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void initShouldThrowOnMissingCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("UserIs")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 
     @Test
-    public void initShouldThrowOnEmptyCondition() throws Exception {
-        expectedException.expect(MessagingException.class);
-        matcher.init(FakeMatcherConfig.builder()
+    void initShouldThrowOnEmptyCondition() {
+        assertThatThrownBy(() ->
+            matcher.init(FakeMatcherConfig.builder()
                 .matcherName("UserIs")
-                .build());
+                .build()))
+            .isInstanceOf(MessagingException.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
index c4b0d8a..cb3a296 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/matchers/util/MailAddressCollectionReaderTest.java
@@ -20,44 +20,40 @@
 package org.apache.james.transport.matchers.util;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.james.core.MailAddress;
 import org.apache.james.transport.matchers.utils.MailAddressCollectionReader;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
-public class MailAddressCollectionReaderTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class MailAddressCollectionReaderTest {
 
     @Test
-    public void readShouldThrowOnNullInput() {
-        expectedException.expect(IllegalArgumentException.class);
-        MailAddressCollectionReader.read(null);
+    void readShouldThrowOnNullInput() {
+        assertThatThrownBy(() -> MailAddressCollectionReader.read(null))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void readShouldThrowOnEmptyInput() {
-        expectedException.expect(IllegalArgumentException.class);
-        MailAddressCollectionReader.read("");
+    void readShouldThrowOnEmptyInput() {
+        assertThatThrownBy(() -> MailAddressCollectionReader.read(""))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void readShouldThrowOnInvalidEmail() {
-        expectedException.expect(RuntimeException.class);
-        MailAddressCollectionReader.read("not_valid");
+    void readShouldThrowOnInvalidEmail() {
+        assertThatThrownBy(() -> MailAddressCollectionReader.read("not_valid"))
+            .isInstanceOf(RuntimeException.class);
     }
 
     @Test
-    public void readShouldThrowOnInvalidEmailOnSecondPosition() {
-        expectedException.expect(RuntimeException.class);
-        MailAddressCollectionReader.read("valid@apache.org, not_valid");
+    void readShouldThrowOnInvalidEmailOnSecondPosition() {
+        assertThatThrownBy(() -> MailAddressCollectionReader.read("valid@apache.org, not_valid"))
+            .isInstanceOf(RuntimeException.class);
     }
 
     @Test
-    public void readShouldParseOneEmail() throws Exception {
+    void readShouldParseOneEmail() throws Exception {
         MailAddress mailAddress = new MailAddress("valid@apache.org");
 
         assertThat(MailAddressCollectionReader.read(mailAddress.toString()))
@@ -65,7 +61,7 @@ public class MailAddressCollectionReaderTest {
     }
 
     @Test
-    public void readShouldParseTwoEmailSeparatedByComaOnly() throws Exception {
+    void readShouldParseTwoEmailSeparatedByComaOnly() throws Exception {
         MailAddress mailAddress1 = new MailAddress("valid@apache.org");
         MailAddress mailAddress2 = new MailAddress("bis@apache.org");
 
@@ -74,7 +70,7 @@ public class MailAddressCollectionReaderTest {
     }
 
     @Test
-    public void readShouldParseTwoEmailSeparatedBySpaceOnly() throws Exception {
+    void readShouldParseTwoEmailSeparatedBySpaceOnly() throws Exception {
         MailAddress mailAddress1 = new MailAddress("valid@apache.org");
         MailAddress mailAddress2 = new MailAddress("bis@apache.org");
 
@@ -83,7 +79,7 @@ public class MailAddressCollectionReaderTest {
     }
 
     @Test
-    public void readShouldParseTwoEmailSeparatedByTabOnly() throws Exception {
+    void readShouldParseTwoEmailSeparatedByTabOnly() throws Exception {
         MailAddress mailAddress1 = new MailAddress("valid@apache.org");
         MailAddress mailAddress2 = new MailAddress("bis@apache.org");
 
@@ -93,7 +89,7 @@ public class MailAddressCollectionReaderTest {
 
 
     @Test
-    public void readShouldParseTwoEmailSeparatorsCombination() throws Exception {
+    void readShouldParseTwoEmailSeparatorsCombination() throws Exception {
         MailAddress mailAddress1 = new MailAddress("valid@apache.org");
         MailAddress mailAddress2 = new MailAddress("bis@apache.org");
 
@@ -102,7 +98,7 @@ public class MailAddressCollectionReaderTest {
     }
 
     @Test
-    public void readShouldRemoveDuplicates() throws Exception {
+    void readShouldRemoveDuplicates() throws Exception {
         MailAddress mailAddress = new MailAddress("valid@apache.org");
 
         assertThat(MailAddressCollectionReader.read(mailAddress.toString() + ", " + mailAddress.toString()))

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e365b3e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2bedd6c..37c9f6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2217,6 +2217,11 @@
                 <version>${junit.jupiter.version}</version>
             </dependency>
             <dependency>
+                <groupId>org.junit.jupiter</groupId>
+                <artifactId>junit-jupiter-params</artifactId>
+                <version>${junit.jupiter.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.junit.platform</groupId>
                 <artifactId>junit-platform-launcher</artifactId>
                 <version>${junit.plateform.version}</version>


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


[07/10] james-project git commit: JAMES-2361 remove duplicate maven entry

Posted by ma...@apache.org.
JAMES-2361 remove duplicate maven entry


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a4c9f2e7
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a4c9f2e7
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a4c9f2e7

Branch: refs/heads/master
Commit: a4c9f2e7b91ba113e27f50e837ed3159dc37d5e5
Parents: 81d5a24
Author: Matthieu Baechler <ma...@apache.org>
Authored: Tue Mar 20 18:13:55 2018 +0100
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Mar 26 14:57:23 2018 +0200

----------------------------------------------------------------------
 pom.xml | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a4c9f2e7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 96f27ec..2bedd6c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2222,11 +2222,6 @@
                 <version>${junit.plateform.version}</version>
             </dependency>
             <dependency>
-                <groupId>org.junit.platform</groupId>
-                <artifactId>junit-platform-launcher</artifactId>
-                <version>${junit.plateform.version}</version>
-            </dependency>
-            <dependency>
                 <groupId>org.junit.vintage</groupId>
                 <artifactId>junit-vintage-engine</artifactId>
                 <version>${junit.vintage.version}</version>


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