james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [11/13] james-project git commit: JAMES-2544 Use CassandraCluster extension where applicable
Date Fri, 14 Sep 2018 03:19:35 GMT
JAMES-2544 Use CassandraCluster extension where applicable

This also include simple migrations to JUNIT 5 for cassandra tests


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/df6fe4fb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/df6fe4fb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/df6fe4fb

Branch: refs/heads/master
Commit: df6fe4fb2e3c5c194aabc444d0da7de71d67574d
Parents: 7023a29
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Sep 13 15:15:24 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Sep 14 10:18:33 2018 +0700

----------------------------------------------------------------------
 .../init/CassandraTypeProviderTest.java         |  45 ++++----
 .../backends/cassandra/utils/PaggingTest.java   |  51 +++------
 .../versions/CassandraSchemaVersionDAOTest.java |  44 ++-----
 .../CassandraGenericEventStoreExtension.java    |  26 ++---
 ...istributedMailboxDelegatingListenerTest.java |  41 ++-----
 ...CassandraMailboxPathRegistrerMapperTest.java |  54 +++------
 .../cassandra/mail/CassandraACLMapperTest.java  |  69 +++++------
 .../mail/CassandraApplicableFlagDAOTest.java    |  57 ++++------
 .../mail/CassandraAttachmentDAOTest.java        |  52 +++------
 .../mail/CassandraAttachmentDAOV2Test.java      |  44 ++-----
 .../mail/CassandraAttachmentFallbackTest.java   |  61 ++++------
 .../mail/CassandraAttachmentOwnerDAOTest.java   |  52 +++------
 .../mail/CassandraDeletedMessageDAOTest.java    |  77 +++++--------
 .../mail/CassandraFirstUnseenDAOTest.java       |  66 ++++-------
 .../mail/CassandraIndexTableHandlerTest.java    | 114 ++++++++-----------
 .../mail/CassandraMailboxCounterDAOTest.java    |  77 +++++--------
 .../cassandra/mail/CassandraMailboxDAOTest.java |  70 +++++-------
 .../CassandraMailboxMapperConcurrencyTest.java  |  45 +++-----
 .../mail/CassandraMailboxPathDAOImplTest.java   |  15 +--
 .../mail/CassandraMailboxPathDAOTest.java       |  55 +++------
 .../mail/CassandraMailboxPathV2DAOTest.java     |   3 +-
 .../mail/CassandraMailboxRecentDAOTest.java     |  59 ++++------
 .../cassandra/mail/CassandraMessageDAOTest.java |  68 +++++------
 .../mail/CassandraMessageIdDAOTest.java         |  74 +++++-------
 .../CassandraMessageIdToImapUidDAOTest.java     |  74 +++++-------
 .../mail/CassandraModSeqProviderTest.java       |  49 +++-----
 .../mail/CassandraUidProviderTest.java          |  50 +++-----
 .../mail/CassandraUserMailboxRightsDAOTest.java |  46 +++-----
 .../AttachmentMessageIdCreationTest.java        |  57 ++++------
 .../migration/AttachmentV2MigrationTest.java    |  67 ++++-------
 .../migration/MailboxPathV2MigrationTest.java   |  54 ++++-----
 .../blob/cassandra/CassandraBlobsDAOTest.java   |  34 ++----
 ...assandraMailRepositoryUrlStoreExtension.java |  20 ++--
 .../sieve/cassandra/CassandraSieveDAOTest.java  |  83 +++++---------
 .../cassandra/CassandraSieveQuotaDAOTest.java   |  65 ++++-------
 .../CassandraMailRepositoryCountDAOTest.java    |  43 +++----
 .../CassandraMailRepositoryKeysDAOTest.java     |  30 +----
 .../CassandraMailRepositoryMailDAOTest.java     |  40 ++-----
 .../cassandra/CassandraMailRepositoryTest.java  |  36 ++----
 39 files changed, 707 insertions(+), 1360 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
index 8de8baa..1bf149c 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/CassandraTypeProviderTest.java
@@ -23,58 +23,51 @@ import static com.datastax.driver.core.DataType.text;
 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.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.datastax.driver.core.schemabuilder.SchemaBuilder;
 
-public class CassandraTypeProviderTest {
-
+class CassandraTypeProviderTest {
     private static final String TYPE_NAME = "typename";
     private static final String PROPERTY = "property";
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+    public static final CassandraModule.Impl MODULE = CassandraModule.type(TYPE_NAME)
+        .statement(statement -> statement.addColumn(PROPERTY, text()))
+        .build();
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(MODULE);
     
     private CassandraCluster cassandra;
-    private CassandraModule module;
 
-    @Before
-    public void setUp() {
-        module = CassandraModule.type(TYPE_NAME)
-            .statement(statement -> statement.addColumn(PROPERTY, text()))
-            .build();
-        cassandra = CassandraCluster.create(module, cassandraServer.getHost());
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
+        this.cassandra = cassandra;
         cassandra.getTypesProvider();
     }
 
-    @After
-    public void tearDown() {
-        cassandra.close();
-    }
-
     @Test
-    public void getDefinedUserTypeShouldNotReturnNullNorFailWhenTypeIsDefined() {
+    void getDefinedUserTypeShouldNotReturnNullNorFailWhenTypeIsDefined() {
         assertThat(cassandra.getTypesProvider().getDefinedUserType(TYPE_NAME))
             .isNotNull();
     }
 
     @Test
-    public void initializeTypesShouldCreateTheTypes() {
+    void initializeTypesShouldCreateTheTypes() {
         cassandra.getConf().execute(SchemaBuilder.dropType(TYPE_NAME));
 
-        new CassandraTypesCreator(module, cassandra.getConf()).initializeTypes();
-        CassandraTypesProvider cassandraTypesProviderTest = new CassandraTypesProvider(module, cassandra.getConf());
+        new CassandraTypesCreator(MODULE, cassandra.getConf()).initializeTypes();
+        CassandraTypesProvider cassandraTypesProviderTest = new CassandraTypesProvider(MODULE, cassandra.getConf());
         assertThat(cassandraTypesProviderTest.getDefinedUserType(TYPE_NAME))
             .isNotNull();
     }
 
     @Test
-    public void initializeTypesShouldNotFailIfCalledTwice() {
-        new CassandraTypesProvider(module, cassandra.getConf());
+    void initializeTypesShouldNotFailIfCalledTwice() {
+        new CassandraTypesProvider(MODULE, cassandra.getConf());
         assertThat(cassandra.getTypesProvider().getDefinedUserType(TYPE_NAME))
             .isNotNull();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
index f9049f9..3395e20 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/utils/PaggingTest.java
@@ -28,59 +28,40 @@ import java.util.UUID;
 import java.util.stream.IntStream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.util.CompletableFutureUtil;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.datastax.driver.core.DataType;
 import com.datastax.driver.core.utils.UUIDs;
 
-public class PaggingTest {
+class PaggingTest {
     
     private static final String TABLE_NAME = "test";
     private static final String ID = "id";
     private static final String CLUSTERING = "clustering";
     private static final UUID UUID = UUIDs.timeBased();
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    
-    private static CassandraCluster cassandra;
-    private CassandraAsyncExecutor executor;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraModule.table(TABLE_NAME)
+        .comment("Testing table")
+        .statement(statement -> statement
+            .addPartitionKey(ID, DataType.timeuuid())
+            .addClusteringColumn(CLUSTERING, DataType.bigint()))
+        .build());
 
-    @BeforeClass
-    public static void setUpClass() {
-        CassandraModule modules = CassandraModule.table(TABLE_NAME)
-            .comment("Testing table")
-            .statement(statement -> statement
-                .addPartitionKey(ID, DataType.timeuuid())
-                .addClusteringColumn(CLUSTERING, DataType.bigint()))
-            .build();
-        cassandra = CassandraCluster.create(modules, cassandraServer.getHost());
-    }
+    private CassandraAsyncExecutor executor;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         executor = new CassandraAsyncExecutor(cassandra.getConf());
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void pagingShouldWork() {
+    void pagingShouldWork() {
         int fetchSize = 200;
         int size = 2 * fetchSize + 50;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
index 7db01dd..e5a0b8b 100644
--- a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
+++ b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionDAOTest.java
@@ -24,51 +24,31 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.Optional;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class CassandraSchemaVersionDAOTest {
-
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+class CassandraSchemaVersionDAOTest {
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraSchemaVersionModule.MODULE);
 
     private CassandraSchemaVersionDAO testee;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraSchemaVersionModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraSchemaVersionDAO(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void getCurrentSchemaVersionShouldReturnEmptyWhenTableIsEmpty() {
+    void getCurrentSchemaVersionShouldReturnEmptyWhenTableIsEmpty() {
         assertThat(testee.getCurrentSchemaVersion().join())
             .isEqualTo(Optional.empty());
     }
 
     @Test
-    public void getCurrentSchemaVersionShouldReturnVersionPresentInTheTable() {
+    void getCurrentSchemaVersionShouldReturnVersionPresentInTheTable() {
         SchemaVersion version = new SchemaVersion(42);
 
         testee.updateVersion(version).join();
@@ -77,7 +57,7 @@ public class CassandraSchemaVersionDAOTest {
     }
 
     @Test
-    public void getCurrentSchemaVersionShouldBeIdempotent() {
+    void getCurrentSchemaVersionShouldBeIdempotent() {
         SchemaVersion version = new SchemaVersion(42);
 
         testee.updateVersion(version.next()).join();

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraGenericEventStoreExtension.java
----------------------------------------------------------------------
diff --git a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraGenericEventStoreExtension.java b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraGenericEventStoreExtension.java
index 2f2650b..56eee29 100644
--- a/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraGenericEventStoreExtension.java
+++ b/event-sourcing/event-store-cassandra/src/test/java/org/apache/james/eventsourcing/eventstore/cassandra/CassandraGenericEventStoreExtension.java
@@ -21,9 +21,7 @@ package org.apache.james.eventsourcing.eventstore.cassandra;
 
 import java.util.Set;
 
-import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraExtension;
-import org.apache.james.backends.cassandra.DockerCassandraExtension.DockerCassandra;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.eventsourcing.eventstore.EventStore;
 import org.apache.james.eventsourcing.eventstore.cassandra.dto.EventDTOModule;
@@ -37,43 +35,37 @@ import org.junit.jupiter.api.extension.ParameterResolutionException;
 import org.junit.jupiter.api.extension.ParameterResolver;
 
 public class CassandraGenericEventStoreExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
-    private final DockerCassandraExtension dockerCassandraExtension;
     @SuppressWarnings("rawtypes")
     private final Set<EventDTOModule> modules;
-    private CassandraCluster cassandra;
-    private DockerCassandra dockerCassandra;
+    private CassandraClusterExtension cassandra;
     private EventStoreDao eventStoreDao;
 
     public CassandraGenericEventStoreExtension(@SuppressWarnings("rawtypes") Set<EventDTOModule> modules) {
         this.modules = modules;
-        dockerCassandraExtension = new DockerCassandraExtension();
+        cassandra = new CassandraClusterExtension(CassandraEventStoreModule.MODULE);
     }
 
     @Override
-    public void beforeAll(ExtensionContext context) throws Exception {
-        dockerCassandraExtension.beforeAll(context);
-        dockerCassandra = dockerCassandraExtension.getDockerCassandra();
-        cassandra = CassandraCluster.create(
-            CassandraEventStoreModule.MODULE, dockerCassandra.getHost());
+    public void beforeAll(ExtensionContext context) {
+        cassandra.beforeAll(context);
     }
 
     @Override
-    public void afterAll(ExtensionContext context) throws Exception {
-        cassandra.closeCluster();
-        dockerCassandraExtension.afterAll(context);
+    public void afterAll(ExtensionContext context) {
+        cassandra.afterAll(context);
     }
 
     @Override
     public void beforeEach(ExtensionContext context) {
         JsonEventSerializer jsonEventSerializer = new JsonEventSerializer(modules);
 
-        eventStoreDao = new EventStoreDao(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION,
+        eventStoreDao = new EventStoreDao(cassandra.getCassandraCluster().getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION,
             jsonEventSerializer);
     }
 
     @Override
     public void afterEach(ExtensionContext context) {
-        cassandra.clearTables();
+        cassandra.afterEach(context);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
index b1563d1..e5150b7 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.TreeMap;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
@@ -46,12 +46,9 @@ import org.apache.james.mailbox.store.json.event.MailboxConverter;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.apache.james.mailbox.util.EventCollector;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.common.collect.ImmutableMap;
 
@@ -60,7 +57,7 @@ import com.google.common.collect.ImmutableMap;
 
  We simulate communications using message queues in memory and check the Listener works as intended.
  */
-public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
+class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
 
     public static final MailboxPath MAILBOX_PATH_1 = MailboxPath.forUser("user", "mbx");
     public static final MailboxPath MAILBOX_PATH_2 = MailboxPath.forUser("user", "mbx.other");
@@ -68,9 +65,8 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
     public static final int SCHEDULER_PERIOD_IN_S = 20;
     public static final ImmutableMap<MessageUid, MailboxMessage> EMPTY_MESSAGE_CACHE = ImmutableMap.of();
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraRegistrationModule.MODULE);
 
     private RegisteredDelegatingMailboxListener registeredDelegatingMailboxListener1;
     private RegisteredDelegatingMailboxListener registeredDelegatingMailboxListener2;
@@ -83,13 +79,8 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
     private EventCollector eventCollectorOnce3;
     private MailboxSession mailboxSession;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraRegistrationModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) throws Exception {
         PublisherReceiver publisherReceiver = new PublisherReceiver();
         DistantMailboxPathRegister mailboxPathRegister1 = new DistantMailboxPathRegister(
             new CassandraMailboxPathRegisterMapper(
@@ -145,18 +136,8 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
         registeredDelegatingMailboxListener3.addListener(MAILBOX_PATH_2, eventCollectorMailbox3, mailboxSession);
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void mailboxEventListenersShouldBeTriggeredIfRegistered() throws Exception {
+    void mailboxEventListenersShouldBeTriggeredIfRegistered() {
         SimpleMailbox simpleMailbox = new SimpleMailbox(MAILBOX_PATH_1, 42);
         simpleMailbox.setMailboxId(TestId.of(52));
         TreeMap<MessageUid, MessageMetaData> uids = new TreeMap<>();
@@ -170,7 +151,7 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
     }
 
     @Test
-    public void onceEventListenersShouldBeTriggeredOnceAcrossTheCluster() {
+    void onceEventListenersShouldBeTriggeredOnceAcrossTheCluster() {
         SimpleMailbox simpleMailbox = new SimpleMailbox(MAILBOX_PATH_1, 42);
         simpleMailbox.setMailboxId(TestId.of(52));
         TreeMap<MessageUid, MessageMetaData> uids = new TreeMap<>();

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
index 9a412ea..213006a 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraMailboxPathRegistrerMapperTest.java
@@ -24,23 +24,18 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.cassandra.modules.CassandraRegistrationModule;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.publisher.Topic;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class CassandraMailboxPathRegistrerMapperTest {
-
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+class CassandraMailboxPathRegistrerMapperTest {
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraRegistrationModule.MODULE);
 
     private static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", "user", "name");
     private static final MailboxPath MAILBOX_PATH_2 = new MailboxPath("namespace2", "user2", "name2");
@@ -50,76 +45,61 @@ public class CassandraMailboxPathRegistrerMapperTest {
 
     private CassandraMailboxPathRegisterMapper mapper;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraRegistrationModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         mapper = new CassandraMailboxPathRegisterMapper(cassandra.getConf(),
             cassandra.getTypesProvider(),
             CassandraUtils.WITH_DEFAULT_CONFIGURATION,
             CASSANDRA_TIME_OUT_IN_S);
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void getTopicsShouldReturnEmptyResultByDefault() {
+    void getTopicsShouldReturnEmptyResultByDefault() {
         assertThat(mapper.getTopics(MAILBOX_PATH)).isEmpty();
     }
 
     @Test
-    public void doRegisterShouldWork() {
+    void doRegisterShouldWork() {
         mapper.doRegister(MAILBOX_PATH, TOPIC);
         assertThat(mapper.getTopics(MAILBOX_PATH)).containsOnly(TOPIC);
     }
 
     @Test
-    public void doRegisterShouldBeMailboxPathSpecific() {
+    void doRegisterShouldBeMailboxPathSpecific() {
         mapper.doRegister(MAILBOX_PATH, TOPIC);
         assertThat(mapper.getTopics(MAILBOX_PATH_2)).isEmpty();
     }
 
     @Test
-    public void doRegisterShouldAllowMultipleTopics() {
+    void doRegisterShouldAllowMultipleTopics() {
         mapper.doRegister(MAILBOX_PATH, TOPIC);
         mapper.doRegister(MAILBOX_PATH, TOPIC_2);
         assertThat(mapper.getTopics(MAILBOX_PATH)).containsOnly(TOPIC, TOPIC_2);
     }
 
     @Test
-    public void doUnRegisterShouldWork() {
+    void doUnRegisterShouldWork() {
         mapper.doRegister(MAILBOX_PATH, TOPIC);
         mapper.doUnRegister(MAILBOX_PATH, TOPIC);
         assertThat(mapper.getTopics(MAILBOX_PATH)).isEmpty();
     }
 
     @Test
-    public void doUnregisterShouldBeMailboxSpecific() {
+    void doUnregisterShouldBeMailboxSpecific() {
         mapper.doRegister(MAILBOX_PATH, TOPIC);
         mapper.doUnRegister(MAILBOX_PATH_2, TOPIC);
         assertThat(mapper.getTopics(MAILBOX_PATH)).containsOnly(TOPIC);
     }
 
     @Test
-    public void doUnregisterShouldBeTopicSpecific() {
+    void doUnregisterShouldBeTopicSpecific() {
         mapper.doRegister(MAILBOX_PATH, TOPIC);
         mapper.doUnRegister(MAILBOX_PATH, TOPIC_2);
         assertThat(mapper.getTopics(MAILBOX_PATH)).containsOnly(TOPIC);
     }
 
     @Test
-    public void entriesShouldExpire() throws Exception {
+    void entriesShouldExpire(CassandraCluster cassandra) throws Exception {
         int verySmallTimeoutInSecond = 1;
         mapper = new CassandraMailboxPathRegisterMapper(cassandra.getConf(),
             cassandra.getTypesProvider(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
index b38c212..cdea6fa 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
@@ -40,48 +40,35 @@ import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.table.CassandraACLTable;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxACL;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class CassandraACLMapperTest {
+class CassandraACLMapperTest {
 
-    public static final CassandraId MAILBOX_ID = CassandraId.of(UUID.fromString("464765a0-e4e7-11e4-aba4-710c1de3782b"));
+    static final CassandraId MAILBOX_ID = CassandraId.of(UUID.fromString("464765a0-e4e7-11e4-aba4-710c1de3782b"));
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraAclModule.MODULE);
 
     private CassandraACLMapper cassandraACLMapper;
     private ExecutorService executor;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraAclModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         cassandraACLMapper = GuiceUtils.testInjector(cassandra)
             .getInstance(CassandraACLMapper.class);
         executor = Executors.newFixedThreadPool(2);
     }
 
-    @After
-    public void tearDown() {
+    @AfterEach
+    void tearDown() {
         executor.shutdownNow();
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
     }
 
     @Test
-    public void retrieveACLWhenInvalidInBaseShouldReturnEmptyACL() throws Exception {
+    void retrieveACLWhenInvalidInBaseShouldReturnEmptyACL(CassandraCluster cassandra) {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
                 .value(CassandraACLTable.ID, MAILBOX_ID.asUuid())
@@ -92,12 +79,12 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void retrieveACLWhenNoACLStoredShouldReturnEmptyACL() {
+    void retrieveACLWhenNoACLStoredShouldReturnEmptyACL() {
         assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(MailboxACL.EMPTY);
     }
 
     @Test
-    public void addACLWhenNoneStoredShouldReturnUpdatedACL() throws Exception {
+    void addACLWhenNoneStoredShouldReturnUpdatedACL() throws Exception {
         MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false);
         MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read);
 
@@ -109,7 +96,7 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void modifyACLWhenStoredShouldReturnUpdatedACL() throws MailboxException {
+    void modifyACLWhenStoredShouldReturnUpdatedACL() throws MailboxException {
         MailboxACL.EntryKey keyBob = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false);
         MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read);
 
@@ -122,7 +109,7 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void removeWhenStoredShouldReturnUpdatedACL() throws MailboxException {
+    void removeWhenStoredShouldReturnUpdatedACL() throws MailboxException {
         MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false);
         MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read);
 
@@ -133,7 +120,7 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void replaceForSingleKeyWithNullRightsWhenSingleKeyStoredShouldReturnEmptyACL() throws MailboxException {
+    void replaceForSingleKeyWithNullRightsWhenSingleKeyStoredShouldReturnEmptyACL() throws MailboxException {
         MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false);
         MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read);
 
@@ -144,7 +131,7 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void replaceWhenNotStoredShouldUpdateACLEntry() throws MailboxException {
+    void replaceWhenNotStoredShouldUpdateACLEntry() throws MailboxException {
         MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false);
         MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read);
 
@@ -154,7 +141,7 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void updateInvalidACLShouldBeBasedOnEmptyACL() throws Exception {
+    void updateInvalidACLShouldBeBasedOnEmptyACL(CassandraCluster cassandra) throws Exception {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
                 .value(CassandraACLTable.ID, MAILBOX_ID.asUuid())
@@ -169,13 +156,13 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void twoConcurrentUpdatesWhenNoACEStoredShouldReturnACEWithTwoEntries() throws Exception {
+    void twoConcurrentUpdatesWhenNoACEStoredShouldReturnACEWithTwoEntries(CassandraCluster cassandra) throws Exception {
         CountDownLatch countDownLatch = new CountDownLatch(2);
         MailboxACL.EntryKey keyBob = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false);
         MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read);
         MailboxACL.EntryKey keyAlice = new MailboxACL.EntryKey("alice", MailboxACL.NameType.user, false);
-        Future<Boolean> future1 = performACLUpdateInExecutor(executor, keyBob, rights, countDownLatch::countDown);
-        Future<Boolean> future2 = performACLUpdateInExecutor(executor, keyAlice, rights, countDownLatch::countDown);
+        Future<Boolean> future1 = performACLUpdateInExecutor(cassandra, executor, keyBob, rights, countDownLatch::countDown);
+        Future<Boolean> future2 = performACLUpdateInExecutor(cassandra, executor, keyAlice, rights, countDownLatch::countDown);
         awaitAll(future1, future2);
 
         assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join())
@@ -183,7 +170,7 @@ public class CassandraACLMapperTest {
     }
 
     @Test
-    public void twoConcurrentUpdatesWhenStoredShouldReturnACEWithTwoEntries() throws Exception {
+    void twoConcurrentUpdatesWhenStoredShouldReturnACEWithTwoEntries(CassandraCluster cassandra) throws Exception {
         CountDownLatch countDownLatch = new CountDownLatch(2);
         MailboxACL.EntryKey keyBenwa = new MailboxACL.EntryKey("benwa", MailboxACL.NameType.user, false);
         MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read);
@@ -191,8 +178,8 @@ public class CassandraACLMapperTest {
 
         MailboxACL.EntryKey keyBob = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false);
         MailboxACL.EntryKey keyAlice = new MailboxACL.EntryKey("alice", MailboxACL.NameType.user, false);
-        Future<Boolean> future1 = performACLUpdateInExecutor(executor, keyBob, rights, countDownLatch::countDown);
-        Future<Boolean> future2 = performACLUpdateInExecutor(executor, keyAlice, rights, countDownLatch::countDown);
+        Future<Boolean> future1 = performACLUpdateInExecutor(cassandra, executor, keyBob, rights, countDownLatch::countDown);
+        Future<Boolean> future2 = performACLUpdateInExecutor(cassandra, executor, keyAlice, rights, countDownLatch::countDown);
         awaitAll(future1, future2);
 
         assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join())
@@ -206,7 +193,7 @@ public class CassandraACLMapperTest {
         }
     }
 
-    private Future<Boolean> performACLUpdateInExecutor(ExecutorService executor, MailboxACL.EntryKey key, MailboxACL.Rfc4314Rights rights, CassandraACLMapper.CodeInjector runnable) {
+    private Future<Boolean> performACLUpdateInExecutor(CassandraCluster cassandra, ExecutorService executor, MailboxACL.EntryKey key, MailboxACL.Rfc4314Rights rights, CassandraACLMapper.CodeInjector runnable) {
         return executor.submit(() -> {
             CassandraACLMapper aclMapper = new CassandraACLMapper(
                 cassandra.getConf(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/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 911d0d0..e2e4f62 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,59 +24,40 @@ 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.backends.cassandra.CassandraClusterExtension;
 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.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.common.collect.ImmutableSet;
 
-public class CassandraApplicableFlagDAOTest {
+class CassandraApplicableFlagDAOTest {
 
-    public static final String USER_FLAG = "User Flag";
-    public static final String USER_FLAG2 = "User Flag 2";
-    public static final CassandraId CASSANDRA_ID = CassandraId.timeBased();
+    private static final String USER_FLAG = "User Flag";
+    private static final String USER_FLAG2 = "User Flag 2";
+    private static final CassandraId CASSANDRA_ID = CassandraId.timeBased();
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraApplicableFlagsModule.MODULE);
 
     private CassandraApplicableFlagDAO testee;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraApplicableFlagsModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraApplicableFlagDAO(cassandra.getConf());
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void updateApplicableFlagsShouldReturnEmptyByDefault() throws Exception {
+    void updateApplicableFlagsShouldReturnEmptyByDefault() {
         assertThat(testee.retrieveApplicableFlag(CASSANDRA_ID).join())
             .isEmpty();
     }
 
     @Test
-    public void updateApplicableFlagsShouldSupportEmptyUserFlags() throws Exception {
+    void updateApplicableFlagsShouldSupportEmptyUserFlags() {
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of()).join();
 
         assertThat(testee.retrieveApplicableFlag(CASSANDRA_ID).join())
@@ -84,7 +65,7 @@ public class CassandraApplicableFlagDAOTest {
     }
 
     @Test
-    public void updateApplicableFlagsShouldUpdateUserFlag() throws Exception {
+    void updateApplicableFlagsShouldUpdateUserFlag() {
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG)).join();
 
         assertThat(testee.retrieveApplicableFlag(CASSANDRA_ID).join())
@@ -92,7 +73,7 @@ public class CassandraApplicableFlagDAOTest {
     }
 
     @Test
-    public void updateApplicableFlagsShouldUnionUserFlags() throws Exception {
+    void updateApplicableFlagsShouldUnionUserFlags() {
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG)).join();
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG2)).join();
 
@@ -101,7 +82,7 @@ public class CassandraApplicableFlagDAOTest {
     }
 
     @Test
-    public void updateApplicableFlagsShouldBeIdempotent() throws Exception {
+    void updateApplicableFlagsShouldBeIdempotent() {
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG)).join();
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG)).join();
 
@@ -110,7 +91,7 @@ public class CassandraApplicableFlagDAOTest {
     }
 
     @Test
-    public void updateApplicableFlagsShouldSkipAlreadyStoredFlagsWhenAddingFlag() throws Exception {
+    void updateApplicableFlagsShouldSkipAlreadyStoredFlagsWhenAddingFlag() {
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG)).join();
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG, USER_FLAG2)).join();
 
@@ -119,7 +100,7 @@ public class CassandraApplicableFlagDAOTest {
     }
 
     @Test
-    public void updateApplicableFlagsShouldUpdateMultiFlags() throws Exception {
+    void updateApplicableFlagsShouldUpdateMultiFlags() {
         testee.updateApplicableFlags(CASSANDRA_ID, ImmutableSet.of(USER_FLAG, USER_FLAG2)).join();
 
         assertThat(testee.retrieveApplicableFlag(CASSANDRA_ID).join())

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOTest.java
index f88406e..f82375e 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOTest.java
@@ -25,63 +25,43 @@ import java.nio.charset.StandardCharsets;
 import java.util.Optional;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
 import org.apache.james.mailbox.model.Attachment;
 import org.apache.james.mailbox.model.AttachmentId;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.github.steveash.guavate.Guavate;
 
-public class CassandraAttachmentDAOTest {
-    public static final AttachmentId ATTACHMENT_ID = AttachmentId.from("id1");
-    public static final AttachmentId ATTACHMENT_ID_2 = AttachmentId.from("id2");
+class CassandraAttachmentDAOTest {
+    private static final AttachmentId ATTACHMENT_ID = AttachmentId.from("id1");
+    private static final AttachmentId ATTACHMENT_ID_2 = AttachmentId.from("id2");
 
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraAttachmentModule.MODULE);
 
     private CassandraAttachmentDAO testee;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraAttachmentModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraAttachmentDAO(cassandra.getConf(),
             CassandraUtils.WITH_DEFAULT_CONFIGURATION,
             CassandraConfiguration.DEFAULT_CONFIGURATION);
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void getAttachmentShouldReturnEmptyWhenAbsent() {
+    void getAttachmentShouldReturnEmptyWhenAbsent() {
         Optional<Attachment> attachment = testee.getAttachment(ATTACHMENT_ID).join();
 
         assertThat(attachment).isEmpty();
     }
 
     @Test
-    public void retrieveAllShouldReturnEmptyByDefault() {
+    void retrieveAllShouldReturnEmptyByDefault() {
         assertThat(
             testee.retrieveAll()
                 .collect(Guavate.toImmutableList()))
@@ -89,7 +69,7 @@ public class CassandraAttachmentDAOTest {
     }
 
     @Test
-    public void retrieveAllShouldReturnStoredAttachments() throws Exception {
+    void retrieveAllShouldReturnStoredAttachments() throws Exception {
         Attachment attachment1 = Attachment.builder()
             .attachmentId(ATTACHMENT_ID)
             .type("application/json")
@@ -110,7 +90,7 @@ public class CassandraAttachmentDAOTest {
     }
 
     @Test
-    public void getAttachmentShouldReturnAttachmentWhenStored() throws Exception {
+    void getAttachmentShouldReturnAttachmentWhenStored() throws Exception {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID)
             .type("application/json")
@@ -124,7 +104,7 @@ public class CassandraAttachmentDAOTest {
     }
 
     @Test
-    public void deleteAttachmentShouldRemoveAttachment() throws Exception {
+    void deleteAttachmentShouldRemoveAttachment() throws Exception {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID)
             .type("application/json")

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
index 7471609..6e3b705 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
@@ -25,60 +25,40 @@ import java.nio.charset.StandardCharsets;
 import java.util.Optional;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.blob.api.BlobId;
 import org.apache.james.blob.api.HashBlobId;
 import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2.DAOAttachment;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
 import org.apache.james.mailbox.model.Attachment;
 import org.apache.james.mailbox.model.AttachmentId;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class CassandraAttachmentDAOV2Test {
-    public static final AttachmentId ATTACHMENT_ID = AttachmentId.from("id1");
+class CassandraAttachmentDAOV2Test {
+    private static final AttachmentId ATTACHMENT_ID = AttachmentId.from("id1");
     private static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
 
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraAttachmentModule.MODULE);
 
     private CassandraAttachmentDAOV2 testee;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraAttachmentModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraAttachmentDAOV2(BLOB_ID_FACTORY, cassandra.getConf());
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void getAttachmentShouldReturnEmptyWhenAbsent() {
+    void getAttachmentShouldReturnEmptyWhenAbsent() {
         Optional<DAOAttachment> attachment = testee.getAttachment(ATTACHMENT_ID).join();
 
         assertThat(attachment).isEmpty();
     }
 
     @Test
-    public void getAttachmentShouldReturnAttachmentWhenStored() throws Exception {
+    void getAttachmentShouldReturnAttachmentWhenStored() {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID)
             .type("application/json")

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java
index 0f8a85a..862ea95 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java
@@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.nio.charset.StandardCharsets;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
@@ -38,24 +38,22 @@ import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
 import org.apache.james.mailbox.exception.AttachmentNotFoundException;
 import org.apache.james.mailbox.model.Attachment;
 import org.apache.james.mailbox.model.AttachmentId;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.common.collect.ImmutableList;
 
-public class CassandraAttachmentFallbackTest {
-    public static final AttachmentId ATTACHMENT_ID_1 = AttachmentId.from("id1");
-    public static final AttachmentId ATTACHMENT_ID_2 = AttachmentId.from("id2");
+class CassandraAttachmentFallbackTest {
+    private static final AttachmentId ATTACHMENT_ID_1 = AttachmentId.from("id1");
+    private static final AttachmentId ATTACHMENT_ID_2 = AttachmentId.from("id2");
     private static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
 
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(
+        CassandraModule.aggregateModules(
+            CassandraAttachmentModule.MODULE,
+            CassandraBlobModule.MODULE));
 
     private CassandraAttachmentDAOV2 attachmentDAOV2;
     private CassandraAttachmentDAO attachmentDAO;
@@ -63,16 +61,9 @@ public class CassandraAttachmentFallbackTest {
     private CassandraBlobsDAO blobsDAO;
     private CassandraAttachmentMessageIdDAO attachmentMessageIdDAO;
 
-    @BeforeClass
-    public static void setUpClass() {
-        CassandraModule modules = CassandraModule.aggregateModules(
-            CassandraAttachmentModule.MODULE,
-            CassandraBlobModule.MODULE);
-        cassandra = CassandraCluster.create(modules, cassandraServer.getHost());
-    }
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         attachmentDAOV2 = new CassandraAttachmentDAOV2(BLOB_ID_FACTORY, cassandra.getConf());
         attachmentDAO = new CassandraAttachmentDAO(cassandra.getConf(),
             CassandraUtils.WITH_DEFAULT_CONFIGURATION,
@@ -83,30 +74,20 @@ public class CassandraAttachmentFallbackTest {
         attachmentMapper = new CassandraAttachmentMapper(attachmentDAO, attachmentDAOV2, blobsDAO, attachmentMessageIdDAO, ownerDAO);
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void getAttachmentShouldThrowWhenAbsentFromV1AndV2() throws Exception {
+    void getAttachmentShouldThrowWhenAbsentFromV1AndV2() {
         assertThatThrownBy(() -> attachmentMapper.getAttachment(ATTACHMENT_ID_1))
             .isInstanceOf(AttachmentNotFoundException.class);
     }
 
     @Test
-    public void getAttachmentsShouldReturnEmptyWhenAbsentFromV1AndV2() throws Exception {
+    void getAttachmentsShouldReturnEmptyWhenAbsentFromV1AndV2() {
         assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1)))
             .isEmpty();
     }
 
     @Test
-    public void getAttachmentShouldReturnV2WhenPresentInV1AndV2() throws Exception {
+    void getAttachmentShouldReturnV2WhenPresentInV1AndV2() throws Exception {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID_1)
             .type("application/json")
@@ -127,7 +108,7 @@ public class CassandraAttachmentFallbackTest {
     }
 
     @Test
-    public void getAttachmentShouldReturnV1WhenV2Absent() throws Exception {
+    void getAttachmentShouldReturnV1WhenV2Absent() throws Exception {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID_1)
             .type("application/json")
@@ -141,7 +122,7 @@ public class CassandraAttachmentFallbackTest {
     }
 
     @Test
-    public void getAttachmentsShouldReturnV2WhenV2AndV1() throws Exception {
+    void getAttachmentsShouldReturnV2WhenV2AndV1() throws Exception {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID_1)
             .type("application/json")
@@ -162,7 +143,7 @@ public class CassandraAttachmentFallbackTest {
     }
 
     @Test
-    public void getAttachmentsShouldReturnV1WhenV2Absent() throws Exception {
+    void getAttachmentsShouldReturnV1WhenV2Absent() throws Exception {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID_1)
             .type("application/json")
@@ -176,7 +157,7 @@ public class CassandraAttachmentFallbackTest {
     }
 
     @Test
-    public void getAttachmentsShouldCombineElementsFromV1AndV2() throws Exception {
+    void getAttachmentsShouldCombineElementsFromV1AndV2() throws Exception {
         Attachment attachment = Attachment.builder()
             .attachmentId(ATTACHMENT_ID_1)
             .type("application/json")

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java
index 0164508..f7d7b5d 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentOwnerDAOTest.java
@@ -24,61 +24,41 @@ 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.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
 import org.apache.james.mailbox.model.AttachmentId;
 import org.apache.james.mailbox.store.mail.model.Username;
 import org.apache.james.util.FluentFutureStream;
 import org.apache.james.util.streams.JamesCollectors;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class CassandraAttachmentOwnerDAOTest {
-    public static final AttachmentId ATTACHMENT_ID = AttachmentId.from("id1");
-    public static final Username OWNER_1 = Username.fromRawValue("owner1");
-    public static final Username OWNER_2 = Username.fromRawValue("owner2");
+class CassandraAttachmentOwnerDAOTest {
+    private static final AttachmentId ATTACHMENT_ID = AttachmentId.from("id1");
+    private static final Username OWNER_1 = Username.fromRawValue("owner1");
+    private static final Username OWNER_2 = Username.fromRawValue("owner2");
 
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraAttachmentModule.MODULE);
 
     private CassandraAttachmentOwnerDAO testee;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraAttachmentModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraAttachmentOwnerDAO(cassandra.getConf(),
             CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void retrieveOwnersShouldReturnEmptyByDefault() {
+    void retrieveOwnersShouldReturnEmptyByDefault() {
         assertThat(testee.retrieveOwners(ATTACHMENT_ID).join())
             .isEmpty();
     }
 
     @Test
-    public void retrieveOwnersShouldReturnAddedOwner() {
+    void retrieveOwnersShouldReturnAddedOwner() {
         testee.addOwner(ATTACHMENT_ID, OWNER_1).join();
 
         assertThat(testee.retrieveOwners(ATTACHMENT_ID).join())
@@ -86,7 +66,7 @@ public class CassandraAttachmentOwnerDAOTest {
     }
 
     @Test
-    public void retrieveOwnersShouldReturnAddedOwners() {
+    void retrieveOwnersShouldReturnAddedOwners() {
         testee.addOwner(ATTACHMENT_ID, OWNER_1).join();
         testee.addOwner(ATTACHMENT_ID, OWNER_2).join();
 
@@ -95,7 +75,7 @@ public class CassandraAttachmentOwnerDAOTest {
     }
 
     @Test
-    public void retrieveOwnersShouldNotThrowWhenMoreReferencesThanPaging() {
+    void retrieveOwnersShouldNotThrowWhenMoreReferencesThanPaging() {
         int referenceCountExceedingPaging = 5050;
 
         IntStream.range(0, referenceCountExceedingPaging)

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/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 913aef7..906f9c7 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
@@ -25,57 +25,38 @@ 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.backends.cassandra.CassandraClusterExtension;
 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.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 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);
-    public static final MessageUid UID_3 = MessageUid.of(3);
-    public static final MessageUid UID_4 = MessageUid.of(4);
-    public static final MessageUid UID_7 = MessageUid.of(7);
-    public static final MessageUid UID_8 = MessageUid.of(8);
+class CassandraDeletedMessageDAOTest {
+    private static final CassandraId MAILBOX_ID = CassandraId.of(UUID.fromString("110e8400-e29b-11d4-a716-446655440000"));
+    private static final MessageUid UID_1 = MessageUid.of(1);
+    private static final MessageUid UID_2 = MessageUid.of(2);
+    private static final MessageUid UID_3 = MessageUid.of(3);
+    private static final MessageUid UID_4 = MessageUid.of(4);
+    private static final MessageUid UID_7 = MessageUid.of(7);
+    private static final MessageUid UID_8 = MessageUid.of(8);
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraDeletedMessageModule.MODULE);
 
     private CassandraDeletedMessageDAO testee;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraDeletedMessageModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraDeletedMessageDAO(cassandra.getConf());
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void retrieveDeletedMessageShouldReturnEmptyByDefault() {
+    void retrieveDeletedMessageShouldReturnEmptyByDefault() {
         List<MessageUid> result = testee
             .retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
             .join()
@@ -85,7 +66,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void addDeletedMessageShouldThenBeReportedAsDeletedMessage() {
+    void addDeletedMessageShouldThenBeReportedAsDeletedMessage() {
         testee.addDeleted(MAILBOX_ID, UID_1).join();
         testee.addDeleted(MAILBOX_ID, UID_2).join();
 
@@ -97,7 +78,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void addDeletedMessageShouldBeIdempotent() {
+    void addDeletedMessageShouldBeIdempotent() {
         testee.addDeleted(MAILBOX_ID, UID_1).join();
         testee.addDeleted(MAILBOX_ID, UID_1).join();
 
@@ -110,7 +91,7 @@ public class CassandraDeletedMessageDAOTest {
 
 
     @Test
-    public void removeUnreadShouldReturnEmptyWhenNoData() {
+    void removeUnreadShouldReturnEmptyWhenNoData() {
         testee.removeDeleted(MAILBOX_ID, UID_1).join();
 
         List<MessageUid> result = testee
@@ -122,7 +103,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void removeDeletedMessageShouldNotAffectOtherMessage() {
+    void removeDeletedMessageShouldNotAffectOtherMessage() {
         testee.addDeleted(MAILBOX_ID, UID_2).join();
         testee.addDeleted(MAILBOX_ID, UID_1).join();
 
@@ -137,7 +118,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void removeDeletedShouldRemoveSpecifiedUID() {
+    void removeDeletedShouldRemoveSpecifiedUID() {
         testee.addDeleted(MAILBOX_ID, UID_2).join();
 
         testee.removeDeleted(MAILBOX_ID, UID_2).join();
@@ -160,7 +141,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void retrieveDeletedMessageShouldReturnAllMessageForMessageRangeAll() {
+    void retrieveDeletedMessageShouldReturnAllMessageForMessageRangeAll() {
         addMessageForRetrieveTest();
 
         List<MessageUid> result = testee
@@ -172,7 +153,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void retrieveDeletedMessageShouldReturnOneMessageForMessageRangeOneIfThisMessageIsPresent() {
+    void retrieveDeletedMessageShouldReturnOneMessageForMessageRangeOneIfThisMessageIsPresent() {
         addMessageForRetrieveTest();
 
         List<MessageUid> result = testee
@@ -184,7 +165,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void retrieveDeletedMessageShouldReturnNoMessageForMessageRangeOneIfThisMessageIsNotPresent() {
+    void retrieveDeletedMessageShouldReturnNoMessageForMessageRangeOneIfThisMessageIsNotPresent() {
         addMessageForRetrieveTest();
 
         List<MessageUid> result = testee
@@ -196,7 +177,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void retrieveDeletedMessageShouldReturnMessageInRangeForMessageRangeRange() {
+    void retrieveDeletedMessageShouldReturnMessageInRangeForMessageRangeRange() {
         addMessageForRetrieveTest();
 
         List<MessageUid> result = testee
@@ -208,7 +189,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void retrieveDeletedMessageShouldReturnNoMessageForMessageRangeRangeIfNoDeletedMessageInThatRange() {
+    void retrieveDeletedMessageShouldReturnNoMessageForMessageRangeRangeIfNoDeletedMessageInThatRange() {
         addMessageForRetrieveTest();
 
         List<MessageUid> result = testee
@@ -220,7 +201,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void retrieveDeletedMessageShouldReturnNoMessageForMessageRangeFromIfNoDeletedMessageWithIdBiggerOrSameThanFrom() {
+    void retrieveDeletedMessageShouldReturnNoMessageForMessageRangeFromIfNoDeletedMessageWithIdBiggerOrSameThanFrom() {
         addMessageForRetrieveTest();
 
         List<MessageUid> result = testee
@@ -232,7 +213,7 @@ public class CassandraDeletedMessageDAOTest {
     }
 
     @Test
-    public void retrieveDeletedMessageShouldReturnDeletedMessageWithIdBiggerOrSameThanFrom() {
+    void retrieveDeletedMessageShouldReturnDeletedMessageWithIdBiggerOrSameThanFrom() {
         addMessageForRetrieveTest();
 
         List<MessageUid> result = testee

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/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 6aef33f..4fae89a 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,56 +22,37 @@ 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.backends.cassandra.CassandraClusterExtension;
 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.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-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 static CassandraCluster cassandra;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-    private CassandraFirstUnseenDAO testee;
-
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraFirstUnseenModule.MODULE, cassandraServer.getHost());
-    }
+class CassandraFirstUnseenDAOTest {
+    private static final CassandraId MAILBOX_ID = CassandraId.timeBased();
+    private static final MessageUid UID_1 = MessageUid.of(1);
+    private static final MessageUid UID_2 = MessageUid.of(2);
 
-    @Before
-    public void setUp() {
-        testee = new CassandraFirstUnseenDAO(cassandra.getConf());
-    }
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraFirstUnseenModule.MODULE);
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
+    private CassandraFirstUnseenDAO testee;
 
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
+        testee = new CassandraFirstUnseenDAO(cassandra.getConf());
     }
 
     @Test
-    public void retrieveFirstUnreadShouldReturnEmptyByDefault() {
+    void retrieveFirstUnreadShouldReturnEmptyByDefault() {
         assertThat(testee.retrieveFirstUnread(MAILBOX_ID).join().isPresent())
             .isFalse();
     }
 
     @Test
-    public void addUnreadShouldThenBeReportedAsFirstUnseen() {
+    void addUnreadShouldThenBeReportedAsFirstUnseen() {
         testee.addUnread(MAILBOX_ID, UID_1).join();
 
         assertThat(testee.retrieveFirstUnread(MAILBOX_ID).join())
@@ -79,7 +60,7 @@ public class CassandraFirstUnseenDAOTest {
     }
 
     @Test
-    public void retrieveFirstUnreadShouldReturnLowestUnreadUid() {
+    void retrieveFirstUnreadShouldReturnLowestUnreadUid() {
         testee.addUnread(MAILBOX_ID, UID_1).join();
 
         testee.addUnread(MAILBOX_ID, UID_2).join();
@@ -89,7 +70,7 @@ public class CassandraFirstUnseenDAOTest {
     }
 
     @Test
-    public void retrieveFirstUnreadShouldBeOrderIndependent() {
+    void retrieveFirstUnreadShouldBeOrderIndependent() {
         testee.addUnread(MAILBOX_ID, UID_2).join();
 
         testee.addUnread(MAILBOX_ID, UID_1).join();
@@ -99,7 +80,7 @@ public class CassandraFirstUnseenDAOTest {
     }
 
     @Test
-    public void addUnreadShouldBeIdempotent() {
+    void addUnreadShouldBeIdempotent() {
         testee.addUnread(MAILBOX_ID, UID_1).join();
 
         testee.addUnread(MAILBOX_ID, UID_1).join();
@@ -108,9 +89,8 @@ public class CassandraFirstUnseenDAOTest {
             .contains(UID_1);
     }
 
-
     @Test
-    public void removeUnreadShouldReturnWhenNoData() {
+    void removeUnreadShouldReturnWhenNoData() {
         testee.removeUnread(MAILBOX_ID, UID_1).join();
 
         assertThat(testee.retrieveFirstUnread(MAILBOX_ID).join())
@@ -118,7 +98,7 @@ public class CassandraFirstUnseenDAOTest {
     }
 
     @Test
-    public void removeUnreadShouldRemoveOnlyUnread() {
+    void removeUnreadShouldRemoveOnlyUnread() {
         testee.addUnread(MAILBOX_ID, UID_1).join();
 
         testee.removeUnread(MAILBOX_ID, UID_1).join();
@@ -128,7 +108,7 @@ public class CassandraFirstUnseenDAOTest {
     }
 
     @Test
-    public void removeUnreadShouldRemoveLastUnread() {
+    void removeUnreadShouldRemoveLastUnread() {
         testee.addUnread(MAILBOX_ID, UID_1).join();
         testee.addUnread(MAILBOX_ID, UID_2).join();
 
@@ -139,7 +119,7 @@ public class CassandraFirstUnseenDAOTest {
     }
 
     @Test
-    public void removeUnreadShouldHaveNoEffectWhenNotLast() {
+    void removeUnreadShouldHaveNoEffectWhenNotLast() {
         testee.addUnread(MAILBOX_ID, UID_1).join();
         testee.addUnread(MAILBOX_ID, UID_2).join();
 


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