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 d8a5883df5fe264554feaa1a9cc622e3aed89b3a Author: Tran Tien Duc <dt...@linagora.com> AuthorDate: Wed May 8 16:08:24 2019 +0700 JAMES-2717 Replace embedded ES in Cassandra cucumber tests --- .../jmap/cassandra/cucumber/CassandraStepdefs.java | 22 +++++++++--------- .../cucumber/CucumberElasticSearchSingleton.java | 27 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java index 7f770d6..416106b 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java @@ -29,15 +29,14 @@ import org.apache.activemq.store.PersistenceAdapter; import org.apache.activemq.store.memory.MemoryPersistenceAdapter; 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.jmap.methods.integration.cucumber.ImapStepdefs; import org.apache.james.jmap.methods.integration.cucumber.MainStepdefs; import org.apache.james.mailbox.cassandra.ids.CassandraMessageId; import org.apache.james.mailbox.extractor.TextExtractor; import org.apache.james.mailbox.store.extractor.DefaultTextExtractor; -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.CassandraTruncateTableTask; import org.apache.james.server.core.configuration.Configuration; @@ -55,9 +54,9 @@ public class CassandraStepdefs { private final MainStepdefs mainStepdefs; private final ImapStepdefs imapStepdefs; - private TemporaryFolder temporaryFolder = new TemporaryFolder(); - private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder); - private DockerCassandraRule cassandraServer = CucumberCassandraSingleton.cassandraServer; + private final TemporaryFolder temporaryFolder = new TemporaryFolder(); + private final DockerElasticSearchRule elasticSearch = CucumberElasticSearchSingleton.elasticSearch; + private final DockerCassandraRule cassandraServer = CucumberCassandraSingleton.cassandraServer; @Inject private CassandraStepdefs(MainStepdefs mainStepdefs, ImapStepdefs imapStepdefs) { @@ -69,7 +68,8 @@ public class CassandraStepdefs { public void init() throws Exception { cassandraServer.start(); temporaryFolder.create(); - embeddedElasticSearch.before(); + elasticSearch.start(); + mainStepdefs.messageIdFactory = new CassandraMessageId.Factory(); Configuration configuration = Configuration.builder() .workingDirectory(temporaryFolder.newFolder()) @@ -79,14 +79,14 @@ public class CassandraStepdefs { mainStepdefs.jmapServer = GuiceJamesServer.forConfiguration(configuration) .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE) .overrideWith(new TestJMAPServerModule(10)) - .overrideWith(new TestEmbeddedESMetricReporterModule()) - .overrideWith(new TestEmbeddedElasticSearchModule(embeddedElasticSearch)) + .overrideWith(new TestDockerESMetricReporterModule(elasticSearch.getDockerEs().getHttpHost())) + .overrideWith(elasticSearch.getModule()) .overrideWith(cassandraServer.getModule()) .overrideWith(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class)) .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)) .overrideWith(binder -> Multibinder.newSetBinder(binder, CleanupTasksPerformer.CleanupTask.class).addBinding().to(CassandraTruncateTableTask.class)) .overrideWith((binder -> binder.bind(CleanupTasksPerformer.class).asEagerSingleton())); - mainStepdefs.awaitMethod = () -> embeddedElasticSearch.awaitForElasticSearch(); + mainStepdefs.awaitMethod = () -> elasticSearch.getDockerEs().awaitForElasticSearch(); mainStepdefs.init(); } @@ -94,7 +94,7 @@ public class CassandraStepdefs { public void tearDown() { ignoreFailures(imapStepdefs::closeConnections, mainStepdefs::tearDown, - () -> embeddedElasticSearch.after(), + () -> elasticSearch.getDockerEs().cleanUpData(), () -> temporaryFolder.delete()); } diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberElasticSearchSingleton.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberElasticSearchSingleton.java new file mode 100644 index 0000000..0abec72 --- /dev/null +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberElasticSearchSingleton.java @@ -0,0 +1,27 @@ +/**************************************************************** + * 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.jmap.cassandra.cucumber; + +import org.apache.james.DockerElasticSearchRule; + +public class CucumberElasticSearchSingleton { + + public static final DockerElasticSearchRule elasticSearch = new DockerElasticSearchRule(); + +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org