Repository: james-project Updated Branches: refs/heads/master 86debb669 -> 22050c479
JAMES-2470 Reduce Cassandra table creation Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1afb7168 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1afb7168 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1afb7168 Branch: refs/heads/master Commit: 1afb716833b0c59a2f43e5522f9f9e5885b69baf Parents: e149f40 Author: benwa <[email protected]> Authored: Thu Jul 19 15:59:24 2018 +0700 Committer: benwa <[email protected]> Committed: Fri Jul 20 18:17:55 2018 +0700 ---------------------------------------------------------------------- .../cassandra/init/CassandraTableManager.java | 32 +++++++++++-- .../backends/cassandra/CassandraCluster.java | 2 + .../cassandra/CassandraMailboxManagerTest.java | 10 ---- .../CassandraMessageIdManagerStorageTest.java | 10 ---- .../mail/CassandraAttachmentOwnerDAOTest.java | 6 +++ .../mail/CassandraMessageMapperTest.java | 10 ---- .../migration/MailboxPathV2MigrationTest.java | 9 +++- .../james/server/CassandraCleanupProbe.java | 40 ++++++++++++++++ .../org/apache/james/DockerCassandraRule.java | 17 ++++--- .../apache/james/FixingGhostMailboxTest.java | 8 ---- .../modules/CassandraJmapServerModule.java | 49 -------------------- ...assandraMailRepositoryUrlStoreExtension.java | 21 +++++++-- .../cassandra/CassandraBulkOperationTest.java | 7 --- .../CassandraForwardIntegrationTest.java | 7 --- .../CassandraGetMailboxesMethodTest.java | 7 --- .../CassandraGetMessageListMethodTest.java | 7 --- .../CassandraGetVacationResponseTest.java | 7 --- .../CassandraJmapAuthenticationTest.java | 7 --- .../cassandra/CassandraProvisioningTest.java | 7 --- .../cassandra/CassandraSendMDNMethodTest.java | 7 --- .../CassandraSetMailboxesMethodTest.java | 7 --- .../CassandraSetMessagesMethodTest.java | 7 --- .../CassandraSetVacationResponseTest.java | 7 --- .../CassandraVacationIntegrationTest.java | 7 --- .../CassandraVacationRelayIntegrationTest.java | 7 --- .../cassandra/cucumber/CassandraStepdefs.java | 24 ++++++++-- .../cucumber/CucumberCassandraSingleton.java | 2 +- 27 files changed, 132 insertions(+), 199 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTableManager.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTableManager.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTableManager.java index 66d8ba2..da0de55 100644 --- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTableManager.java +++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTableManager.java @@ -19,8 +19,17 @@ package org.apache.james.backends.cassandra.init; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import javax.inject.Inject; + import org.apache.james.backends.cassandra.components.CassandraModule; +import org.apache.james.backends.cassandra.components.CassandraTable; +import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor; +import org.apache.james.util.FluentFutureStream; +import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Session; import com.datastax.driver.core.querybuilder.QueryBuilder; @@ -29,6 +38,7 @@ public class CassandraTableManager { private final Session session; private final CassandraModule module; + @Inject public CassandraTableManager(CassandraModule module, Session session) { this.session = session; this.module = module; @@ -41,11 +51,25 @@ public class CassandraTableManager { } public void clearAllTables() { - module.moduleTables() - .forEach(table -> clearTable(table.getName())); + CassandraAsyncExecutor executor = new CassandraAsyncExecutor(session); + FluentFutureStream.of( + module.moduleTables() + .stream() + .map(CassandraTable::getName) + .map(name -> truncate(executor, name))) + .join(); + } + + private CompletableFuture<?> truncate(CassandraAsyncExecutor executor, String name) { + return executor.execute( + QueryBuilder.select().from(name).limit(1)) + .thenCompose(resultSet -> truncateIfNeeded(executor, name, resultSet)); } - private void clearTable(String tableName) { - session.execute(QueryBuilder.truncate(tableName)); + private CompletionStage<ResultSet> truncateIfNeeded(CassandraAsyncExecutor executor, String name, ResultSet resultSet) { + if (resultSet.isExhausted()) { + return CompletableFuture.completedFuture(null); + } + return executor.execute(QueryBuilder.truncate(name)); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java index eec7c80..03490c9 100644 --- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java +++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraCluster.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.apache.james.backends.cassandra.components.CassandraModule; +import org.apache.james.backends.cassandra.init.CassandraTableManager; import org.apache.james.backends.cassandra.init.CassandraTypesProvider; import org.apache.james.backends.cassandra.init.ClusterBuilder; import org.apache.james.backends.cassandra.init.ClusterWithKeyspaceCreatedFactory; @@ -85,6 +86,7 @@ public final class CassandraCluster implements AutoCloseable { @Override public void close() { + new CassandraTableManager(module, session).clearAllTables(); cluster.closeAsync(); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java index 795afec..4594300 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java @@ -19,7 +19,6 @@ package org.apache.james.mailbox.cassandra; import org.apache.james.backends.cassandra.CassandraCluster; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.backends.cassandra.DockerCassandraRule; import org.apache.james.backends.cassandra.init.CassandraModuleComposite; import org.apache.james.blob.cassandra.CassandraBlobModule; @@ -42,19 +41,10 @@ import org.apache.james.mailbox.cassandra.modules.CassandraUidModule; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraMailboxManagerTest extends MailboxManagerTest { @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule(); - - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart() - .container(cassandraServer.getRawContainer()) - .build(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); private CassandraCluster cassandra; http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java index 8e9750c..5e3b728 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerStorageTest.java @@ -22,7 +22,6 @@ package org.apache.james.mailbox.cassandra; import static org.mockito.Mockito.mock; import org.apache.james.backends.cassandra.CassandraCluster; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.backends.cassandra.DockerCassandraRule; import org.apache.james.backends.cassandra.init.CassandraModuleComposite; import org.apache.james.blob.cassandra.CassandraBlobModule; @@ -46,8 +45,6 @@ import org.apache.james.mailbox.store.quota.NoQuotaManager; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraMessageIdManagerStorageTest extends AbstractMessageIdManagerStorageTest { @@ -55,13 +52,6 @@ public class CassandraMessageIdManagerStorageTest extends AbstractMessageIdManag private CassandraCluster cassandra; - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart() - .container(cassandraServer.getRawContainer()) - .build(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - @Override @Before public void setUp() throws Exception { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java index 758ae57..6423c16 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java @@ -29,6 +29,7 @@ import org.apache.james.backends.cassandra.utils.CassandraUtils; import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule; import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.Username; +import org.junit.After; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; @@ -53,6 +54,11 @@ public class CassandraAttachmentOwnerDAOTest { CassandraUtils.WITH_DEFAULT_CONFIGURATION); } + @After + public void tearDown() { + cassandra.close(); + } + @Test public void retrieveOwnersShouldReturnEmptyByDefault() { assertThat(testee.retrieveOwners(ATTACHMENT_ID).join()) http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java index fa64788..572b8c7 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java @@ -20,7 +20,6 @@ package org.apache.james.mailbox.cassandra.mail; import org.apache.james.backends.cassandra.CassandraCluster; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.backends.cassandra.DockerCassandraRule; import org.apache.james.backends.cassandra.init.CassandraModuleComposite; import org.apache.james.blob.cassandra.CassandraBlobModule; @@ -41,20 +40,11 @@ import org.apache.james.mailbox.store.mail.model.MessageMapperTest; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraMessageMapperTest extends MessageMapperTest { @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart() - .container(cassandraServer.getRawContainer()) - .build(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - private CassandraCluster cassandra; @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java index c1da035..85af4a4 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java @@ -39,6 +39,7 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox; import org.assertj.core.api.SoftAssertions; +import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -50,6 +51,7 @@ public class MailboxPathV2MigrationTest { private static final int UID_VALIDITY_1 = 452; private static final SimpleMailbox MAILBOX_1 = new SimpleMailbox(MAILBOX_PATH_1, UID_VALIDITY_1); private static final CassandraId MAILBOX_ID_1 = CassandraId.timeBased(); + private CassandraCluster cassandra; @BeforeClass public static void setUpClass() { @@ -66,7 +68,7 @@ public class MailboxPathV2MigrationTest { @Before public void setUp() { - CassandraCluster cassandra = CassandraCluster.create( + cassandra = CassandraCluster.create( new CassandraModuleComposite( new CassandraMailboxModule(), new CassandraAclModule()), @@ -91,6 +93,11 @@ public class MailboxPathV2MigrationTest { new CassandraACLMapper(cassandra.getConf(), userMailboxRightsDAO, CassandraConfiguration.DEFAULT_CONFIGURATION)); } + @After + public void tearDown() { + cassandra.close(); + } + @Test public void newValuesShouldBeSavedInMostRecentDAO() throws Exception { mailboxMapper.save(MAILBOX_1); http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java new file mode 100644 index 0000000..fe8989d --- /dev/null +++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/server/CassandraCleanupProbe.java @@ -0,0 +1,40 @@ +/**************************************************************** + * 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.server; + +import javax.annotation.PreDestroy; +import javax.inject.Inject; + +import org.apache.james.backends.cassandra.init.CassandraTableManager; +import org.apache.james.utils.GuiceProbe; + +public class CassandraCleanupProbe implements GuiceProbe { + private final CassandraTableManager tableManager; + + @Inject + public CassandraCleanupProbe(CassandraTableManager tableManager) { + this.tableManager = tableManager; + } + + @PreDestroy + public void clearAllTables() { + tableManager.clearAllTables(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java index 1196586..cbf2fe4 100644 --- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java +++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerCassandraRule.java @@ -18,15 +18,18 @@ ****************************************************************/ package org.apache.james; -import org.apache.commons.text.RandomStringGenerator; + import org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration; +import org.apache.james.server.CassandraCleanupProbe; import org.apache.james.util.Host; +import org.apache.james.utils.GuiceProbe; import org.junit.runner.Description; import org.junit.runners.model.Statement; import org.testcontainers.containers.GenericContainer; import com.google.inject.Module; - +import com.google.inject.multibindings.Multibinder; +import com.google.inject.util.Modules; public class DockerCassandraRule implements GuiceModuleTestRule { @@ -43,15 +46,17 @@ public class DockerCassandraRule implements GuiceModuleTestRule { @Override public Module getModule() { - String keyspace = new RandomStringGenerator.Builder().withinRange('a', 'z').build().generate(12); - return (binder) -> binder.bind(ClusterConfiguration.class) + return Modules.combine((binder) -> binder.bind(ClusterConfiguration.class) .toInstance(ClusterConfiguration.builder() .host(cassandraContainer.getHost()) - .keyspace(keyspace) + .keyspace("testing") .replicationFactor(1) .maxRetry(20) .minDelay(5000) - .build()); + .build()), + binder -> Multibinder.newSetBinder(binder, GuiceProbe.class) + .addBinding() + .to(CassandraCleanupProbe.class)); } public String getIp() { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java index 3b10005..9def511 100644 --- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java +++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java @@ -40,7 +40,6 @@ import static org.hamcrest.Matchers.nullValue; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.mailbox.MessageManager.AppendCommand; import org.apache.james.mailbox.cassandra.mail.task.MailboxMergingTask; @@ -71,7 +70,6 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestRule; import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; @@ -85,19 +83,13 @@ public class FixingGhostMailboxTest { private static final String NAME = "[0][0]"; private static final String ARGUMENTS = "[0][1]"; private static final String FIRST_MAILBOX = ARGUMENTS + ".list[0]"; - public static final boolean RECENT = true; @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - private AccessToken accessToken; private String domain; private String alice; http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java deleted file mode 100644 index 23cebc4..0000000 --- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java +++ /dev/null @@ -1,49 +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.modules; - -import org.apache.james.backends.es.EmbeddedElasticSearch; -import org.apache.james.mailbox.extractor.TextExtractor; -import org.apache.james.mailbox.store.extractor.DefaultTextExtractor; -import org.apache.james.util.Host; - -import com.google.inject.AbstractModule; - -public class CassandraJmapServerModule extends AbstractModule { - - private static final int LIMIT_TO_3_MESSAGES = 3; - private final EmbeddedElasticSearch embeddedElasticSearch; - private final Host cassandraHost; - - public CassandraJmapServerModule(EmbeddedElasticSearch embeddedElasticSearch, Host cassandraHost) { - this.embeddedElasticSearch = embeddedElasticSearch; - this.cassandraHost = cassandraHost; - } - - @Override - protected void configure() { - install(new CassandraTestModule(cassandraHost)); - install(new TestElasticSearchModule(embeddedElasticSearch)); - install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES)); - - install(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class)); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java ---------------------------------------------------------------------- diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java b/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java index 2dec108..7d9bee9 100644 --- a/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java +++ b/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java @@ -24,14 +24,17 @@ import org.apache.james.backends.cassandra.DockerCassandraRule; import org.apache.james.backends.cassandra.utils.CassandraUtils; import org.apache.james.mailrepository.api.MailRepositoryUrlStore; import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; 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; -public class CassandraMailRepositoryUrlStoreExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback { +public class CassandraMailRepositoryUrlStoreExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback, AfterEachCallback, BeforeEachCallback { private final DockerCassandraRule cassandra; + private CassandraCluster cassandraCluster; public CassandraMailRepositoryUrlStoreExtension() { this.cassandra = new DockerCassandraRule(); @@ -43,6 +46,18 @@ public class CassandraMailRepositoryUrlStoreExtension implements ParameterResolv } @Override + public void beforeEach(ExtensionContext context) { + cassandraCluster = CassandraCluster.create( + new CassandraMailRepositoryUrlModule(), + cassandra.getHost()); + } + + @Override + public void afterEach(ExtensionContext context) { + cassandraCluster.close(); + } + + @Override public void afterAll(ExtensionContext context) { cassandra.stop(); } @@ -54,9 +69,7 @@ public class CassandraMailRepositoryUrlStoreExtension implements ParameterResolv @Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { - CassandraCluster cassandraCluster = CassandraCluster.create( - new CassandraMailRepositoryUrlModule(), - cassandra.getHost()); + return new CassandraMailRepositoryUrlStore( new UrlsDao( http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraBulkOperationTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraBulkOperationTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraBulkOperationTest.java index 8aa327c..6d56aff 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraBulkOperationTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraBulkOperationTest.java @@ -38,7 +38,6 @@ import java.util.stream.IntStream; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration; import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; @@ -55,7 +54,6 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestRule; import com.jayway.restassured.RestAssured; import com.jayway.restassured.parsing.Parser; @@ -66,14 +64,9 @@ public class CassandraBulkOperationTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - private static final String USERNAME = "username@" + DOMAIN; private static final MailboxPath TRASH_PATH = MailboxPath.forUser(USERNAME, DefaultMailboxes.TRASH); private static final String PASSWORD = "password"; http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java index 293228a..559ea93 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraForwardIntegrationTest.java @@ -24,25 +24,18 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.ForwardIntegrationTest; import org.apache.james.webadmin.WebAdminConfiguration; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraForwardIntegrationTest extends ForwardIntegrationTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); @Override protected GuiceJamesServer createJmapServer() throws IOException { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java index 67a1464..3d4b68b 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java @@ -24,24 +24,17 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.GetMailboxesMethodTest; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraGetMailboxesMethodTest extends GetMailboxesMethodTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); @Override protected GuiceJamesServer createJmapServer() throws IOException { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java index ed41abe..9357f42 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java @@ -24,26 +24,19 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.GetMessageListMethodTest; import org.apache.james.modules.TestJMAPServerModule; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraGetMessageListMethodTest extends GetMessageListMethodTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - @Override protected GuiceJamesServer createJmapServer() throws IOException { return rule.jmapServer(cassandra.getModule(), http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java index e8593fe..c4497b6 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java @@ -24,25 +24,18 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.GetVacationResponseTest; import org.apache.james.util.date.ZonedDateTimeProvider; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraGetVacationResponseTest extends GetVacationResponseTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); @Override protected GuiceJamesServer createJmapServer(ZonedDateTimeProvider zonedDateTimeProvider) throws IOException { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java index 64c2e2c..791f337 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java @@ -23,26 +23,19 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.FixedDateZonedDateTimeProvider; import org.apache.james.jmap.JMAPAuthenticationTest; import org.apache.james.util.date.ZonedDateTimeProvider; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraJmapAuthenticationTest extends JMAPAuthenticationTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); @Override protected GuiceJamesServer createJmapServer(FixedDateZonedDateTimeProvider zonedDateTimeProvider) throws IOException { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraProvisioningTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraProvisioningTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraProvisioningTest.java index 5abfdd2..ffb726a 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraProvisioningTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraProvisioningTest.java @@ -24,25 +24,18 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.ProvisioningTest; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraProvisioningTest extends ProvisioningTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - @Override protected GuiceJamesServer createJmapServer() throws IOException { return rule.jmapServer(cassandra.getModule()); http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSendMDNMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSendMDNMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSendMDNMethodTest.java index 2e7ddd8..c77853b 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSendMDNMethodTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSendMDNMethodTest.java @@ -24,27 +24,20 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.SendMDNMethodTest; import org.apache.james.mailbox.cassandra.ids.CassandraMessageId; import org.apache.james.mailbox.model.MessageId; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraSendMDNMethodTest extends SendMDNMethodTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - @Override protected GuiceJamesServer createJmapServer() throws IOException { return rule.jmapServer(cassandra.getModule()); http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java index cd5d011..4b81728 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java @@ -24,25 +24,18 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.SetMailboxesMethodTest; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraSetMailboxesMethodTest extends SetMailboxesMethodTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); @Override protected GuiceJamesServer createJmapServer() throws IOException { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java index c4ad90a..3de53d3 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java @@ -24,7 +24,6 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.SetMessagesMethodTest; import org.apache.james.mailbox.cassandra.ids.CassandraMessageId; import org.apache.james.mailbox.model.MessageId; @@ -32,21 +31,15 @@ import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestRule; public class CassandraSetMessagesMethodTest extends SetMessagesMethodTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - @Override protected GuiceJamesServer createJmapServer() throws IOException { return rule.jmapServer(cassandra.getModule()); http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java index cb7fbfd..3e8ad35 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetVacationResponseTest.java @@ -24,24 +24,17 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.methods.integration.SetVacationResponseTest; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraSetVacationResponseTest extends SetVacationResponseTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); @Override protected GuiceJamesServer createJmapServer() throws IOException { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationIntegrationTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationIntegrationTest.java index d501807..08321df 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationIntegrationTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationIntegrationTest.java @@ -24,24 +24,17 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.jmap.VacationIntegrationTest; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraVacationIntegrationTest extends VacationIntegrationTest { @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); @Override protected GuiceJamesServer createJmapServer() throws IOException { http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java index 71382b5..1e81479 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraVacationRelayIntegrationTest.java @@ -24,13 +24,11 @@ import java.io.IOException; import org.apache.james.CassandraJmapTestRule; import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration; import org.apache.james.dnsservice.api.DNSService; import org.apache.james.dnsservice.api.InMemoryDNSService; import org.apache.james.jmap.VacationRelayIntegrationTest; import org.junit.ClassRule; import org.junit.Rule; -import org.junit.rules.TestRule; public class CassandraVacationRelayIntegrationTest extends VacationRelayIntegrationTest { @@ -39,14 +37,9 @@ public class CassandraVacationRelayIntegrationTest extends VacationRelayIntegrat @ClassRule public static DockerCassandraRule cassandra = new DockerCassandraRule(); - public static ContainerLifecycleConfiguration cassandraLifecycleConfiguration = ContainerLifecycleConfiguration.withDefaultIterationsBetweenRestart().container(cassandra.getRawContainer()).build(); - @Rule public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule(); - @Rule - public TestRule cassandraLifecycleTestRule = cassandraLifecycleConfiguration.asTestRule(); - @Override protected GuiceJamesServer getJmapServer() throws IOException { return rule.jmapServer( http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java ---------------------------------------------------------------------- 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 cc6f34d..1e16410 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 @@ -27,18 +27,26 @@ import javax.inject.Inject; import org.apache.activemq.store.PersistenceAdapter; import org.apache.activemq.store.memory.MemoryPersistenceAdapter; +import org.apache.james.DockerCassandraRule; import org.apache.james.GuiceJamesServer; -import org.apache.james.backends.cassandra.DockerCassandraRule; 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.elasticsearch.MailboxElasticSearchConstants; -import org.apache.james.modules.CassandraJmapServerModule; +import org.apache.james.mailbox.extractor.TextExtractor; +import org.apache.james.mailbox.store.extractor.DefaultTextExtractor; +import org.apache.james.mailbox.store.search.PDFTextExtractor; +import org.apache.james.modules.TestESMetricReporterModule; +import org.apache.james.modules.TestElasticSearchModule; +import org.apache.james.modules.TestJMAPServerModule; +import org.apache.james.server.CassandraCleanupProbe; import org.apache.james.server.core.configuration.Configuration; +import org.apache.james.utils.GuiceProbe; import org.junit.rules.TemporaryFolder; import com.github.fge.lambdas.runnable.ThrowingRunnable; +import com.google.inject.multibindings.Multibinder; import cucumber.api.java.After; import cucumber.api.java.Before; @@ -70,9 +78,15 @@ public class CassandraStepdefs { .build(); mainStepdefs.jmapServer = new GuiceJamesServer(configuration) - .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE) - .overrideWith(new CassandraJmapServerModule(embeddedElasticSearch, cassandraServer.getHost())) - .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)); + .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE) + .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class)) + .overrideWith(new TestJMAPServerModule(10)) + .overrideWith(new TestESMetricReporterModule()) + .overrideWith(new TestElasticSearchModule(embeddedElasticSearch)) + .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, GuiceProbe.class).addBinding().to(CassandraCleanupProbe.class)); mainStepdefs.awaitMethod = () -> embeddedElasticSearch.awaitForElasticSearch(); mainStepdefs.init(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/1afb7168/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberCassandraSingleton.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberCassandraSingleton.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberCassandraSingleton.java index 2d963e5..c3e94f9 100644 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberCassandraSingleton.java +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CucumberCassandraSingleton.java @@ -18,7 +18,7 @@ ****************************************************************/ package org.apache.james.jmap.cassandra.cucumber; -import org.apache.james.backends.cassandra.DockerCassandraRule; +import org.apache.james.DockerCassandraRule; public class CucumberCassandraSingleton { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
