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 de884ed23524b842b8188ea76ed0edb885dded26 Author: Rene Cordier <rcord...@linagora.com> AuthorDate: Thu Dec 5 16:36:25 2019 +0700 [Refactoring] Move MailboxMessageAssertTest to JUnit 5 --- .../store/mail/model/MailboxMessageAssertTest.java | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java index c338fb5..703eae0 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java @@ -19,6 +19,8 @@ package org.apache.james.mailbox.store.mail.model; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + import java.io.IOException; import java.util.Date; @@ -31,56 +33,66 @@ import org.apache.james.mailbox.model.TestId; import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder; import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MailboxMessageAssertTest { +class MailboxMessageAssertTest { - public static final TestId MAILBOX_ID = TestId.of(42L); - public static final MessageUid UID = MessageUid.of(24); - public static final MessageId MESSAGE_ID = new DefaultMessageId(); + static final TestId MAILBOX_ID = TestId.of(42L); + static final MessageUid UID = MessageUid.of(24); + static final MessageId MESSAGE_ID = new DefaultMessageId(); @Test - public void messageAssertShouldSucceedWithTwoEqualsMessages() throws IOException { + void messageAssertShouldSucceedWithTwoEqualsMessages() throws IOException { String headerString = "name: headerName\n\n"; String bodyString = "body\n.\n"; Date date = new Date(); + SimpleMailboxMessage message1 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(), headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID); message1.setUid(UID); + SimpleMailboxMessage message2 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(), headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID); message2.setUid(UID); + MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Full); } @Test - public void messageAssertShouldSucceedWhenBodyMismatchInFetchHeaderMode() throws IOException { + void messageAssertShouldSucceedWhenBodyMismatchInFetchHeaderMode() throws IOException { String headerString = "name: headerName\n\n"; String bodyString = "body\n.\n"; Date date = new Date(); + SimpleMailboxMessage message1 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(), headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID); message1.setUid(UID); + bodyString = "work\n.\n"; SimpleMailboxMessage message2 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(), headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID); message2.setUid(UID); + MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Headers); } - @Test(expected = AssertionError.class) - public void messageAssertShouldFailWhenBodyMismatchInFetchBodyMode() throws IOException { + @Test + void messageAssertShouldFailWhenBodyMismatchInFetchBodyMode() { String headerString = "name: headerName\n\n"; String bodyString = "body\n.\n"; Date date = new Date(); + SimpleMailboxMessage message1 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(), headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID); message1.setUid(UID); + bodyString = "work\n.\n"; SimpleMailboxMessage message2 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(), headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID); message2.setUid(UID); - MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Body); + + assertThatThrownBy(() -> MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Body)) + .isInstanceOf(AssertionError.class); } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org