Modified: james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java (original) +++ james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java Tue Sep 22 11:50:44 2015 @@ -64,18 +64,21 @@ public class InMemoryMailboxMapperTest { mapper.save(new SimpleMailbox<InMemoryId>(user1OtherNamespacePath, UID_VALIDITY)); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPatchLikeOnAllMaillboxesShouldReturnMailboxesBelongingToThisNamespaceAndUser() throws MailboxException{ assertThat(mapper.findMailboxWithPathLike(new MailboxPath("#private", "user1", "%"))) .containsOnly(user1Inbox, user1SubMailbox1, user1SubMailbox2); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPatchLikeBasedOnInboxShouldReturnItsChildren() throws MailboxException{ assertThat(mapper.findMailboxWithPathLike(new MailboxPath("#private", "user1", "INBOX.%"))) .containsOnly(user1SubMailbox1, user1SubMailbox2); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPatchLikeBasedOnAStringShouldReturnMailboxesStartingWithThisString() throws MailboxException{ assertThat(mapper.findMailboxWithPathLike(new MailboxPath("#private", "user1", "IN%")))
Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java (original) +++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java Tue Sep 22 11:50:44 2015 @@ -413,7 +413,7 @@ public class StoreMailboxManager<Id exte return null; } - }); + }, true); } } @@ -489,7 +489,7 @@ public class StoreMailboxManager<Id exte return null; } - }); + }, true); } }); } Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingModSeqProvider.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingModSeqProvider.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingModSeqProvider.java (original) +++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingModSeqProvider.java Tue Sep 22 11:50:44 2015 @@ -48,7 +48,7 @@ public abstract class AbstractLockingMod public Long execute() throws MailboxException { return lockedNextModSeq(session, mailbox); } - }); + }, true); } /** Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingUidProvider.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingUidProvider.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingUidProvider.java (original) +++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingUidProvider.java Tue Sep 22 11:50:44 2015 @@ -50,7 +50,7 @@ public abstract class AbstractLockingUid public Long execute() throws MailboxException { return lockedNextUid(session, mailbox); } - }); + }, true); } /** Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearcher.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearcher.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearcher.java (original) +++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearcher.java Tue Sep 22 11:50:44 2015 @@ -173,6 +173,17 @@ public class MessageSearcher { result, parser); } break; + case T_END_BODYPART: + case T_END_HEADER: + case T_END_MESSAGE: + case T_END_MULTIPART: + case T_END_OF_STREAM: + case T_RAW_ENTITY: + case T_START_BODYPART: + case T_START_HEADER: + case T_START_MESSAGE: + case T_START_MULTIPART: + break; } } return result; Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/PartContentBuilder.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/PartContentBuilder.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/PartContentBuilder.java (original) +++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/PartContentBuilder.java Tue Sep 22 11:50:44 2015 @@ -106,6 +106,17 @@ public class PartContentBuilder { break; case T_END_OF_STREAM: throw new PartNotFoundException(position); + case T_END_BODYPART: + case T_END_HEADER: + case T_END_MESSAGE: + case T_END_MULTIPART: + case T_EPILOGUE: + case T_FIELD: + case T_PREAMBLE: + case T_RAW_ENTITY: + case T_START_HEADER: + case T_START_MESSAGE: + break; } } } catch (IllegalStateException e) { @@ -123,6 +134,19 @@ public class PartContentBuilder { case T_START_MULTIPART: ignoreInnerMessage(); break; + case T_BODY: + case T_END_BODYPART: + case T_END_HEADER: + case T_END_MESSAGE: + case T_END_MULTIPART: + case T_EPILOGUE: + case T_FIELD: + case T_PREAMBLE: + case T_RAW_ENTITY: + case T_START_BODYPART: + case T_START_HEADER: + case T_START_MESSAGE: + break; } } } @@ -221,6 +245,19 @@ public class PartContentBuilder { ResultHeader header = new ResultHeader(fieldName, fieldValue); results.add(header); break; + case T_BODY: + case T_END_BODYPART: + case T_END_HEADER: + case T_END_MESSAGE: + case T_END_MULTIPART: + case T_EPILOGUE: + case T_PREAMBLE: + case T_RAW_ENTITY: + case T_START_BODYPART: + case T_START_HEADER: + case T_START_MESSAGE: + case T_START_MULTIPART: + break; } } } @@ -249,6 +286,19 @@ public class PartContentBuilder { ResultHeader header = new ResultHeader(fieldName, fieldValue); results.add(header); break; + case T_BODY: + case T_END_BODYPART: + case T_END_HEADER: + case T_END_MESSAGE: + case T_END_MULTIPART: + case T_EPILOGUE: + case T_PREAMBLE: + case T_START_HEADER: + case T_START_MESSAGE: + case T_START_MULTIPART: + case T_RAW_ENTITY: + case T_START_BODYPART: + break; } } } catch (UnexpectedEOFException e) { Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java Tue Sep 22 11:50:44 2015 @@ -26,8 +26,6 @@ import java.io.InputStream; import java.nio.charset.Charset; import java.util.List; -import javax.management.openmbean.InvalidOpenTypeException; - import org.apache.commons.io.IOUtils; import org.apache.james.mailbox.model.MessageResult.Header; import org.apache.james.mailbox.store.ResultHeader; Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java Tue Sep 22 11:50:44 2015 @@ -31,70 +31,70 @@ import static org.assertj.core.api.Asser public class StoreMailboxManagerTest { public static final int UID_VALIDITY = 42; - private StoreMailboxManager storeMailboxManager; + private StoreMailboxManager<TestId> storeMailboxManager; @Before public void setUp() { - storeMailboxManager = new StoreMailboxManager(null, new MockAuthenticator(), new JVMMailboxPathLocker(), new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver()); + storeMailboxManager = new StoreMailboxManager<TestId>(null, new MockAuthenticator(), new JVMMailboxPathLocker(), new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver()); } @Test public void belongsToNamespaceAndUserShouldReturnTrueWithIdenticalMailboxes() { MailboxPath path = new MailboxPath("namespace", "user", "name"); - assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, new SimpleMailbox(path, UID_VALIDITY))).isTrue(); + assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, new SimpleMailbox<TestId>(path, UID_VALIDITY))).isTrue(); } @Test public void belongsToNamespaceAndUserShouldReturnTrueWithIdenticalMailboxesWithNullUser() { MailboxPath path = new MailboxPath("namespace", null, "name"); - assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, new SimpleMailbox(path, UID_VALIDITY))).isTrue(); + assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, new SimpleMailbox<TestId>(path, UID_VALIDITY))).isTrue(); } @Test public void belongsToNamespaceAndUserShouldReturnTrueWithIdenticalMailboxesWithNullNamespace() { MailboxPath path = new MailboxPath(null, "user", "name"); assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, - new SimpleMailbox(new MailboxPath(null, "user", "name"), UID_VALIDITY))).isTrue(); + new SimpleMailbox<TestId>(new MailboxPath(null, "user", "name"), UID_VALIDITY))).isTrue(); } @Test public void belongsToNamespaceAndUserShouldReturnTrueWithMailboxWithSameNamespaceAndUserWithNullUser() { MailboxPath path = new MailboxPath("namespace", null, "name"); assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, - new SimpleMailbox(new MailboxPath("namespace", null, "name2"), UID_VALIDITY))).isTrue(); + new SimpleMailbox<TestId>(new MailboxPath("namespace", null, "name2"), UID_VALIDITY))).isTrue(); } @Test public void belongsToNamespaceAndUserShouldReturnTrueWithMailboxWithSameNamespaceAndUser() { MailboxPath path = new MailboxPath("namespace", "user", "name"); assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, - new SimpleMailbox(new MailboxPath("namespace", "user", "name2"), UID_VALIDITY))).isTrue(); + new SimpleMailbox<TestId>(new MailboxPath("namespace", "user", "name2"), UID_VALIDITY))).isTrue(); } @Test public void belongsToNamespaceAndUserShouldReturnFalseWithDifferentNamespace() { MailboxPath path = new MailboxPath("namespace", "user", "name"); assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, - new SimpleMailbox(new MailboxPath("namespace2", "user", "name"), UID_VALIDITY))).isFalse(); + new SimpleMailbox<TestId>(new MailboxPath("namespace2", "user", "name"), UID_VALIDITY))).isFalse(); } @Test public void belongsToNamespaceAndUserShouldReturnFalseWithDifferentUser() { MailboxPath path = new MailboxPath("namespace", "user", "name"); assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, - new SimpleMailbox(new MailboxPath("namespace", "user2", "name"), UID_VALIDITY))).isFalse(); + new SimpleMailbox<TestId>(new MailboxPath("namespace", "user2", "name"), UID_VALIDITY))).isFalse(); } @Test public void belongsToNamespaceAndUserShouldReturnFalseWithOneOfTheUserNull() { MailboxPath path = new MailboxPath("namespace", null, "name"); assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, - new SimpleMailbox(new MailboxPath("namespace", "user", "name"), UID_VALIDITY))).isFalse(); + new SimpleMailbox<TestId>(new MailboxPath("namespace", "user", "name"), UID_VALIDITY))).isFalse(); } @Test public void belongsToNamespaceAndUserShouldReturnFalseIfNamespaceAreDifferentWithNullUser() { MailboxPath path = new MailboxPath("namespace", null, "name"); assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, - new SimpleMailbox(new MailboxPath("namespace2", null, "name"), UID_VALIDITY))).isFalse(); + new SimpleMailbox<TestId>(new MailboxPath("namespace2", null, "name"), UID_VALIDITY))).isFalse(); } Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMessageResultIteratorTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMessageResultIteratorTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMessageResultIteratorTest.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMessageResultIteratorTest.java Tue Sep 22 11:50:44 2015 @@ -19,6 +19,8 @@ package org.apache.james.mailbox.store; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -28,8 +30,6 @@ import java.util.Set; import javax.mail.Flags; import javax.mail.util.SharedByteArrayInputStream; -import junit.framework.Assert; - import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MessageMetaData; import org.apache.james.mailbox.model.MessageRange; @@ -41,6 +41,7 @@ import org.apache.james.mailbox.store.ma import org.apache.james.mailbox.store.mail.model.Message; import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder; import org.apache.james.mailbox.store.mail.model.impl.SimpleMessage; +import org.assertj.core.api.iterable.Extractor; import org.junit.Test; public class StoreMessageResultIteratorTest { @@ -69,7 +70,7 @@ public class StoreMessageResultIteratorT long end = set.getUidTo(); long calcEnd = start + limit; if (calcEnd > end) { - calcEnd = end; + calcEnd = end + 1; } List<Message<TestId>> messages = new ArrayList<Message<TestId>>(); @@ -164,13 +165,12 @@ public class StoreMessageResultIteratorT } }); - long i = 1; - while (it.hasNext()) { - MessageResult r = it.next(); - Assert.assertEquals(i++, r.getUid()); - } - Assert.assertEquals(10, i); - + assertThat(it).extracting(new Extractor<MessageResult, Long>(){ + @Override + public Long extract(MessageResult input) { + return input.getUid(); + } + }).containsExactly(1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l, 9l, 10l); } } Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java Tue Sep 22 11:50:44 2015 @@ -139,6 +139,7 @@ public abstract class AbstractMailboxMap MailboxAssert.assertThat(mailboxMapper.findMailboxByPath(esnDevGroupInboxPath)).isEqualTo(esnDevGroupInboxMailbox); } + @SuppressWarnings("unchecked") @Test public void listShouldRetrieveAllMailbox() throws MailboxException { saveAll(); @@ -177,6 +178,7 @@ public abstract class AbstractMailboxMap assertThat(mailboxMapper.hasChildren(bobInboxMailbox, '.')).isFalse(); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPathLikeShouldBeLimitedToUserAndNamespace() throws MailboxException { saveAll(); @@ -206,6 +208,7 @@ public abstract class AbstractMailboxMap mailboxMapper.findMailboxByPath(esnDevGroupJamesPath); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPathLikeWithChildRegexShouldRetrieveChildren() throws MailboxException { saveAll(); @@ -213,6 +216,7 @@ public abstract class AbstractMailboxMap assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).containsOnly(benwaWorkMailbox, benwaWorkTodoMailbox, benwaWorkDoneMailbox); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPathLikeWithNullUserWithChildRegexShouldRetrieveChildren() throws MailboxException { saveAll(); @@ -220,6 +224,7 @@ public abstract class AbstractMailboxMap assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).contains(obmTeamGroupInboxMailbox, obmTeamGroupOPushMailbox, obmTeamGroupRoundCubeMailbox); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPathLikeWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException { saveAll(); @@ -227,6 +232,7 @@ public abstract class AbstractMailboxMap assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).containsOnly(benwaInboxMailbox); } + @SuppressWarnings("unchecked") @Test public void findMailboxWithPathLikeWithNullUserWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException { saveAll(); Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java Tue Sep 22 11:50:44 2015 @@ -149,6 +149,7 @@ public abstract class AbstractMessageMap assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), MessageMapper.FetchType.Metadata, LIMIT)).isEmpty(); } + @SuppressWarnings("unchecked") @Test public void deletingUnExistingMessageShouldHaveNoSideEffect() throws MailboxException, IOException { saveMessages(); @@ -172,6 +173,7 @@ public abstract class AbstractMessageMap .isEqualTo(message1, fetchType); } + @SuppressWarnings("unchecked") @Test public void messagesCanBeRetrievedInMailboxWithRangeTypeRange() throws MailboxException, IOException{ saveMessages(); @@ -180,6 +182,7 @@ public abstract class AbstractMessageMap assertThat(retrievedMessageIterator).containsOnly(message1, message2, message3, message4); } + @SuppressWarnings("unchecked") @Test public void messagesCanBeRetrievedInMailboxWithRangeTypeRangeContainingAHole() throws MailboxException, IOException { saveMessages(); @@ -189,6 +192,7 @@ public abstract class AbstractMessageMap assertThat(retrievedMessageIterator).containsOnly(message1, message2, message4); } + @SuppressWarnings("unchecked") @Test public void messagesCanBeRetrievedInMailboxWithRangeTypeFrom() throws MailboxException, IOException { saveMessages(); @@ -197,6 +201,7 @@ public abstract class AbstractMessageMap assertThat(retrievedMessageIterator).containsOnly(message3, message4, message5); } + @SuppressWarnings("unchecked") @Test public void messagesCanBeRetrievedInMailboxWithRangeTypeFromContainingAHole() throws MailboxException, IOException { saveMessages(); @@ -206,6 +211,7 @@ public abstract class AbstractMessageMap assertThat(retrievedMessageIterator).containsOnly(message3, message5); } + @SuppressWarnings("unchecked") @Test public void messagesCanBeRetrievedInMailboxWithRangeTypeAll() throws MailboxException, IOException { saveMessages(); @@ -213,6 +219,7 @@ public abstract class AbstractMessageMap .containsOnly(message1, message2, message3, message4, message5); } + @SuppressWarnings("unchecked") @Test public void messagesCanBeRetrievedInMailboxWithRangeTypeAllContainingHole() throws MailboxException, IOException { saveMessages(); @@ -297,6 +304,7 @@ public abstract class AbstractMessageMap assertThat(messageMapper.expungeMarkedForDeletionInMailbox(benwaInboxMailbox, MessageRange.all())).isEmpty(); } + @SuppressWarnings("unchecked") @Test public void expungeMarkedForDeletionInMailboxShouldReturnEmptyResultWhenNoMessageInMailboxIsDeleted() throws MailboxException, IOException { saveMessages(); @@ -313,6 +321,7 @@ public abstract class AbstractMessageMap .containsMetadataForMessages(message1, message4); } + @SuppressWarnings("unchecked") @Test public void expungeShouldModifyUnderlyingStorageWithRangeAll() throws MailboxException, IOException { saveMessages(); @@ -329,6 +338,7 @@ public abstract class AbstractMessageMap .containsMetadataForMessages(message1); } + @SuppressWarnings("unchecked") @Test public void expungeShouldModifyUnderlyingStorageWithRangeOne() throws MailboxException, IOException { saveMessages(); @@ -345,6 +355,7 @@ public abstract class AbstractMessageMap .containsMetadataForMessages(message4); } + @SuppressWarnings("unchecked") @Test public void expungeShouldModifyUnderlyingStorageWithRangeFrom() throws MailboxException, IOException { saveMessages(); @@ -361,6 +372,7 @@ public abstract class AbstractMessageMap .containsMetadataForMessages(message4); } + @SuppressWarnings("unchecked") @Test public void expungeShouldModifyUnderlyingStorageWithRange() throws MailboxException, IOException { saveMessages(); @@ -660,7 +672,7 @@ public abstract class AbstractMessageMap message6.setModSeq(messageMapper.getHighestModSeq(benwaWorkMailbox)); } - private Message<Id> retrieveMessageFromStorage(Message message) throws MailboxException { + private Message<Id> retrieveMessageFromStorage(Message<Id> message) throws MailboxException { return messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message.getUid()), MessageMapper.FetchType.Metadata, LIMIT).next(); } Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssert.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssert.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssert.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssert.java Tue Sep 22 11:50:44 2015 @@ -41,6 +41,7 @@ public class MetadataMapAssert extends A return this; } + @SuppressWarnings("rawtypes") public MetadataMapAssert containsMetadataForMessages(Message... messages) { for(Message message : messages) { if (actual.get(message.getUid()).getUid() != message.getUid()) { Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java Tue Sep 22 11:50:44 2015 @@ -57,9 +57,8 @@ public class SimpleMessageTest { @Test public void testInputStreamSize() throws IOException { InputStream is = MESSAGE.getFullContent(); - int b = 0; int byteCount = 0; - while ((b = is.read()) != -1) { + while (is.read() != -1) { byteCount++; } assertEquals(MESSAGE_CONTENT.length(), byteCount); @@ -68,9 +67,8 @@ public class SimpleMessageTest { @Test public void testInputStreamSizeSpecialCharacters() throws IOException { InputStream is = MESSAGE_SPECIAL_CHAR.getFullContent(); - int b = 0; int byteCount = 0; - while ((b = is.read()) != -1) { + while (is.read() != -1) { byteCount++; } assertFalse(MESSAGE_CONTENT_SPECIAL_CHAR.length() == byteCount); Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/streaming/BodyOffsetInputStreamTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/streaming/BodyOffsetInputStreamTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/streaming/BodyOffsetInputStreamTest.java (original) +++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/streaming/BodyOffsetInputStreamTest.java Tue Sep 22 11:50:44 2015 @@ -29,18 +29,17 @@ public class BodyOffsetInputStreamTest { private String mail = "Subject: test\r\n\r\nbody"; private long expectedOffset = 17; private long bytes = mail.length(); + @Test public void testRead() throws IOException { BodyOffsetInputStream in = new BodyOffsetInputStream(new ByteArrayInputStream(mail.getBytes())); - @SuppressWarnings("unused") - int i = -1; - while ((i = in.read())!= -1) { + while (in.read() != -1) { // consume stream } assertEquals(expectedOffset, in.getBodyStartOffset()); assertEquals(bytes, in.getReadBytes()); - + in.close(); } @@ -48,14 +47,13 @@ public class BodyOffsetInputStreamTest { public void testReadWithArray() throws IOException { BodyOffsetInputStream in = new BodyOffsetInputStream(new ByteArrayInputStream(mail.getBytes())); - @SuppressWarnings("unused") - int i = -1; byte[] b = new byte[8]; - while ((i = in.read(b))!= -1) { + while (in.read(b) != -1) { // consume stream } assertEquals(expectedOffset, in.getBodyStartOffset()); assertEquals(bytes, in.getReadBytes()); + in.close(); } @@ -63,13 +61,12 @@ public class BodyOffsetInputStreamTest { public void testReadWithArrayBiggerThenStream() throws IOException { BodyOffsetInputStream in = new BodyOffsetInputStream(new ByteArrayInputStream(mail.getBytes())); - @SuppressWarnings("unused") - int i = -1; byte[] b = new byte[4096]; - while ((i = in.read(b))!= -1) { + while (in.read(b) != -1) { // consume stream } assertEquals(expectedOffset, in.getBodyStartOffset()); assertEquals(bytes, in.getReadBytes()); + in.close(); } } Modified: james/mailbox/trunk/tool/pom.xml URL: http://svn.apache.org/viewvc/james/mailbox/trunk/tool/pom.xml?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/tool/pom.xml (original) +++ james/mailbox/trunk/tool/pom.xml Tue Sep 22 11:50:44 2015 @@ -70,5 +70,11 @@ <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + </dependencies> </project> Modified: james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP168JpaMigrateCommand.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP168JpaMigrateCommand.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP168JpaMigrateCommand.java (original) +++ james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP168JpaMigrateCommand.java Tue Sep 22 11:50:44 2015 @@ -56,6 +56,8 @@ public class IMAP168JpaMigrateCommand im JpaMigrateQuery.executeUpdate(em, "ALTER TABLE MAILBOX ADD COLUMN USER0 VARCHAR(255)"); Query query = em.createNativeQuery("SELECT NAME FROM MAILBOX"); + + @SuppressWarnings("unchecked") List<String> nameList = query.getResultList(); System.out.println("getResultList returned a result=" + nameList.size()); for (String name: nameList) { Modified: james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP180JpaMigrateCommand.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP180JpaMigrateCommand.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP180JpaMigrateCommand.java (original) +++ james/mailbox/trunk/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/command/IMAP180JpaMigrateCommand.java Tue Sep 22 11:50:44 2015 @@ -64,6 +64,7 @@ public class IMAP180JpaMigrateCommand im /** * Migrate the headers. */ + @SuppressWarnings("rawtypes") private static void migrateHeaders(EntityManager em) { em.getTransaction().begin(); @@ -111,6 +112,7 @@ public class IMAP180JpaMigrateCommand im /** * Migrate the properties. */ + @SuppressWarnings("rawtypes") private static void migrateProperties(EntityManager em) { em.getTransaction().begin(); Modified: james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java (original) +++ james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java Tue Sep 22 11:50:44 2015 @@ -18,14 +18,15 @@ ****************************************************************/ package org.apache.james.mailbox.copier; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.IOException; import java.util.List; -import junit.framework.Assert; - import org.apache.james.mailbox.MailboxManager; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.MessageManager; +import org.apache.james.mailbox.MessageManager.MetaData.FetchGroup; import org.apache.james.mailbox.acl.GroupMembershipResolver; import org.apache.james.mailbox.acl.MailboxACLResolver; import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver; @@ -133,11 +134,11 @@ public class MailboxCopierTest { List<MailboxPath> mailboxPathList = mailboxManager.list(mailboxSession); - Assert.assertEquals(MockMailboxManager.EXPECTED_MAILBOXES_COUNT, mailboxPathList.size()); + assertThat(mailboxPathList).hasSize(MockMailboxManager.EXPECTED_MAILBOXES_COUNT); for (MailboxPath mailboxPath: mailboxPathList) { MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession); - Assert.assertEquals(MockMailboxManager.MESSAGE_PER_MAILBOX_COUNT * multiplicationFactor, messageManager.getMessageCount(mailboxSession)); + assertThat(messageManager.getMetaData(false, mailboxSession, FetchGroup.NO_UNSEEN).getMessageCount()).isEqualTo(MockMailboxManager.MESSAGE_PER_MAILBOX_COUNT * multiplicationFactor); } mailboxManager.endProcessingRequest(mailboxSession); Modified: james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/jpa/migrator/JpaMigratorTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/jpa/migrator/JpaMigratorTest.java?rev=1704587&r1=1704586&r2=1704587&view=diff ============================================================================== --- james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/jpa/migrator/JpaMigratorTest.java (original) +++ james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/jpa/migrator/JpaMigratorTest.java Tue Sep 22 11:50:44 2015 @@ -25,6 +25,7 @@ import org.junit.Test; /** * TODO this test class needs to be reviewed. */ +@SuppressWarnings("unused") public class JpaMigratorTest { @Test() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
