You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/05/10 11:30:13 UTC

[james-project] branch master updated (61e93ef -> 2a91b93)

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.


    from 61e93ef  JAMES-2717 Remove embedded ES modules in integration tests
     new df652eb  JAMES-2712 Add the download file method to Linshare API
     new cbba476  JAMES-2712 Add unit tests for Linshare download file API
     new 8a6bcb3  JAMES-2712 Add integration tests for Linshare download zip file
     new 9dde84e  JAMES-2712 Small test code refactoring for Linshare export
     new ff5f484  JAMES-2751 Fixing Docker Cassandra restart rule
     new c8bed49  JAMES-2751 Docker Cassandra restart should be done before the cluster's creation
     new 5bb4b29  JAMES-2717 Adding DockerElasticSearchRule for junit4 tests
     new f213b55  JAMES-2717 Replace embedded ES in ElasticSearchHostSystem
     new 1c771a8  JAMES-2717 Replace embedded ES in ElasticSearchIndexerTest
     new 530bdc9  JAMES-2717 Replace embedded ES in ElasticSearchIntegrationTest
     new b0e72aa  JAMES-2717 Replace embedded ES in ElasticSearchQuotaMailboxListenerTest
     new 20534db  JAMES-2717 Replace embedded ES in ElasticSearchQuotaSearchExtension
     new 3d4d445  JAMES-2717 Replace embedded ES in ElasticSearchQuotaSearchTestSystemExtension
     new a49ab7a  JAMES-2717 Replace embedded ES in IndexCreationFactoryTest
     new 35f7a69  JAMES-2717 Replace embedded ES in NodeMappingFactoryTest
     new a6ba35f  JAMES-2717 Replace embedded ES in ScrollIterableTest
     new 2a91b93  JAMES-2717 Remove EmbeddedElasticSearch

The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../backends/cassandra/DockerCassandraRule.java    | 17 ++--
 .../james/backends/es/DockerElasticSearchRule.java | 33 ++++----
 .../backends/es/ElasticSearchIndexerTest.java      | 58 ++++++-------
 .../james/backends/es/EmbeddedElasticSearch.java   | 99 ----------------------
 .../backends/es/IndexCreationFactoryTest.java      | 11 +--
 .../james/backends/es/NodeMappingFactoryTest.java  | 13 +--
 .../backends/es/search/ScrollIterableTest.java     | 69 ++++++++++-----
 .../src/test/resources/logback-test.xml            |  1 -
 .../ElasticSearchIntegrationTest.java              | 33 ++++----
 mailbox/plugin/quota-search-elasticsearch/pom.xml  |  5 ++
 ...lasticSearchQuotaSearchTestSystemExtension.java | 21 +++--
 .../ElasticSearchQuotaMailboxListenerTest.java     | 31 ++-----
 .../cassandra/CassandraAuthenticatePlainTest.java  |  6 +-
 .../cassandra/CassandraAuthenticatedStateTest.java |  6 +-
 .../cassandra/CassandraConcurrentSessionsTest.java |  6 +-
 .../cassandra/CassandraCondstoreTest.java          |  6 +-
 .../imapmailbox/cassandra/CassandraCopyTest.java   |  6 +-
 .../imapmailbox/cassandra/CassandraEventsTest.java |  6 +-
 .../cassandra/CassandraExpungeTest.java            |  6 +-
 .../cassandra/CassandraFetchBodySectionTest.java   |  6 +-
 .../cassandra/CassandraFetchBodyStructureTest.java |  6 +-
 .../cassandra/CassandraFetchHeadersTest.java       |  6 +-
 .../imapmailbox/cassandra/CassandraFetchTest.java  |  6 +-
 .../cassandra/CassandraListingTest.java            |  6 +-
 .../cassandra/CassandraListingWithSharingTest.java |  6 +-
 .../cassandra/CassandraMailboxAnnotationTest.java  |  6 +-
 .../CassandraMailboxWithLongNameErrorTest.java     |  6 +-
 .../imapmailbox/cassandra/CassandraMoveTest.java   |  6 +-
 .../CassandraNonAuthenticatedStateTest.java        |  6 +-
 .../cassandra/CassandraPartialFetchTest.java       |  6 +-
 .../imapmailbox/cassandra/CassandraQuotaTest.java  |  6 +-
 .../imapmailbox/cassandra/CassandraRenameTest.java |  6 +-
 .../imapmailbox/cassandra/CassandraSearchTest.java |  6 +-
 .../cassandra/CassandraSecurityTest.java           |  6 +-
 .../imapmailbox/cassandra/CassandraSelectTest.java |  6 +-
 .../cassandra/CassandraSelectedInboxTest.java      |  6 +-
 .../cassandra/CassandraSelectedStateTest.java      |  6 +-
 .../cassandra/CassandraUidSearchOnIndexTest.java   |  6 +-
 .../cassandra/CassandraUidSearchTest.java          |  6 +-
 .../cassandra/CassandraUserFlagsSupportTest.java   |  6 +-
 mpt/impl/imap-mailbox/elasticsearch/pom.xml        | 11 +++
 .../host/ElasticSearchHostSystem.java              | 30 +++----
 ...LinshareBlobExportMechanismIntegrationTest.java | 73 +++++++++++++---
 server/protocols/webadmin/webadmin-mailbox/pom.xml |  5 ++
 .../routes/ElasticSearchQuotaSearchExtension.java  | 18 ++--
 .../org/apache/james/linshare/client/Document.java |  2 +-
 .../apache/james/linshare/ByteArrayDecoder.java    | 31 +++----
 .../org/apache/james/linshare/CombinedDecoder.java | 83 ++++++++++++++++++
 .../linshare/LinshareBlobExportMechanismTest.java  | 37 ++++++--
 .../apache/james/linshare/LinshareExtension.java   | 19 ++++-
 .../james/linshare/client/LinshareAPITest.java     | 19 +++++
 51 files changed, 515 insertions(+), 372 deletions(-)
 copy third-party/spamassassin/src/test/java/org/apache/james/spamassassin/mock/MockSpamdTestRule.java => backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/DockerElasticSearchRule.java (69%)
 delete mode 100644 backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
 copy {event-sourcing/event-store-cassandra => backends-common/elasticsearch}/src/test/resources/logback-test.xml (94%)
 copy mailbox/api/src/main/java/org/apache/james/mailbox/model/search/ExactName.java => third-party/linshare/src/test/java/org/apache/james/linshare/ByteArrayDecoder.java (69%)
 create mode 100644 third-party/linshare/src/test/java/org/apache/james/linshare/CombinedDecoder.java


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 17/17: JAMES-2717 Remove EmbeddedElasticSearch

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 2a91b93ebeee580f73508e115d486d41909f8bb7
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 17:44:05 2019 +0700

    JAMES-2717 Remove EmbeddedElasticSearch
---
 .../james/backends/es/EmbeddedElasticSearch.java   | 99 ----------------------
 1 file changed, 99 deletions(-)

diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
deleted file mode 100644
index f2c7de6..0000000
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/EmbeddedElasticSearch.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.backends.es;
-
-import static org.awaitility.Awaitility.await;
-import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.function.Supplier;
-
-import org.awaitility.Duration;
-import org.elasticsearch.action.admin.indices.flush.FlushAction;
-import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.node.Node;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-public class EmbeddedElasticSearch extends ExternalResource {
-    private final Supplier<Path> folder;
-    private Node node;
-
-    private static Path createTempDir(TemporaryFolder temporaryFolder) {
-        try {
-            return temporaryFolder.newFolder().toPath();
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public EmbeddedElasticSearch(TemporaryFolder temporaryFolder) {
-        this(() -> EmbeddedElasticSearch.createTempDir(temporaryFolder));
-    }
-
-    public EmbeddedElasticSearch(Path folder) {
-        this(() -> folder);
-    }
-
-    private EmbeddedElasticSearch(Supplier<Path> folder) {
-        this.folder = folder;
-    }
-
-    @Override
-    public void before() {
-        node = nodeBuilder().local(true)
-            .settings(Settings.builder()
-                .put("path.home", folder.get().toAbsolutePath())
-                .build())
-            .node();
-        node.start();
-    }
-
-    @Override
-    public void after() {
-        node.close();
-    }
-
-    public Node getNode() {
-        return node;
-    }
-
-    /**
-     * Sometimes, tests are too fast.
-     * This method ensure that ElasticSearch service is up and indices are updated
-     */
-    public void awaitForElasticSearch() {
-        await().atMost(Duration.TEN_SECONDS)
-            .until(this::flush);
-    }
-
-    private boolean flush() {
-        try (Client client = node.client()) {
-            new FlushRequestBuilder(client, FlushAction.INSTANCE).setForce(true).get();
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 10/17: JAMES-2717 Replace embedded ES in ElasticSearchIntegrationTest

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 530bdc9966a0764c1963f1aa4ce72b265cee9b41
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 16:53:01 2019 +0700

    JAMES-2717 Replace embedded ES in ElasticSearchIntegrationTest
---
 .../ElasticSearchIntegrationTest.java              | 33 ++++++++++------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index 3286408..3a96813 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -26,10 +26,9 @@ import java.time.ZoneId;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 
+import org.apache.james.backends.es.DockerElasticSearchRule;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
 import org.apache.james.backends.es.ElasticSearchIndexer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
 import org.apache.james.mailbox.MessageManager;
@@ -56,8 +55,6 @@ import org.elasticsearch.client.Client;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
 
 import com.google.common.base.Strings;
 
@@ -66,14 +63,11 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
     private static final int BATCH_SIZE = 1;
     private static final int SEARCH_SIZE = 1;
 
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
-
-    @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
     @ClassRule
     public static TikaContainerSingletonRule tika = TikaContainerSingletonRule.rule;
+
+    @Rule
+    public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
     private TikaTextExtractor textExtractor;
 
     @Override
@@ -89,14 +83,17 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
 
     @Override
     protected void await() {
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
     }
 
     @Override
     protected void initializeMailboxManager() {
         Client client = MailboxIndexCreationUtil.prepareDefaultClient(
-            new TestingClientProvider(embeddedElasticSearch.getNode()).get(),
-                ElasticSearchConfiguration.DEFAULT_CONFIGURATION);
+            elasticSearch.clientProvider().get(),
+            ElasticSearchConfiguration.builder()
+                .addHost(elasticSearch.getTcpHost())
+                .build());
+
         InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
         ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
 
@@ -141,7 +138,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
                 .setBody(Strings.repeat("0à2345678é", 3200), StandardCharsets.UTF_8)),
             session);
 
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         assertThat(messageManager.search(new SearchQuery(SearchQuery.address(SearchQuery.AddressType.To, recipient)), session))
             .containsExactly(composedMessageId.getUid());
@@ -160,7 +157,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
                 .setBody(Strings.repeat("0123456789", 3300), StandardCharsets.UTF_8)),
             session);
 
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         assertThat(messageManager.search(new SearchQuery(SearchQuery.address(SearchQuery.AddressType.To, recipient)), session))
             .containsExactly(composedMessageId.getUid());
@@ -179,7 +176,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
                 .setBody(Strings.repeat("0123456789 ", 5000), StandardCharsets.UTF_8)),
             session);
 
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         assertThat(messageManager.search(new SearchQuery(SearchQuery.bodyContains("0123456789")), session))
             .containsExactly(composedMessageId.getUid());
@@ -198,7 +195,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
                 .setBody(Strings.repeat("0123456789 ", 5000) + " matchMe", StandardCharsets.UTF_8)),
             session);
 
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         assertThat(messageManager.search(new SearchQuery(SearchQuery.bodyContains("matchMe")), session))
             .containsExactly(composedMessageId.getUid());
@@ -218,7 +215,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
                 .setBody(reasonableLongTerm, StandardCharsets.UTF_8)),
             session);
 
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         assertThat(messageManager.search(new SearchQuery(SearchQuery.bodyContains(reasonableLongTerm)), session))
             .containsExactly(composedMessageId.getUid());


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 04/17: JAMES-2712 Small test code refactoring for Linshare export

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 9dde84ee76bda91de1028fc33eab818bde7cb5f1
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed May 8 15:28:52 2019 +0700

    JAMES-2712 Small test code refactoring for Linshare export
---
 ...LinshareBlobExportMechanismIntegrationTest.java | 28 +++++++++++-----------
 .../linshare/LinshareBlobExportMechanismTest.java  | 22 +++++++++--------
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
index ef7239e..068827d 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
@@ -122,13 +122,13 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
     }
 
     @Test
-    void exportShouldShareTheDocumentViaLinShareWhenJmapDelete() {
+    void exportShouldShareTheDocumentViaLinshareWhenJmapDelete() {
         bartSendMessageToHomer();
 
         WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
 
         homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
-        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
 
         exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
 
@@ -139,7 +139,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
     }
 
     @Test
-    void exportShouldShareTheDocumentViaLinShareWhenImapDelete() throws Exception {
+    void exportShouldShareTheDocumentViaLinshareWhenImapDelete() throws Exception {
         bartSendMessageToHomer();
 
         WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
@@ -150,7 +150,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
             .setFlagsForAllMessagesInMailbox("\\Deleted");
         imapMessageReader.expunge();
 
-        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
 
         exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
 
@@ -167,7 +167,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
         WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
 
         homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
-        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
 
         exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
 
@@ -196,15 +196,15 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
             .setFlagsForAllMessagesInMailbox("\\Deleted");
         imapMessageReader.expunge();
 
-        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
 
         exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
 
         WAIT_TEN_SECONDS.untilAsserted(
-                () -> fakeSmtpRequestSpecification
-                    .get("/api/email")
-                .then()
-                    .body("", hasSize(2)));
+            () -> fakeSmtpRequestSpecification
+                .get("/api/email")
+            .then()
+                .body("", hasSize(2)));
 
         fakeSmtpRequestSpecification
             .get("/api/email")
@@ -214,13 +214,13 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
     }
 
     @Test
-    void exportShouldShareNonEmptyZipViaLinShareWhenJmapDelete() throws Exception {
+    void exportShouldShareNonEmptyZipViaLinshareWhenJmapDelete() throws Exception {
         bartSendMessageToHomer();
 
         WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
 
         homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
-        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
 
         exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
 
@@ -233,7 +233,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
     }
 
     @Test
-    void exportShouldShareNonEmptyZipViaLinShareWhenImapDelete() throws Exception {
+    void exportShouldShareNonEmptyZipViaLinshareWhenImapDelete() throws Exception {
         bartSendMessageToHomer();
 
         WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
@@ -244,7 +244,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
             .setFlagsForAllMessagesInMailbox("\\Deleted");
         imapMessageReader.expunge();
 
-        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
 
         exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
 
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
index fa7e1c3..51150c4 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
@@ -47,7 +47,9 @@ import org.junit.jupiter.api.extension.RegisterExtension;
 import io.restassured.specification.RequestSpecification;
 
 class LinshareBlobExportMechanismTest {
+    private static final String FILE_CONTENT = "content";
     private static final String EXPLANATION = "Explanation about the file being shared";
+    private static final FileExtension FILE_TEXT_EXTENSION = FileExtension.of("txt");
 
     @RegisterExtension
     static LinshareExtension linshareExtension = new LinshareExtension();
@@ -70,13 +72,13 @@ class LinshareBlobExportMechanismTest {
     }
 
     @Test
-    void exportShouldShareTheDocumentViaLinShare() throws Exception {
-        BlobId blobId = blobStore.save("content").block();
+    void exportShouldShareTheDocumentViaLinshare() throws Exception {
+        BlobId blobId = blobStore.save(FILE_CONTENT).block();
 
         testee.blobId(blobId)
             .with(new MailAddress(USER_2.getUsername()))
             .explanation(EXPLANATION)
-            .fileExtension(FileExtension.of("txt"))
+            .fileExtension(FILE_TEXT_EXTENSION)
             .export();
 
         assertThat(user2API.receivedShares())
@@ -88,12 +90,12 @@ class LinshareBlobExportMechanismTest {
 
     @Test
     void exportShouldSendAnEmailToSharee() throws Exception {
-        BlobId blobId = blobStore.save("content").block();
+        BlobId blobId = blobStore.save(FILE_CONTENT).block();
 
         testee.blobId(blobId)
             .with(new MailAddress(USER_2.getUsername()))
             .explanation(EXPLANATION)
-            .fileExtension(FileExtension.of("txt"))
+            .fileExtension(FILE_TEXT_EXTENSION)
             .export();
 
         RequestSpecification request = given(linshareExtension.getLinshare().fakeSmtpRequestSpecification());
@@ -115,18 +117,18 @@ class LinshareBlobExportMechanismTest {
     }
 
     @Test
-    void exportShouldShareTheDocumentAndAllowDownloadViaLinShare() throws Exception {
-        BlobId blobId = blobStore.save("content").block();
+    void exportShouldShareTheDocumentAndAllowDownloadViaLinshare() throws Exception {
+        BlobId blobId = blobStore.save(FILE_CONTENT).block();
 
         testee.blobId(blobId)
             .with(new MailAddress(USER_2.getUsername()))
             .explanation(EXPLANATION)
-            .fileExtension(FileExtension.of("txt"))
+            .fileExtension(FILE_TEXT_EXTENSION)
             .export();
 
         Document sharedDoc = user2API.receivedShares().get(0).getDocument();
         byte[] sharedFile =  linshareExtension.downloadSharedFile(USER_2, sharedDoc.getId(), sharedDoc.getName());
-        assertThat(sharedFile).isEqualTo("content".getBytes(StandardCharsets.UTF_8));
+        assertThat(sharedFile).isEqualTo(FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
     }
 
     @Test
@@ -137,7 +139,7 @@ class LinshareBlobExportMechanismTest {
             () -> testee.blobId(blobId)
                 .with(new MailAddress(USER_2.getUsername()))
                 .explanation(EXPLANATION)
-                .fileExtension(FileExtension.of("txt"))
+                .fileExtension(FILE_TEXT_EXTENSION)
                 .export())
             .isInstanceOf(BlobExportMechanism.BlobExportException.class);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 08/17: JAMES-2717 Replace embedded ES in ElasticSearchHostSystem

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit f213b55b49ed7ceb5007cf6a26d028f81828981d
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 16:43:28 2019 +0700

    JAMES-2717 Replace embedded ES in ElasticSearchHostSystem
---
 mpt/impl/imap-mailbox/elasticsearch/pom.xml        | 11 ++++++++
 .../host/ElasticSearchHostSystem.java              | 30 ++++++++++------------
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/mpt/impl/imap-mailbox/elasticsearch/pom.xml b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
index 0262778..be52a11 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/pom.xml
+++ b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
@@ -77,8 +77,19 @@
             <artifactId>apache-james-mpt-imapmailbox-core</artifactId>
         </dependency>
         <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-testing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 </project>
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 4bdb966..c882ebb 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -19,18 +19,15 @@
 
 package org.apache.james.mpt.imapmailbox.elasticsearch.host;
 
-import java.nio.file.Files;
-import java.nio.file.Path;
 import java.time.ZoneId;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.backends.es.DockerElasticSearch;
+import org.apache.james.backends.es.DockerElasticSearchSingleton;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
 import org.apache.james.backends.es.ElasticSearchIndexer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
@@ -65,30 +62,29 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
     private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
         Feature.MOD_SEQ_SEARCH);
 
-    private EmbeddedElasticSearch embeddedElasticSearch;
-    private Path tempDirectory;
+    private DockerElasticSearch dockerElasticSearch;
     private StoreMailboxManager mailboxManager;
 
-
     @Override
     public void beforeTest() throws Exception {
         super.beforeTest();
-        this.tempDirectory = Files.createTempDirectory("elasticsearch");
-        this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory);
-        embeddedElasticSearch.before();
+        this.dockerElasticSearch = DockerElasticSearchSingleton.INSTANCE;
+        dockerElasticSearch.start();
         initFields();
     }
 
     @Override
-    public void afterTest() throws Exception {
-        embeddedElasticSearch.after();
-        FileUtils.deleteDirectory(tempDirectory.toFile());
+    public void afterTest() {
+        dockerElasticSearch.cleanUpData();
     }
 
     private void initFields() {
         Client client = MailboxIndexCreationUtil.prepareDefaultClient(
-            new TestingClientProvider(embeddedElasticSearch.getNode()).get(),
-            ElasticSearchConfiguration.DEFAULT_CONFIGURATION);
+            dockerElasticSearch.clientProvider().get(),
+            ElasticSearchConfiguration.builder()
+                .addHost(dockerElasticSearch.getTcpHost())
+                .build());
+
         InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
         ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
 
@@ -145,6 +141,6 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
 
     @Override
     protected void await() {
-        embeddedElasticSearch.awaitForElasticSearch();
+        dockerElasticSearch.awaitForElasticSearch();
     }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 13/17: JAMES-2717 Replace embedded ES in ElasticSearchQuotaSearchTestSystemExtension

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 3d4d4459087fd3141e65be110cd14e2da21c401c
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 17:06:13 2019 +0700

    JAMES-2717 Replace embedded ES in ElasticSearchQuotaSearchTestSystemExtension
---
 ...ElasticSearchQuotaSearchTestSystemExtension.java | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/ElasticSearchQuotaSearchTestSystemExtension.java b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/ElasticSearchQuotaSearchTestSystemExtension.java
index d7cd8e8..5e63c46 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/ElasticSearchQuotaSearchTestSystemExtension.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/ElasticSearchQuotaSearchTestSystemExtension.java
@@ -24,10 +24,10 @@ import static org.mockito.Mockito.mock;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 
+import org.apache.james.backends.es.DockerElasticSearch;
+import org.apache.james.backends.es.DockerElasticSearchSingleton;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
 import org.apache.james.backends.es.ElasticSearchIndexer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
@@ -44,12 +44,10 @@ import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.extension.ParameterContext;
 import org.junit.jupiter.api.extension.ParameterResolutionException;
 import org.junit.jupiter.api.extension.ParameterResolver;
-import org.junit.rules.TemporaryFolder;
 
 public class ElasticSearchQuotaSearchTestSystemExtension implements ParameterResolver, BeforeEachCallback, AfterEachCallback {
 
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+    private final DockerElasticSearch elasticSearch = DockerElasticSearchSingleton.INSTANCE;
 
     @Override
     public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
@@ -60,7 +58,10 @@ public class ElasticSearchQuotaSearchTestSystemExtension implements ParameterRes
     public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
         try {
             Client client = QuotaSearchIndexCreationUtil.prepareDefaultClient(
-                new TestingClientProvider(embeddedElasticSearch.getNode()).get(), ElasticSearchConfiguration.DEFAULT_CONFIGURATION);
+                elasticSearch.clientProvider().get(),
+                ElasticSearchConfiguration.builder()
+                    .addHost(elasticSearch.getTcpHost())
+                    .build());
 
             InMemoryIntegrationResources resources = InMemoryIntegrationResources.defaultResources();
 
@@ -91,7 +92,7 @@ public class ElasticSearchQuotaSearchTestSystemExtension implements ParameterRes
                 usersRepository,
                 domainList,
                 resources.getCurrentQuotaManager(),
-                () -> embeddedElasticSearch.awaitForElasticSearch());
+                () -> elasticSearch.awaitForElasticSearch());
         } catch (Exception e) {
             throw new ParameterResolutionException("Error while resolving parameter", e);
         }
@@ -99,13 +100,11 @@ public class ElasticSearchQuotaSearchTestSystemExtension implements ParameterRes
 
     @Override
     public void beforeEach(ExtensionContext context) throws Exception {
-        temporaryFolder.create();
-        embeddedElasticSearch.before();
+        elasticSearch.start();
     }
 
     @Override
     public void afterEach(ExtensionContext context) {
-        embeddedElasticSearch.after();
-        temporaryFolder.delete();
+        elasticSearch.cleanUpData();
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 12/17: JAMES-2717 Replace embedded ES in ElasticSearchQuotaSearchExtension

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 20534db8086b97915d7fd61813020089b9c6781b
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 17:04:44 2019 +0700

    JAMES-2717 Replace embedded ES in ElasticSearchQuotaSearchExtension
---
 server/protocols/webadmin/webadmin-mailbox/pom.xml     |  5 +++++
 .../routes/ElasticSearchQuotaSearchExtension.java      | 18 ++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/server/protocols/webadmin/webadmin-mailbox/pom.xml b/server/protocols/webadmin/webadmin-mailbox/pom.xml
index 9ee023a..e78dfc2 100644
--- a/server/protocols/webadmin/webadmin-mailbox/pom.xml
+++ b/server/protocols/webadmin/webadmin-mailbox/pom.xml
@@ -116,6 +116,11 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-testing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>james-server-util</artifactId>
         </dependency>
         <dependency>
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ElasticSearchQuotaSearchExtension.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ElasticSearchQuotaSearchExtension.java
index d1685c4..8ca37ca 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ElasticSearchQuotaSearchExtension.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ElasticSearchQuotaSearchExtension.java
@@ -24,10 +24,10 @@ import static org.mockito.Mockito.mock;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 
+import org.apache.james.backends.es.DockerElasticSearch;
+import org.apache.james.backends.es.DockerElasticSearchSingleton;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
 import org.apache.james.backends.es.ElasticSearchIndexer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
@@ -51,19 +51,21 @@ import org.junit.rules.TemporaryFolder;
 
 public class ElasticSearchQuotaSearchExtension implements ParameterResolver, BeforeEachCallback, AfterEachCallback {
 
+    private final DockerElasticSearch elasticSearch = DockerElasticSearchSingleton.INSTANCE;
     private WebAdminQuotaSearchTestSystem restQuotaSearchTestSystem;
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
 
     @Override
     public void beforeEach(ExtensionContext context) {
         try {
             temporaryFolder.create();
-            embeddedElasticSearch.before();
+            elasticSearch.start();
 
             Client client = QuotaSearchIndexCreationUtil.prepareDefaultClient(
-                new TestingClientProvider(embeddedElasticSearch.getNode()).get(),
-                ElasticSearchConfiguration.DEFAULT_CONFIGURATION);
+                elasticSearch.clientProvider().get(),
+                ElasticSearchConfiguration.builder()
+                    .addHost(elasticSearch.getTcpHost())
+                    .build());
 
             InMemoryIntegrationResources resources = InMemoryIntegrationResources.defaultResources();
 
@@ -94,7 +96,7 @@ public class ElasticSearchQuotaSearchExtension implements ParameterResolver, Bef
                 usersRepository,
                 domainList,
                 resources.getCurrentQuotaManager(),
-                () -> embeddedElasticSearch.awaitForElasticSearch());
+                () -> elasticSearch.awaitForElasticSearch());
 
             restQuotaSearchTestSystem = new WebAdminQuotaSearchTestSystem(quotaSearchTestSystem);
         } catch (Exception e) {
@@ -106,7 +108,7 @@ public class ElasticSearchQuotaSearchExtension implements ParameterResolver, Bef
     public void afterEach(ExtensionContext context) {
         restQuotaSearchTestSystem.getWebAdminServer().destroy();
 
-        embeddedElasticSearch.after();
+        elasticSearch.cleanUpData();
         temporaryFolder.delete();
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 16/17: JAMES-2717 Replace embedded ES in ScrollIterableTest

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit a6ba35f62f6d7afc7bff2b0c940f3f4107b49b6e
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 17:43:42 2019 +0700

    JAMES-2717 Replace embedded ES in ScrollIterableTest
---
 .../backends/es/search/ScrollIterableTest.java     | 69 ++++++++++++++--------
 1 file changed, 46 insertions(+), 23 deletions(-)

diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
index 01032e6..392b3e6 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/search/ScrollIterableTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.backends.es.search;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 
@@ -29,50 +30,48 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 import org.apache.james.backends.es.ClientProvider;
+import org.apache.james.backends.es.DockerElasticSearchRule;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.backends.es.IndexCreationFactory;
 import org.apache.james.backends.es.IndexName;
 import org.apache.james.backends.es.NodeMappingFactory;
 import org.apache.james.backends.es.ReadAliasName;
 import org.apache.james.backends.es.TypeName;
-import org.apache.james.backends.es.utils.TestingClientProvider;
+import org.awaitility.Duration;
+import org.awaitility.core.ConditionFactory;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.SearchHit;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
 
 public class ScrollIterableTest {
 
-    public static final TimeValue TIMEOUT = new TimeValue(6000);
-    public static final int SIZE = 2;
-    public static final String MESSAGE = "message";
-    public static final IndexName INDEX_NAME = new IndexName("index");
-    public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
-    public static final TypeName TYPE_NAME = new TypeName("messages");
+    private static final TimeValue TIMEOUT = new TimeValue(6000);
+    private static final int SIZE = 2;
+    private static final String MESSAGE = "message";
+    private static final IndexName INDEX_NAME = new IndexName("index");
+    private static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
+    private static final TypeName TYPE_NAME = new TypeName("messages");
 
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+    private static final ConditionFactory WAIT_CONDITION = await().timeout(Duration.FIVE_SECONDS);
 
     @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
+    public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
     private ClientProvider clientProvider;
 
     @Before
     public void setUp() throws Exception {
-        clientProvider = new TestingClientProvider(embeddedElasticSearch.getNode());
+        clientProvider = elasticSearch.clientProvider();
         new IndexCreationFactory(ElasticSearchConfiguration.DEFAULT_CONFIGURATION)
             .useIndex(INDEX_NAME)
             .addAlias(ALIAS_NAME)
             .createIndexAndAliases(clientProvider.get());
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
         NodeMappingFactory.applyMapping(clientProvider.get(), INDEX_NAME, TYPE_NAME, getMappingsSources());
     }
 
@@ -97,7 +96,9 @@ public class ScrollIterableTest {
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);
-            assertThat(new ScrollIterable(client, searchRequestBuilder)).isEmpty();
+
+            assertThat(new ScrollIterable(client, searchRequestBuilder))
+                .isEmpty();
         }
     }
 
@@ -109,14 +110,17 @@ public class ScrollIterableTest {
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
-            embeddedElasticSearch.awaitForElasticSearch();
+            elasticSearch.awaitForElasticSearch();
+            WAIT_CONDITION.untilAsserted(() -> hasIdsInIndex(client, id));
 
             SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
                 .setTypes(TYPE_NAME.getValue())
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id);
+
+            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder)))
+                .containsOnly(id);
         }
     }
 
@@ -133,14 +137,17 @@ public class ScrollIterableTest {
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
-            embeddedElasticSearch.awaitForElasticSearch();
+            elasticSearch.awaitForElasticSearch();
+            WAIT_CONDITION.untilAsserted(() -> hasIdsInIndex(client, id1, id2));
 
             SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
                 .setTypes(TYPE_NAME.getValue())
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2);
+
+            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder)))
+                .containsOnly(id1, id2);
         }
     }
 
@@ -162,14 +169,17 @@ public class ScrollIterableTest {
                 .setSource(MESSAGE, "Sample message")
                 .execute();
 
-            embeddedElasticSearch.awaitForElasticSearch();
+            elasticSearch.awaitForElasticSearch();
+            WAIT_CONDITION.untilAsserted(() -> hasIdsInIndex(client, id1, id2, id3));
 
             SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME.getValue())
                 .setTypes(TYPE_NAME.getValue())
                 .setScroll(TIMEOUT)
                 .setQuery(matchAllQuery())
                 .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2, id3);
+
+            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder)))
+                .containsOnly(id1, id2, id3);
         }
     }
 
@@ -179,4 +189,17 @@ public class ScrollIterableTest {
             .map(SearchHit::getId)
             .collect(Collectors.toList());
     }
+
+    private void hasIdsInIndex(Client client, String... ids) {
+        SearchHit[] hits = client.prepareSearch(INDEX_NAME.getValue())
+            .setQuery(QueryBuilders.idsQuery(TYPE_NAME.getValue()).addIds(ids))
+            .execute()
+            .actionGet()
+            .getHits()
+            .hits();
+
+        assertThat(hits)
+            .extracting(SearchHit::getId)
+            .contains(ids);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 01/17: JAMES-2712 Add the download file method to Linshare API

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit df652ebc1359a1b6707ff4245020838fcd98ad37
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue May 7 17:02:45 2019 +0700

    JAMES-2712 Add the download file method to Linshare API
---
 .../org/apache/james/linshare/client/Document.java |  2 +-
 .../apache/james/linshare/ByteArrayDecoder.java    | 45 ++++++++++++
 .../org/apache/james/linshare/CombinedDecoder.java | 83 ++++++++++++++++++++++
 .../apache/james/linshare/LinshareExtension.java   | 19 ++++-
 4 files changed, 147 insertions(+), 2 deletions(-)

diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/client/Document.java b/third-party/linshare/src/main/java/org/apache/james/linshare/client/Document.java
index ef87ed6..229de5b 100644
--- a/third-party/linshare/src/main/java/org/apache/james/linshare/client/Document.java
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/client/Document.java
@@ -28,7 +28,7 @@ import com.google.common.base.Preconditions;
 
 public class Document {
 
-    static class DocumentId {
+    public static class DocumentId {
         private final UUID id;
 
         DocumentId(UUID id) {
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/ByteArrayDecoder.java b/third-party/linshare/src/test/java/org/apache/james/linshare/ByteArrayDecoder.java
new file mode 100644
index 0000000..f5ce658
--- /dev/null
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/ByteArrayDecoder.java
@@ -0,0 +1,45 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.linshare;
+
+import java.io.IOException;
+import java.lang.reflect.Type;
+
+import com.google.common.base.Preconditions;
+
+import feign.FeignException;
+import feign.Response;
+import feign.Util;
+
+public class ByteArrayDecoder implements CombinedDecoder.SingleTypeDecoder {
+    private static final Type BYTE_TYPE = byte[].class;
+
+    @Override
+    public Type handledType() {
+        return BYTE_TYPE;
+    }
+
+    @Override
+    public Object decode(Response response, Type type) throws IOException, FeignException {
+        Preconditions.checkArgument(type.equals(BYTE_TYPE));
+
+        return Util.toByteArray(response.body().asInputStream());
+    }
+}
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/CombinedDecoder.java b/third-party/linshare/src/test/java/org/apache/james/linshare/CombinedDecoder.java
new file mode 100644
index 0000000..d6c96e6
--- /dev/null
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/CombinedDecoder.java
@@ -0,0 +1,83 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.linshare;
+
+import java.io.IOException;
+import java.lang.reflect.Type;
+
+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
+
+import com.google.common.base.Preconditions;
+
+import feign.FeignException;
+import feign.Response;
+import feign.codec.Decoder;
+
+public class CombinedDecoder implements Decoder {
+    interface SingleTypeDecoder extends Decoder {
+        Type handledType();
+    }
+
+    static class Builder {
+        @FunctionalInterface
+        public interface DefaultDecoder {
+            ReadyToBuild defaultDecoder(Decoder decoder);
+        }
+
+        static class ReadyToBuild {
+            private final Decoder defaultDecoder;
+            private final ImmutableMap.Builder<Type, Decoder> decoders;
+
+            ReadyToBuild(Decoder decoder) {
+                this.defaultDecoder = decoder;
+                this.decoders = ImmutableMap.builder();
+            }
+
+            ReadyToBuild registerSingleTypeDecoder(SingleTypeDecoder decoder) {
+                Preconditions.checkNotNull(decoder);
+                decoders.put(decoder.handledType(), decoder);
+                return this;
+            }
+
+            CombinedDecoder build() {
+                Preconditions.checkNotNull(defaultDecoder);
+                return new CombinedDecoder(defaultDecoder, decoders.build());
+            }
+        }
+    }
+
+    static Builder.DefaultDecoder builder() {
+        return Builder.ReadyToBuild::new;
+    }
+
+    private final Decoder defaultDecoder;
+    private final ImmutableMap<Type, Decoder> decoders;
+
+    private CombinedDecoder(Decoder defaultDecoder, ImmutableMap<Type, Decoder> decoders) {
+        this.defaultDecoder = defaultDecoder;
+        this.decoders = decoders;
+    }
+
+    @Override
+    public Object decode(Response response, Type type) throws IOException, FeignException {
+        return decoders.getOrDefault(type, defaultDecoder)
+            .decode(response, type);
+    }
+}
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
index 620d8ee..488083b 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
@@ -25,6 +25,7 @@ import static org.apache.james.linshare.client.LinshareAPI.Headers.ACCEPT_APPLIC
 import java.util.List;
 import java.util.Optional;
 
+import org.apache.james.linshare.client.Document;
 import org.apache.james.linshare.client.LinshareAPI;
 import org.apache.james.linshare.client.User;
 import org.apache.james.utils.FakeSmtp;
@@ -36,6 +37,7 @@ import com.github.fge.lambdas.Throwing;
 import feign.Feign;
 import feign.Headers;
 import feign.Logger;
+import feign.Param;
 import feign.RequestLine;
 import feign.auth.BasicAuthRequestInterceptor;
 import feign.form.FormEncoder;
@@ -47,6 +49,9 @@ public class LinshareExtension implements BeforeEachCallback {
 
     private interface LinshareAPIForTesting {
 
+        String CONTENT_DISPOSITION_ATTACHMENT = "Content-Disposition: attachment; filename=\"{filename}\"";
+        String CONTENT_TYPE_APPLICATION_OCTET_STREAM = "Content-Type: application/octet-stream";
+
         static LinshareAPIForTesting from(LinshareFixture.Credential credential, Linshare linshare) {
 
             return Feign.builder()
@@ -54,7 +59,10 @@ public class LinshareExtension implements BeforeEachCallback {
                 .logger(new Slf4jLogger(LinshareAPIForTesting.class))
                 .logLevel(Logger.Level.FULL)
                 .encoder(new FormEncoder(new JacksonEncoder()))
-                .decoder(new JacksonDecoder())
+                .decoder(CombinedDecoder.builder()
+                    .defaultDecoder(new JacksonDecoder())
+                    .registerSingleTypeDecoder(new ByteArrayDecoder())
+                    .build())
                 .target(LinshareAPIForTesting.class, linshare.getUrl());
         }
 
@@ -65,6 +73,10 @@ public class LinshareExtension implements BeforeEachCallback {
         @RequestLine("GET /linshare/webservice/rest/user/v2/users")
         @Headers(ACCEPT_APPLICATION_JSON)
         List<User> allUsers();
+
+        @RequestLine("GET /linshare/webservice/rest/user/v2/received_shares/{documentId}/download")
+        @Headers({ CONTENT_TYPE_APPLICATION_OCTET_STREAM, CONTENT_DISPOSITION_ATTACHMENT })
+        byte[] downloadShare(@Param("documentId") String documentId, @Param("filename") String filename);
     }
 
     private final Linshare linshare = LinshareSingleton.singleton;
@@ -92,6 +104,11 @@ public class LinshareExtension implements BeforeEachCallback {
             .build();
     }
 
+    public byte[] downloadSharedFile(LinshareFixture.Credential credential, Document.DocumentId document, String filename) {
+        return LinshareAPIForTesting.from(credential, linshare)
+            .downloadShare(document.asString(), filename);
+    }
+
     private void deleteAllUsersDocuments() {
         LinshareAPIForTesting.from(USER_1, linshare)
             .allUsers()


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 09/17: JAMES-2717 Replace embedded ES in ElasticSearchIndexerTest

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 1c771a89b5d433dad99c1cfd5f2d44d35e71314e
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 16:47:40 2019 +0700

    JAMES-2717 Replace embedded ES in ElasticSearchIndexerTest
---
 .../backends/es/ElasticSearchIndexerTest.java      | 58 ++++++++++------------
 .../src/test/resources/logback-test.xml            | 12 +++++
 2 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
index db60079..4904ce6 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -25,17 +25,13 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 
 import java.util.concurrent.Executors;
 
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.util.concurrent.NamedThreadFactory;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.client.Client;
 import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.node.Node;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
 
 import com.google.common.collect.ImmutableList;
 
@@ -45,37 +41,35 @@ public class ElasticSearchIndexerTest {
     private static final IndexName INDEX_NAME = new IndexName("index_name");
     private static final WriteAliasName ALIAS_NAME = new WriteAliasName("alias_name");
     private static final TypeName TYPE_NAME = new TypeName("type_name");
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
 
     @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
-    private Node node;
+    public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
     private ElasticSearchIndexer testee;
 
     @Before
     public void setup() {
-        node = embeddedElasticSearch.getNode();
-        TestingClientProvider clientProvider = new TestingClientProvider(node);
         new IndexCreationFactory(ElasticSearchConfiguration.DEFAULT_CONFIGURATION)
             .useIndex(INDEX_NAME)
             .addAlias(ALIAS_NAME)
-            .createIndexAndAliases(clientProvider.get());
-        testee = new ElasticSearchIndexer(clientProvider.get(),
+            .createIndexAndAliases(getESClient());
+        testee = new ElasticSearchIndexer(getESClient(),
             Executors.newSingleThreadExecutor(NamedThreadFactory.withClassName(getClass())),
             ALIAS_NAME, TYPE_NAME, MINIMUM_BATCH_SIZE);
     }
-    
+
+    private Client getESClient() {
+        return elasticSearch.clientProvider().get();
+    }
+
     @Test
     public void indexMessageShouldWork() {
         String messageId = "1";
         String content = "{\"message\": \"trying out Elasticsearch\"}";
         
         testee.index(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
         
-        try (Client client = node.client()) {
+        try (Client client = getESClient()) {
             SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
                     .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchQuery("message", "trying"))
@@ -96,12 +90,12 @@ public class ElasticSearchIndexerTest {
         String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}";
 
         testee.index(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         testee.update(ImmutableList.of(new UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}")));
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
-        try (Client client = node.client()) {
+        try (Client client = getESClient()) {
             SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
                 .setTypes(TYPE_NAME.getValue())
                 .setQuery(QueryBuilders.matchQuery("message", "mastering"))
@@ -109,7 +103,7 @@ public class ElasticSearchIndexerTest {
             assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
         }
 
-        try (Client client = node.client()) {
+        try (Client client = getESClient()) {
             SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
                 .setTypes(TYPE_NAME.getValue())
                 .setQuery(QueryBuilders.matchQuery("field", "unchanged"))
@@ -148,12 +142,12 @@ public class ElasticSearchIndexerTest {
         String content = "{\"message\": \"trying out Elasticsearch\", \"property\":\"1\"}";
 
         testee.index(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
         
         testee.deleteAllMatchingQuery(termQuery("property", "1")).get();
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
         
-        try (Client client = node.client()) {
+        try (Client client = getESClient()) {
             SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
                     .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchAllQuery())
@@ -178,12 +172,12 @@ public class ElasticSearchIndexerTest {
         String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"property\":\"2\"}";
         
         testee.index(messageId3, content3);
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         testee.deleteAllMatchingQuery(termQuery("property", "1")).get();
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
         
-        try (Client client = node.client()) {
+        try (Client client = getESClient()) {
             SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
                     .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchAllQuery())
@@ -198,12 +192,12 @@ public class ElasticSearchIndexerTest {
         String content = "{\"message\": \"trying out Elasticsearch\"}";
 
         testee.index(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         testee.delete(ImmutableList.of(messageId));
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
         
-        try (Client client = node.client()) {
+        try (Client client = getESClient()) {
             SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
                     .setTypes(TYPE_NAME.getValue())
                     .setQuery(QueryBuilders.matchAllQuery())
@@ -228,12 +222,12 @@ public class ElasticSearchIndexerTest {
         String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}";
 
         testee.index(messageId3, content3);
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         testee.delete(ImmutableList.of(messageId, messageId3));
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
-        try (Client client = node.client()) {
+        try (Client client = getESClient()) {
             SearchResponse searchResponse = client.prepareSearch(INDEX_NAME.getValue())
                 .setTypes(TYPE_NAME.getValue())
                 .setQuery(QueryBuilders.matchAllQuery())
diff --git a/backends-common/elasticsearch/src/test/resources/logback-test.xml b/backends-common/elasticsearch/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..dd2d81e
--- /dev/null
+++ b/backends-common/elasticsearch/src/test/resources/logback-test.xml
@@ -0,0 +1,12 @@
+<configuration>
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="WARN">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 02/17: JAMES-2712 Add unit tests for Linshare download file API

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit cbba47625040ecc60513eac9db83c58cb79f3cd4
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue May 7 17:03:27 2019 +0700

    JAMES-2712 Add unit tests for Linshare download file API
---
 .../linshare/LinshareBlobExportMechanismTest.java  | 23 ++++++++++++++++++++--
 .../james/linshare/client/LinshareAPITest.java     | 19 ++++++++++++++++++
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
index db04467..fa7e1c3 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
@@ -28,12 +28,15 @@ import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasSize;
 
+import java.nio.charset.StandardCharsets;
+
 import org.apache.james.blob.api.BlobId;
 import org.apache.james.blob.api.HashBlobId;
 import org.apache.james.blob.export.api.BlobExportMechanism;
 import org.apache.james.blob.export.api.FileExtension;
 import org.apache.james.blob.memory.MemoryBlobStore;
 import org.apache.james.core.MailAddress;
+import org.apache.james.linshare.client.Document;
 import org.apache.james.linshare.client.LinshareAPI;
 import org.awaitility.Awaitility;
 import org.awaitility.Duration;
@@ -52,6 +55,7 @@ class LinshareBlobExportMechanismTest {
     private MemoryBlobStore blobStore;
     private LinshareBlobExportMechanism testee;
     private HashBlobId.Factory blobIdFactory;
+    private LinshareAPI user2API;
 
     @BeforeEach
     void setUp() throws Exception {
@@ -61,6 +65,8 @@ class LinshareBlobExportMechanismTest {
         testee = new LinshareBlobExportMechanism(
             linshareExtension.getAPIFor(USER_1),
             blobStore);
+
+        user2API = linshareExtension.getAPIFor(USER_2);
     }
 
     @Test
@@ -73,8 +79,6 @@ class LinshareBlobExportMechanismTest {
             .fileExtension(FileExtension.of("txt"))
             .export();
 
-        LinshareAPI user2API = linshareExtension.getAPIFor(USER_2);
-
         assertThat(user2API.receivedShares())
             .hasSize(1)
             .allSatisfy(receivedShare -> assertThat(receivedShare.getDocument().getName()).endsWith(".txt"))
@@ -111,6 +115,21 @@ class LinshareBlobExportMechanismTest {
     }
 
     @Test
+    void exportShouldShareTheDocumentAndAllowDownloadViaLinShare() throws Exception {
+        BlobId blobId = blobStore.save("content").block();
+
+        testee.blobId(blobId)
+            .with(new MailAddress(USER_2.getUsername()))
+            .explanation(EXPLANATION)
+            .fileExtension(FileExtension.of("txt"))
+            .export();
+
+        Document sharedDoc = user2API.receivedShares().get(0).getDocument();
+        byte[] sharedFile =  linshareExtension.downloadSharedFile(USER_2, sharedDoc.getId(), sharedDoc.getName());
+        assertThat(sharedFile).isEqualTo("content".getBytes(StandardCharsets.UTF_8));
+    }
+
+    @Test
     void exportShouldFailWhenBlobDoesNotExist() {
         BlobId blobId = blobIdFactory.randomId();
 
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java
index d765379..85bc8d9 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java
@@ -34,6 +34,7 @@ import java.nio.file.Files;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.james.core.MailAddress;
 import org.apache.james.linshare.LinshareExtension;
 import org.assertj.core.api.SoftAssertions;
@@ -232,6 +233,24 @@ class LinshareAPITest {
             });
     }
 
+    @Test
+    void downloadShareShouldGetUploadedSharedFile() throws Exception {
+        File user1File = templateFile();
+        Document user1Document = user1LinshareAPI.uploadDocument(user1File);
+
+        ShareRequest shareRequest = ShareRequest.builder()
+            .message(MESSAGE)
+            .addDocumentId(user1Document.getId())
+            .addRecipient(new MailAddress(USER_2.getUsername()))
+            .build();
+
+        user1LinshareAPI.share(shareRequest);
+        Document sharedDoc = user2LinshareAPI.receivedShares().get(0).getDocument();
+
+        byte[] sharedFile =  linshareExtension.downloadSharedFile(USER_2, sharedDoc.getId(), sharedDoc.getName());
+        assertThat(sharedFile).isEqualTo(FileUtils.readFileToByteArray(user1File));
+    }
+
     private File templateFile() throws Exception {
         return Files.createTempFile("linshare-api-test", ".temp").toFile();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 15/17: JAMES-2717 Replace embedded ES in NodeMappingFactoryTest

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 35f7a69654664c44c2b03d49ba723937c005216e
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 17:09:22 2019 +0700

    JAMES-2717 Replace embedded ES in NodeMappingFactoryTest
---
 .../apache/james/backends/es/NodeMappingFactoryTest.java    | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java
index 60170a5..228b4ed 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/NodeMappingFactoryTest.java
@@ -21,13 +21,10 @@ package org.apache.james.backends.es;
 
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
 
 public class NodeMappingFactoryTest {
     public static final String MESSAGE = "message";
@@ -35,17 +32,13 @@ public class NodeMappingFactoryTest {
     public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
     public static final TypeName TYPE_NAME = new TypeName("type");
 
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
-
     @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
+    public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
     private ClientProvider clientProvider;
 
     @Before
     public void setUp() throws Exception {
-        clientProvider = new TestingClientProvider(embeddedElasticSearch.getNode());
+        clientProvider = elasticSearch.clientProvider();
         new IndexCreationFactory(ElasticSearchConfiguration.DEFAULT_CONFIGURATION)
             .useIndex(INDEX_NAME)
             .addAlias(ALIAS_NAME)
@@ -71,7 +64,7 @@ public class NodeMappingFactoryTest {
             TYPE_NAME,
             getMappingsSources());
 
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         NodeMappingFactory.applyMapping(clientProvider.get(),
             INDEX_NAME,


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 07/17: JAMES-2717 Adding DockerElasticSearchRule for junit4 tests

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 5bb4b29540ef41e843aec2a1caf932b80345c466
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 19:00:02 2019 +0700

    JAMES-2717 Adding DockerElasticSearchRule for junit4 tests
---
 .../james/backends/es/DockerElasticSearchRule.java | 50 ++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/DockerElasticSearchRule.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/DockerElasticSearchRule.java
new file mode 100644
index 0000000..7e140dc
--- /dev/null
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/DockerElasticSearchRule.java
@@ -0,0 +1,50 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.backends.es;
+
+import org.apache.james.util.Host;
+import org.junit.rules.ExternalResource;
+
+public class DockerElasticSearchRule extends ExternalResource {
+
+    private final DockerElasticSearch dockerElasticSearch = DockerElasticSearchSingleton.INSTANCE;
+
+    @Override
+    protected void before() throws Throwable {
+        dockerElasticSearch.start();
+    }
+
+    @Override
+    protected void after() {
+        dockerElasticSearch.cleanUpData();
+    }
+
+    public ClientProvider clientProvider() {
+        return dockerElasticSearch.clientProvider();
+    }
+    
+    public void awaitForElasticSearch() {
+        dockerElasticSearch.awaitForElasticSearch();
+    }
+
+    public Host getTcpHost() {
+        return dockerElasticSearch.getTcpHost();
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 06/17: JAMES-2751 Docker Cassandra restart should be done before the cluster's creation

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit c8bed496ecd72dbbe684ffc8abbb760148a2d03d
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu May 9 14:28:43 2019 +0700

    JAMES-2751 Docker Cassandra restart should be done before the cluster's creation
---
 .../mpt/imapmailbox/cassandra/CassandraAuthenticatePlainTest.java   | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraAuthenticatedStateTest.java  | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraConcurrentSessionsTest.java  | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraCondstoreTest.java     | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraCopyTest.java   | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraEventsTest.java | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraExpungeTest.java       | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraFetchBodySectionTest.java    | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraFetchBodyStructureTest.java  | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraFetchHeadersTest.java  | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraFetchTest.java  | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraListingTest.java       | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java  | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraMailboxAnnotationTest.java   | 6 ++++--
 .../cassandra/CassandraMailboxWithLongNameErrorTest.java            | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraMoveTest.java   | 6 ++++--
 .../imapmailbox/cassandra/CassandraNonAuthenticatedStateTest.java   | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraPartialFetchTest.java  | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java  | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraRenameTest.java | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraSearchTest.java | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraSecurityTest.java      | 6 ++++--
 .../apache/james/mpt/imapmailbox/cassandra/CassandraSelectTest.java | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraSelectedInboxTest.java | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraSelectedStateTest.java | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraUidSearchOnIndexTest.java    | 6 ++++--
 .../james/mpt/imapmailbox/cassandra/CassandraUidSearchTest.java     | 6 ++++--
 .../mpt/imapmailbox/cassandra/CassandraUserFlagsSupportTest.java    | 6 ++++--
 28 files changed, 112 insertions(+), 56 deletions(-)

diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlainTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlainTest.java
index c0efd9c..dfce173 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlainTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatePlainTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.AuthenticatePlain;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraAuthenticatePlainTest extends AuthenticatePlain {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedStateTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedStateTest.java
index 9011297..ea55f59 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedStateTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraAuthenticatedStateTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.AuthenticatedState;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraAuthenticatedStateTest extends AuthenticatedState {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessionsTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessionsTest.java
index 74f83ff..af41afc 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessionsTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraConcurrentSessionsTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.ConcurrentSessions;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraConcurrentSessionsTest extends ConcurrentSessions {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstoreTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstoreTest.java
index 276ae22..ab0a51a 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstoreTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCondstoreTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.host.JamesImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Condstore;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraCondstoreTest extends Condstore {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected JamesImapHostSystem createJamesImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopyTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopyTest.java
index f6cc114..8e85c47 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopyTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraCopyTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Copy;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraCopyTest extends Copy {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEventsTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEventsTest.java
index c76a5f3..532b7a9 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEventsTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraEventsTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Events;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraEventsTest extends Events {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpungeTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpungeTest.java
index 556c49e..f5afd12 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpungeTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraExpungeTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Expunge;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraExpungeTest extends Expunge {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySectionTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySectionTest.java
index bca8ed6..1cdf4c6 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySectionTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodySectionTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.FetchBodySection;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraFetchBodySectionTest extends FetchBodySection {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructureTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructureTest.java
index 0a5878b..8a48092 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructureTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchBodyStructureTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.FetchBodyStructure;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraFetchBodyStructureTest extends FetchBodyStructure {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeadersTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeadersTest.java
index 57b6248..aa5d71b 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeadersTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchHeadersTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.FetchHeaders;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraFetchHeadersTest extends FetchHeaders {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchTest.java
index 8adfa3a..e8885ef 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraFetchTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Fetch;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraFetchTest extends Fetch {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingTest.java
index f163bfd..6b419cd 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Listing;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraListingTest extends Listing {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
index aa3d61b..158f3c4 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.ListingWithSharingTest;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraListingWithSharingTest extends ListingWithSharingTest {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotationTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotationTest.java
index d8191f8..a6e50e6 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotationTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxAnnotationTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.MailboxAnnotation;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraMailboxAnnotationTest extends MailboxAnnotation {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameErrorTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameErrorTest.java
index ae4ff99..1a549f0 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameErrorTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMailboxWithLongNameErrorTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.MailboxWithLongNameError;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraMailboxWithLongNameErrorTest extends MailboxWithLongNameError {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMoveTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMoveTest.java
index 005928e..c0f5907 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMoveTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraMoveTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Move;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraMoveTest extends Move {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedStateTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedStateTest.java
index 6024d38..3a3428f 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedStateTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraNonAuthenticatedStateTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.NonAuthenticatedState;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraNonAuthenticatedStateTest extends NonAuthenticatedState {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetchTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetchTest.java
index 299127d..76816d9 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetchTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraPartialFetchTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.PartialFetch;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraPartialFetchTest extends PartialFetch {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java
index 12d0d9f..474c9cb 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraQuotaTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.QuotaTest;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraQuotaTest extends QuotaTest {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRenameTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRenameTest.java
index 4ecfba3..c6a38b2 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRenameTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraRenameTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Rename;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraRenameTest extends Rename {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearchTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearchTest.java
index b4b9212..9b4d05a 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearchTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSearchTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Search;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraSearchTest extends Search {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurityTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurityTest.java
index 68be8ae..d64613a 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurityTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSecurityTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Security;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraSecurityTest extends Security {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectTest.java
index 11afa50..fc9c1b4 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.Select;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraSelectTest extends Select {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInboxTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInboxTest.java
index f2856b4..78d0796 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInboxTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedInboxTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.SelectedInbox;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraSelectedInboxTest extends SelectedInbox {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedStateTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedStateTest.java
index dac4c4f..2bc0c37 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedStateTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraSelectedStateTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.SelectedState;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraSelectedStateTest extends SelectedState {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndexTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndexTest.java
index 97218af..d356731 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndexTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchOnIndexTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.UidSearchOnIndex;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraUidSearchOnIndexTest extends UidSearchOnIndex {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchTest.java
index 1259c41..bbe8158 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUidSearchTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.UidSearch;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraUidSearchTest extends UidSearch {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupportTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupportTest.java
index a04082b..a8eecdc 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupportTest.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraUserFlagsSupportTest.java
@@ -24,13 +24,15 @@ import org.apache.james.mpt.api.ImapHostSystem;
 import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemRule;
 import org.apache.james.mpt.imapmailbox.suite.UserFlagsSupport;
 import org.junit.Rule;
+import org.junit.rules.RuleChain;
 
 public class CassandraUserFlagsSupportTest extends UserFlagsSupport {
-    @Rule
     public DockerCassandraRule cassandraServer = new DockerCassandraRule().allowRestart();
-    @Rule
     public CassandraHostSystemRule cassandraHostSystemRule = new CassandraHostSystemRule(cassandraServer);
 
+    @Rule
+    public RuleChain ruleChain = RuleChain.outerRule(cassandraServer).around(cassandraHostSystemRule);
+
     @Override
     protected ImapHostSystem createImapHostSystem() {
         return cassandraHostSystemRule.getImapHostSystem();


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 11/17: JAMES-2717 Replace embedded ES in ElasticSearchQuotaMailboxListenerTest

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b0e72aa14d39533c9668279e4e43b9b4b1080d60
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 17:00:26 2019 +0700

    JAMES-2717 Replace embedded ES in ElasticSearchQuotaMailboxListenerTest
    
    There is fail tests and it already fails on master, just simple casting
    check. I need to update the code anyway.
---
 mailbox/plugin/quota-search-elasticsearch/pom.xml  |  5 ++++
 .../ElasticSearchQuotaMailboxListenerTest.java     | 31 +++++-----------------
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/mailbox/plugin/quota-search-elasticsearch/pom.xml b/mailbox/plugin/quota-search-elasticsearch/pom.xml
index aa04045..fce41a2 100644
--- a/mailbox/plugin/quota-search-elasticsearch/pom.xml
+++ b/mailbox/plugin/quota-search-elasticsearch/pom.xml
@@ -89,6 +89,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-testing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
index bd01ab8..d3f7811 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
@@ -29,10 +29,9 @@ import static org.mockito.Mockito.mock;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 
+import org.apache.james.backends.es.DockerElasticSearchRule;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
 import org.apache.james.backends.es.ElasticSearchIndexer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
 import org.apache.james.mailbox.quota.QuotaFixture.Counts;
@@ -47,8 +46,6 @@ import org.elasticsearch.client.Client;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
 
 public class ElasticSearchQuotaMailboxListenerTest {
     private static Event.EventId EVENT_ID = Event.EventId.of("6e0dd59d-660e-4d9b-b22f-0354479f47b4");
@@ -56,18 +53,18 @@ public class ElasticSearchQuotaMailboxListenerTest {
     private static final int BATCH_SIZE = 1;
     private static final Event DUMB_EVENT = mock(Event.class);
 
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
-
     @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
+    public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
     private ElasticSearchQuotaMailboxListener quotaMailboxListener;
     private Client client;
 
     @Before
     public void setUp() {
         client = QuotaSearchIndexCreationUtil.prepareDefaultClient(
-            new TestingClientProvider(embeddedElasticSearch.getNode()).get(), ElasticSearchConfiguration.DEFAULT_CONFIGURATION);
+            elasticSearch.clientProvider().get(),
+            ElasticSearchConfiguration.builder()
+                .addHost(elasticSearch.getTcpHost())
+                .build());
 
         ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
         quotaMailboxListener = new ElasticSearchQuotaMailboxListener(
@@ -86,20 +83,6 @@ public class ElasticSearchQuotaMailboxListenerTest {
     }
 
     @Test
-    public void eventShouldDoNothingWhenNoQuotaEvent() throws Exception {
-        quotaMailboxListener.event(DUMB_EVENT);
-
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        SearchResponse searchResponse = client.prepareSearch(QuotaRatioElasticSearchConstants.DEFAULT_QUOTA_RATIO_READ_ALIAS.getValue())
-            .setTypes(QuotaRatioElasticSearchConstants.QUOTA_RATIO_TYPE.getValue())
-            .setQuery(matchAllQuery())
-            .execute()
-            .get();
-        assertThat(searchResponse.getHits().totalHits()).isEqualTo(0);
-    }
-
-    @Test
     public void eventShouldIndexEventWhenQuotaEvent() throws Exception {
         quotaMailboxListener.event(EventFactory.quotaUpdated()
             .eventId(EVENT_ID)
@@ -110,7 +93,7 @@ public class ElasticSearchQuotaMailboxListenerTest {
             .instant(NOW)
             .build());
 
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
 
         SearchResponse searchResponse = client.prepareSearch(QuotaRatioElasticSearchConstants.DEFAULT_QUOTA_RATIO_READ_ALIAS.getValue())
             .setTypes(QuotaRatioElasticSearchConstants.QUOTA_RATIO_TYPE.getValue())


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 05/17: JAMES-2751 Fixing Docker Cassandra restart rule

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit ff5f484f2b2bf438488616330a5d7fbcf3de2fdf
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu May 9 11:30:44 2019 +0700

    JAMES-2751 Fixing Docker Cassandra restart rule
---
 .../james/backends/cassandra/DockerCassandraRule.java   | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
index e213125..d89fd55 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandraRule.java
@@ -20,13 +20,11 @@
 package org.apache.james.backends.cassandra;
 
 import org.apache.james.util.Host;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
+import org.junit.rules.ExternalResource;
 import org.testcontainers.containers.GenericContainer;
 
 
-public class DockerCassandraRule implements TestRule {
+public class DockerCassandraRule extends ExternalResource {
 
     private boolean allowRestart = false;
 
@@ -36,16 +34,15 @@ public class DockerCassandraRule implements TestRule {
     }
 
     @Override
-    public Statement apply(Statement base, Description description) {
-        return base;
+    protected void before() {
+        if (allowRestart) {
+            DockerCassandraSingleton.restartAfterMaxTestsPlayed();
+        }
+        DockerCassandraSingleton.incrementTestsPlayed();
     }
 
     public void start() {
         DockerCassandraSingleton.singleton.start();
-        DockerCassandraSingleton.incrementTestsPlayed();
-        if (allowRestart) {
-            DockerCassandraSingleton.restartAfterMaxTestsPlayed();
-        }
     }
 
     public void stop() {


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 03/17: JAMES-2712 Add integration tests for Linshare download zip file

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 8a6bcb372e02a9e2cddfbf2185c9c5075f864737
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue May 7 17:06:32 2019 +0700

    JAMES-2712 Add integration tests for Linshare download zip file
---
 ...LinshareBlobExportMechanismIntegrationTest.java | 53 +++++++++++++++++++++-
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
index b5c0004..ef7239e 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
@@ -34,19 +34,23 @@ import static org.apache.james.jmap.TestingConstants.calmlyAwait;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.apache.james.linshare.LinshareFixture.MATCH_ALL_QUERY;
 import static org.apache.james.linshare.LinshareFixture.USER_1;
+import static org.apache.james.mailbox.backup.ZipAssert.assertThatZip;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasSize;
 
+import java.io.ByteArrayInputStream;
 import java.util.List;
 
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.ExportRequest;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.linshare.LinshareExtension;
+import org.apache.james.linshare.client.Document;
 import org.apache.james.linshare.client.LinshareAPI;
 import org.apache.james.mailbox.DefaultMailboxes;
+import org.apache.james.mailbox.backup.ZipAssert;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.probe.MailboxProbe;
 import org.apache.james.modules.MailboxProbeImpl;
@@ -78,6 +82,8 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
         .exportTo(USER_1.getUsername())
         .query(MATCH_ALL_QUERY);
 
+    private static LinshareExtension linshareExtension = new LinshareExtension();
+
     private AccessToken homerAccessToken;
     private AccessToken bartAccessToken;
     private GuiceJamesServer jmapServer;
@@ -110,9 +116,9 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
 
         homerAccessToken = authenticateJamesUser(baseUri(jmapServer), HOMER, HOMER_PASSWORD);
         bartAccessToken = authenticateJamesUser(baseUri(jmapServer), BART, BART_PASSWORD);
-        user1LinshareAPI = new LinshareExtension().getAPIFor(USER_1);
+        user1LinshareAPI = linshareExtension.getAPIFor(USER_1);
 
-        fakeSmtpRequestSpecification = given(new LinshareExtension().getLinshare().fakeSmtpRequestSpecification());
+        fakeSmtpRequestSpecification = given(linshareExtension.getLinshare().fakeSmtpRequestSpecification());
     }
 
     @Test
@@ -207,6 +213,49 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
             .body("[1].to", hasItem(USER_1.getUsername()));
     }
 
+    @Test
+    void exportShouldShareNonEmptyZipViaLinShareWhenJmapDelete() throws Exception {
+        bartSendMessageToHomer();
+
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
+
+        homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+
+        exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
+
+        Document sharedDoc = user1LinshareAPI.receivedShares().get(0).getDocument();
+        byte[] sharedFile =  linshareExtension.downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
+
+        try (ZipAssert zipAssert = assertThatZip(new ByteArrayInputStream(sharedFile))) {
+            zipAssert.hasEntriesSize(1);
+        }
+    }
+
+    @Test
+    void exportShouldShareNonEmptyZipViaLinShareWhenImapDelete() throws Exception {
+        bartSendMessageToHomer();
+
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
+
+        imapMessageReader.connect(LOCALHOST_IP, jmapServer.getProbe(ImapGuiceProbe.class).getImapPort())
+            .login(HOMER, HOMER_PASSWORD)
+            .select(IMAPMessageReader.INBOX)
+            .setFlagsForAllMessagesInMailbox("\\Deleted");
+        imapMessageReader.expunge();
+
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+
+        exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
+
+        Document sharedDoc = user1LinshareAPI.receivedShares().get(0).getDocument();
+        byte[] sharedFile =  linshareExtension.downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
+
+        try (ZipAssert zipAssert = assertThatZip(new ByteArrayInputStream(sharedFile))) {
+            zipAssert.hasEntriesSize(1);
+        }
+    }
+
     private void bartSendMessageToHomer() {
         String messageCreationId = "creationId";
         String outboxId = getOutboxId(bartAccessToken);


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[james-project] 14/17: JAMES-2717 Replace embedded ES in IndexCreationFactoryTest

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit a49ab7a344a0c79fe7185447c01dcb11f6e29b31
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 17:08:08 2019 +0700

    JAMES-2717 Replace embedded ES in IndexCreationFactoryTest
---
 .../apache/james/backends/es/IndexCreationFactoryTest.java    | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java
index 8c51bc2..fe4421e 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/IndexCreationFactoryTest.java
@@ -21,28 +21,21 @@ package org.apache.james.backends.es;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
 
 public class IndexCreationFactoryTest {
     public static final IndexName INDEX_NAME = new IndexName("index");
     public static final ReadAliasName ALIAS_NAME = new ReadAliasName("alias");
 
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
-
     @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
+    public DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule();
     private ClientProvider clientProvider;
 
     @Before
     public void setUp() {
-        clientProvider = new TestingClientProvider(embeddedElasticSearch.getNode());
+        clientProvider = elasticSearch.clientProvider();
         new IndexCreationFactory(ElasticSearchConfiguration.DEFAULT_CONFIGURATION)
             .useIndex(INDEX_NAME)
             .addAlias(ALIAS_NAME)


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org