james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [10/13] james-project git commit: JAMES-2133 Switch from cassandraunit to cassandra in docker
Date Sat, 02 Sep 2017 06:00:12 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java
new file mode 100644
index 0000000..473a56e
--- /dev/null
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraConfigurationTest.java
@@ -0,0 +1,233 @@
+/****************************************************************
+ * 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.cassandra.init;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
+import org.assertj.core.api.JUnitSoftAssertions;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class CassandraConfigurationTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Rule
+    public final JUnitSoftAssertions softly = new JUnitSoftAssertions();
+
+    @Test
+    public void cassandraConfigurationShouldRespectBeanContract() {
+        EqualsVerifier.forClass(CassandraConfiguration.class).verify();
+    }
+
+    @Test
+    public void defaultBuilderShouldConstructDefaultConfiguration() {
+        assertThat(CassandraConfiguration.builder().build())
+            .isEqualTo(CassandraConfiguration.DEFAULT_CONFIGURATION);
+    }
+
+    @Test
+    public void aclMaxRetryShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .aclMaxRetry(-1);
+    }
+
+    @Test
+    public void aclMaxRetryShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .aclMaxRetry(0);
+    }
+
+    @Test
+    public void expungeChunkSizeShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .expungeChunkSize(-1);
+    }
+
+    @Test
+    public void expungeChunkSizeShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .expungeChunkSize(0);
+    }
+
+    @Test
+    public void messageReadChunkSizeShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .messageReadChunkSize(-1);
+    }
+
+    @Test
+    public void messageReadChunkSizeShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .messageReadChunkSize(0);
+    }
+
+    @Test
+    public void flagsUpdateChunkSizeShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .flagsUpdateChunkSize(-1);
+    }
+
+    @Test
+    public void flagsUpdateChunkSizeShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .flagsUpdateChunkSize(0);
+    }
+
+    @Test
+    public void flagsUpdateMessageIdMaxRetryShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .flagsUpdateMessageIdMaxRetry(-1);
+    }
+
+    @Test
+    public void flagsUpdateMessageIdMaxRetryShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .flagsUpdateMessageIdMaxRetry(0);
+    }
+
+    @Test
+    public void flagsUpdateMessageMaxRetryShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .flagsUpdateMessageMaxRetry(-1);
+    }
+
+    @Test
+    public void flagsUpdateMessageMaxRetryShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .flagsUpdateMessageMaxRetry(0);
+    }
+
+    @Test
+    public void fetchNextPageInAdvanceRowShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .fetchNextPageInAdvanceRow(-1);
+    }
+
+    @Test
+    public void fetchNextPageInAdvanceRowShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .fetchNextPageInAdvanceRow(0);
+    }
+
+    @Test
+    public void modSeqMaxRetryShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .modSeqMaxRetry(-1);
+    }
+
+    @Test
+    public void modSeqMaxRetryShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .modSeqMaxRetry(0);
+    }
+
+    @Test
+    public void uidMaxRetryShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .uidMaxRetry(-1);
+    }
+
+    @Test
+    public void uidMaxRetryShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .uidMaxRetry(0);
+    }
+
+    @Test
+    public void builderShouldCreateTheRightObject() {
+        int aclMaxRetry = 1;
+        int modSeqMaxRetry = 2;
+        int uidMaxRetry = 3;
+        int fetchNextPageInAdvanceRow = 4;
+        int flagsUpdateMessageMaxRetry = 5;
+        int flagsUpdateMessageIdMaxRetry = 6;
+        int flagsUpdateChunkSize = 7;
+        int messageReadChunkSize = 8;
+        int expungeChunkSize = 9;
+        int blobPartSize = 10;
+
+        CassandraConfiguration configuration = CassandraConfiguration.builder()
+            .aclMaxRetry(aclMaxRetry)
+            .modSeqMaxRetry(modSeqMaxRetry)
+            .uidMaxRetry(uidMaxRetry)
+            .fetchNextPageInAdvanceRow(fetchNextPageInAdvanceRow)
+            .flagsUpdateMessageMaxRetry(flagsUpdateMessageMaxRetry)
+            .flagsUpdateMessageIdMaxRetry(flagsUpdateMessageIdMaxRetry)
+            .flagsUpdateChunkSize(flagsUpdateChunkSize)
+            .messageReadChunkSize(messageReadChunkSize)
+            .expungeChunkSize(expungeChunkSize)
+            .blobPartSize(blobPartSize)
+            .build();
+
+        softly.assertThat(configuration.getAclMaxRetry()).isEqualTo(aclMaxRetry);
+        softly.assertThat(configuration.getModSeqMaxRetry()).isEqualTo(modSeqMaxRetry);
+        softly.assertThat(configuration.getUidMaxRetry()).isEqualTo(uidMaxRetry);
+        softly.assertThat(configuration.getFetchNextPageInAdvanceRow()).isEqualTo(fetchNextPageInAdvanceRow);
+        softly.assertThat(configuration.getFlagsUpdateMessageMaxRetry()).isEqualTo(flagsUpdateMessageMaxRetry);
+        softly.assertThat(configuration.getFlagsUpdateMessageIdMaxRetry()).isEqualTo(flagsUpdateMessageIdMaxRetry);
+        softly.assertThat(configuration.getFlagsUpdateChunkSize()).isEqualTo(flagsUpdateChunkSize);
+        softly.assertThat(configuration.getMessageReadChunkSize()).isEqualTo(messageReadChunkSize);
+        softly.assertThat(configuration.getExpungeChunkSize()).isEqualTo(expungeChunkSize);
+        softly.assertThat(configuration.getBlobPartSize()).isEqualTo(blobPartSize);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
index 67fe7ee..3517349 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
@@ -19,27 +19,32 @@
 
 package org.apache.james.backends.cassandra.init;
 
-import java.util.Arrays;
-import java.util.List;
-
 import static com.datastax.driver.core.DataType.text;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.fail;
 
-import com.datastax.driver.core.schemabuilder.SchemaBuilder;
-import com.google.common.collect.ImmutableList;
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.backends.cassandra.components.CassandraTable;
 import org.apache.james.backends.cassandra.components.CassandraType;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
+import com.google.common.collect.ImmutableList;
+
 public class CassandraTypeProviderTest {
 
     private static final String TYPE_NAME = "typename";
     private static final String PROPERTY = "property";
+
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
     
     private CassandraCluster cassandra;
     private CassandraModule module;
@@ -58,13 +63,13 @@ public class CassandraTypeProviderTest {
                         .addColumn(PROPERTY, text()))));
             }
         };
-        cassandra = CassandraCluster.create(module);
+        cassandra = CassandraCluster.create(module, cassandraServer.getIp(), cassandraServer.getBindingPort());
         cassandra.getTypesProvider();
-        cassandra.ensureAllTables();
     }
 
     @After
     public void tearDown() {
+        cassandra.close();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
index a9fc183..bc0f678 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
@@ -29,12 +29,14 @@ import java.util.UUID;
 import java.util.stream.IntStream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.backends.cassandra.components.CassandraTable;
 import org.apache.james.backends.cassandra.components.CassandraType;
 import org.apache.james.util.CompletableFutureUtil;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.datastax.driver.core.DataType;
@@ -43,17 +45,20 @@ import com.datastax.driver.core.utils.UUIDs;
 import com.google.common.collect.ImmutableList;
 
 public class PaggingTest {
+    
     private static final String TABLE_NAME = "test";
     private static final String ID = "id";
     private static final String CLUSTERING = "clustering";
     private static final UUID UUID = UUIDs.timeBased();
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraAsyncExecutor executor;
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraModule() {
+        CassandraModule modules = new CassandraModule() {
             @Override
             public List<CassandraTable> moduleTables() {
                 return ImmutableList.of(new CassandraTable(TABLE_NAME,
@@ -67,14 +72,14 @@ public class PaggingTest {
             public List<CassandraType> moduleTypes() {
                 return ImmutableList.of();
             }
-        });
-        cassandra.ensureAllTables();
+        };
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
         executor = new CassandraAsyncExecutor(cassandra.getConf());
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
+        cassandra.close();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
index 41b8efd..5e61068 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
@@ -24,28 +24,30 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Optional;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraSchemaVersionDAOTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
     private CassandraCluster cassandra;
 
     private CassandraSchemaVersionDAO testee;
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraSchemaVersionModule());
-        cassandra.ensureAllTables();
+        cassandra = CassandraCluster.create(new CassandraSchemaVersionModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
 
         testee = new CassandraSchemaVersionDAO(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
         cassandra.close();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/backends-common/cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/resources/logback-test.xml b/backends-common/cassandra/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..7f9da84
--- /dev/null
+++ b/backends-common/cassandra/src/test/resources/logback-test.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+        <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
+                <resetJUL>true</resetJUL>
+        </contextListener>
+
+        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+                <encoder>
+                        <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
+                        <immediateFlush>false</immediateFlush>
+                </encoder>
+        </appender>
+
+        <root level="INFO">
+                <appender-ref ref="CONSOLE" />
+        </root>
+
+
+        <logger name="org.apache.james" level="DEBUG" >
+                <appender-ref ref="CONSOLE" />
+        </logger>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ClientProviderImplConnectionTest.java
----------------------------------------------------------------------
diff --git a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ClientProviderImplConnectionTest.java b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ClientProviderImplConnectionTest.java
index f6be380..ea93049 100644
--- a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ClientProviderImplConnectionTest.java
+++ b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ClientProviderImplConnectionTest.java
@@ -52,7 +52,7 @@ public class ClientProviderImplConnectionTest {
         Awaitility.await()
             .atMost(1, TimeUnit.MINUTES)
             .pollInterval(5, TimeUnit.SECONDS)
-            .until(() -> isConnected(ClientProviderImpl.forHost(es1.getIp(), 9300)));
+            .until(() -> isConnected(ClientProviderImpl.forHost(es1.getHostIp(), 9300)));
     }
 
     @Test
@@ -62,8 +62,8 @@ public class ClientProviderImplConnectionTest {
             .pollInterval(5, TimeUnit.SECONDS)
             .until(() ->isConnected(
                 ClientProviderImpl.fromHostsString(
-                    es1.getIp() + ":" + ES_APPLICATIVE_PORT + ","
-                    + es2.getIp() + ":" + ES_APPLICATIVE_PORT)));
+                    es1.getHostIp() + ":" + ES_APPLICATIVE_PORT + ","
+                    + es2.getHostIp() + ":" + ES_APPLICATIVE_PORT)));
     }
 
     @Test
@@ -75,8 +75,8 @@ public class ClientProviderImplConnectionTest {
             .pollInterval(5, TimeUnit.SECONDS)
             .until(() -> isConnected(
                 ClientProviderImpl.fromHostsString(
-                    es1.getIp() + ":" + ES_APPLICATIVE_PORT + ","
-                    + es2.getIp() + ":" + ES_APPLICATIVE_PORT)));
+                    es1.getHostIp() + ":" + ES_APPLICATIVE_PORT + ","
+                    + es2.getHostIp() + ":" + ES_APPLICATIVE_PORT)));
     }
 
     private boolean isConnected(ClientProvider clientProvider) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/api/src/test/java/org/apache/james/mailbox/AbstractSubscriptionManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/AbstractSubscriptionManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/AbstractSubscriptionManagerTest.java
index 3cff664..a34c6c1 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/AbstractSubscriptionManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/AbstractSubscriptionManagerTest.java
@@ -22,8 +22,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.mailbox.exception.SubscriptionException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -41,14 +39,12 @@ public abstract class AbstractSubscriptionManagerTest {
 
     public abstract SubscriptionManager createSubscriptionManager();
 
-    @Before
     public void setup() {
         manager = createSubscriptionManager();
         session = new MockMailboxSession(USER1);
         manager.startProcessingRequest(session);
     }
     
-    @After
     public void teardown() throws SubscriptionException {
         manager.unsubscribe(session, MAILBOX1);
         manager.unsubscribe(session, MAILBOX2);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
index a1e7f25..115f867 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
@@ -37,7 +37,6 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -50,8 +49,8 @@ public abstract class MailboxManagerStressTest {
 
     protected abstract MailboxManager provideManager();
 
-    @Before
-    public final void setUp() throws MailboxException {
+    
+    public void setUp() throws MailboxException, Exception {
         this.mailboxManager = provideManager();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 4e9f02d..226745c 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -38,9 +38,7 @@ import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxMetaData;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MailboxQuery;
-import org.junit.After;
 import org.junit.Assume;
-import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -83,12 +81,10 @@ public abstract class MailboxManagerTest {
 
     protected abstract MailboxManager provideMailboxManager();
 
-    @Before
-    public final void setUp() throws Exception {
+    public void setUp() throws Exception {
         this.mailboxManager = new MockMailboxManager(provideMailboxManager()).getMockMailboxManager();
     }
 
-    @After
     public void tearDown() throws Exception {
         mailboxManager.logout(session, false);
         mailboxManager.endProcessingRequest(session);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/pom.xml b/mailbox/cassandra/pom.xml
index 51b65ad..a36043b 100644
--- a/mailbox/cassandra/pom.xml
+++ b/mailbox/cassandra/pom.xml
@@ -68,6 +68,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
@@ -144,9 +149,8 @@
             <artifactId>slf4j-api</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
         </dependency>
     </dependencies>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
index 020e6a1..3d6ee37 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
@@ -21,7 +21,7 @@ package org.apache.james.mailbox.cassandra;
 
 import javax.inject.Inject;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.mail.CassandraAnnotationMapper;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
index 8cf4d76..9a951a2 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
@@ -29,7 +29,7 @@ import java.io.IOException;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.backends.cassandra.utils.CassandraConstants;
 import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
index 89173a7..73325db 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
@@ -30,7 +30,8 @@ import java.util.stream.IntStream;
 import java.util.stream.Stream;
 import javax.inject.Inject;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.mailbox.cassandra.ids.BlobId;
 import org.apache.james.mailbox.cassandra.mail.utils.DataChunker;
@@ -38,7 +39,6 @@ import org.apache.james.mailbox.cassandra.table.BlobTable;
 import org.apache.james.mailbox.cassandra.table.BlobTable.BlobParts;
 import org.apache.james.util.FluentFutureStream;
 import org.apache.james.util.OptionalUtils;
-import org.apache.commons.lang3.tuple.Pair;
 
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.Row;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAO.java
index 823ac59..6d06e5e 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAO.java
@@ -38,7 +38,7 @@ import java.util.stream.Stream;
 
 import javax.inject.Inject;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.init.CassandraTypesProvider;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
index 2e407ec..c170a73 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
@@ -29,7 +29,8 @@ import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import javax.inject.Inject;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.exception.MailboxException;
@@ -45,7 +46,6 @@ import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.apache.james.util.CompletableFutureUtil;
 import org.apache.james.util.FluentFutureStream;
 import org.apache.james.util.OptionalUtils;
-import org.apache.commons.lang3.StringUtils;
 
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.exceptions.InvalidQueryException;
@@ -97,7 +97,9 @@ public class CassandraMailboxMapper implements MailboxMapper {
                 .orElseThrow(() -> new MailboxNotFoundException(path));
         } catch (CompletionException e) {
             if (e.getCause() instanceof InvalidQueryException) {
-                if (StringUtils.containsIgnoreCase(e.getCause().getMessage(), VALUES_MAY_NOT_BE_LARGER_THAN_64_K)) {
+                String errorMessage = e.getCause().getMessage();
+                if (StringUtils.containsIgnoreCase(errorMessage, VALUES_MAY_NOT_BE_LARGER_THAN_64_K)||
+                    StringUtils.containsIgnoreCase(errorMessage, CLUSTERING_COLUMNS_IS_TOO_LONG)) {
                     throw new TooLongMailboxNameException("too long mailbox name");
                 }
                 throw new MailboxException("It has error with cassandra storage", e.getCause());

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
index e2a63f4..47830b2 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
@@ -49,7 +49,9 @@ import java.util.stream.Stream;
 import javax.inject.Inject;
 import javax.mail.util.SharedByteArrayInputStream;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.init.CassandraTypesProvider;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.mailbox.cassandra.ids.BlobId;
@@ -71,8 +73,6 @@ import org.apache.james.mailbox.store.mail.model.impl.SimpleProperty;
 import org.apache.james.util.CompletableFutureUtil;
 import org.apache.james.util.FluentFutureStream;
 import org.apache.james.util.streams.JamesCollectors;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.tuple.Pair;
 
 import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.PreparedStatement;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
index c9e7880..494cf91 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
@@ -28,7 +28,7 @@ import java.util.stream.Stream;
 import javax.mail.Flags;
 
 import org.apache.commons.lang3.tuple.Pair;
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.backends.cassandra.utils.LightweightTransactionException;
 import org.apache.james.mailbox.MailboxSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
index 2ae4928..957595a 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
@@ -30,7 +30,7 @@ import java.util.stream.Stream;
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.mailbox.ApplicableFlagBuilder;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MailboxSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
index d07a607..0cbfa3f 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
@@ -34,7 +34,7 @@ import java.util.concurrent.CompletionException;
 import java.util.function.Supplier;
 import javax.inject.Inject;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.mailbox.MailboxSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
index 4f061c2..c90a278 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
@@ -32,7 +32,7 @@ import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 import javax.inject.Inject;
 
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.mailbox.MailboxSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
index 3f96c22..bf341fe 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTest.java
@@ -21,28 +21,65 @@ 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.DockerCassandraRule;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.apache.james.mailbox.store.AbstractCombinationManagerTest;
 import org.apache.james.mailbox.store.CombinationManagerTestSystem;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.quota.NoQuotaManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraCombinationManagerTest extends AbstractCombinationManagerTest {
 
-    @BeforeClass
-    public static void init() {
-        CassandraCombinationManagerTestSystem.init();
-    }
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra;
 
-    @AfterClass
-    public static void close() {
-        CassandraCombinationManagerTestSystem.stop();
+    @Before
+    public void setUp() throws Exception {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraUidModule(),
+                new CassandraModSeqModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraBlobModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
     }
-
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     public CombinationManagerTestSystem createTestingData() throws Exception {
-        return CassandraCombinationManagerTestSystem.createTestingData(new NoQuotaManager(), MailboxEventDispatcher.ofListener(mock(MailboxListener.class)));
+        return CassandraCombinationManagerTestSystem.createTestingData(cassandra, new NoQuotaManager(), MailboxEventDispatcher.ofListener(mock(MailboxListener.class)));
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTestSystem.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTestSystem.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTestSystem.java
index 82eeec7..373dc4d 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTestSystem.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraCombinationManagerTestSystem.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.mailbox.cassandra;
 
+import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
@@ -35,8 +36,8 @@ public class CassandraCombinationManagerTestSystem extends CombinationManagerTes
     private final CassandraMailboxSessionMapperFactory mapperFactory;
     private final CassandraMailboxManager cassandraMailboxManager;
 
-    public static CombinationManagerTestSystem createTestingData(QuotaManager quotaManager, MailboxEventDispatcher dispatcher) throws Exception {
-        CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory();
+    public static CombinationManagerTestSystem createTestingData(CassandraCluster cassandra, QuotaManager quotaManager, MailboxEventDispatcher dispatcher) throws Exception {
+        CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory(cassandra);
 
         return new CassandraCombinationManagerTestSystem(CassandraTestSystemFixture.createMessageIdManager(mapperFactory, quotaManager, dispatcher),
             mapperFactory,
@@ -60,16 +61,4 @@ public class CassandraCombinationManagerTestSystem extends CombinationManagerTes
         return cassandraMailboxManager.createMessageManager(mailbox, session);
     }
 
-    @Override
-    public void clean() {
-        CassandraTestSystemFixture.clean();
-    }
-
-    public static void init() {
-        CassandraTestSystemFixture.init();
-    }
-
-    public static void stop() {
-        CassandraTestSystemFixture.stop();
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
index 93ec3c9..8c744fb 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.cassandra;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxManagerStressTest;
@@ -38,33 +39,45 @@ import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Ignore;
 
 @Ignore("https://issues.apache.org/jira/browse/JAMES-2009")
 public class CassandraMailboxManagerStressTest extends MailboxManagerStressTest {
-    private static final CassandraCluster CASSANDRA = CassandraCluster.create(new CassandraModuleComposite(
-        new CassandraAclModule(),
-        new CassandraMailboxModule(),
-        new CassandraMessageModule(),
-        new CassandraBlobModule(),
-        new CassandraMailboxCounterModule(),
-        new CassandraMailboxRecentsModule(),
-        new CassandraFirstUnseenModule(),
-        new CassandraUidModule(),
-        new CassandraModSeqModule(),
-        new CassandraSubscriptionModule(),
-        new CassandraAttachmentModule(),
-        new CassandraDeletedMessageModule(),
-        new CassandraAnnotationModule(),
-        new CassandraApplicableFlagsModule()));
-
+    
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra;
+    
+    @Before
+    public void setup() throws Exception {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraBlobModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraUidModule(),
+                new CassandraModSeqModule(),
+                new CassandraSubscriptionModule(),
+                new CassandraAttachmentModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraAnnotationModule(),
+                new CassandraApplicableFlagsModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
     @Override
     protected MailboxManager provideManager() {
-        return CassandraMailboxManagerProvider.provideMailboxManager(CASSANDRA.getConf(), CASSANDRA.getTypesProvider());
+        return CassandraMailboxManagerProvider.provideMailboxManager(cassandra.getConf(), cassandra.getTypesProvider());
     }
 
     @After
     public void tearDown() {
-        CASSANDRA.clearAllTables();
+        cassandra.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/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 9bc0934..13da244 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,6 +19,7 @@
 package org.apache.james.mailbox.cassandra;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxManagerTest;
@@ -37,37 +38,36 @@ import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMailboxManagerTest extends MailboxManagerTest {
 
-    private static CassandraCluster cassandra;
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
     
-    @BeforeClass
-    public static void init() {
-        cassandra = CassandraCluster.create(
-                new CassandraModuleComposite(
-                    new CassandraAclModule(),
-                    new CassandraMailboxModule(),
-                    new CassandraMessageModule(),
-                    new CassandraBlobModule(),
-                    new CassandraMailboxCounterModule(),
-                    new CassandraMailboxRecentsModule(),
-                    new CassandraFirstUnseenModule(),
-                    new CassandraUidModule(),
-                    new CassandraModSeqModule(),
-                    new CassandraSubscriptionModule(),
-                    new CassandraAttachmentModule(),
-                    new CassandraDeletedMessageModule(),
-                    new CassandraAnnotationModule(),
-                    new CassandraApplicableFlagsModule()));
-    }
-
-    @AfterClass
-    public static void close() {
-        cassandra.close();
+    private CassandraCluster cassandra;
+    
+    @Before
+    public void setup() throws Exception {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraBlobModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraUidModule(),
+                new CassandraModSeqModule(),
+                new CassandraSubscriptionModule(),
+                new CassandraAttachmentModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraAnnotationModule(),
+                new CassandraApplicableFlagsModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
     }
+    
 
     @Override
     protected MailboxManager provideMailboxManager() {
@@ -77,7 +77,7 @@ public class CassandraMailboxManagerTest extends MailboxManagerTest {
     @After
     public void tearDown() throws Exception {
         super.tearDown();
-        cassandra.clearAllTables();
+        cassandra.close();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java
index 423af97..15384f5 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerQuotaTest.java
@@ -19,35 +19,73 @@
 
 package org.apache.james.mailbox.cassandra;
 
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
+import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraQuotaModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.store.AbstractMessageIdManagerQuotaTest;
 import org.apache.james.mailbox.store.MessageIdManagerTestSystem;
 import org.apache.james.mailbox.store.quota.StoreQuotaManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMessageIdManagerQuotaTest extends AbstractMessageIdManagerQuotaTest {
 
-    @BeforeClass
-    public static void init() {
-        CassandraMessageIdManagerTestSystem.initWithQuota();
-    }
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
+    private CassandraCluster cassandra;
 
-    @AfterClass
-    public static void close() {
-        CassandraMessageIdManagerTestSystem.stop();
+    @Before
+    public void setUp() throws Exception {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraUidModule(),
+                new CassandraModSeqModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraQuotaModule(),
+                new CassandraBlobModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
     }
 
     @Override
     protected MessageIdManagerTestSystem createTestSystem(QuotaManager quotaManager, CurrentQuotaManager currentQuotaManager) throws Exception {
-        return CassandraMessageIdManagerTestSystem.createTestingDataWithQuota(quotaManager, currentQuotaManager);
+        return CassandraMessageIdManagerTestSystem.createTestingDataWithQuota(cassandra, quotaManager, currentQuotaManager);
     }
 
     @Override
     protected MaxQuotaManager createMaxQuotaManager() {
-        return CassandraTestSystemFixture.createMaxQuotaManager();
+        return CassandraTestSystemFixture.createMaxQuotaManager(cassandra);
     }
 
     @Override
@@ -57,6 +95,6 @@ public class CassandraMessageIdManagerQuotaTest extends AbstractMessageIdManager
 
     @Override
     protected CurrentQuotaManager createCurrentQuotaManager() {
-        return CassandraTestSystemFixture.createCurrentQuotaManager();
+        return CassandraTestSystemFixture.createCurrentQuotaManager(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerSideEffectTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerSideEffectTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerSideEffectTest.java
index 1468dc4..14877ed 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerSideEffectTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerSideEffectTest.java
@@ -19,27 +19,63 @@
 
 package org.apache.james.mailbox.cassandra;
 
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
+import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.store.AbstractMessageIdManagerSideEffectTest;
 import org.apache.james.mailbox.store.MessageIdManagerTestSystem;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMessageIdManagerSideEffectTest extends AbstractMessageIdManagerSideEffectTest {
 
-    @BeforeClass
-    public static void init() {
-        CassandraMessageIdManagerTestSystem.init();
-    }
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
+    private CassandraCluster cassandra;
 
-    @AfterClass
-    public static void close() {
-        CassandraMessageIdManagerTestSystem.stop();
+    @Before
+    public void setUp() throws Exception {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraUidModule(),
+                new CassandraModSeqModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraBlobModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
     }
 
     @Override
     protected MessageIdManagerTestSystem createTestSystem(QuotaManager quotaManager, MailboxEventDispatcher dispatcher) throws Exception {
-        return CassandraMessageIdManagerTestSystem.createTestingData(quotaManager, dispatcher);
+        return CassandraMessageIdManagerTestSystem.createTestingData(cassandra, quotaManager, dispatcher);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/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 34040a9..85b8dd9 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
@@ -21,28 +21,64 @@ 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.DockerCassandraRule;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.apache.james.mailbox.store.AbstractMessageIdManagerStorageTest;
 import org.apache.james.mailbox.store.MessageIdManagerTestSystem;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.quota.NoQuotaManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMessageIdManagerStorageTest extends AbstractMessageIdManagerStorageTest {
 
-    @BeforeClass
-    public static void init() {
-        CassandraMessageIdManagerTestSystem.init();
-    }
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
 
-    @AfterClass
-    public static void close() {
-        CassandraMessageIdManagerTestSystem.stop();
-    }
+    private CassandraCluster cassandra;
 
+    @Before
+    public void setUp() throws Exception {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraUidModule(),
+                new CassandraModSeqModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraBlobModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected MessageIdManagerTestSystem createTestingData() throws Exception {
-        return CassandraMessageIdManagerTestSystem.createTestingData(new NoQuotaManager(), MailboxEventDispatcher.ofListener(mock(MailboxListener.class)));
+        return CassandraMessageIdManagerTestSystem.createTestingData(cassandra, new NoQuotaManager(), MailboxEventDispatcher.ofListener(mock(MailboxListener.class)));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
index e7561be..174cca4 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMessageIdManagerTestSystem.java
@@ -24,6 +24,7 @@ import java.util.Date;
 import javax.mail.Flags;
 import javax.mail.util.SharedByteArrayInputStream;
 
+import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.MessageUid;
@@ -51,8 +52,8 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
 
     private static final byte[] MESSAGE_CONTENT = "subject: any\n\nbody".getBytes(Charsets.UTF_8);
 
-    public static MessageIdManagerTestSystem createTestingData(QuotaManager quotaManager, MailboxEventDispatcher dispatcher) throws Exception {
-        CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory();
+    public static MessageIdManagerTestSystem createTestingData(CassandraCluster cassandra, QuotaManager quotaManager, MailboxEventDispatcher dispatcher) throws Exception {
+        CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory(cassandra);
 
         return new CassandraMessageIdManagerTestSystem(CassandraTestSystemFixture.createMessageIdManager(mapperFactory, quotaManager, dispatcher),
             new CassandraMessageId.Factory(),
@@ -60,8 +61,8 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
             CassandraTestSystemFixture.createMailboxManager(mapperFactory));
     }
 
-    public static MessageIdManagerTestSystem createTestingDataWithQuota(QuotaManager quotaManager, CurrentQuotaManager currentQuotaManager) throws Exception {
-        CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory();
+    public static MessageIdManagerTestSystem createTestingDataWithQuota(CassandraCluster cassandra, QuotaManager quotaManager, CurrentQuotaManager currentQuotaManager) throws Exception {
+        CassandraMailboxSessionMapperFactory mapperFactory = CassandraTestSystemFixture.createMapperFactory(cassandra);
 
         CassandraMailboxManager mailboxManager = CassandraTestSystemFixture.createMailboxManager(mapperFactory);
         ListeningCurrentQuotaUpdater listeningCurrentQuotaUpdater = new ListeningCurrentQuotaUpdater(
@@ -120,11 +121,6 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
         }
     }
 
-    @Override
-    public void clean() {
-        CassandraTestSystemFixture.clean();
-    }
-
     private static MailboxMessage createMessage(MailboxId mailboxId, Flags flags, MessageId messageId, MessageUid uid) {
         MailboxMessage mailboxMessage = new SimpleMailboxMessage(messageId, new Date(), MESSAGE_CONTENT.length, 1256,
             new SharedByteArrayInputStream(MESSAGE_CONTENT), flags, new PropertyBuilder(), mailboxId);
@@ -133,18 +129,6 @@ public class CassandraMessageIdManagerTestSystem extends MessageIdManagerTestSys
         return mailboxMessage;
     }
 
-    public static void init() {
-        CassandraTestSystemFixture.init();
-    }
-
-    public static void initWithQuota() {
-        CassandraTestSystemFixture.initWithQuota();
-    }
-
-    public static void stop() {
-        CassandraTestSystemFixture.stop();
-    }
-
     @Override
     public int getConstantMessageSize() {
         return MESSAGE_CONTENT.length;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
index 93eb618..bd3a31e 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.cassandra;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.AbstractSubscriptionManagerTest;
 import org.apache.james.mailbox.SubscriptionManager;
@@ -39,28 +40,34 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.james.mailbox.exception.SubscriptionException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 /**
  * Test Cassandra subscription against some general purpose written code.
  */
 public class CassandraSubscriptionManagerTest extends AbstractSubscriptionManagerTest {
 
-    private static CassandraCluster cassandra;
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra;
 
-    @BeforeClass
-    public static void init() {
-        cassandra = CassandraCluster.create(
-            new CassandraModuleComposite(
-                new CassandraSubscriptionModule(),
-                new CassandraMailboxCounterModule(),
-                new CassandraUidModule(),
-                new CassandraModSeqModule()));
+    @Before
+    public void init() {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+            new CassandraSubscriptionModule(),
+            new CassandraMailboxCounterModule(),
+            new CassandraUidModule(),
+            new CassandraModSeqModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setup();
     }
 
-    @AfterClass
-    public static void close() {
+    @After
+    public void close() throws SubscriptionException {
+        super.teardown();
         cassandra.close();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index c38adf5..6450073 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.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.init.CassandraModuleComposite;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
 import org.apache.james.mailbox.cassandra.mail.CassandraApplicableFlagDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraBlobsDAO;
@@ -37,20 +36,6 @@ import org.apache.james.mailbox.cassandra.mail.CassandraMessageIdDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraMessageIdToImapUidDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
 import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
-import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraQuotaModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.apache.james.mailbox.cassandra.quota.CassandraCurrentQuotaManager;
 import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
@@ -68,24 +53,8 @@ import org.apache.james.mailbox.store.quota.StoreQuotaManager;
 public class CassandraTestSystemFixture {
     
     public static final int MOD_SEQ = 452;
-    public static final CassandraModuleComposite BASE_MAILBOX_MODULES = new CassandraModuleComposite(
-        new CassandraAclModule(),
-        new CassandraMailboxModule(),
-        new CassandraMessageModule(),
-        new CassandraBlobModule(),
-        new CassandraMailboxCounterModule(),
-        new CassandraMailboxRecentsModule(),
-        new CassandraFirstUnseenModule(),
-        new CassandraDeletedMessageModule(),
-        new CassandraUidModule(),
-        new CassandraModSeqModule(),
-        new CassandraAttachmentModule(),
-        new CassandraAnnotationModule(),
-        new CassandraApplicableFlagsModule());
-    private static CassandraCluster cassandra;
-    
-    public static CassandraMailboxSessionMapperFactory createMapperFactory() {
-        cassandra.ensureAllTables();
+
+    public static CassandraMailboxSessionMapperFactory createMapperFactory(CassandraCluster cassandra) {
         CassandraUidProvider uidProvider = new CassandraUidProvider(cassandra.getConf());
         CassandraModSeqProvider modSeqProvider = new CassandraModSeqProvider(cassandra.getConf());
         CassandraMessageId.Factory messageIdFactory = new CassandraMessageId.Factory();
@@ -101,6 +70,7 @@ public class CassandraTestSystemFixture {
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
         CassandraFirstUnseenDAO firstUnseenDAO = new CassandraFirstUnseenDAO(cassandra.getConf());
         CassandraDeletedMessageDAO deletedMessageDAO = new CassandraDeletedMessageDAO(cassandra.getConf());
+        
         return new CassandraMailboxSessionMapperFactory(uidProvider,
             modSeqProvider,
             cassandra.getConf(),
@@ -132,34 +102,16 @@ public class CassandraTestSystemFixture {
             new DefaultQuotaRootResolver(mapperFactory));
     }
 
-    public static MaxQuotaManager createMaxQuotaManager() {
+    public static MaxQuotaManager createMaxQuotaManager(CassandraCluster cassandra) {
         return new CassandraPerUserMaxQuotaManager(cassandra.getConf());
     }
 
-    public static CurrentQuotaManager createCurrentQuotaManager() {
+    public static CurrentQuotaManager createCurrentQuotaManager(CassandraCluster cassandra) {
         return new CassandraCurrentQuotaManager(cassandra.getConf());
     }
 
-    public static QuotaManager createQuotaManager(MaxQuotaManager maxQuotaManager) {
+    public static QuotaManager createQuotaManager(CassandraCluster cassandra, MaxQuotaManager maxQuotaManager) {
         return new StoreQuotaManager(new CassandraCurrentQuotaManager(cassandra.getConf()), maxQuotaManager);
     }
 
-    public static void clean() {
-        cassandra.clearAllTables();
-    }
-
-    public static void init() {
-        cassandra = CassandraCluster.create(BASE_MAILBOX_MODULES);
-    }
-
-    public static void initWithQuota() {
-        cassandra = CassandraCluster.create(
-            new CassandraModuleComposite(
-                BASE_MAILBOX_MODULES,
-                new CassandraQuotaModule()));
-    }
-
-    public static void stop() {
-        cassandra.close();
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
index 37cb6ed..3585f27 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.TreeMap;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
@@ -47,6 +48,7 @@ import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.apache.james.mailbox.util.EventCollector;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableMap;
@@ -64,7 +66,9 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
     public static final int SCHEDULER_PERIOD_IN_S = 20;
     public static final ImmutableMap<MessageUid, MailboxMessage> EMPTY_MESSAGE_CACHE = ImmutableMap.of();
 
-    private CassandraCluster cassandra = CassandraCluster.create(new CassandraRegistrationModule());
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra = CassandraCluster.create(new CassandraRegistrationModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
     private RegisteredDelegatingMailboxListener registeredDelegatingMailboxListener1;
     private RegisteredDelegatingMailboxListener registeredDelegatingMailboxListener2;
     private RegisteredDelegatingMailboxListener registeredDelegatingMailboxListener3;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
index 3e66222..99b57da 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
@@ -19,23 +19,26 @@
 
 package org.apache.james.mailbox.cassandra.event.distributed;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.concurrent.TimeUnit;
+
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.cassandra.modules.CassandraRegistrationModule;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.publisher.Topic;
 import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.concurrent.TimeUnit;
-
 public class CassandraMailboxPathRegistrerMapperTest {
 
-    private static final CassandraCluster cassandra = CassandraCluster.create(new CassandraRegistrationModule());
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private final CassandraCluster cassandra = CassandraCluster.create(new CassandraRegistrationModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
     private static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", "user", "name");
     private static final MailboxPath MAILBOX_PATH_2 = new MailboxPath("namespace2", "user2", "name2");
     private static final Topic TOPIC = new Topic("topic");
@@ -54,11 +57,6 @@ public class CassandraMailboxPathRegistrerMapperTest {
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
-    }
-
-    @AfterClass
-    public static void stop() {
         cassandra.close();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
index 4303f4f..1ac0071 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
@@ -31,7 +31,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
@@ -41,6 +42,7 @@ import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.SimpleMailboxACL;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.google.common.base.Throwables;
@@ -53,10 +55,11 @@ public class CassandraACLMapperTest {
     private CassandraAsyncExecutor cassandraAsyncExecutor;
     private ExecutorService executor;
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraAclModule());
-        cassandra.ensureAllTables();
+        cassandra = CassandraCluster.create(new CassandraAclModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         cassandraAsyncExecutor = new CassandraAsyncExecutor(cassandra.getConf());
         cassandraACLMapper = new CassandraACLMapper(MAILBOX_ID, cassandra.getConf(), cassandraAsyncExecutor, CassandraConfiguration.DEFAULT_CONFIGURATION);
         executor = Executors.newFixedThreadPool(2);
@@ -64,7 +67,6 @@ public class CassandraACLMapperTest {
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
         executor.shutdownNow();
         cassandra.close();
     }


---------------------------------------------------------------------
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