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:43 UTC
[james-project] 13/23: [Refactoring] Migrate GatewayTest 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 d5e95969076cb44faeb93e9a72187b48bc597a05
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Jul 31 14:17:23 2020 +0700
[Refactoring] Migrate GatewayTest to JUnit5
---
.../org/apache/james/mdn/fields/GatewayTest.java | 61 +++++++++-------------
1 file changed, 26 insertions(+), 35 deletions(-)
diff --git a/mdn/src/test/java/org/apache/james/mdn/fields/GatewayTest.java b/mdn/src/test/java/org/apache/james/mdn/fields/GatewayTest.java
index 7132c6b..518b239 100644
--- a/mdn/src/test/java/org/apache/james/mdn/fields/GatewayTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/fields/GatewayTest.java
@@ -20,77 +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 GatewayTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
+class GatewayTest {
@Test
- public void shouldMatchBeanContract() throws Exception {
+ void shouldMatchBeanContract() {
EqualsVerifier.forClass(Gateway.class)
.verify();
}
@Test
- public void shouldThrowOnNullName() {
- expectedException.expect(NullPointerException.class);
-
- Gateway.builder()
- .name(null)
- .build();
+ void shouldThrowOnNullName() {
+ assertThatThrownBy(() -> Gateway.builder()
+ .name(null)
+ .build())
+ .isInstanceOf(NullPointerException.class);
}
@Test
- public void shouldThrowOnNullNameWhenType() {
- expectedException.expect(NullPointerException.class);
-
- Gateway.builder()
- .nameType(new AddressType("type"))
- .name(null)
- .build();
+ void shouldThrowOnNullNameWhenType() {
+ assertThatThrownBy(() -> Gateway.builder()
+ .nameType(new AddressType("type"))
+ .name(null)
+ .build())
+ .isInstanceOf(NullPointerException.class);
}
@Test
- public void shouldThrowOnNullType() {
- expectedException.expect(NullPointerException.class);
-
- Gateway.builder()
- .nameType(null)
- .name(Text.fromRawText("name"))
- .build();
+ void shouldThrowOnNullType() {
+ assertThatThrownBy(() -> Gateway.builder()
+ .nameType(null)
+ .name(Text.fromRawText("name"))
+ .build())
+ .isInstanceOf(NullPointerException.class);
}
@Test
- public void addressTypeShouldDefaultToDNS() {
+ void addressTypeShouldDefaultToDNS() {
Text address = Text.fromRawText("address");
assertThat(Gateway.builder().name(Text.fromRawText("address")).build())
.isEqualTo(Gateway.builder().nameType(AddressType.DNS).name(address).build());
}
@Test
- public void formattedValueShouldDisplayAddress() {
+ void formattedValueShouldDisplayAddress() {
assertThat(Gateway.builder().name(Text.fromRawText("address")).build()
.formattedValue())
.isEqualTo("MDN-Gateway: dns;address");
}
@Test
- public void formattedValueShouldDisplayMultilineAddress() {
+ void formattedValueShouldDisplayMultilineAddress() {
assertThat(Gateway.builder().name(Text.fromRawText("address\nmultiline")).build()
.formattedValue())
- .isEqualTo("MDN-Gateway: dns;address\r\n" +
- " multiline");
+ .isEqualTo("MDN-Gateway: dns;address\r\n multiline");
}
@Test
- public void formattedValueShouldDisplayCustomAddress() {
+ void formattedValueShouldDisplayCustomAddress() {
assertThat(Gateway.builder().nameType(new AddressType("custom")).name(Text.fromRawText("address")).build()
.formattedValue())
.isEqualTo("MDN-Gateway: custom;address");
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org