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 rc...@apache.org on 2020/08/10 02:47:47 UTC

[james-project] 17/23: [Refactoring] Migrate TextTest to JUnit5

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

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

commit ca4c33440ede73a35944427405c63f87a9a8cd89
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Jul 31 14:52:10 2020 +0700

    [Refactoring] Migrate TextTest to JUnit5
---
 .../java/org/apache/james/mdn/fields/TextTest.java | 39 +++++++++-------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/mdn/src/test/java/org/apache/james/mdn/fields/TextTest.java b/mdn/src/test/java/org/apache/james/mdn/fields/TextTest.java
index f64804c..a5e7eba 100644
--- a/mdn/src/test/java/org/apache/james/mdn/fields/TextTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/fields/TextTest.java
@@ -20,75 +20,68 @@
 package org.apache.james.mdn.fields;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;
 
-public class TextTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
+class TextTest {
     @Test
-    public void shouldMatchBeanContact() {
+    void shouldMatchBeanContact() {
         EqualsVerifier.forClass(Text.class)
             .verify();
     }
 
     @Test
-    public void fromRawTextShouldThrowOnNull() {
-        expectedException.expect(NullPointerException.class);
-
-        Text.fromRawText(null);
+    void fromRawTextShouldThrowOnNull() {
+        assertThatThrownBy(() -> Text.fromRawText(null))
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void fromRawTextShouldThrowOnEmptyStrings() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        Text.fromRawText("");
+    void fromRawTextShouldThrowOnEmptyStrings() {
+        assertThatThrownBy(() -> Text.fromRawText(""))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void formattedShouldKeepSpaces() {
+    void formattedShouldKeepSpaces() {
         Text text = Text.fromRawText("text with spaces");
 
         assertThat(text.formatted()).isEqualTo("text with spaces");
     }
 
     @Test
-    public void formattedShouldWrapLines() {
+    void formattedShouldWrapLines() {
         Text text = Text.fromRawText("text with spaces\r\non several lines");
 
         assertThat(text.formatted()).isEqualTo("text with spaces\r\n on several lines");
     }
 
     @Test
-    public void formattedShouldPreserveLineWrapping() {
+    void formattedShouldPreserveLineWrapping() {
         Text text = Text.fromRawText("text with spaces\r\n on several lines");
 
         assertThat(text.formatted()).isEqualTo("text with spaces\r\n on several lines");
     }
 
     @Test
-    public void formattedShouldTrimExtraSpacesAfterWrapping() {
+    void formattedShouldTrimExtraSpacesAfterWrapping() {
         Text text = Text.fromRawText("text with spaces\r\n  on several lines");
 
         assertThat(text.formatted()).isEqualTo("text with spaces\r\n on several lines");
     }
 
     @Test
-    public void formattedShouldTrimExtraSpacesBeforeWrapping() {
+    void formattedShouldTrimExtraSpacesBeforeWrapping() {
         Text text = Text.fromRawText("text with spaces  \r\non several lines");
 
         assertThat(text.formatted()).isEqualTo("text with spaces\r\n on several lines");
     }
 
     @Test
-    public void formattedShouldPreserveFoldingSpaces() {
+    void formattedShouldPreserveFoldingSpaces() {
         Text text = Text.fromRawText("text with folding    spaces");
 
         assertThat(text.formatted()).isEqualTo("text with folding    spaces");


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