structural refactoring from assert{,Not}Null to assertj assertThat().is{,Not}Null
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/bf6b9d06 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/bf6b9d06 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/bf6b9d06 Branch: refs/heads/master Commit: bf6b9d0656621bbdec52f0e52c89b574c9e6ff2e Parents: 63ab7ab Author: Matthieu Baechler <matth...@apache.org> Authored: Thu May 31 21:27:26 2018 +0200 Committer: Antoine Duprat <adup...@linagora.com> Committed: Thu Sep 6 14:33:53 2018 +0200 ---------------------------------------------------------------------- .../HBaseMailboxSessionMapperFactoryTest.java | 6 +- .../hbase/user/HBaseSubscriptionMapperTest.java | 4 +- .../mailbox/store/search/SearchUtilTest.java | 6 +- .../AbstractTestForStatusResponseFactory.java | 72 ++++++++++---------- .../imap/decode/FetchPartPathDecoderTest.java | 6 +- .../fetch/MailboxMessageResultUtilsTest.java | 6 +- .../protocols/imap/utils/DecoderUtilsTest.java | 3 +- .../smtp/core/fastfail/DNSRBLHandlerTest.java | 6 +- .../core/MimeMessageCopyOnWriteProxyTest.java | 10 +-- .../james/server/core/MimeMessageTest.java | 3 +- .../library/MXHostAddressIteratorTest.java | 4 +- .../lib/AbstractStateMailetProcessorTest.java | 16 ++--- .../matchers/InSpammerBlacklistTest.java | 10 ++- .../apache/james/pop3server/POP3ServerTest.java | 26 +++---- 14 files changed, 88 insertions(+), 90 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java ---------------------------------------------------------------------- diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java index d08af07..aa84956 100644 --- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java +++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java @@ -91,7 +91,7 @@ public class HBaseMailboxSessionMapperFactoryTest { MessageId.Factory messageIdFactory = null; HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null, messageIdFactory); MessageMapper messageMapper = instance.createMessageMapper(session); - assertNotNull(messageMapper); + assertThat(messageMapper).isNotNull(); assertThat(messageMapper instanceof MessageMapper).isTrue(); } @@ -106,7 +106,7 @@ public class HBaseMailboxSessionMapperFactoryTest { MessageId.Factory messageIdFactory = null; HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null, messageIdFactory); MailboxMapper mailboxMapper = instance.createMailboxMapper(session); - assertNotNull(mailboxMapper); + assertThat(mailboxMapper).isNotNull(); assertThat(mailboxMapper instanceof MailboxMapper).isTrue(); } @@ -121,7 +121,7 @@ public class HBaseMailboxSessionMapperFactoryTest { MessageId.Factory messageIdFactory = null; HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null, messageIdFactory); SubscriptionMapper subscriptionMapper = instance.createSubscriptionMapper(session); - assertNotNull(subscriptionMapper); + assertThat(subscriptionMapper).isNotNull(); assertThat(subscriptionMapper instanceof SubscriptionMapper).isTrue(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapperTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapperTest.java index 029fa95..6eabd6a 100644 --- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapperTest.java +++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapperTest.java @@ -142,8 +142,8 @@ public class HBaseSubscriptionMapperTest { assertEquals(subscription.getUser(), result.getUser()); } } - assertNull(mapper.findMailboxSubscriptionForUser(fake1.getUser(), fake1.getMailbox())); - assertNull(mapper.findMailboxSubscriptionForUser(fake2.getUser(), fake2.getMailbox())); + assertThat(mapper.findMailboxSubscriptionForUser(fake1.getUser(), fake1.getMailbox())).isNull(); + assertThat(mapper.findMailboxSubscriptionForUser(fake2.getUser(), fake2.getMailbox())).isNull(); } /** http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java index b02fb8f..ffffbd9 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java @@ -18,8 +18,8 @@ ****************************************************************/ package org.apache.james.mailbox.store.search; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -82,7 +82,7 @@ public class SearchUtilTest { String serialiazedMessageId = SearchUtil.getSerializedMessageIdIfSupportedByUnderlyingStorageOrNull(message); //expect - assertNull(serialiazedMessageId); + assertThat(serialiazedMessageId).isNull(); } @Test @@ -100,7 +100,7 @@ public class SearchUtilTest { String serialiazedMessageId = SearchUtil.getSerializedMessageIdIfSupportedByUnderlyingStorageOrNull(message); //expect - assertNull(serialiazedMessageId); + assertThat(serialiazedMessageId).isNull(); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/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 c2ea59b..7dd771f 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 @@ -19,14 +19,12 @@ package org.apache.james.imap.api.message.response; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import org.apache.james.imap.api.ImapCommand; import org.apache.james.imap.api.display.HumanReadableText; -import org.apache.james.imap.api.message.response.StatusResponse; -import org.apache.james.imap.api.message.response.StatusResponseFactory; import org.junit.Before; import org.junit.Test; @@ -55,14 +53,14 @@ public abstract class AbstractTestForStatusResponseFactory { @Test public void testTaggedOk() { StatusResponse response = factory.taggedOk(TAG, command, KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.OK, response.getServerResponseType()); assertEquals(TAG, response.getTag()); assertEquals(KEY, response.getTextKey()); assertEquals(command, response.getCommand()); - assertNull(response.getResponseCode()); + assertThat(response.getResponseCode()).isNull(); response = factory.taggedOk(TAG, command, KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.OK, response.getServerResponseType()); assertEquals(TAG, response.getTag()); assertEquals(KEY, response.getTextKey()); @@ -73,14 +71,14 @@ public abstract class AbstractTestForStatusResponseFactory { @Test public void testTaggedNo() { StatusResponse response = factory.taggedNo(TAG, command, KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.NO, response.getServerResponseType()); assertEquals(TAG, response.getTag()); assertEquals(KEY, response.getTextKey()); assertEquals(command, response.getCommand()); - assertNull(response.getResponseCode()); + assertThat(response.getResponseCode()).isNull(); response = factory.taggedNo(TAG, command, KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.NO, response.getServerResponseType()); assertEquals(TAG, response.getTag()); assertEquals(KEY, response.getTextKey()); @@ -91,14 +89,14 @@ public abstract class AbstractTestForStatusResponseFactory { @Test public void testTaggedBad() { StatusResponse response = factory.taggedBad(TAG, command, KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BAD, response.getServerResponseType()); assertEquals(TAG, response.getTag()); assertEquals(KEY, response.getTextKey()); - assertNull(response.getResponseCode()); + assertThat(response.getResponseCode()).isNull(); assertEquals(command, response.getCommand()); response = factory.taggedBad(TAG, command, KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BAD, response.getServerResponseType()); assertEquals(TAG, response.getTag()); assertEquals(KEY, response.getTextKey()); @@ -109,94 +107,94 @@ public abstract class AbstractTestForStatusResponseFactory { @Test public void testUntaggedOk() { StatusResponse response = factory.untaggedOk(KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.OK, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); - assertNull(response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getResponseCode()).isNull(); + assertThat(response.getCommand()).isNull(); response = factory.untaggedOk(KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.OK, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getCommand()).isNull(); } @Test public void testUntaggedNo() { StatusResponse response = factory.untaggedNo(KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.NO, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); - assertNull(response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getResponseCode()).isNull(); + assertThat(response.getCommand()).isNull(); response = factory.untaggedNo(KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.NO, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getCommand()).isNull(); } @Test public void testUntaggedBad() { StatusResponse response = factory.untaggedBad(KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BAD, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); - assertNull(response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getResponseCode()).isNull(); + assertThat(response.getCommand()).isNull(); response = factory.untaggedBad(KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BAD, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getCommand()).isNull(); } @Test public void testPreauth() { StatusResponse response = factory.preauth(KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.PREAUTH, response .getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); - assertNull(response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getResponseCode()).isNull(); + assertThat(response.getCommand()).isNull(); response = factory.preauth(KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.PREAUTH, response .getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getCommand()).isNull(); } @Test public void testBye() { StatusResponse response = factory.bye(KEY); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BYE, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); - assertNull(response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getResponseCode()).isNull(); + assertThat(response.getCommand()).isNull(); response = factory.bye(KEY, CODE); - assertNotNull(response); + assertThat(response).isNotNull(); assertEquals(StatusResponse.Type.BYE, response.getServerResponseType()); assertEquals(null, response.getTag()); assertEquals(KEY, response.getTextKey()); assertEquals(CODE, response.getResponseCode()); - assertNull(response.getCommand()); + assertThat(response.getCommand()).isNull(); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/protocols/imap/src/test/java/org/apache/james/imap/decode/FetchPartPathDecoderTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/FetchPartPathDecoderTest.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/FetchPartPathDecoderTest.java index 8ffdce1..766f2a9 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/decode/FetchPartPathDecoderTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/FetchPartPathDecoderTest.java @@ -19,8 +19,8 @@ package org.apache.james.imap.decode; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.util.Collection; @@ -191,7 +191,7 @@ public class FetchPartPathDecoderTest { base = base + ')'; decoder.decode(base); Collection<String> results = decoder.getNames(); - assertNotNull(results); + assertThat(results).isNotNull(); Iterator<String> it = results.iterator(); for (String name : names) { assertEquals(name, it.next()); @@ -220,7 +220,7 @@ public class FetchPartPathDecoderTest { private void checkPath(int[] expected, String encoded) throws Exception { decoder.decode(encoded); final int[] path = decoder.getPath(); - assertNotNull(path); + assertThat(path).isNotNull(); assertEquals(expected.length, path.length); for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], path[i]); http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java index 54354b6..7f0cabf 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java @@ -19,8 +19,9 @@ package org.apache.james.imap.processor.fetch; +import static org.apache.james.imap.processor.fetch.MessageResultUtils.getMatching; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import java.io.InputStream; import java.util.ArrayList; @@ -122,8 +123,7 @@ public class MailboxMessageResultUtilsTest { .iterator())); assertEquals(headerThree, MessageResultUtils.getMatching("Three", headers.iterator())); - assertNull(MessageResultUtils - .getMatching("Missing", headers.iterator())); + assertThat(getMatching("Missing", headers.iterator())).isNull(); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/protocols/imap/src/test/java/org/apache/james/protocols/imap/utils/DecoderUtilsTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/protocols/imap/utils/DecoderUtilsTest.java b/protocols/imap/src/test/java/org/apache/james/protocols/imap/utils/DecoderUtilsTest.java index e831820..935fd34 100644 --- a/protocols/imap/src/test/java/org/apache/james/protocols/imap/utils/DecoderUtilsTest.java +++ b/protocols/imap/src/test/java/org/apache/james/protocols/imap/utils/DecoderUtilsTest.java @@ -21,7 +21,6 @@ package org.apache.james.protocols.imap.utils; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.util.Calendar; @@ -255,7 +254,7 @@ public class DecoderUtilsTest { } private String formatAsImap(Date date, TimeZone zone) { - assertNotNull(date); + assertThat(date).isNotNull(); FastDateFormat format = FastDateFormat.getInstance( "dd-MMM-yyyy hh:mm:ss Z", zone, Locale.US); String out = format.format(date); http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java ---------------------------------------------------------------------- diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java index f0322ac..af425d4 100644 --- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java +++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java @@ -20,6 +20,8 @@ package org.apache.james.protocols.smtp.core.fastfail; +import static org.apache.james.protocols.api.ProtocolSession.State.Connection; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -243,7 +245,7 @@ public class DNSRBLHandlerTest { rbl.setBlacklist(new String[] { "bl.spamcop.net." }); rbl.setGetDetail(true); rbl.doRcpt(mockedSMTPSession, null, new MailAddress("test@localhost")); - assertNull(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, State.Connection)); + assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).isNull(); assertNotNull("Blocked", mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, State.Connection)); } @@ -258,7 +260,7 @@ public class DNSRBLHandlerTest { rbl.setWhitelist(new String[] { "bl.spamcop.net." }); rbl.setGetDetail(true); rbl.doRcpt(mockedSMTPSession, null, new MailAddress("test@localhost")); - assertNull(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, State.Connection)); + assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).isNull(); assertNull("Not blocked", mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, State.Connection)); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/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 119f1e9..5f02353 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 @@ -106,7 +106,7 @@ public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest { assertNotSame(m2.getMessage(), m2clone.getMessage()); // test that m2clone has a valid wrapped message MimeMessage mm3 = getWrappedMessage(m2clone.getMessage()); - assertNotNull(mm3); + assertThat(mm3).isNotNull(); // dispose m2 and check that the clone has still a valid message and it // is the same! LifecycleUtil.dispose(m2); @@ -195,13 +195,13 @@ public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest { MailImpl mailClone = MailImpl.duplicate(mail); LifecycleUtil.dispose(mail); - assertNotNull(getWrappedMessage(mailClone.getMessage())); - assertNull(mail.getMessage()); + assertThat(getWrappedMessage(mailClone.getMessage())).isNotNull(); + assertThat(mail.getMessage()).isNull(); LifecycleUtil.dispose(mailClone); - assertNull(mailClone.getMessage()); - assertNull(mail.getMessage()); + assertThat(mailClone.getMessage()).isNull(); + assertThat(mail.getMessage()).isNull(); LifecycleUtil.dispose(mail); LifecycleUtil.dispose(messageFromSources); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/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 21ac2e6..6488230 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 @@ -18,6 +18,7 @@ ****************************************************************/ package org.apache.james.server.core; +import static org.apache.mailet.base.RFC2822Headers.RETURN_PATH; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -379,7 +380,7 @@ public class MimeMessageTest { @Test public void testReturnPath() throws Exception { MimeMessage message = getSimpleMessage(); - assertNull(message.getHeader(RFC2822Headers.RETURN_PATH)); + assertThat(message.getHeader(RETURN_PATH)).isNull(); LifecycleUtil.dispose(message); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java ---------------------------------------------------------------------- diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java index 96e7816..def13f9 100644 --- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java +++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/MXHostAddressIteratorTest.java @@ -50,14 +50,14 @@ public class MXHostAddressIteratorTest { MXHostAddressIterator it = new MXHostAddressIterator(Arrays.asList("localhost", "localhost2").iterator(), dns, false); for (int i = 0; i < 4; i++) { assertThat(it.hasNext()).isTrue(); - assertNotNull(it.next()); + assertThat(it.next()).isNotNull(); } assertThat(it.hasNext()).isFalse(); it = new MXHostAddressIterator(Arrays.asList("localhost", "localhost2").iterator(), dns, true); for (int i = 0; i < 2; i++) { assertThat(it.hasNext()).isTrue(); - assertNotNull(it.next()); + assertThat(it.next()).isNotNull(); } assertThat(it.hasNext()).isFalse(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java index a787279..bf1d173 100644 --- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java +++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java @@ -85,7 +85,7 @@ public abstract class AbstractStateMailetProcessorTest { assertEquals(mail.getName(), mailName); // match one recipient assertEquals(1, matches.size()); - assertNull(e); + assertThat(e).isNull(); latch.countDown(); } @@ -98,7 +98,7 @@ public abstract class AbstractStateMailetProcessorTest { if (MockMailet.class.equals(m.getClass())) { //assertEquals(mail.getName(), mailName); assertEquals("test", state); - assertNull(e); + assertThat(e).isNull(); latch.countDown(); } } @@ -133,7 +133,7 @@ public abstract class AbstractStateMailetProcessorTest { assertEquals(mail.getName(), mailName); // match all recipient assertEquals(2, matches.size()); - assertNull(e); + assertThat(e).isNull(); latch.countDown(); } @@ -147,7 +147,7 @@ public abstract class AbstractStateMailetProcessorTest { // the name should be the same as we have a full match assertEquals(mail.getName(), mailName); assertEquals("test", state); - assertNull(e); + assertThat(e).isNull(); latch.countDown(); } } @@ -182,8 +182,8 @@ public abstract class AbstractStateMailetProcessorTest { if (ExceptionThrowingMatcher.class.equals(m.getClass())) { assertEquals(mail.getName(), mailName); // match no recipient because of the error - assertNull(matches); - assertNotNull(e); + assertThat(matches).isNull(); + assertThat(e).isNotNull(); latch.countDown(); } @@ -260,7 +260,7 @@ public abstract class AbstractStateMailetProcessorTest { assertEquals(mail.getName(), mailName); // match one recipient assertEquals(1, matches.size()); - assertNull(e); + assertThat(e).isNull(); latch.countDown(); } @@ -271,7 +271,7 @@ public abstract class AbstractStateMailetProcessorTest { if (ExceptionThrowingMailet.class.equals(m.getClass())) { // the name should be not the same as we have a part match assertThat(mail.getName().equals(mailName)).isFalse(); - assertNotNull(e); + assertThat(e).isNotNull(); assertEquals(Mail.ERROR, state); latch.countDown(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java index 6b7826f..6869787 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/InSpammerBlacklistTest.java @@ -18,9 +18,7 @@ ****************************************************************/ package org.apache.james.transport.matchers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.assertj.core.api.Assertions.assertThat; import java.net.InetAddress; import java.net.UnknownHostException; @@ -82,8 +80,8 @@ public class InSpammerBlacklistTest { Collection<MailAddress> matchedRecipients = matcher.match(mail); - assertNotNull(matchedRecipients); - assertEquals(matchedRecipients.size(), mail.getRecipients().size()); + assertThat(matchedRecipients).isNotNull(); + assertThat(matchedRecipients.size()).isEqualTo(mail.getRecipients().size()); } @Test @@ -93,6 +91,6 @@ public class InSpammerBlacklistTest { Collection<MailAddress> matchedRecipients = matcher.match(mail); - assertNull(matchedRecipients); + assertThat(matchedRecipients).isNull(); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/bf6b9d06/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java index 1eb7aa5..f113313 100644 --- a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java +++ b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java @@ -139,7 +139,7 @@ public class POP3ServerTest { // not authenticated POP3MessageInfo[] entries = pop3Client.listMessages(); - assertNull(entries); + assertThat(entries).isNull(); pop3Client.login("foo", "bar"); System.err.println(pop3Client.getState()); @@ -148,12 +148,12 @@ public class POP3ServerTest { entries = pop3Client.listMessages(); assertEquals(1, pop3Client.getState()); - assertNotNull(entries); + assertThat(entries).isNotNull(); assertEquals(entries.length, 0); POP3MessageInfo p3i = pop3Client.listMessage(1); assertEquals(1, pop3Client.getState()); - assertNull(p3i); + assertThat(p3i).isNull(); } // TODO: This currently fails with Async implementation because @@ -223,7 +223,7 @@ public class POP3ServerTest { assertEquals("Expected 2 messages, found: " + list.length, 2, list.length); POP3MessageInfo p3i = pop3Client.listUniqueIdentifier(1); - assertNotNull(p3i); + assertThat(p3i).isNotNull(); mailboxManager.deleteMailbox(mailboxPath, session); @@ -312,18 +312,18 @@ public class POP3ServerTest { POP3MessageInfo[] entries = pop3Client.listMessages(); - assertNotNull(entries); + assertThat(entries).isNotNull(); assertEquals(2, entries.length); assertEquals(1, pop3Client.getState()); Reader r = pop3Client.retrieveMessageTop(entries[0].number, 0); - assertNotNull(r); + assertThat(r).isNotNull(); r.close(); Reader r2 = pop3Client.retrieveMessage(entries[0].number); - assertNotNull(r2); + assertThat(r2).isNotNull(); r2.close(); // existing message @@ -356,7 +356,7 @@ public class POP3ServerTest { entries = pop3Client.listMessages(); - assertNotNull(entries); + assertThat(entries).isNotNull(); assertEquals(1, entries.length); assertEquals(1, pop3Client.getState()); @@ -365,7 +365,7 @@ public class POP3ServerTest { assertEquals("-ERR", pop3Client.getReplyString().substring(0, 4)); Reader r3 = pop3Client.retrieveMessageTop(entries[0].number, 0); - assertNotNull(r3); + assertThat(r3).isNotNull(); r3.close(); mailboxManager.deleteMailbox(mailboxPath, session); } @@ -503,8 +503,8 @@ public class POP3ServerTest { assertEquals(msgCount, statInfo2.number); // This both should error and so return null - assertNull(pop3Protocol2.retrieveMessageTop(1, 100)); - assertNull(pop3Protocol2.retrieveMessage(1)); + assertThat(pop3Protocol2.retrieveMessageTop(1, 100)).isNull(); + assertThat(pop3Protocol2.retrieveMessage(1)).isNull(); pop3Protocol2.sendCommand("quit"); pop3Protocol2.disconnect(); @@ -681,13 +681,13 @@ public class POP3ServerTest { POP3MessageInfo[] entries = pop3Client.listMessages(); - assertNotNull(entries); + assertThat(entries).isNotNull(); assertEquals(1, entries.length); assertEquals(1, pop3Client.getState()); Reader r = pop3Client.retrieveMessage(entries[0].number); - assertNotNull(r); + assertThat(r).isNotNull(); r.close(); mailboxManager.deleteMailbox(mailboxPath, session); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org