JAMES-1757 Explicit reference to the UTF-8 charset when comparing SimpleMailboxMessage full content size
Before, it was platform dependant. Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/98c6090a Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/98c6090a Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/98c6090a Branch: refs/heads/master Commit: 98c6090a6e80907bd6f398adebf44f04c4fd5e5d Parents: 67918f3 Author: Benoit Tellier <[email protected]> Authored: Mon Jun 13 16:00:39 2016 +0700 Committer: Benoit Tellier <[email protected]> Committed: Tue Jun 14 15:44:38 2016 +0700 ---------------------------------------------------------------------- .../store/mail/model/impl/SimpleMailboxMessageTest.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/98c6090a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java index 1dea1d2..f836c7e 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java @@ -37,8 +37,10 @@ import org.assertj.core.internal.FieldByFieldComparator; import org.junit.Before; import org.junit.Test; +import com.google.common.base.Charsets; + public class SimpleMailboxMessageTest { - private static final Charset MESSAGE_CHARSET = Charset.forName("UTF-8"); + private static final Charset MESSAGE_CHARSET = Charsets.UTF_8; private static final String MESSAGE_CONTENT = "Simple message content without special characters"; private static final String MESSAGE_CONTENT_SPECIAL_CHAR = "Simple message content with special characters: \"'(§è!çà $*`"; public static final TestId TEST_ID = TestId.of(1L); @@ -62,7 +64,7 @@ public class SimpleMailboxMessageTest { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { byteArrayOutputStream.write(MESSAGE.getFullContent()); - assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT.getBytes().length); + assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT.getBytes(MESSAGE_CHARSET).length); } finally { byteArrayOutputStream.close(); } @@ -73,7 +75,7 @@ public class SimpleMailboxMessageTest { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { byteArrayOutputStream.write(MESSAGE_SPECIAL_CHAR.getFullContent()); - assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR.getBytes().length); + assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR.getBytes(MESSAGE_CHARSET).length); } finally { byteArrayOutputStream.close(); } @@ -81,8 +83,8 @@ public class SimpleMailboxMessageTest { @Test public void testFullContent() throws IOException { - assertThat(new String(IOUtils.toByteArray(MESSAGE.getFullContent()),MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT); - assertThat(new String(IOUtils.toByteArray(MESSAGE_SPECIAL_CHAR.getFullContent()),MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR); + assertThat(new String(IOUtils.toByteArray(MESSAGE.getFullContent()), MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT); + assertThat(new String(IOUtils.toByteArray(MESSAGE_SPECIAL_CHAR.getFullContent()), MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
