james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [04/13] james-project git commit: JAMES-2133 Switch from cassandraunit to cassandra in docker
Date Sat, 02 Sep 2017 06:00:06 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
index ce18ad9..678dcc2 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
@@ -30,7 +30,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.james.util.streams.SwarmGenericContainer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -75,32 +74,36 @@ public class JamesServerWithRetryConnectionTest {
 
     @Test
     public void serverShouldRetryToConnectToCassandraWhenStartService() throws Exception {
-        jamesServer = cassandraJmapTestRule.jmapServer();
-        dockerCassandraRule.getCassandraContainer().stop();
+        jamesServer = cassandraJmapTestRule.jmapServer(dockerCassandraRule.getModule());
+        dockerCassandraRule.pause();
 
-        waitToStartContainer(WAITING_TIME, dockerCassandraRule.getCassandraContainer());
+        waitToStartContainer(WAITING_TIME, dockerCassandraRule::unpause);
 
         assertThatServerStartCorrectly();
     }
 
     @Test
     public void serverShouldRetryToConnectToElasticSearchWhenStartService() throws Exception {
-        jamesServer = cassandraJmapTestRule.jmapServer();
-        dockerElasticSearchRule.getElasticSearchContainer().stop();
+        jamesServer = cassandraJmapTestRule.jmapServer(dockerCassandraRule.getModule());
+        dockerElasticSearchRule.pause();
 
-        waitToStartContainer(WAITING_TIME, dockerElasticSearchRule.getElasticSearchContainer());
+        waitToStartContainer(WAITING_TIME, dockerElasticSearchRule::unpause);
 
         assertThatServerStartCorrectly();
     }
 
-    private void waitToStartContainer(long waitingTime, SwarmGenericContainer dockerContainer) {
+    interface StartAction {
+        void execute();
+    }
+    
+    private void waitToStartContainer(long waitingTime, StartAction action) {
         executorService.submit(() -> {
             try {
                 Thread.sleep(waitingTime);
             } catch (InterruptedException e) {
                 throw Throwables.propagate(e);
             }
-            dockerContainer.start();
+            action.execute();
         });
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
index 5a61948..29434d5 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/CassandraJmapServerModule.java
@@ -25,7 +25,6 @@ import java.util.function.Supplier;
 import javax.inject.Singleton;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
 import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
@@ -34,22 +33,25 @@ import org.junit.rules.TemporaryFolder;
 import com.datastax.driver.core.Session;
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
+import com.google.inject.name.Names;
 
 public class CassandraJmapServerModule extends AbstractModule {
 
     private static final int LIMIT_TO_3_MESSAGES = 3;
     private final Supplier<File> fileSupplier;
     private final EmbeddedElasticSearch embeddedElasticSearch;
-    private final EmbeddedCassandra cassandra;
+    private final String cassandraHost;
+    private final int cassandraPort;
 
-    public CassandraJmapServerModule(Supplier<File> fileSupplier, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
+    public CassandraJmapServerModule(Supplier<File> fileSupplier, EmbeddedElasticSearch embeddedElasticSearch, String cassandraHost, int cassandraPort) {
         this.fileSupplier = fileSupplier;
         this.embeddedElasticSearch = embeddedElasticSearch;
-        this.cassandra = cassandra;
+        this.cassandraHost = cassandraHost;
+        this.cassandraPort = cassandraPort;
     }
 
-    public CassandraJmapServerModule(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
-        this(temporaryFolder::getRoot, embeddedElasticSearch, cassandra);
+    public CassandraJmapServerModule(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, String cassandraHost, int cassandraPort) {
+        this(temporaryFolder::getRoot, embeddedElasticSearch, cassandraHost, cassandraPort);
     }
 
 
@@ -59,7 +61,8 @@ public class CassandraJmapServerModule extends AbstractModule {
         install(new TestFilesystemModule(fileSupplier));
         install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES));
         install(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class));
-        bind(EmbeddedCassandra.class).toInstance(cassandra);
+        install(binder -> binder.bindConstant().annotatedWith(Names.named("cassandraHost")).to(cassandraHost));
+        install(binder -> binder.bindConstant().annotatedWith(Names.named("cassandraPort")).to(cassandraPort));
     }
     
     @Provides

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
index 5ed9f0f..29c3853 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.backends.cassandra.CassandraConfiguration;
+import org.apache.james.backends.cassandra.init.CassandraConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/container/guice/cassandra-ldap-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-ldap-guice/pom.xml b/server/container/guice/cassandra-ldap-guice/pom.xml
index aa60944..1c1d96d 100644
--- a/server/container/guice/cassandra-ldap-guice/pom.xml
+++ b/server/container/guice/cassandra-ldap-guice/pom.xml
@@ -41,6 +41,12 @@
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>apache-james-backends-cassandra</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>apache-james-backends-es</artifactId>
             <type>test-jar</type>
             <scope>test</scope>
@@ -112,11 +118,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.cassandraunit</groupId>
-            <artifactId>cassandra-unit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.testcontainers</groupId>
             <artifactId>testcontainers</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
index aa6233d..25a7dca 100644
--- a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
+++ b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
@@ -39,7 +39,7 @@ public class CassandraLdapJmapTestRule implements TestRule {
 
     public static CassandraLdapJmapTestRule defaultTestRule() {
         return new CassandraLdapJmapTestRule(
-            AggregateGuiceModuleTestRule.of(new EmbeddedElasticSearchRule(), new EmbeddedCassandraRule()));
+            AggregateGuiceModuleTestRule.of(new EmbeddedElasticSearchRule(), new DockerCassandraRule()));
     }
 
     private GuiceModuleTestRule guiceModuleTestRule;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
index 293c80d..2878e90 100644
--- a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
+++ b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
@@ -63,7 +63,7 @@ public class ESReporterTest {
 
     @Before
     public void setUp() {
-        clientProvider = ClientProviderImpl.forHost(esContainer.getIp(), ES_APPLICATIVE_PORT);
+        clientProvider = ClientProviderImpl.forHost(esContainer.getHostIp(), esContainer.getMappedPort(ES_APPLICATIVE_PORT));
         await().atMost(Duration.ONE_MINUTE)
             .until(() -> elasticSearchStarted(clientProvider));
 
@@ -72,7 +72,7 @@ public class ESReporterTest {
         esMetricReporter = new ESMetricReporter(
             ESReporterConfiguration.builder()
                 .enabled()
-                .onHost(esContainer.getIp(), ES_HTTP_PORT)
+                .onHost(esContainer.getHostIp(), esContainer.getMappedPort(ES_HTTP_PORT))
                 .onIndex(INDEX)
                 .periodInSecond(PERIOD_IN_SECOND)
                 .build(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java b/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
index 2622ea8..8b50aa2 100644
--- a/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
+++ b/server/container/util-java8/src/test/java/org/apache/james/util/streams/SwarmGenericContainer.java
@@ -28,6 +28,7 @@ import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.wait.WaitStrategy;
 import org.testcontainers.images.builder.ImageFromDockerfile;
@@ -105,9 +106,25 @@ public class SwarmGenericContainer implements TestRule {
         container.stop();
     }
 
+    public void pause() {
+        DockerClientFactory.instance().client().pauseContainerCmd(container.getContainerInfo().getId());
+    }
+
+    public void unpause() {
+        DockerClientFactory.instance().client().unpauseContainerCmd(container.getContainerInfo().getId());
+    }
+
+    public Integer getMappedPort(int originalPort) {
+        return container.getMappedPort(originalPort);
+    }
+
     @SuppressWarnings("deprecation")
-    public String getIp() {
-        return getContainerInfo().getNetworkSettings().getIpAddress();
+    public String getContainerIp() {
+        return container.getContainerInfo().getNetworkSettings().getIpAddress();
+    }
+    
+    public String getHostIp() {
+        return container.getContainerIpAddress();
     }
 
     public InspectContainerResponse getContainerInfo() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/pom.xml b/server/data/data-cassandra/pom.xml
index 2b0b28d..85ee4e4 100644
--- a/server/data/data-cassandra/pom.xml
+++ b/server/data/data-cassandra/pom.xml
@@ -112,17 +112,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.cassandraunit</groupId>
-            <artifactId>cassandra-unit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
index b710e4e..f5abd9f 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/domainlist/cassandra/CassandraDomainListTest.java
@@ -20,16 +20,32 @@
 package org.apache.james.domainlist.cassandra;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraDomainListTest extends AbstractDomainListTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
     private CassandraCluster cassandra;
 
+    @Before
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraDomainListModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() {
+        cassandra.close();
+    }
+
     @Override
     protected DomainList createDomainList() {
-        cassandra = CassandraCluster.create(new CassandraDomainListModule());
         CassandraDomainList testee = new CassandraDomainList(getDNSServer("localhost"), cassandra.getConf());
         testee.setAutoDetect(false);
         testee.setAutoDetectIP(false);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
index 171dd71..a5b21d8 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
@@ -20,34 +20,34 @@ package org.apache.james.rrt.cassandra;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 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.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
-
-import cucumber.api.java.After;
-import cucumber.api.java.Before;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraRecipientRewriteTableTest extends AbstractRecipientRewriteTableTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
     private CassandraCluster cassandra;
 
     @Before
-    @Override
     public void setUp() throws Exception {
-        cassandra = CassandraCluster.create(new CassandraRRTModule());
-        cassandra.ensureAllTables();
+        cassandra = CassandraCluster.create(new CassandraRRTModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         super.setUp();
     }
 
     @After
-    @Override
     public void tearDown() throws Exception {
         super.tearDown();
-        cassandra.clearAllTables();
         cassandra.close();
     }
 
+
     @Override
     protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
         CassandraRecipientRewriteTable rrt = new CassandraRecipientRewriteTable(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraStepdefs.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraStepdefs.java b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraStepdefs.java
index b3d1166..a1c8138 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraStepdefs.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraStepdefs.java
@@ -39,14 +39,12 @@ public class CassandraStepdefs {
 
     @Before
     public void setup() throws Throwable {
-        cassandra = CassandraCluster.create(new CassandraRRTModule());
-        cassandra.ensureAllTables();
+        cassandra = CassandraCluster.create(new CassandraRRTModule(), RewriteTablesTest.cassandraServer.getIp(), RewriteTablesTest.cassandraServer.getBindingPort());
         mainStepdefs.rewriteTable = getRecipientRewriteTable(); 
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
         cassandra.close();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/RewriteTablesTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/RewriteTablesTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/RewriteTablesTest.java
index 766ba86..392ff7e 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/RewriteTablesTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/RewriteTablesTest.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.rrt.cassandra;
 
+import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.junit.ClassRule;
 import org.junit.runner.RunWith;
 
 import cucumber.api.CucumberOptions;
@@ -29,4 +31,6 @@ import cucumber.api.junit.Cucumber;
         glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.cassandra" }
     )
 public class RewriteTablesTest {
+    
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
index d1c8beb..93ac85b 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraActiveScriptDAOTest.java
@@ -24,9 +24,11 @@ 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.sieve.cassandra.model.ActiveScriptInfo;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraActiveScriptDAOTest {
@@ -34,20 +36,20 @@ public class CassandraActiveScriptDAOTest {
     public static final String USER = "user";
     public static final String SCRIPT_NAME = "sciptName";
     public static final String NEW_SCRIPT_NAME = "newScriptName";
+
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
     
     private CassandraCluster cassandra;
     private CassandraActiveScriptDAO activeScriptDAO;
 
     @Before
-    public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule());
-        cassandra.ensureAllTables();
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         activeScriptDAO = new CassandraActiveScriptDAO(cassandra.getConf());
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
         cassandra.close();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
index f665ddd..95750b9 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveDAOTest.java
@@ -25,10 +25,12 @@ 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.sieve.cassandra.model.Script;
 import org.apache.james.sieverepository.api.ScriptSummary;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraSieveDAOTest {
@@ -54,24 +56,24 @@ public class CassandraSieveDAOTest {
         .copyOf(SCRIPT)
         .content("newContent")
         .build();
+
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
     
     private CassandraCluster cassandra;
     private CassandraSieveDAO sieveDAO;
 
     @Before
-    public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule());
-        cassandra.ensureAllTables();
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         sieveDAO = new CassandraSieveDAO(cassandra.getConf());
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
         cassandra.close();
     }
-
-    @Test
+    
+     @Test
     public void getScriptShouldReturnEmptyByDefault() {
         assertThat(sieveDAO.getScript(USER, SCRIPT_NAME).join().isPresent())
             .isFalse();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
index e3ff18a..49de699 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveQuotaDAOTest.java
@@ -24,26 +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.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 public class CassandraSieveQuotaDAOTest {
 
     public static final String USER = "user";
+
+    
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
     private CassandraSieveQuotaDAO sieveQuotaDAO;
 
     @Before
-    public void setUp() {
-        cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule());
-        cassandra.ensureAllTables();
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
         sieveQuotaDAO = new CassandraSieveQuotaDAO(cassandra.getConf());
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
         cassandra.close();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveRepositoryTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveRepositoryTest.java
index 8d37f63..8f039fb 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveRepositoryTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/sieve/cassandra/CassandraSieveRepositoryTest.java
@@ -20,12 +20,31 @@
 package org.apache.james.sieve.cassandra;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.lib.AbstractSieveRepositoryTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraSieveRepositoryTest extends AbstractSieveRepositoryTest {
-    private CassandraCluster cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule());
+    
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra;
+
+    @Before
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraSieveRepositoryModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        cassandra.close();
+    }
+    
     @Override
     protected SieveRepository createSieveRepository() throws Exception {
         return new CassandraSieveRepository(
@@ -33,10 +52,4 @@ public class CassandraSieveRepositoryTest extends AbstractSieveRepositoryTest {
             new CassandraSieveQuotaDAO(cassandra.getConf()),
             new CassandraActiveScriptDAO(cassandra.getConf()));
     }
-
-    @Override
-    protected void cleanUp() throws Exception {
-        cassandra.clearAllTables();
-        cassandra.close();
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
index 326bc6b..7ac7e55 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/user/cassandra/CassandraUsersRepositoryTest.java
@@ -20,23 +20,34 @@
 package org.apache.james.user.cassandra;
 
 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.user.lib.AbstractUsersRepository;
 import org.apache.james.user.lib.AbstractUsersRepositoryTest;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraUsersRepositoryTest extends AbstractUsersRepositoryTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
 
+    @Before
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraUsersRepositoryModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
     @After
-    public void tearDown() {
-        cassandra.clearAllTables();
+    public void tearDown() throws Exception {
+        super.tearDown();
+        cassandra.close();
     }
 
     @Override
     protected AbstractUsersRepository getUsersRepository() throws Exception {
-        cassandra = CassandraCluster.create(new CassandraUsersRepositoryModule());
         return new CassandraUsersRepository(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java b/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
index b5a5771..07d7f79 100644
--- a/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
+++ b/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
@@ -30,7 +31,7 @@ import org.apache.james.rrt.lib.MappingImpl;
 import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.rrt.lib.MappingsImpl.Builder;
-import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -43,12 +44,17 @@ public class XMLRecipientRewriteTableTest extends AbstractRecipientRewriteTableT
     private final DefaultConfigurationBuilder defaultConfiguration = new DefaultConfigurationBuilder();
 
     @Before
-    @Override
     public void setUp() throws Exception {
         defaultConfiguration.setDelimiterParsingDisabled(true);
         super.setUp();
     }
 
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+
     @Override
     protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
         return new XMLRecipientRewriteTable();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-file/src/test/java/org/apache/james/sieverepository/file/SieveFileRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/test/java/org/apache/james/sieverepository/file/SieveFileRepositoryTest.java b/server/data/data-file/src/test/java/org/apache/james/sieverepository/file/SieveFileRepositoryTest.java
index f2a7daf..fa92742 100644
--- a/server/data/data-file/src/test/java/org/apache/james/sieverepository/file/SieveFileRepositoryTest.java
+++ b/server/data/data-file/src/test/java/org/apache/james/sieverepository/file/SieveFileRepositoryTest.java
@@ -6,6 +6,8 @@ import org.apache.commons.io.FileUtils;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.sieverepository.lib.AbstractSieveRepositoryTest;
+import org.junit.After;
+import org.junit.Before;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -17,9 +19,10 @@ public class SieveFileRepositoryTest extends AbstractSieveRepositoryTest {
 
     private static final String SIEVE_ROOT = FileSystem.FILE_PROTOCOL + "sieve";
 
-    private final FileSystem fileSystem;
+    private FileSystem fileSystem;
 
-    public SieveFileRepositoryTest() {
+    @Before
+    public void setUp() throws Exception {
         this.fileSystem = new FileSystem() {
             public File getBasedir() throws FileNotFoundException {
                 return new File(System.getProperty("java.io.tmpdir"));
@@ -31,6 +34,7 @@ public class SieveFileRepositoryTest extends AbstractSieveRepositoryTest {
                 return new File(getBasedir(), fileURL.substring(FileSystem.FILE_PROTOCOL.length()));
             }
         };
+        super.setUp();
     }
 
     @Override
@@ -38,8 +42,8 @@ public class SieveFileRepositoryTest extends AbstractSieveRepositoryTest {
         return new SieveFileRepository(fileSystem);
     }
 
-    @Override
-    protected void cleanUp() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         File root = fileSystem.getFile(SIEVE_ROOT);
         // Remove files from the previous test, if any
         if (root.exists()) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java b/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
index e78ba41..2df0de2 100644
--- a/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
+++ b/server/data/data-hbase/src/test/java/org/apache/james/domainlist/hbase/HBaseDomainListTest.java
@@ -25,6 +25,8 @@ import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.lib.AbstractDomainListTest;
 import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
 import org.apache.james.system.hbase.TablePool;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -44,6 +46,19 @@ public class HBaseDomainListTest extends AbstractDomainListTest {
         TablePool.getInstance(cluster.getConf());
     }
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() throws DomainListException {
+        DomainList domainList = createDomainList();
+        for (String domain: domainList.getDomains()) {
+            domainList.removeDomain(domain);
+        }
+    }
+
     /**
      * @see org.apache.james.domainlist.lib.AbstractDomainListTest#createDomainList()
      */

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
index e8769ca..acfa754 100644
--- a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
+++ b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
@@ -18,14 +18,13 @@
  ****************************************************************/
 package org.apache.james.rrt.hbase;
 
-import java.io.IOException;
-
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
 import org.apache.james.system.hbase.TablePool;
+import org.junit.After;
 import org.junit.Before;
 
 /**
@@ -39,10 +38,16 @@ public class HBaseRecipientRewriteTableTest extends AbstractRecipientRewriteTabl
     private static final HBaseClusterSingleton cluster = HBaseClusterSingleton.build();
 
     @Before
-    public void setMeUp() throws IOException {
+    public void setMeUp() throws Exception {
         TablePool.getInstance(cluster.getConf());
+        super.setUp();
     }
 
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+    
     /**
      * @see org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest#getRecipientRewriteTable()
      */

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java b/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
index 766df10..13a42ce 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
@@ -30,12 +30,6 @@ import org.apache.james.mailrepository.api.MailRepository;
 
 public class JDBCMailRepositoryTest extends AbstractMailRepositoryTest {
 
-    /**
-     * @return
-     * @throws ServiceException
-     * @throws ConfigurationException
-     * @throws Exception
-     */
     @Override
     protected MailRepository getMailRepository() throws Exception {
         MockFileSystem fs = new MockFileSystem();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java b/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
index bd5d614..b7c0fc3 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
@@ -25,12 +25,25 @@ import org.apache.james.filesystem.api.mock.MockFileSystem;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Test the JDBC Virtual User Table implementation.
  */
 public class JDBCRecipientRewriteTableTest extends AbstractRecipientRewriteTableTest {
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+
     /**
      * @see org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest#getRecipientRewriteTable()
      */

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java b/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java
index 90935d5..5c868c1 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepositoryTest.java
@@ -30,12 +30,24 @@ import org.apache.james.filesystem.api.mock.MockFileSystem;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.lib.AbstractUsersRepository;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Test basic behaviors of UsersFileRepository
  */
 public class DefaultUsersJdbcRepositoryTest extends AbstractUsersJdbcRepositoryTest {
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
     /**
      * Create the repository to be tested.
      * 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java b/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java
index 1e69cb8..c04a713 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/user/jdbc/JamesUsersJdbcRepositoryTest.java
@@ -30,12 +30,25 @@ import org.apache.james.filesystem.api.mock.MockFileSystem;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.lib.AbstractUsersRepository;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Test basic behaviors of UsersFileRepository
  */
 public class JamesUsersJdbcRepositoryTest extends AbstractUsersJdbcRepositoryTest {
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+
     /**
      * Create the repository to be tested.
      *

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jmap-cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/pom.xml b/server/data/data-jmap-cassandra/pom.xml
index 93e89b3..6aa4e01 100644
--- a/server/data/data-jmap-cassandra/pom.xml
+++ b/server/data/data-jmap-cassandra/pom.xml
@@ -78,11 +78,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.cassandraunit</groupId>
-            <artifactId>cassandra-unit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
             <scope>test</scope>
@@ -91,6 +86,11 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/access/CassandraAccessTokenRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/access/CassandraAccessTokenRepositoryTest.java b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/access/CassandraAccessTokenRepositoryTest.java
index da5f421..a465a42 100644
--- a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/access/CassandraAccessTokenRepositoryTest.java
+++ b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/access/CassandraAccessTokenRepositoryTest.java
@@ -20,21 +20,35 @@
 package org.apache.james.jmap.cassandra.access;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.jmap.api.access.AccessTokenRepository;
 import org.apache.james.jmap.api.access.AccessTokenRepositoryTest;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraAccessTokenRepositoryTest extends AccessTokenRepositoryTest {
-    private static final CassandraCluster CLUSTER = CassandraCluster.create(new CassandraAccessModule());
+    
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
+    private CassandraCluster cassandra;
+
+    @Before
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraAccessModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        cassandra.close();
+    }
+    
     @Override
     protected AccessTokenRepository provideAccessTokenRepository() {
         return new CassandraAccessTokenRepository(
-            new CassandraAccessTokenDAO(CLUSTER.getConf(), AccessTokenRepositoryTest.TTL_IN_MS));
+            new CassandraAccessTokenDAO(cassandra.getConf(), AccessTokenRepositoryTest.TTL_IN_MS));
     }
 
-    @After
-    public void tearDown() {
-        CLUSTER.clearAllTables();
-   }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java
index f09e276..1ef9edf 100644
--- a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java
+++ b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java
@@ -20,23 +20,34 @@
 package org.apache.james.jmap.cassandra.vacation;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.jmap.api.vacation.AbstractNotificationRegistryTest;
 import org.apache.james.jmap.api.vacation.NotificationRegistry;
 import org.apache.james.util.date.ZonedDateTimeProvider;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraNotificationRegistryTest extends AbstractNotificationRegistryTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
 
-    @Override
-    protected NotificationRegistry createNotificationRegistry(ZonedDateTimeProvider zonedDateTimeProvider) {
-        cassandra = CassandraCluster.create(new CassandraNotificationRegistryModule());
-        return new CassandraNotificationRegistry(zonedDateTimeProvider, new CassandraNotificationRegistryDAO(cassandra.getConf()));
+    @Before
+    public void setUp() throws Exception {
+        cassandra = CassandraCluster.create(new CassandraNotificationRegistryModule(), cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
+        cassandra.close();
+    }
+    
+    @Override
+    protected NotificationRegistry createNotificationRegistry(ZonedDateTimeProvider zonedDateTimeProvider) {
+        return new CassandraNotificationRegistry(zonedDateTimeProvider, new CassandraNotificationRegistryDAO(cassandra.getConf()));
     }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraVacationRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraVacationRepositoryTest.java b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraVacationRepositoryTest.java
index f45f020..788790b 100644
--- a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraVacationRepositoryTest.java
+++ b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraVacationRepositoryTest.java
@@ -20,24 +20,36 @@
 package org.apache.james.jmap.cassandra.vacation;
 
 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.backends.cassandra.init.CassandraZonedDateTimeModule;
 import org.apache.james.jmap.api.vacation.AbstractVacationRepositoryTest;
 import org.apache.james.jmap.api.vacation.VacationRepository;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
 
 public class CassandraVacationRepositoryTest extends AbstractVacationRepositoryTest {
 
+    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    
     private CassandraCluster cassandra;
 
-    @Override
-    protected VacationRepository createVacationRepository() {
-        cassandra = CassandraCluster.create(new CassandraModuleComposite(new CassandraVacationModule(), new CassandraZonedDateTimeModule()));
-        return new CassandraVacationRepository(new CassandraVacationDAO(cassandra.getConf(), cassandra.getTypesProvider()));
+    @Before
+    public void setUp() throws Exception {
+        CassandraModuleComposite module = new CassandraModuleComposite(new CassandraVacationModule(), new CassandraZonedDateTimeModule());
+        cassandra = CassandraCluster.create(module, cassandraServer.getIp(), cassandraServer.getBindingPort());
+        super.setUp();
     }
 
     @After
     public void tearDown() {
-        cassandra.clearAllTables();
+        cassandra.close();
+    }
+    
+    @Override
+    protected VacationRepository createVacationRepository() {
+        return new CassandraVacationRepository(new CassandraVacationDAO(cassandra.getConf(), cassandra.getTypesProvider()));
     }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/access/AccessTokenRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/access/AccessTokenRepositoryTest.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/access/AccessTokenRepositoryTest.java
index b7f6c32..d8fa18d 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/access/AccessTokenRepositoryTest.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/access/AccessTokenRepositoryTest.java
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.util.concurrent.CompletionException;
 
 import org.apache.james.jmap.api.access.exceptions.InvalidAccessToken;
-import org.junit.Before;
 import org.junit.Test;
 
 public abstract class AccessTokenRepositoryTest {
@@ -38,8 +37,7 @@ public abstract class AccessTokenRepositoryTest {
 
     protected abstract AccessTokenRepository provideAccessTokenRepository();
 
-    @Before
-    public final void setUp() {
+    public void setUp() throws Exception {
         this.accessTokenRepository = provideAccessTokenRepository();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractVacationRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractVacationRepositoryTest.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractVacationRepositoryTest.java
index 3b72f18..71340ff 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractVacationRepositoryTest.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractVacationRepositoryTest.java
@@ -50,7 +50,7 @@ public abstract class AbstractVacationRepositoryTest {
     protected abstract VacationRepository createVacationRepository();
 
     @Before
-    public void setUp() {
+    public void setUp() throws Exception {
         vacationRepository = createVacationRepository();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/access/MemoryAccessTokenRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/access/MemoryAccessTokenRepositoryTest.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/access/MemoryAccessTokenRepositoryTest.java
index 6cb063a..9c32627 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/access/MemoryAccessTokenRepositoryTest.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/access/MemoryAccessTokenRepositoryTest.java
@@ -21,8 +21,15 @@ package org.apache.james.jmap.memory.access;
 
 import org.apache.james.jmap.api.access.AccessTokenRepository;
 import org.apache.james.jmap.api.access.AccessTokenRepositoryTest;
+import org.junit.Before;
 
 public class MemoryAccessTokenRepositoryTest extends AccessTokenRepositoryTest {
+    
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+    
     @Override
     protected AccessTokenRepository provideAccessTokenRepository() {
         return new MemoryAccessTokenRepository(AccessTokenRepositoryTest.TTL_IN_MS);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java b/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
index 04e8c61..57694af 100644
--- a/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
+++ b/server/data/data-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
@@ -20,8 +20,11 @@ package org.apache.james.domainlist.jpa;
 
 import org.apache.james.backends.jpa.JpaTestCluster;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.jpa.model.JPADomain;
 import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Test the JPA implementation of the DomainList.
@@ -30,6 +33,19 @@ public class JPADomainListTest extends AbstractDomainListTest {
 
     private static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPADomain.class);
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws DomainListException {
+        DomainList domainList = createDomainList();
+        for (String domain: domainList.getDomains()) {
+            domainList.removeDomain(domain);
+        }
+    }
+
     @Override
     protected DomainList createDomainList() {
         JPADomainList jpaDomainList = new JPADomainList(getDNSServer("localhost"),

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java b/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
index 5b49a8a..523356a 100644
--- a/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
+++ b/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
@@ -24,6 +24,8 @@ import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.jpa.model.JPARecipientRewrite;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Test the JPA Virtual User Table implementation.
@@ -32,6 +34,16 @@ public class JPARecipientRewriteTableTest extends AbstractRecipientRewriteTableT
 
     private static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPARecipientRewrite.class);
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
         JPARecipientRewriteTable localVirtualUserTable = new JPARecipientRewriteTable();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java b/server/data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
index 63012b3..ac298f3 100644
--- a/server/data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
+++ b/server/data/data-jpa/src/test/java/org/apache/james/user/jpa/JpaUsersRepositoryTest.java
@@ -24,14 +24,21 @@ import org.apache.james.user.jpa.model.JPAUser;
 import org.apache.james.user.lib.AbstractUsersRepository;
 import org.apache.james.user.lib.AbstractUsersRepositoryTest;
 import org.junit.After;
+import org.junit.Before;
 
 public class JpaUsersRepositoryTest extends AbstractUsersRepositoryTest {
 
     private static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPAUser.class);
 
-    @After
+    @Before
     @Override
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
     public void tearDown() throws Exception {
+        super.tearDown();
         JPA_TEST_CLUSTER.clear("JAMES_USER");
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
----------------------------------------------------------------------
diff --git a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
index d1f3b9c..7be9d6b 100644
--- a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
+++ b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
@@ -86,9 +86,17 @@ public class LdapGenericContainer extends ExternalResource {
         container.stop();
     }
 
+    public void pause() {
+        container.pause();
+    }
+
+    public void unpause() {
+        container.unpause();
+    }
+
     public String getLdapHost() {
         return "ldap://" +
-                container.getIp() +
+                container.getContainerIp() +
                 ":" +
                 LdapGenericContainer.DEFAULT_LDAP_PORT;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
index 01e21d1..785d74f 100644
--- a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
+++ b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepositoryTest.java
@@ -136,13 +136,13 @@ public class ReadOnlyUsersLDAPRepositoryTest {
         startUsersRepository(ldapRepositoryConfigurationWithVirtualHosting());
         ldapRepository.test(JAMES_USER_MAIL, PASSWORD);
 
-        ldapContainer.stop();
+        ldapContainer.pause();
         try {
             ldapRepository.test(JAMES_USER_MAIL, PASSWORD);
         } catch (Exception e) {
             LOGGER.info("This exception is expected as we shut down the LDAP and forced its use", e);
         }
-        startLdapContainer();
+        ldapContainer.unpause();
 
         assertThat(ldapRepository.test(JAMES_USER_MAIL, PASSWORD)).isTrue();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
index 2f4b66d..03a0555 100644
--- a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
@@ -29,8 +29,6 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.mock.MockDNSService;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,16 +48,10 @@ public abstract class AbstractDomainListTest {
 
     private DomainList domainList;
 
-    @Before
     public void setUp() throws Exception {
         domainList = createDomainList();
     }
 
-    @After
-    public void tearDown() throws Exception {
-        deleteAll();
-    }
-
     @Test
     public void createListDomains() throws DomainListException {
         domainList.addDomain(DOMAIN_3);
@@ -161,23 +153,6 @@ public abstract class AbstractDomainListTest {
     }
 
     /**
-     * Delete all possible domains from database.
-     */
-    private void deleteAll() throws DomainListException {
-        for (String domain : domainList.getDomains()) {
-            deleteWithoutError(domain);
-        }
-    }
-
-    private void deleteWithoutError(String domain) {
-        try {
-            domainList.removeDomain(domain);
-        } catch(DomainListException e) {
-            LOGGER.info("Ignored error", e);
-        }
-    }
-
-    /**
      * Return a fake DNSServer.
      */
     protected DNSService getDNSServer(final String hostName) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
index 67a414d..c41059c 100644
--- a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
@@ -27,8 +27,6 @@ import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -48,12 +46,10 @@ public abstract class AbstractRecipientRewriteTableTest {
     protected final static int ADDRESS_TYPE = 2;
     protected final static int ALIASDOMAIN_TYPE = 3;
 
-    @Before
     public void setUp() throws Exception {
         virtualUserTable = getRecipientRewriteTable();
     }
 
-    @After
     public void tearDown() throws Exception {
 
         Map<String, Mappings> mappings = virtualUserTable.getAllMappings();
@@ -348,7 +344,7 @@ public abstract class AbstractRecipientRewriteTableTest {
 
         addMapping(user, domain, address, ADDRESS_TYPE);
         addMapping(user, domain, address, REGEX_TYPE);
-        
+
         assertThat(virtualUserTable.getMappings(user, domain)).hasSize(2);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
index b545160..b614a4c 100644
--- a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
@@ -32,8 +32,6 @@ import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.joda.time.DateTime;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 public abstract class AbstractSieveRepositoryTest {
@@ -50,16 +48,10 @@ public abstract class AbstractSieveRepositoryTest {
 
     protected SieveRepository sieveRepository;
 
-    @Before
     public void setUp() throws Exception {
         sieveRepository = createSieveRepository();
     }
 
-    @After
-    public void tearDown() throws Exception {
-        cleanUp();
-    }
-
     @Test(expected = ScriptNotFoundException.class)
     public void getScriptShouldThrowIfUnableToFindScript() throws Exception {
         sieveRepository.getScript(USER, SCRIPT_NAME);
@@ -353,6 +345,4 @@ public abstract class AbstractSieveRepositoryTest {
 
     protected abstract SieveRepository createSieveRepository() throws Exception;
 
-    protected abstract void cleanUp() throws Exception;
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
index 1b8a0e7..a4d889d 100644
--- a/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/user/lib/AbstractUsersRepositoryTest.java
@@ -29,9 +29,7 @@ import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.api.model.User;
 import org.apache.mailet.MailAddress;
-import org.junit.After;
 import org.junit.Assume;
-import org.junit.Before;
 import org.junit.Test;
 
 
@@ -54,7 +52,6 @@ public abstract class AbstractUsersRepositoryTest {
     private String user3;
     private String admin;
     
-    @Before 
     public void setUp() throws Exception { 
         this.usersRepository = getUsersRepository();
         SimpleDomainList domainList = new SimpleDomainList();
@@ -66,7 +63,6 @@ public abstract class AbstractUsersRepositoryTest {
         admin = login("admin");
     }
 
-    @After
     public void tearDown() throws Exception {
         disposeUsersRepository();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java b/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
index f6f06f9..95c79cc 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
@@ -21,9 +21,15 @@ package org.apache.james.domainlist.memory;
 
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.junit.Before;
 
 public class MemoryDomainListTest extends AbstractDomainListTest {
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
     @Override
     protected DomainList createDomainList() {
         MemoryDomainList testee = new MemoryDomainList(getDNSServer("localhost"));

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
index b099737..999cbef 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
@@ -23,9 +23,21 @@ import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.junit.After;
+import org.junit.Before;
 
 public class MemoryRecipientRewriteTableTest extends AbstractRecipientRewriteTableTest {
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
         AbstractRecipientRewriteTable rrt = new MemoryRecipientRewriteTable();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java b/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
index 4057eb7..05e096c 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
@@ -21,9 +21,15 @@ package org.apache.james.user.memory;
 
 import org.apache.james.user.lib.AbstractUsersRepository;
 import org.apache.james.user.lib.AbstractUsersRepositoryTest;
+import org.junit.Before;
 
 public class MemoryUsersRepositoryTest extends AbstractUsersRepositoryTest {
 
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+    
     @Override
     protected AbstractUsersRepository getUsersRepository() throws Exception {
         return MemoryUsersRepository.withVirtualHosting();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
index 3923fc9..06341df 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/amqp/AmqpRule.java
@@ -54,7 +54,7 @@ public class AmqpRule extends ExternalResource {
 
     @Override
     protected void before() throws Throwable {
-        amqpUri = "amqp://" + rabbitMqContainer.getIp();
+        amqpUri = "amqp://" + rabbitMqContainer.getContainerIp();
         ConnectionFactory factory = new ConnectionFactory();
         factory.setUri(amqpUri);
         waitingForRabbitToBeReady(factory);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
index 20de651..b2e3329 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
@@ -41,6 +41,12 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>apache-james-backends-cassandra</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>apache-james-mailbox-api</artifactId>
             <type>test-jar</type>
             <scope>test</scope>
@@ -133,11 +139,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.cassandraunit</groupId>
-            <artifactId>cassandra-unit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>java-hamcrest</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java
index ce824ef..34f0335 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java
@@ -20,18 +20,23 @@
 package org.apache.james.jmap.cassandra;
 
 import org.apache.james.CassandraJmapTestRule;
+import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.methods.integration.GetMailboxesMethodTest;
+import org.junit.ClassRule;
 import org.junit.Rule;
 
 public class CassandraGetMailboxesMethodTest extends GetMailboxesMethodTest {
 
+    @ClassRule
+    public static DockerCassandraRule cassandra = new DockerCassandraRule();
+    
     @Rule 
     public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule();
     
     @Override
     protected GuiceJamesServer createJmapServer() {
-        return rule.jmapServer();
+        return rule.jmapServer(cassandra.getModule());
     }
     
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java
index 8207859..7e4abe5 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java
@@ -20,18 +20,23 @@
 package org.apache.james.jmap.cassandra;
 
 import org.apache.james.CassandraJmapTestRule;
+import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.methods.integration.GetMessageListMethodTest;
+import org.junit.ClassRule;
 import org.junit.Rule;
 
 public class CassandraGetMessageListMethodTest extends GetMessageListMethodTest {
 
+    @ClassRule
+    public static DockerCassandraRule cassandra = new DockerCassandraRule();
+    
     @Rule 
     public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule();
     
     @Override
     protected GuiceJamesServer createJmapServer() {
-        return rule.jmapServer();
+        return rule.jmapServer(cassandra.getModule());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
index 96101bc..7d7a3cc 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
@@ -20,19 +20,24 @@
 package org.apache.james.jmap.cassandra;
 
 import org.apache.james.CassandraJmapTestRule;
+import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.methods.integration.GetVacationResponseTest;
 import org.apache.james.util.date.ZonedDateTimeProvider;
+import org.junit.ClassRule;
 import org.junit.Rule;
 
 public class CassandraGetVacationResponseTest extends GetVacationResponseTest {
 
+    @ClassRule
+    public static DockerCassandraRule cassandra = new DockerCassandraRule();
+    
     @Rule 
     public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule();
     
     @Override
     protected GuiceJamesServer createJmapServer(ZonedDateTimeProvider zonedDateTimeProvider) {
-        return rule.jmapServer()
+        return rule.jmapServer(cassandra.getModule())
                 .overrideWith(binder -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java
index 71a42c3..db874ef 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java
@@ -19,20 +19,25 @@
 package org.apache.james.jmap.cassandra;
 
 import org.apache.james.CassandraJmapTestRule;
+import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.FixedDateZonedDateTimeProvider;
 import org.apache.james.jmap.JMAPAuthenticationTest;
 import org.apache.james.util.date.ZonedDateTimeProvider;
+import org.junit.ClassRule;
 import org.junit.Rule;
 
 public class CassandraJmapAuthenticationTest extends JMAPAuthenticationTest {
 
+    @ClassRule
+    public static DockerCassandraRule cassandra = new DockerCassandraRule();
+    
     @Rule 
     public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule();
     
     @Override
     protected GuiceJamesServer createJmapServer(FixedDateZonedDateTimeProvider zonedDateTimeProvider) {
-        return rule.jmapServer()
+        return rule.jmapServer(cassandra.getModule())
                 .overrideWith(binder -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/a18a4488/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
index cdad450..5eb0929 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
@@ -20,19 +20,24 @@
 package org.apache.james.jmap.cassandra;
 
 import org.apache.james.CassandraJmapTestRule;
+import org.apache.james.DockerCassandraRule;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.methods.integration.SetMailboxesMethodTest;
+import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Rule;
 
 public class CassandraSetMailboxesMethodTest extends SetMailboxesMethodTest {
 
+    @ClassRule
+    public static DockerCassandraRule cassandra = new DockerCassandraRule();
+    
     @Rule 
     public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule();
     
     @Override
     protected GuiceJamesServer createJmapServer() {
-        return rule.jmapServer();
+        return rule.jmapServer(cassandra.getModule());
     }
 
     @Override
@@ -40,13 +45,14 @@ public class CassandraSetMailboxesMethodTest extends SetMailboxesMethodTest {
         rule.await();
     }
 
-    @Ignore
     @Override
+    @Ignore
     public void setMailboxesShouldCreateWhenOverLimitName() throws Exception {
     }
 
-    @Ignore
     @Override
+    @Ignore
     public void setMailboxesShouldUpdateMailboxWhenOverLimitName() throws Exception {
     }
+
 }


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