JAMES-2543 replace assertEquals({true,false} by assertThat(...).is{True,False}Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6388bd2b Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6388bd2b Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6388bd2b Branch: refs/heads/master Commit: 6388bd2b1bac46e90d6ae427e55a195267d352f2 Parents: 5bafaf0 Author: Matthieu Baechler <[email protected]> Authored: Thu Sep 6 18:04:57 2018 +0200 Committer: Matthieu Baechler <[email protected]> Committed: Mon Sep 10 21:25:25 2018 +0200 ---------------------------------------------------------------------- .../AbstractTestForStatusResponseFactory.java | 20 +++++----- .../server/core/MimeMessageWrapperTest.java | 2 +- .../inetnetwork/model/InetNetworkTest.java | 28 ++++++------- .../library/netmatcher/NetMatcherTest.java | 41 ++++++++++---------- .../dnsservice/api/AbstractDNSServiceTest.java | 3 +- 5 files changed, 48 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/6388bd2b/protocols/imap/src/test/java/org/apache/james/imap/api/message/response/AbstractTestForStatusResponseFactory.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/api/message/response/AbstractTestForStatusResponseFactory.java b/protocols/imap/src/test/java/org/apache/james/imap/api/message/response/AbstractTestForStatusResponseFactory.java index 628d44e..c216469 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/api/message/response/AbstractTestForStatusResponseFactory.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/api/message/response/AbstractTestForStatusResponseFactory.java @@ -108,14 +108,14 @@ public abstract class AbstractTestForStatusResponseFactory { StatusResponse response = factory.untaggedOk(KEY); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.OK, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertThat(response.getResponseCode()).isNull(); assertThat(response.getCommand()).isNull(); response = factory.untaggedOk(KEY, CODE); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.OK, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); assertThat(response.getCommand()).isNull(); @@ -127,14 +127,14 @@ public abstract class AbstractTestForStatusResponseFactory { StatusResponse response = factory.untaggedNo(KEY); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.NO, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertThat(response.getResponseCode()).isNull(); assertThat(response.getCommand()).isNull(); response = factory.untaggedNo(KEY, CODE); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.NO, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); assertThat(response.getCommand()).isNull(); @@ -145,14 +145,14 @@ public abstract class AbstractTestForStatusResponseFactory { StatusResponse response = factory.untaggedBad(KEY); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BAD, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertThat(response.getResponseCode()).isNull(); assertThat(response.getCommand()).isNull(); response = factory.untaggedBad(KEY, CODE); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BAD, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); assertThat(response.getCommand()).isNull(); @@ -164,7 +164,7 @@ public abstract class AbstractTestForStatusResponseFactory { assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.PREAUTH, response .getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertThat(response.getResponseCode()).isNull(); assertThat(response.getCommand()).isNull(); @@ -172,7 +172,7 @@ public abstract class AbstractTestForStatusResponseFactory { assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.PREAUTH, response .getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); assertThat(response.getCommand()).isNull(); @@ -183,14 +183,14 @@ public abstract class AbstractTestForStatusResponseFactory { StatusResponse response = factory.bye(KEY); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BYE, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertThat(response.getResponseCode()).isNull(); assertThat(response.getCommand()).isNull(); response = factory.bye(KEY, CODE); assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BYE, response.getServerResponseType()); - assertEquals(null, response.getTag()); + assertThat(response.getTag()).isNull(); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); assertThat(response.getCommand()).isNull(); http://git-wip-us.apache.org/repos/asf/james-project/blob/6388bd2b/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 3a15cae..92ab6c5 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 @@ -182,7 +182,7 @@ public class MimeMessageWrapperTest extends MimeMessageFromStreamTest { String res = rawMessage.toString(); boolean found = res.indexOf("X-Test: X-Value") > 0; - assertEquals(true, found); + assertThat(found).isTrue(); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/6388bd2b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java ---------------------------------------------------------------------- diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java index 909535f..cf4b5d4 100644 --- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java +++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/inetnetwork/model/InetNetworkTest.java @@ -52,8 +52,8 @@ public class InetNetworkTest { // Test name alone (can be IPv4 or IPv6 depending on the OS plaform // configuration). address = InetAddress.getByName("localhost"); - assertEquals(true, address instanceof InetAddress); - assertEquals(true, address.toString().contains("localhost")); + assertThat(address).isInstanceOf(InetAddress.class); + assertThat(address.toString().contains("localhost")).isTrue(); } @@ -79,19 +79,19 @@ public class InetNetworkTest { // Test IP V4 address. address = InetAddress.getByAddress(getBytesFromAddress("127.0.0.1")); - assertEquals(true, address instanceof Inet4Address); - assertEquals(true, address.toString().contains("/127.0.0.1")); + assertThat(address).isInstanceOf(Inet4Address.class); + assertThat(address.toString().contains("/127.0.0.1")).isTrue(); // Test IP V4 with 255 values (just 'like' a subnet mask). address = InetAddress.getByAddress(getBytesFromAddress("255.255.225.0")); - assertEquals(true, address instanceof Inet4Address); - assertEquals(true, address.toString().contains("/255.255.225.0")); + assertThat(address).isInstanceOf(Inet4Address.class); + assertThat(address.toString().contains("/255.255.225.0")).isTrue(); // Test IP V4 Address with name and IP address. address = InetAddress.getByAddress("localhost", getBytesFromAddress("127.0.0.1")); - assertEquals(true, address instanceof Inet4Address); - assertEquals(true, address.toString().contains("localhost")); - assertEquals(true, address.toString().contains("/127.0.0.1")); + assertThat(address).isInstanceOf(Inet4Address.class); + assertThat(address.toString().contains("localhost")).isTrue(); + assertThat(address.toString().contains("/127.0.0.1")).isTrue(); } /** @@ -116,14 +116,14 @@ public class InetNetworkTest { // Test IP V6 address. address = InetAddress.getByAddress(getBytesFromAddress("0000:0000:0000:0000:0000:0000:0000:0001")); - assertEquals(true, address instanceof Inet6Address); - assertEquals(true, address.toString().contains("/0:0:0:0:0:0:0:1")); + assertThat(address).isInstanceOf(Inet6Address.class); + assertThat(address.toString().contains("/0:0:0:0:0:0:0:1")).isTrue(); // Test IP V6 Address with name and IP address. address = InetAddress.getByAddress("localhost", getBytesFromAddress("0000:0000:0000:0000:0000:0000:0000:0001")); - assertEquals(true, address instanceof Inet6Address); - assertEquals(true, address.toString().contains("localhost")); - assertEquals(true, address.toString().contains("/0:0:0:0:0:0:0:1")); + assertThat(address).isInstanceOf(Inet6Address.class); + assertThat(address.toString().contains("localhost")).isTrue(); + assertThat(address.toString().contains("/0:0:0:0:0:0:0:1")).isTrue(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/6388bd2b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java ---------------------------------------------------------------------- diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java index ba77a2b..72aa6a7 100644 --- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java +++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java @@ -18,6 +18,7 @@ ****************************************************************/ package org.apache.james.dnsservice.library.netmatcher; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import java.net.UnknownHostException; @@ -60,11 +61,11 @@ public class NetMatcherTest { netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK); - assertEquals(true, netMatcher.matchInetNetwork("127.0.0.1")); - assertEquals(true, netMatcher.matchInetNetwork("localhost")); - assertEquals(true, netMatcher.matchInetNetwork("172.16.15.254")); - assertEquals(true, netMatcher.matchInetNetwork("192.168.1.254")); - assertEquals(false, netMatcher.matchInetNetwork("192.169.1.254")); + assertThat(netMatcher.matchInetNetwork("127.0.0.1")).isTrue(); + assertThat(netMatcher.matchInetNetwork("localhost")).isTrue(); + assertThat(netMatcher.matchInetNetwork("172.16.15.254")).isTrue(); + assertThat(netMatcher.matchInetNetwork("192.168.1.254")).isTrue(); + assertThat(netMatcher.matchInetNetwork("192.169.1.254")).isFalse(); } /** @@ -75,11 +76,11 @@ public class NetMatcherTest { netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK); - assertEquals(false, netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0")); - assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1")); - assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2")); - assertEquals(false, netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001")); - assertEquals(false, netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001")); + assertThat(netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0")).isFalse(); + assertThat(netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1")).isFalse(); + assertThat(netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2")).isFalse(); + assertThat(netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001")).isFalse(); + assertThat(netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001")).isFalse(); } /** @@ -90,11 +91,11 @@ public class NetMatcherTest { netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK); - assertEquals(true, netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0")); - assertEquals(true, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1")); - assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2")); - assertEquals(true, netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001")); - assertEquals(false, netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001")); + assertThat(netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0")).isTrue(); + assertThat(netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1")).isTrue(); + assertThat(netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2")).isFalse(); + assertThat(netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001")).isTrue(); + assertThat(netMatcher.matchInetNetwork("2781:0db8:1235:8612:45ee:ffff:fffe:0001")).isFalse(); } /** @@ -105,10 +106,10 @@ public class NetMatcherTest { netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK); - assertEquals(false, netMatcher.matchInetNetwork("127.0.0.1")); - assertEquals(false, netMatcher.matchInetNetwork("localhost")); - assertEquals(false, netMatcher.matchInetNetwork("172.16.15.254")); - assertEquals(false, netMatcher.matchInetNetwork("192.168.1.254")); - assertEquals(false, netMatcher.matchInetNetwork("192.169.1.254")); + assertThat(netMatcher.matchInetNetwork("127.0.0.1")).isFalse(); + assertThat(netMatcher.matchInetNetwork("localhost")).isFalse(); + assertThat(netMatcher.matchInetNetwork("172.16.15.254")).isFalse(); + assertThat(netMatcher.matchInetNetwork("192.168.1.254")).isFalse(); + assertThat(netMatcher.matchInetNetwork("192.169.1.254")).isFalse(); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/6388bd2b/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java ---------------------------------------------------------------------- diff --git a/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java b/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java index 5be85c0..9c18b7a 100644 --- a/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java +++ b/server/dns-service/dnsservice-test/src/main/java/org/apache/james/dnsservice/api/AbstractDNSServiceTest.java @@ -20,6 +20,7 @@ package org.apache.james.dnsservice.api; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.net.InetAddress; import java.net.UnknownHostException; @@ -89,6 +90,6 @@ public class AbstractDNSServiceTest { @Ignore(value = "It requires internet connection!") public void testApache() throws UnknownHostException { //TODO: move to some sort of Live tests - assertEquals(true, DNS_SERVER.getByName("www.apache.org").toString().startsWith("www.apache.org")); + assertThat(DNS_SERVER.getByName("www.apache.org").toString().startsWith("www.apache.org")).isTrue(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
