james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [james-project] 01/04: JAMES-2717 Replace embedded ES in CassandraJmapExtension
Date Fri, 10 May 2019 04:27:25 GMT
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 f90d4621e5d82c091bc36f140b4f5723c61d4888
Author: Tran Tien Duc <dtran@linagora.com>
AuthorDate: Wed May 8 16:07:51 2019 +0700

    JAMES-2717 Replace embedded ES in CassandraJmapExtension
---
 .../org/apache/james/DockerElasticSearchRule.java     |  4 ++++
 .../webadmin/integration/CassandraJmapExtension.java  | 19 ++++++++-----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
index 6287009..fed09ce 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
@@ -50,4 +50,8 @@ public class DockerElasticSearchRule implements GuiceModuleTestRule {
     public DockerElasticSearch getDockerEs() {
         return elasticSearch;
     }
+
+    public void start() {
+        elasticSearch.start();
+    }
 }
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
index c89aea7..5d7c8b2 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
@@ -24,12 +24,11 @@ import java.io.IOException;
 
 import org.apache.james.CleanupTasksPerformer;
 import org.apache.james.DockerCassandraRule;
+import org.apache.james.DockerElasticSearchRule;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.search.PDFTextExtractor;
-import org.apache.james.modules.TestEmbeddedESMetricReporterModule;
-import org.apache.james.modules.TestEmbeddedElasticSearchModule;
+import org.apache.james.modules.TestDockerESMetricReporterModule;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.server.core.configuration.Configuration;
 import org.apache.james.util.Runnables;
@@ -50,13 +49,13 @@ public class CassandraJmapExtension implements BeforeAllCallback, AfterAllCallba
 
     private final TemporaryFolder temporaryFolder;
     private final DockerCassandraRule cassandra;
-    private final EmbeddedElasticSearch elasticSearch;
+    private final DockerElasticSearchRule elasticSearchRule;
     private GuiceJamesServer james;
 
     public CassandraJmapExtension() {
         this.temporaryFolder = new TemporaryFolder();
         this.cassandra = new DockerCassandraRule();
-        this.elasticSearch = new EmbeddedElasticSearch(temporaryFolder);
+        this.elasticSearchRule = new DockerElasticSearchRule();
     }
 
     private GuiceJamesServer james() throws IOException {
@@ -68,9 +67,9 @@ public class CassandraJmapExtension implements BeforeAllCallback, AfterAllCallba
         return GuiceJamesServer.forConfiguration(configuration)
                 .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE).overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
                 .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
-                .overrideWith(new TestEmbeddedESMetricReporterModule())
+                .overrideWith(new TestDockerESMetricReporterModule(elasticSearchRule.getDockerEs().getHttpHost()))
                 .overrideWith(cassandra.getModule())
-                .overrideWith(new TestEmbeddedElasticSearchModule(elasticSearch))
+                .overrideWith(elasticSearchRule.getModule())
                 .overrideWith(binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION))
                 .overrideWith(new UnauthorizedModule())
                 .overrideWith((binder -> binder.bind(CleanupTasksPerformer.class).asEagerSingleton()));
@@ -80,14 +79,12 @@ public class CassandraJmapExtension implements BeforeAllCallback, AfterAllCallba
     public void beforeAll(ExtensionContext context) throws Exception {
         temporaryFolder.create();
 
-        Runnables.runParallel(cassandra::start, elasticSearch::before);
+        Runnables.runParallel(cassandra::start, elasticSearchRule::start);
     }
 
     @Override
     public void afterAll(ExtensionContext context) {
-        elasticSearch.after();
-
-        Runnables.runParallel(cassandra::stop, elasticSearch::after);
+        Runnables.runParallel(cassandra::stop, elasticSearchRule.getDockerEs()::cleanUpData);
     }
 
     @Override


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


Mime
View raw message