This is an automated email from the ASF dual-hosted git repository. rouazana pushed a commit to branch 3.3.x in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 14ec22154f312abf140c3cc72c0fbf16cc79667d Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Thu Mar 7 14:49:02 2019 +0700 JAMES-2675 Add a simple unit test about indexing upon large copies --- mailbox/elasticsearch/pom.xml | 5 ++++ mailbox/lucene/pom.xml | 5 ++++ mailbox/scanning-search/pom.xml | 5 ++++ mailbox/store/pom.xml | 5 ++++ .../search/AbstractMessageSearchIndexTest.java | 27 ++++++++++++++++++++++ 5 files changed, 47 insertions(+) diff --git a/mailbox/elasticsearch/pom.xml b/mailbox/elasticsearch/pom.xml index 5a78c03..b47a071 100644 --- a/mailbox/elasticsearch/pom.xml +++ b/mailbox/elasticsearch/pom.xml @@ -126,6 +126,11 @@ <artifactId>guava</artifactId> </dependency> <dependency> + <groupId>com.jayway.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> </dependency> diff --git a/mailbox/lucene/pom.xml b/mailbox/lucene/pom.xml index 5247bd6..8a709a6 100644 --- a/mailbox/lucene/pom.xml +++ b/mailbox/lucene/pom.xml @@ -77,6 +77,11 @@ <artifactId>apache-mime4j-dom</artifactId> </dependency> <dependency> + <groupId>com.jayway.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> </dependency> diff --git a/mailbox/scanning-search/pom.xml b/mailbox/scanning-search/pom.xml index 5aafd7c..1b51127 100644 --- a/mailbox/scanning-search/pom.xml +++ b/mailbox/scanning-search/pom.xml @@ -69,6 +69,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>com.jayway.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/mailbox/store/pom.xml b/mailbox/store/pom.xml index 572fd84..f33e689 100644 --- a/mailbox/store/pom.xml +++ b/mailbox/store/pom.xml @@ -97,6 +97,11 @@ <artifactId>guava</artifactId> </dependency> <dependency> + <groupId>com.jayway.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> </dependency> diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java index e60475e..7a7748a 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java @@ -28,6 +28,7 @@ import java.time.ZoneId; import java.util.Date; import java.util.List; import java.util.TimeZone; +import java.util.concurrent.TimeUnit; import javax.mail.Flags; @@ -37,8 +38,10 @@ import org.apache.james.mailbox.MessageIdManager; import org.apache.james.mailbox.MessageManager; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.ComposedMessageId; +import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MessageId; +import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.SearchQuery; import org.apache.james.mailbox.model.SearchQuery.AddressType; import org.apache.james.mailbox.model.SearchQuery.DateResolution; @@ -59,6 +62,9 @@ import org.junit.Before; import org.junit.Test; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterators; +import com.jayway.awaitility.Awaitility; +import com.jayway.awaitility.Duration; public abstract class AbstractMessageSearchIndexTest { @@ -1453,6 +1459,27 @@ public abstract class AbstractMessageSearchIndexTest { } @Test + public void copiedMessageShouldAllBeIndexed() throws Exception { + MailboxPath newBoxPath = MailboxPath.forUser(USERNAME, "newBox"); + MailboxId newBoxId = storeMailboxManager.createMailbox(newBoxPath, session).get(); + + storeMailboxManager.copyMessages(MessageRange.all(), inboxMessageManager.getId(), newBoxId, session); + + SearchQuery searchQuery = new SearchQuery(); + + StoreMessageManager newBox = (StoreMessageManager) storeMailboxManager.getMailbox(newBoxId, session); + + Awaitility.with() + .pollInterval(Duration.ONE_HUNDRED_MILLISECONDS) + .and().with() + .pollDelay(new Duration(1, TimeUnit.MILLISECONDS)) + .await() + .atMost(30, TimeUnit.SECONDS) + .until( + () -> Iterators.size(messageSearchIndex.search(session, newBox.getMailboxEntity(), searchQuery)) == 9); + } + + @Test public void searchShouldRetrieveMailByAttachmentFileName() throws Exception { Assume.assumeTrue(messageSearchIndex.getSupportedCapabilities(storeMailboxManager.getSupportedMessageCapabilities()) .contains(MailboxManager.SearchCapabilities.AttachmentFileName)); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org