james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [09/13] james-project git commit: JAMES-2133 Switch from cassandraunit to cassandra in docker
Date Sat, 02 Sep 2017 06:00:11 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java
index 775ab0a..7e4e320 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java
@@ -19,12 +19,61 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
+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.store.mail.model.AnnotationMapperTest;
 import org.apache.james.mailbox.store.mail.model.MapperProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraAnnotationMapperTest extends AnnotationMapperTest {
+    
+    @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 CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraModSeqModule(),
+                new CassandraUidModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraBlobModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected MapperProvider createMapperProvider() {
-        return new CassandraMapperProvider();
+        return new CassandraMapperProvider(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAOTest.java
index fd380db..f6b4004 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraApplicableFlagDAOTest.java
@@ -24,11 +24,13 @@ import static org.assertj.core.api.Assertions.assertThat;
 import javax.mail.Flags;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -39,21 +41,20 @@ public class CassandraApplicableFlagDAOTest {
     public static final String USER_FLAG2 = "User Flag 2";
     public static final CassandraId CASSANDRA_ID = CassandraId.timeBased();
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
 
     private CassandraApplicableFlagDAO testee;
 
     @Before
     public void setUp() throws Exception {
-        cassandra = CassandraCluster.create(new CassandraApplicableFlagsModule());
-        cassandra.ensureAllTables();
-
+        cassandra = CassandraCluster.create(new CassandraApplicableFlagsModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         testee = new CassandraApplicableFlagDAO(cassandra.getConf());
     }
 
     @After
     public void tearDown() throws Exception {
-        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/mail/CassandraAttachmentMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java
index c144e06..ed3948d 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java
@@ -19,12 +19,62 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
+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.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.model.AttachmentMapperTest;
 import org.apache.james.mailbox.store.mail.model.MapperProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraAttachmentMapperTest extends AttachmentMapperTest {
+    
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra;
+
+    @Before
+    public void setUp() throws MailboxException {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraModSeqModule(),
+                new CassandraUidModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraBlobModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected MapperProvider createMapperProvider() {
-        return new CassandraMapperProvider();
+        return new CassandraMapperProvider(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAOTest.java
index d2f9ceb..f03a3f7 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAOTest.java
@@ -25,11 +25,13 @@ import java.io.IOException;
 import java.util.Optional;
 
 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.mailbox.cassandra.ids.BlobId;
 import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.google.common.base.Charsets;
@@ -38,23 +40,27 @@ import com.google.common.base.Strings;
 public class CassandraBlobsDAOTest {
     private static final int CHUNK_SIZE = 1024;
     private static final int MULTIPLE_CHUNK_SIZE = 3;
+
+    
+
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraBlobsDAO testee;
 
     @Before
-    public void setUp() throws Exception {
-        cassandra = CassandraCluster.create(new CassandraBlobModule());
-        cassandra.ensureAllTables();
-
+    public void setUp() {
+        cassandra = CassandraCluster.create(
+                new CassandraBlobModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
+        
         testee = new CassandraBlobsDAO(cassandra.getConf(),
             CassandraConfiguration.builder()
                 .blobPartSize(CHUNK_SIZE)
-                .build());
+                .build());;
     }
 
     @After
-    public void tearDown() throws Exception {
-        cassandra.clearAllTables();
+    public void 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/mail/CassandraDeletedMessageDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraDeletedMessageDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraDeletedMessageDAOTest.java
index 10c2e2d..98f6b28 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraDeletedMessageDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraDeletedMessageDAOTest.java
@@ -19,22 +19,26 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
-import com.github.steveash.guavate.Guavate;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
 import java.util.UUID;
+
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
 import org.apache.james.mailbox.model.MessageRange;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
+import com.github.steveash.guavate.Guavate;
 
 public class CassandraDeletedMessageDAOTest {
+    
     public static final CassandraId MAILBOX_ID = CassandraId.of(UUID.fromString("110e8400-e29b-11d4-a716-446655440000"));
     public static final MessageUid UID_1 = MessageUid.of(1);
     public static final MessageUid UID_2 = MessageUid.of(2);
@@ -43,21 +47,20 @@ public class CassandraDeletedMessageDAOTest {
     public static final MessageUid UID_7 = MessageUid.of(7);
     public static final MessageUid UID_8 = MessageUid.of(8);
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraDeletedMessageDAO testee;
 
     @Before
     public void setUp() {
         cassandra = CassandraCluster.create(
-            new CassandraDeletedMessageModule());
-        cassandra.ensureAllTables();
-
+            new CassandraDeletedMessageModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         testee = new CassandraDeletedMessageDAO(cassandra.getConf());
     }
 
     @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/mail/CassandraFirstUnseenDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraFirstUnseenDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraFirstUnseenDAOTest.java
index 45d8e20..1c885ac 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraFirstUnseenDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraFirstUnseenDAOTest.java
@@ -22,27 +22,30 @@ package org.apache.james.mailbox.cassandra.mail;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraFirstUnseenDAOTest {
+    
     public static final CassandraId MAILBOX_ID = CassandraId.timeBased();
     public static final MessageUid UID_1 = MessageUid.of(1);
     public static final MessageUid UID_2 = MessageUid.of(2);
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraFirstUnseenDAO testee;
 
     @Before
     public void setUp() {
         cassandra = CassandraCluster.create(
-            new CassandraFirstUnseenModule());
-        cassandra.ensureAllTables();
-
+            new CassandraFirstUnseenModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         testee = new CassandraFirstUnseenDAO(cassandra.getConf());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java
index 60a1dab..24eaff9 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java
@@ -19,12 +19,61 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
+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.store.mail.model.MailboxMapperTest;
 import org.apache.james.mailbox.store.mail.model.MapperProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraGenericMailboxMapperTest extends MailboxMapperTest {
+    
+    @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 CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraModSeqModule(),
+                new CassandraUidModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraBlobModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected MapperProvider createMapperProvider() {
-        return new CassandraMapperProvider();
+        return new CassandraMapperProvider(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
index 3dc96ea..33e8253 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
@@ -28,6 +28,7 @@ import java.util.Optional;
 import javax.mail.Flags;
 
 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.FlagsBuilder;
 import org.apache.james.mailbox.MessageUid;
@@ -48,6 +49,7 @@ import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.github.steveash.guavate.Guavate;
@@ -60,6 +62,8 @@ public class CassandraIndexTableHandlerTest {
     public static final int UID_VALIDITY = 15;
     public static final long MODSEQ = 17;
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraMailboxCounterDAO mailboxCounterDAO;
     private CassandraMailboxRecentsDAO mailboxRecentsDAO;
@@ -77,9 +81,7 @@ public class CassandraIndexTableHandlerTest {
                 new CassandraMailboxRecentsModule(),
                 new CassandraFirstUnseenModule(),
                 new CassandraApplicableFlagsModule(),
-                new CassandraDeletedMessageModule()));
-        cassandra.ensureAllTables();
-
+                new CassandraDeletedMessageModule()), cassandraServer.getIp(), cassandraServer.getBindingPort());
         mailboxCounterDAO = new CassandraMailboxCounterDAO(cassandra.getConf());
         mailboxRecentsDAO = new CassandraMailboxRecentsDAO(cassandra.getConf());
         firstUnseenDAO = new CassandraFirstUnseenDAO(cassandra.getConf());
@@ -99,7 +101,6 @@ public class CassandraIndexTableHandlerTest {
 
     @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/mail/CassandraMailboxCounterDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxCounterDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxCounterDAOTest.java
index 4964d9a..07d9cc6 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxCounterDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxCounterDAOTest.java
@@ -22,6 +22,7 @@ package org.apache.james.mailbox.cassandra.mail;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.model.MailboxCounters;
@@ -29,21 +30,22 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraMailboxCounterDAOTest {
     public static final int UID_VALIDITY = 15;
     public static final CassandraId MAILBOX_ID = CassandraId.timeBased();
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraMailboxCounterDAO testee;
     private SimpleMailbox mailbox;
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraMailboxCounterModule());
-        cassandra.ensureAllTables();
-
+        cassandra = CassandraCluster.create(new CassandraMailboxCounterModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         testee = new CassandraMailboxCounterDAO(cassandra.getConf());
 
         mailbox = new SimpleMailbox(new MailboxPath("#private", "user", "name"), UID_VALIDITY, MAILBOX_ID);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAOTest.java
index b3bbb78..ba5ead9 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxDAOTest.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Optional;
 
 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.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
@@ -34,6 +35,7 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.github.steveash.guavate.Guavate;
@@ -45,6 +47,9 @@ public class CassandraMailboxDAOTest {
     public static final MailboxPath NEW_MAILBOX_PATH = new MailboxPath(MailboxConstants.USER_NAMESPACE, "user", "xyz");
     public static CassandraId CASSANDRA_ID_1 = CassandraId.timeBased();
     public static CassandraId CASSANDRA_ID_2 = CassandraId.timeBased();
+
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraMailboxDAO testee;
     private SimpleMailbox mailbox1;
@@ -52,10 +57,11 @@ public class CassandraMailboxDAOTest {
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraModuleComposite(new CassandraMailboxModule(), new CassandraAclModule()));
-        cassandra.ensureAllTables();
+        CassandraModuleComposite modules = new CassandraModuleComposite(new CassandraMailboxModule(), new CassandraAclModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
 
         testee = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider());
+
         mailbox1 = new SimpleMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE, "user", "abcd"),
             UID_VALIDITY_1,
             CASSANDRA_ID_1);
@@ -66,7 +72,6 @@ public class CassandraMailboxDAOTest {
 
     @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/mail/CassandraMailboxManagerAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
index b904598..ccafa4a 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 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.cassandra.CassandraMailboxManager;
@@ -46,16 +47,23 @@ import org.apache.james.mailbox.store.Authorizator;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.NoMailboxPathLocker;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManagerAttachmentTest {
 
-    private static CassandraCluster cassandra;
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
 
-    @BeforeClass
-    public static void init() {
-        cassandra = CassandraCluster.create(
+    private CassandraMailboxSessionMapperFactory mailboxSessionMapperFactory;
+    private CassandraMailboxManager mailboxManager;
+    private CassandraMailboxManager parseFailingMailboxManager;
+    private CassandraCluster cassandra;
+
+    @Before
+    public void init() throws Exception {
+        
+        CassandraModuleComposite modules = 
                 new CassandraModuleComposite(
                     new CassandraAclModule(),
                     new CassandraMailboxModule(),
@@ -68,19 +76,19 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
                     new CassandraModSeqModule(),
                     new CassandraUidModule(),
                     new CassandraAttachmentModule(),
-                    new CassandraApplicableFlagsModule()));
+                    new CassandraApplicableFlagsModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        initSystemUnderTest();
+        super.setUp();
     }
 
-    @AfterClass
-    public static void close() {
+    @After
+    public void tearDown() {
         cassandra.close();
     }
 
-    private CassandraMailboxSessionMapperFactory mailboxSessionMapperFactory;
-    private CassandraMailboxManager mailboxManager;
-    private CassandraMailboxManager parseFailingMailboxManager;
-
-    public CassandraMailboxManagerAttachmentTest() throws Exception {
+    
+    private void initSystemUnderTest() throws Exception {
         CassandraMessageId.Factory messageIdFactory = new CassandraMessageId.Factory();
 
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider());
@@ -129,9 +137,4 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
     protected MailboxManager getParseFailingMailboxManager() {
         return parseFailingMailboxManager;
     }
-
-    @Override
-    protected void clean() {
-        cassandra.clearAllTables();
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
index bd849e9..8b3716f 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java
@@ -25,7 +25,8 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 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.init.CassandraModuleComposite;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -35,22 +36,25 @@ import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.apache.james.util.concurrency.ConcurrentTestRunner;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraMailboxMapperConcurrencyTest {
 
-    public static final int UID_VALIDITY = 52;
-    public static final MailboxPath MAILBOX_PATH = new MailboxPath("#private", "user", "name");
-    public static final int THREAD_COUNT = 10;
-    public static final int OPERATION_COUNT = 10;
+    private static final int UID_VALIDITY = 52;
+    private static final MailboxPath MAILBOX_PATH = new MailboxPath("#private", "user", "name");
+    private static final int THREAD_COUNT = 10;
+    private static final int OPERATION_COUNT = 10;
+
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraMailboxMapper testee;
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraModuleComposite(new CassandraMailboxModule(), new CassandraAclModule()));
-        cassandra.ensureAllTables();
-
+        CassandraModuleComposite modules = new CassandraModuleComposite(new CassandraMailboxModule(), new CassandraAclModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider());
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
         testee = new CassandraMailboxMapper(cassandra.getConf(), mailboxDAO, mailboxPathDAO, CassandraConfiguration.DEFAULT_CONFIGURATION);
@@ -58,7 +62,6 @@ public class CassandraMailboxMapperConcurrencyTest {
 
     @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/mail/CassandraMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
index 8eb5136..f67ffc6 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
@@ -26,7 +26,8 @@ import java.util.Optional;
 
 import org.apache.commons.lang3.StringUtils;
 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.init.CassandraModuleComposite;
 import org.apache.james.mailbox.cassandra.mail.CassandraMailboxPathDAO.CassandraIdAndPath;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
@@ -37,24 +38,27 @@ import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class CassandraMailboxMapperTest {
+    
     private static final Logger LOGGER = LoggerFactory.getLogger(CassandraMailboxMapperTest.class);
+    private static final int UID_VALIDITY = 52;
+    private static final MailboxPath MAILBOX_PATH = new MailboxPath("#private", "user", "name");
 
-    public static final int UID_VALIDITY = 52;
-    public static final MailboxPath MAILBOX_PATH = new MailboxPath("#private", "user", "name");
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraMailboxPathDAO mailboxPathDAO;
     private CassandraMailboxMapper testee;
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraModuleComposite(new CassandraMailboxModule(), new CassandraAclModule()));
-        cassandra.ensureAllTables();
-
+        CassandraModuleComposite modules = new CassandraModuleComposite(new CassandraMailboxModule(), new CassandraAclModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider());
         mailboxPathDAO = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
         testee = new CassandraMailboxMapper(cassandra.getConf(), mailboxDAO, mailboxPathDAO, CassandraConfiguration.DEFAULT_CONFIGURATION);
@@ -62,7 +66,6 @@ public class CassandraMailboxMapperTest {
 
     @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/mail/CassandraMailboxPathDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxPathDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxPathDAOTest.java
index 7e42ba1..430c086 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxPathDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxPathDAOTest.java
@@ -24,12 +24,14 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.List;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.mail.CassandraMailboxPathDAO.CassandraIdAndPath;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.github.steveash.guavate.Guavate;
@@ -49,22 +51,21 @@ public class CassandraMailboxPathDAOTest {
     public static final MailboxPath USER_OUTBOX_MAILBOXPATH = new MailboxPath(PRIVATE_NAMESPACE, USER, "OUTBOX");
     public static final MailboxPath OTHER_USER_MAILBOXPATH = new MailboxPath(PRIVATE_NAMESPACE, OTHER_USER, "INBOX");
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
 
     private CassandraMailboxPathDAO testee;
 
     @Before
     public void setUp() throws Exception {
-        cassandra = CassandraCluster.create(new CassandraMailboxModule());
-        cassandra.ensureAllTables();
-
+        cassandra = CassandraCluster.create(new CassandraMailboxModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         testee = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
 
     }
 
     @After
     public void tearDown() throws Exception {
-        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/mail/CassandraMailboxRecentDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxRecentDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxRecentDAOTest.java
index c0acc70..f4b7639 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxRecentDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxRecentDAOTest.java
@@ -24,11 +24,13 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.stream.IntStream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.github.steveash.guavate.Guavate;
@@ -38,20 +40,19 @@ public class CassandraMailboxRecentDAOTest {
     public static final MessageUid UID2 = MessageUid.of(37L);
     public static final CassandraId CASSANDRA_ID = CassandraId.timeBased();
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraMailboxRecentsDAO testee;
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraMailboxRecentsModule());
-        cassandra.ensureAllTables();
-
+        cassandra = CassandraCluster.create(new CassandraMailboxRecentsModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         testee = new CassandraMailboxRecentsDAO(cassandra.getConf());
     }
 
     @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/mail/CassandraMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
index 827e869..d29f520 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
@@ -21,26 +21,12 @@ package org.apache.james.mailbox.cassandra.mail;
 import java.util.List;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId.Factory;
-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.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MessageId;
@@ -65,22 +51,8 @@ public class CassandraMapperProvider implements MapperProvider {
     private final MockMailboxSession mailboxSession = new MockMailboxSession("benwa");
 
 
-    public CassandraMapperProvider() {
-        this.cassandra = CassandraCluster.create(
-                new CassandraModuleComposite(
-                    new CassandraAclModule(),
-                    new CassandraMailboxModule(),
-                    new CassandraMessageModule(),
-                    new CassandraMailboxCounterModule(),
-                    new CassandraMailboxRecentsModule(),
-                    new CassandraModSeqModule(),
-                    new CassandraUidModule(),
-                    new CassandraAttachmentModule(),
-                    new CassandraAnnotationModule(),
-                    new CassandraFirstUnseenModule(),
-                    new CassandraApplicableFlagsModule(),
-                    new CassandraDeletedMessageModule(),
-                    new CassandraBlobModule()));
+    public CassandraMapperProvider(CassandraCluster cassandra) {
+        this.cassandra = cassandra;
         messageUidProvider = new MessageUidProvider();
         cassandraModSeqProvider = new CassandraModSeqProvider(this.cassandra.getConf());
     }
@@ -144,11 +116,6 @@ public class CassandraMapperProvider implements MapperProvider {
     }
 
     @Override
-    public void ensureMapperPrepared() throws MailboxException {
-        cassandra.ensureAllTables();
-    }
-
-    @Override
     public boolean supportPartialAttachmentFetch() {
         return true;
     }
@@ -180,8 +147,4 @@ public class CassandraMapperProvider implements MapperProvider {
         return cassandraModSeqProvider.highestModSeq(mailboxSession, mailbox);
     }
 
-    @Override
-    public void close() {
-        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/CassandraMessageDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java
index 0fbfc71..ae0f3cf 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailbox.cassandra.mail;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -33,6 +32,7 @@ import javax.mail.util.SharedByteArrayInputStream;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.tuple.Pair;
 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.MessageUid;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
@@ -48,6 +48,7 @@ import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.google.common.base.Charsets;
@@ -60,6 +61,8 @@ public class CassandraMessageDAOTest {
     private static final String CONTENT = "Subject: Test7 \n\nBody7\n.\n";
     private static final MessageUid messageUid = MessageUid.of(1);
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
     private CassandraCluster cassandra;
 
     private CassandraMessageDAO testee;
@@ -73,9 +76,7 @@ public class CassandraMessageDAOTest {
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraModuleComposite(new CassandraMessageModule(), new CassandraBlobModule()));
-        cassandra.ensureAllTables();
-
+        cassandra = CassandraCluster.create(new CassandraModuleComposite(new CassandraMessageModule(), new CassandraBlobModule()), cassandraServer.getIp(), cassandraServer.getBindingPort());
         messageIdFactory = new CassandraMessageId.Factory();
         messageId = messageIdFactory.generate();
         blobsDAO = new CassandraBlobsDAO(cassandra.getConf());
@@ -92,7 +93,6 @@ public class CassandraMessageDAOTest {
 
     @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/mail/CassandraMessageIdDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAOTest.java
index 4856f1d..b56db70 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdDAOTest.java
@@ -29,6 +29,7 @@ import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
@@ -38,10 +39,13 @@ import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
 import org.apache.james.mailbox.model.MessageRange;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraMessageIdDAOTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
 
     private CassandraMessageId.Factory messageIdFactory;
@@ -50,16 +54,13 @@ public class CassandraMessageIdDAOTest {
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraMessageModule());
-        cassandra.ensureAllTables();
-
+        cassandra = CassandraCluster.create(new CassandraMessageModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         messageIdFactory = new CassandraMessageId.Factory();
         testee = new CassandraMessageIdDAO(cassandra.getConf(), messageIdFactory);
     }
 
     @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/mail/CassandraMessageIdMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java
index bc4bdfd..72c4544 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java
@@ -19,11 +19,61 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
+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.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.model.MessageIdMapperTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMessageIdMapperTest extends MessageIdMapperTest {
+    
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra;
+
+    @Before
+    public void setUp() throws MailboxException {
+        CassandraModuleComposite modules = new CassandraModuleComposite(
+                new CassandraAclModule(),
+                new CassandraMailboxModule(),
+                new CassandraMessageModule(),
+                new CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraModSeqModule(),
+                new CassandraUidModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraBlobModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected CassandraMapperProvider provideMapper() {
-        return new CassandraMapperProvider();
+        return new CassandraMapperProvider(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAOTest.java
index 0b71c4b..05c461c 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdToImapUidDAOTest.java
@@ -29,6 +29,7 @@ import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
@@ -37,6 +38,7 @@ import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.datastax.driver.core.utils.UUIDs;
@@ -44,6 +46,8 @@ import com.github.steveash.guavate.Guavate;
 
 public class CassandraMessageIdToImapUidDAOTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraMessageId.Factory messageIdFactory;
 
@@ -51,16 +55,13 @@ public class CassandraMessageIdToImapUidDAOTest {
 
     @Before
     public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraMessageModule());
-        cassandra.ensureAllTables();
-
+        cassandra = CassandraCluster.create(new CassandraMessageModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         messageIdFactory = new CassandraMessageId.Factory();
         testee = new CassandraMessageIdToImapUidDAO(cassandra.getConf(), messageIdFactory);
     }
 
     @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/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 391bea1..36710cc 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
@@ -19,12 +19,61 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
+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.store.mail.model.MapperProvider;
 import org.apache.james.mailbox.store.mail.model.MessageMapperTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMessageMapperTest extends MessageMapperTest {
+    
+    @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 CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraModSeqModule(),
+                new CassandraUidModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraBlobModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected MapperProvider createMapperProvider() {
-        return new CassandraMapperProvider();
+        return new CassandraMapperProvider(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
index 2bd7701..8f62042 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
@@ -19,12 +19,61 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
+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.store.mail.model.MapperProvider;
 import org.apache.james.mailbox.store.mail.model.MessageMoveTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMessageMoveTest extends MessageMoveTest {
+    
+    @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 CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraModSeqModule(),
+                new CassandraUidModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraBlobModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected MapperProvider createMapperProvider() {
-        return new CassandraMapperProvider();
+        return new CassandraMapperProvider(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java
index 256298d..2d35c39 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java
@@ -19,12 +19,61 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
+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.store.mail.model.MapperProvider;
 import org.apache.james.mailbox.store.mail.model.MessageWithAttachmentMapperTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraMessageWithAttachmentMapperTest extends MessageWithAttachmentMapperTest {
+    
+    @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 CassandraMailboxCounterModule(),
+                new CassandraMailboxRecentsModule(),
+                new CassandraModSeqModule(),
+                new CassandraUidModule(),
+                new CassandraAttachmentModule(),
+                new CassandraAnnotationModule(),
+                new CassandraFirstUnseenModule(),
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule(),
+                new CassandraBlobModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+    
     @Override
     protected MapperProvider createMapperProvider() {
-        return new CassandraMapperProvider();
+        return new CassandraMapperProvider(cassandra);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
index 8fcca84..becbeac 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
@@ -24,7 +24,8 @@ import static org.junit.Assert.assertEquals;
 import java.util.stream.LongStream;
 
 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.init.CassandraModuleComposite;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -33,12 +34,15 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.github.fge.lambdas.Throwing;
 
 public class CassandraModSeqProviderTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     
     private CassandraModSeqProvider modSeqProvider;
@@ -46,13 +50,13 @@ public class CassandraModSeqProviderTest {
     private SimpleMailbox mailbox;
 
     @Before
-    public void setUpClass() throws Exception {
-        cassandra = CassandraCluster.create(
+    public void setUp() throws Exception {
+        CassandraModuleComposite modules = 
                 new CassandraModuleComposite(
                     new CassandraAclModule(),
                     new CassandraMailboxModule(),
-                    new CassandraModSeqModule()));
-        cassandra.ensureAllTables();
+                    new CassandraModSeqModule());
+        cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
         modSeqProvider = new CassandraModSeqProvider(cassandra.getConf());
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider());
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
@@ -64,7 +68,6 @@ public class CassandraModSeqProviderTest {
     
     @After
     public void cleanUp() {
-        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/mail/CassandraUidProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
index c6b27d9..8f71f05 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
@@ -23,7 +23,8 @@ import java.util.Optional;
 import java.util.stream.LongStream;
 
 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.init.CassandraModuleComposite;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
@@ -33,16 +34,22 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import com.github.fge.lambdas.Throwing;
 
 public class CassandraUidProviderTest {
 
-    private final CassandraCluster cassandra = CassandraCluster.create(new CassandraModuleComposite(
-        new CassandraAclModule(),
-        new CassandraMailboxModule(),
-        new CassandraUidModule()));
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    
+    private final CassandraModuleComposite modules = new CassandraModuleComposite(
+            new CassandraAclModule(),
+            new CassandraMailboxModule(),
+            new CassandraUidModule());
+    
+    private final CassandraCluster cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
     
     private CassandraUidProvider uidProvider;
     private CassandraMailboxMapper mapper;
@@ -50,7 +57,6 @@ public class CassandraUidProviderTest {
 
     @Before
     public void setUpClass() throws Exception {
-        cassandra.ensureAllTables();
         uidProvider = new CassandraUidProvider(cassandra.getConf());
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider());
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
@@ -62,7 +68,6 @@ public class CassandraUidProviderTest {
     
     @After
     public void cleanUp() {
-        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/quota/CassandraCurrentQuotaManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManagerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManagerTest.java
index f5f4893..836cd09 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManagerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraCurrentQuotaManagerTest.java
@@ -20,15 +20,18 @@
 package org.apache.james.mailbox.cassandra.quota;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.cassandra.modules.CassandraQuotaModule;
 import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManager;
 import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManagerTest;
 import org.junit.After;
-import org.junit.AfterClass;
+import org.junit.ClassRule;
 
 public class CassandraCurrentQuotaManagerTest extends StoreCurrentQuotaManagerTest {
 
-    private static final CassandraCluster cassandra = CassandraCluster.create(new CassandraQuotaModule());
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private final CassandraCluster cassandra = CassandraCluster.create(new CassandraQuotaModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
 
     @Override
     protected StoreCurrentQuotaManager provideTestee() {
@@ -37,11 +40,7 @@ public class CassandraCurrentQuotaManagerTest extends StoreCurrentQuotaManagerTe
 
     @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/quota/CassandraPerUserMaxQuotaManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManagerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManagerTest.java
index 499449c..150203e 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManagerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManagerTest.java
@@ -20,25 +20,27 @@
 package org.apache.james.mailbox.cassandra.quota;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.mailbox.cassandra.modules.CassandraQuotaModule;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.store.quota.GenericMaxQuotaManagerTest;
 import org.junit.After;
+import org.junit.ClassRule;
 
 public class CassandraPerUserMaxQuotaManagerTest extends GenericMaxQuotaManagerTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
 
     @Override
     protected MaxQuotaManager provideMaxQuotaManager() {
-        cassandra = CassandraCluster.create(new CassandraQuotaModule());
-        cassandra.ensureAllTables();
+        cassandra = CassandraCluster.create(new CassandraQuotaModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         return new CassandraPerUserMaxQuotaManager(cassandra.getConf());
     }
 
     @After
     public void cleanUp() {
-        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/user/CassandraSubscriptionMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapperTest.java
index a08b589..a8bca0e 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/user/CassandraSubscriptionMapperTest.java
@@ -19,30 +19,28 @@
 package org.apache.james.mailbox.cassandra.user;
 
 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.CassandraSubscriptionModule;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 import org.apache.james.mailbox.store.user.SubscriptionMapperTest;
 import org.junit.After;
-import org.junit.AfterClass;
+import org.junit.ClassRule;
 
 public class CassandraSubscriptionMapperTest extends SubscriptionMapperTest {
 
-    private static final CassandraCluster cassandra = CassandraCluster.create(new CassandraSubscriptionModule());
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private final CassandraCluster cassandra = CassandraCluster.create(new CassandraSubscriptionModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
 
     @Override
     protected SubscriptionMapper createSubscriptionMapper() {
-        cassandra.ensureAllTables();
         return new CassandraSubscriptionMapper(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 
     @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/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/resources/logback-test.xml b/mailbox/cassandra/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..f2c08d8
--- /dev/null
+++ b/mailbox/cassandra/src/test/resources/logback-test.xml
@@ -0,0 +1,19 @@
+<?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>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerStressTest.java b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerStressTest.java
index 5a9c27c..1ad8662 100644
--- a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerStressTest.java
+++ b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerStressTest.java
@@ -29,6 +29,7 @@ import org.apache.james.mailbox.MailboxManagerStressTest;
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.junit.After;
+import org.junit.Before;
 
 import com.google.common.base.Throwables;
 
@@ -36,6 +37,11 @@ public class JCRMailboxManagerStressTest extends MailboxManagerStressTest {
 
     private Optional<RepositoryImpl> repository = Optional.empty();
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+    
     @Override
     protected MailboxManager provideManager() {
         String user = "user";

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
index 4970196..01c63ea 100644
--- a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
+++ b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
@@ -28,6 +28,7 @@ import org.apache.james.mailbox.MailboxManagerTest;
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.junit.After;
+import org.junit.Before;
 
 import com.google.common.base.Throwables;
 
@@ -35,6 +36,11 @@ public class JCRMailboxManagerTest extends MailboxManagerTest {
 
     private Optional<RepositoryImpl> repository = Optional.empty();
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+    
     @Override
     protected MailboxManager provideMailboxManager() {
         String user = "user";

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
index 92175c1..9fefd7b 100644
--- a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
+++ b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRSubscriptionManagerTest.java
@@ -28,7 +28,10 @@ import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.james.mailbox.AbstractSubscriptionManagerTest;
 import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.exception.SubscriptionException;
+import org.junit.After;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.xml.sax.InputSource;
 
@@ -59,6 +62,16 @@ public class JCRSubscriptionManagerTest extends AbstractSubscriptionManagerTest
         FileUtils.forceDelete(new File(JACKRABBIT_HOME));
     }
 
+    @Before
+    public void setUp() throws Exception {
+        super.setup();
+    }
+    
+    @After
+    public void tearDown() throws SubscriptionException {
+        super.teardown();
+    }
+    
     @Override
     public SubscriptionManager createSubscriptionManager() {
         MailboxSessionJCRRepository sessionRepos = new GlobalMailboxSessionJCRRepository(repository, workspace, user, pass);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
index c6b5fda..0b5f58f 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
@@ -26,12 +26,18 @@ import org.apache.james.mailbox.MailboxManagerTest;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
 import org.junit.After;
+import org.junit.Before;
 
 public class JPAMailboxManagerTest extends MailboxManagerTest {
 
     private static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPAMailboxFixture.MAILBOX_PERSISTANCE_CLASSES);
     private Optional<OpenJPAMailboxManager> openJPAMailboxManager = Optional.empty();
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+    
     @Override
     protected MailboxManager provideMailboxManager() {
         if (!openJPAMailboxManager.isPresent()) {


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