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 47c0a08e328cf5b33f2382ac8f77e257e7750a64 Author: Rene Cordier <rcord...@linagora.com> AuthorDate: Fri Jul 31 14:04:24 2020 +0700 [Refactoring] Migrate AddressTypeTest to JUnit5 --- .../apache/james/mdn/fields/AddressTypeTest.java | 57 +++++++++------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/mdn/src/test/java/org/apache/james/mdn/fields/AddressTypeTest.java b/mdn/src/test/java/org/apache/james/mdn/fields/AddressTypeTest.java index 527d6d7..0b610d5 100644 --- a/mdn/src/test/java/org/apache/james/mdn/fields/AddressTypeTest.java +++ b/mdn/src/test/java/org/apache/james/mdn/fields/AddressTypeTest.java @@ -20,67 +20,58 @@ 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 AddressTypeTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class AddressTypeTest { @Test - public void shouldMatchBeanContract() { + void shouldMatchBeanContract() { EqualsVerifier.forClass(AddressType.class) .verify(); } @Test - public void constructorShouldThrowOnNull() { - expectedException.expect(NullPointerException.class); - - new AddressType(null); + void constructorShouldThrowOnNull() { + assertThatThrownBy(() -> new AddressType(null)) + .isInstanceOf(NullPointerException.class); } @Test - public void constructorShouldThrowOnEmpty() { - expectedException.expect(IllegalArgumentException.class); - - new AddressType(""); + void constructorShouldThrowOnEmpty() { + assertThatThrownBy(() -> new AddressType("")) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void constructorShouldThrowOnFoldingWhiteSpaces() { - expectedException.expect(IllegalArgumentException.class); - - new AddressType(" "); + void constructorShouldThrowOnFoldingWhiteSpaces() { + assertThatThrownBy(() -> new AddressType(" ")) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void constructorShouldThrowOnLineBreaks() { - expectedException.expect(IllegalArgumentException.class); - - new AddressType("a\nb"); + void constructorShouldThrowOnLineBreaks() { + assertThatThrownBy(() -> new AddressType("a\nb")) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void constructorShouldThrowOnLineBreakAtTheEnd() { - expectedException.expect(IllegalArgumentException.class); - - new AddressType("a\n"); + void constructorShouldThrowOnLineBreakAtTheEnd() { + assertThatThrownBy(() -> new AddressType("a\n")) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void constructorShouldThrowOnLineBreakAtTheBeginning() { - expectedException.expect(IllegalArgumentException.class); - - new AddressType("\na"); + void constructorShouldThrowOnLineBreakAtTheBeginning() { + assertThatThrownBy(() -> new AddressType("\na")) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void constructorShouldAcceptValidValue() { + void constructorShouldAcceptValidValue() { String type = "ab"; AddressType addressType = new AddressType(type); @@ -89,7 +80,7 @@ public class AddressTypeTest { } @Test - public void typeShouldBeTrimmed() { + void typeShouldBeTrimmed() { AddressType addressType = new AddressType(" ab "); assertThat(addressType.getType()) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org