james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [14/17] james-project git commit: JAMES-2578 Add tests on new API
Date Mon, 05 Nov 2018 10:52:17 GMT
JAMES-2578 Add tests on new API


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

Branch: refs/heads/master
Commit: 90012fe9f437438df02420420d10e979e501a38e
Parents: 9ebeaf0
Author: Gautier DI FOLCO <gdifolco@linagora.com>
Authored: Mon Nov 5 11:35:46 2018 +0100
Committer: Gautier DI FOLCO <gdifolco@linagora.com>
Committed: Mon Nov 5 11:37:07 2018 +0100

----------------------------------------------------------------------
 .../org/apache/mailet/ContractMailTest.java     | 148 +++++++++++++++++++
 mailet/test/pom.xml                             |  14 +-
 .../apache/mailet/base/test/FakeMailTest.java   |  15 +-
 pom.xml                                         |   6 +
 server/container/core/pom.xml                   |  20 ++-
 .../org/apache/james/server/core/MailImpl.java  |   4 +-
 .../james/server/core/MailHeadersTest.java      |   2 +-
 .../apache/james/server/core/MailImplTest.java  |  22 ++-
 .../core/MimeMessageCopyOnWriteProxyTest.java   |   2 +-
 .../core/MimeMessageInputStreamSourceTest.java  |   6 +-
 .../james/server/core/MimeMessageTest.java      |   2 +-
 .../james/server/core/MimeMessageUtilTest.java  |   2 +-
 .../server/core/MimeMessageWrapperTest.java     |  20 +--
 .../server/core/filesystem/SimpleUrlTest.java   |  11 +-
 14 files changed, 232 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java b/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java
new file mode 100644
index 0000000..7dda0b9
--- /dev/null
+++ b/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java
@@ -0,0 +1,148 @@
+/****************************************************************
+ * 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.mailet;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+
+import com.google.common.collect.ImmutableMap;
+
+public abstract class ContractMailTest {
+    private final static AttributeName ATTRIBUTE_NAME_1 = AttributeName.of("name1");
+    private final static AttributeName ATTRIBUTE_NAME_2 = AttributeName.of("name2");
+    private final static Attribute ATTRIBUTE_1 = new Attribute(ATTRIBUTE_NAME_1, AttributeValue.of(true));
+    private final static Attribute ATTRIBUTE_2 = new Attribute(ATTRIBUTE_NAME_2, AttributeValue.of("value2"));
+    private final static Attribute ATTRIBUTE_1_BIS = new Attribute(ATTRIBUTE_NAME_1, AttributeValue.of("value1"));
+
+    public abstract Mail newMail();
+
+    @Nested
+    public class AttributeTests {
+        private Mail mail;
+        
+        @BeforeEach
+        void setUp() {
+            mail = newMail();
+        }
+
+        @Test
+        void newMailShouldHaveNoAttribute() {
+            assertThat(mail.attributes()).isEmpty();
+        }
+        
+        @Test
+        void newMailShouldHaveNoAttributeName() {
+            assertThat(mail.attributeNames()).isEmpty();
+        }
+
+        @Test
+        void newMailShouldHaveAnEmptyAttributeMap() {
+            assertThat(mail.attributesMap()).isEmpty();
+        }
+
+        @Test
+        void setAttributeShouldReturnEmptyWhenNoPreviousValue() {
+            assertThat(mail.setAttribute(ATTRIBUTE_1)).isEmpty();
+        }
+    }
+    
+    @Nested
+    public class OneAttributeMail {
+        private Mail mail;
+        
+        @BeforeEach
+        void setUp() {
+            mail = newMail();
+            mail.setAttribute(ATTRIBUTE_1);
+        }
+        
+        @Test
+        void shouldHaveOneAttribute() {
+            assertThat(mail.attributes()).containsExactly(ATTRIBUTE_1);
+        }
+        
+        @Test
+        void shouldHaveOneAttributeName() {
+            assertThat(mail.attributeNames()).containsExactly(ATTRIBUTE_NAME_1);
+        }
+
+        @Test
+        void shouldHaveOneAttributeMap() {
+            assertThat(mail.attributesMap()).isEqualTo(ImmutableMap.of(ATTRIBUTE_NAME_1,
ATTRIBUTE_1));
+        }
+        
+        @Test
+        void shouldBeRetrievable() {
+            assertThat(mail.getAttribute(ATTRIBUTE_NAME_1)).contains(ATTRIBUTE_1);
+        }
+        
+        @Test
+        void shouldBeRemovable() {
+            SoftAssertions.assertSoftly(
+                softly -> {
+                    softly.assertThat(mail.removeAttribute(ATTRIBUTE_NAME_1)).contains(ATTRIBUTE_1);
+                    softly.assertThat(mail.getAttribute(ATTRIBUTE_NAME_1)).isEmpty();
+                }
+            );
+        }
+        
+        @Test
+        void shouldBeReplacable() {
+            SoftAssertions.assertSoftly(
+                softly -> {
+                    softly.assertThat(mail.setAttribute(ATTRIBUTE_1_BIS)).contains(ATTRIBUTE_1);
+                    softly.assertThat(mail.getAttribute(ATTRIBUTE_NAME_1)).contains(ATTRIBUTE_1_BIS);
+                }
+            );
+        }
+    }
+    
+    @Nested
+    public class TwoAttributesMail {
+        private Mail mail;
+
+        @BeforeEach
+        void setUp() {
+            mail = newMail();
+            mail.setAttribute(ATTRIBUTE_1);
+            mail.setAttribute(ATTRIBUTE_2);
+        }
+
+        @Test
+        void shouldHaveTwoAttributes() {
+            assertThat(mail.attributes()).containsExactlyInAnyOrder(ATTRIBUTE_1, ATTRIBUTE_2);
+        }
+
+        @Test
+        void shouldHaveTwoAttributesName() {
+            assertThat(mail.attributeNames()).containsExactlyInAnyOrder(ATTRIBUTE_NAME_1,
ATTRIBUTE_NAME_2);
+        }
+
+        @Test
+        void shouldHaveTwoAttributesMap() {
+            assertThat(mail.attributesMap()).isEqualTo(ImmutableMap.of(ATTRIBUTE_NAME_1,
ATTRIBUTE_1, ATTRIBUTE_NAME_2, ATTRIBUTE_2));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/mailet/test/pom.xml
----------------------------------------------------------------------
diff --git a/mailet/test/pom.xml b/mailet/test/pom.xml
index a0a8627..7e31b27 100644
--- a/mailet/test/pom.xml
+++ b/mailet/test/pom.xml
@@ -78,8 +78,18 @@
             <artifactId>activation</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/mailet/test/src/test/java/org/apache/mailet/base/test/FakeMailTest.java
----------------------------------------------------------------------
diff --git a/mailet/test/src/test/java/org/apache/mailet/base/test/FakeMailTest.java b/mailet/test/src/test/java/org/apache/mailet/base/test/FakeMailTest.java
index 6dc3dbf..5d6a2dc 100644
--- a/mailet/test/src/test/java/org/apache/mailet/base/test/FakeMailTest.java
+++ b/mailet/test/src/test/java/org/apache/mailet/base/test/FakeMailTest.java
@@ -27,13 +27,23 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
+import org.apache.mailet.ContractMailTest;
 import org.apache.mailet.base.MailAddressFixture;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;
 import nl.jqno.equalsverifier.Warning;
 
-public class FakeMailTest {
+public class FakeMailTest extends ContractMailTest {
+
+    @Override
+    public FakeMail newMail() {
+        try {
+            return FakeMail.builder().build();
+        } catch (MessagingException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
     @Test
     public void beanShouldRespectBeanContract() {
@@ -100,5 +110,4 @@ public class FakeMailTest {
                 .hasSender())
             .isTrue();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c34f86f..52f9740 100644
--- a/pom.xml
+++ b/pom.xml
@@ -951,6 +951,12 @@
             </dependency>
             <dependency>
                 <groupId>${james.groupId}</groupId>
+                <artifactId>apache-mailet-api</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+            </dependency>
+            <dependency>
+                <groupId>${james.groupId}</groupId>
                 <artifactId>apache-mailet-base</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/core/pom.xml b/server/container/core/pom.xml
index ef1d3d3..5f59080 100644
--- a/server/container/core/pom.xml
+++ b/server/container/core/pom.xml
@@ -43,6 +43,12 @@
             <artifactId>apache-mailet-api</artifactId>
         </dependency>
         <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>apache-mailet-api</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <!-- RFC2822Headers constants imported from mailet-base (undetected by bytecode
analyzers because constants are inlined) -->
             <groupId>${james.groupId}</groupId>
             <artifactId>apache-mailet-base</artifactId>
@@ -98,8 +104,18 @@
             <artifactId>javax.inject</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
b/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
index 3bcaeb6..28626cc 100644
--- a/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
+++ b/server/container/core/src/main/java/org/apache/james/server/core/MailImpl.java
@@ -410,7 +410,7 @@ public class MailImpl implements Disposable, Mail {
         setErrorMessage(mail.getErrorMessage());
         try {
             if (mail instanceof MailImpl) {
-                setAttributesRaw((HashMap<String, Object>) cloneSerializableObject(((MailImpl)
mail).getAttributesRaw()));
+                setAttributesRaw((Map<String, Object>) cloneSerializableObject(((MailImpl)
mail).getAttributesRaw()));
             } else {
                 HashMap<String, Object> attribs = new HashMap<>();
                 for (Iterator<String> i = mail.getAttributeNames(); i.hasNext(); )
{
@@ -783,7 +783,7 @@ public class MailImpl implements Disposable, Mail {
 
     @Override
     public Stream<AttributeName> attributeNames() {
-        return attributes.keySet().stream().map(AttributeName::of);
+        return attributes().map(Attribute::getName);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
index f3bf537..95da025 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MailHeadersTest.java
@@ -26,7 +26,7 @@ import java.util.Enumeration;
 import javax.mail.MessagingException;
 
 import org.apache.mailet.base.RFC2822Headers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class MailHeadersTest {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
index 62d2f1e..c152056 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MailImplTest.java
@@ -33,20 +33,26 @@ import javax.mail.internet.MimeMessage;
 import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.core.builder.MimeMessageBuilder;
+import org.apache.mailet.ContractMailTest;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.MailAddressFixture;
 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;
 
 import com.github.fge.lambdas.Throwing;
 import com.google.common.collect.ImmutableList;
 
-public class MailImplTest {
+public class MailImplTest extends ContractMailTest {
+
+    @Override
+    public MailImpl newMail() {
+        return new MailImpl();
+    }
 
     private MimeMessage emptyMessage;
 
-    @Before
+    @BeforeEach
     public void setup() throws MessagingException {
         emptyMessage = MimeMessageBuilder.mimeMessageBuilder()
             .setText("")
@@ -55,7 +61,7 @@ public class MailImplTest {
 
     @Test
     public void mailImplShouldHaveSensibleInitialValues() throws MessagingException {
-        MailImpl mail = new MailImpl();
+        MailImpl mail = newMail();
 
         assertThat(mail.hasAttributes()).describedAs("no initial attributes").isFalse();
         assertThat(mail.getErrorMessage()).describedAs("no initial error").isNull();
@@ -71,7 +77,7 @@ public class MailImplTest {
 
     @Test
     public void mailImplShouldThrowWhenComputingSizeOnDefaultInstance() throws MessagingException
{
-        MailImpl mail = new MailImpl();
+        MailImpl mail = newMail();
 
         assertThatThrownBy(mail::getMessageSize).isInstanceOf(NullPointerException.class);
     }
@@ -85,7 +91,7 @@ public class MailImplTest {
         MailImpl mail = new MailImpl(name, senderMailAddress, recipients);
 
 
-        MailImpl expected = new MailImpl();
+        MailImpl expected = newMail();
         assertThat(mail).isEqualToIgnoringGivenFields(expected, "sender", "name", "recipients",
"lastUpdated");
         assertThat(mail.getLastUpdated()).isCloseTo(new Date(), TimeUnit.SECONDS.toMillis(1));
     }
@@ -161,7 +167,7 @@ public class MailImplTest {
 
     @Test
     public void setAttributeShouldThrowOnNullAttributeName() throws MessagingException {
-        MailImpl mail = new MailImpl();
+        MailImpl mail = newMail();
 
         assertThatThrownBy(() -> mail.setAttribute(null, "toto"))
             .isInstanceOf(NullPointerException.class);

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
index 8a1889a..dfa46e5 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageCopyOnWriteProxyTest.java
@@ -31,7 +31,7 @@ import org.apache.james.core.MailAddress;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.mailet.Mail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
index a81c422..6a005a0 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageInputStreamSourceTest.java
@@ -25,8 +25,8 @@ import java.io.IOException;
 import javax.mail.MessagingException;
 
 import org.apache.james.util.ZeroedInputStream;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
 public class MimeMessageInputStreamSourceTest {
 
@@ -34,7 +34,7 @@ public class MimeMessageInputStreamSourceTest {
     private static final int _10KB = 10 * 1024;
     private MimeMessageInputStreamSource testee;
 
-    @After
+    @AfterEach
     public void tearDown() {
         testee.dispose();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
index 36ee6ab..eab98ac 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageTest.java
@@ -39,7 +39,7 @@ import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.util.MimeMessageUtil;
 import org.apache.mailet.base.RFC2822Headers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class MimeMessageTest {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
index 8a12390..b5236cf 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageUtilTest.java
@@ -28,7 +28,7 @@ import javax.mail.MessagingException;
 import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class MimeMessageUtilTest {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
index 426aee7..cb39e6a 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/MimeMessageWrapperTest.java
@@ -19,6 +19,7 @@
 package org.apache.james.server.core;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
@@ -36,11 +37,9 @@ import javax.mail.util.SharedByteArrayInputStream;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.util.MimeMessageUtil;
 import org.apache.mailet.base.RFC2822Headers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test the subject folding issue.
@@ -88,21 +87,18 @@ public class MimeMessageWrapperTest extends MimeMessageFromStreamTest
{
     final String sep = "\r\n\r\n";
     final String body = "bar\r\n";
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
     @Override
     protected MimeMessage getMessageFromSources(String sources) throws Exception {
         MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new
SharedByteArrayInputStream(sources.getBytes()));
         return new TestableMimeMessageWrapper(mmis);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         mw = (TestableMimeMessageWrapper) getMessageFromSources(content + sep + body);
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         LifecycleUtil.dispose(mw);
     }
@@ -131,9 +127,7 @@ public class MimeMessageWrapperTest extends MimeMessageFromStreamTest
{
     public void testDeferredHeaderLoading() throws MessagingException, IOException {
         mw.setHeadersLoadable(false);
 
-        expectedException.expect(IllegalStateException.class);
-
-        mw.getSubject();
+        assertThatThrownBy(() -> mw.getSubject()).isInstanceOf(IllegalStateException.class);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/90012fe9/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
b/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
index 21b6707..ffa8d25 100644
--- a/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
+++ b/server/container/core/src/test/java/org/apache/james/server/core/filesystem/SimpleUrlTest.java
@@ -19,14 +19,15 @@
 package org.apache.james.server.core.filesystem;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class SimpleUrlTest {
 
-    @Test(expected = NullPointerException.class)
+    @Test()
     public void simplifyPathShouldThrowOnNull() {
-        SimpleUrl.simplifyPath(null);
+        assertThatThrownBy(() -> SimpleUrl.simplifyPath(null)).isInstanceOf(NullPointerException.class);
     }
     
     @Test
@@ -52,9 +53,9 @@ public class SimpleUrlTest {
         assertThat(new SimpleUrl("").getSimplified()).isEmpty();
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void simplifiedShouldThrowWhenNullInput() {
-        new SimpleUrl(null);
+        assertThatThrownBy(() -> new SimpleUrl(null)).isInstanceOf(NullPointerException.class);
     }
 
     @Test


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


Mime
View raw message