james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [09/13] james-project git commit: JAMES-2544 Use CassandraCluster extension where applicable
Date Fri, 14 Sep 2018 03:19:33 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
index d8a4c2d..9730bda 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
@@ -21,7 +21,7 @@ package org.apache.james.mailbox.cassandra.mail;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailbox.acl.ACLDiff;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
@@ -31,49 +31,29 @@ import org.apache.james.mailbox.model.MailboxACL.Entry;
 import org.apache.james.mailbox.model.MailboxACL.EntryKey;
 import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
 import org.apache.james.mailbox.model.MailboxACL.Right;
-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 CassandraUserMailboxRightsDAOTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
+class CassandraUserMailboxRightsDAOTest {
     private static final String USER_NAME = "userName";
     private static final EntryKey ENTRY_KEY = EntryKey.createUserEntryKey(USER_NAME);
     private static final CassandraId MAILBOX_ID = CassandraId.timeBased();
     private static final Rfc4314Rights RIGHTS = MailboxACL.FULL_RIGHTS;
     private static final Rfc4314Rights OTHER_RIGHTS = new Rfc4314Rights(Right.Administer, Right.Read);
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraAclModule.MODULE);
 
     private CassandraUserMailboxRightsDAO testee;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraAclModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraUserMailboxRightsDAO(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 
-    @After
-    public void tearDown() throws Exception {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void saveShouldInsertNewEntry() {
+    void saveShouldInsertNewEntry() {
         testee.update(MAILBOX_ID, ACLDiff.computeDiff(
             MailboxACL.EMPTY,
             new MailboxACL(new Entry(ENTRY_KEY, RIGHTS))))
@@ -84,7 +64,7 @@ public class CassandraUserMailboxRightsDAOTest {
     }
 
     @Test
-    public void saveOnSecondShouldOverwrite() {
+    void saveOnSecondShouldOverwrite() {
         testee.update(MAILBOX_ID, ACLDiff.computeDiff(
             MailboxACL.EMPTY,
             new MailboxACL(new Entry(ENTRY_KEY, RIGHTS))))
@@ -100,13 +80,13 @@ public class CassandraUserMailboxRightsDAOTest {
     }
 
     @Test
-    public void listRightsForUserShouldReturnEmptyWhenEmptyData() {
+    void listRightsForUserShouldReturnEmptyWhenEmptyData() {
         assertThat(testee.listRightsForUser(USER_NAME).join())
             .isEmpty();
     }
 
     @Test
-    public void deleteShouldDeleteWhenExisting() {
+    void deleteShouldDeleteWhenExisting() {
         testee.update(MAILBOX_ID, ACLDiff.computeDiff(
             MailboxACL.EMPTY,
             new MailboxACL(new Entry(ENTRY_KEY, RIGHTS))))

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentMessageIdCreationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentMessageIdCreationTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentMessageIdCreationTest.java
index e1651f2..84f33e8 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentMessageIdCreationTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentMessageIdCreationTest.java
@@ -35,7 +35,7 @@ import javax.mail.Flags;
 import javax.mail.util.SharedByteArrayInputStream;
 
 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.migration.Migration;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
@@ -55,20 +55,20 @@ import org.apache.james.mailbox.model.MessageAttachment;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.junit.After;
-import org.junit.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;
 import com.google.common.collect.ImmutableSet;
 
-public class AttachmentMessageIdCreationTest {
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    private static CassandraCluster cassandra;
+class AttachmentMessageIdCreationTest {
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(
+        CassandraModule.aggregateModules(
+            CassandraMessageModule.MODULE,
+            CassandraAttachmentModule.MODULE,
+            CassandraBlobModule.MODULE));
 
     private CassandraBlobsDAO blobsDAO;
     private CassandraMessageDAO cassandraMessageDAO;
@@ -79,17 +79,8 @@ public class AttachmentMessageIdCreationTest {
     private SimpleMailboxMessage message;
     private CassandraMessageId messageId;
 
-    @BeforeClass
-    public static void setUpClass() {
-        CassandraModule modules = CassandraModule.aggregateModules(
-            CassandraMessageModule.MODULE,
-            CassandraAttachmentModule.MODULE,
-            CassandraBlobModule.MODULE);
-        cassandra = CassandraCluster.create(modules, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         CassandraMessageId.Factory messageIdFactory = new CassandraMessageId.Factory();
 
         blobsDAO = new CassandraBlobsDAO(cassandra.getConf());
@@ -104,24 +95,14 @@ public class AttachmentMessageIdCreationTest {
         messageId = messageIdFactory.generate();
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void emptyMigrationShouldSucceed() {
+    void emptyMigrationShouldSucceed() {
         assertThat(migration.run())
             .isEqualTo(Migration.Result.COMPLETED);
     }
 
     @Test
-    public void migrationShouldSucceedWhenNoAttachment() throws Exception {
+    void migrationShouldSucceedWhenNoAttachment() throws Exception {
         List<MessageAttachment> noAttachment = ImmutableList.of();
         message = createMessage(messageId, noAttachment);
 
@@ -132,7 +113,7 @@ public class AttachmentMessageIdCreationTest {
     }
 
     @Test
-    public void migrationShouldSucceedWhenAttachment() throws Exception {
+    void migrationShouldSucceedWhenAttachment() throws Exception {
         MessageAttachment attachment = createAttachment();
         message = createMessage(messageId, ImmutableList.of(attachment));
 
@@ -143,7 +124,7 @@ public class AttachmentMessageIdCreationTest {
     }
 
     @Test
-    public void migrationShouldCreateAttachmentIdOnAttachmentMessageIdTableFromMessage() throws Exception {
+    void migrationShouldCreateAttachmentIdOnAttachmentMessageIdTableFromMessage() throws Exception {
         MessageAttachment attachment = createAttachment();
         message = createMessage(messageId, ImmutableList.of(attachment));
 
@@ -156,7 +137,7 @@ public class AttachmentMessageIdCreationTest {
     }
 
     @Test
-    public void migrationShouldReturnPartialWhenRetrieveAllAttachmentIdFromMessageFail() throws Exception {
+    void migrationShouldReturnPartialWhenRetrieveAllAttachmentIdFromMessageFail() throws Exception {
         CassandraMessageDAO cassandraMessageDAO = mock(CassandraMessageDAO.class);
         CassandraAttachmentMessageIdDAO attachmentMessageIdDAO = mock(CassandraAttachmentMessageIdDAO.class);
         migration = new AttachmentMessageIdCreation(cassandraMessageDAO, attachmentMessageIdDAO);
@@ -167,7 +148,7 @@ public class AttachmentMessageIdCreationTest {
     }
 
     @Test
-    public void migrationShouldReturnPartialWhenSavingAttachmentIdForMessageIdFail() throws Exception {
+    void migrationShouldReturnPartialWhenSavingAttachmentIdForMessageIdFail() throws Exception {
         CassandraMessageDAO cassandraMessageDAO = mock(CassandraMessageDAO.class);
         CassandraAttachmentMessageIdDAO attachmentMessageIdDAO = mock(CassandraAttachmentMessageIdDAO.class);
         CassandraMessageDAO.MessageIdAttachmentIds messageIdAttachmentIds = mock(CassandraMessageDAO.MessageIdAttachmentIds.class);

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java
index 131eca0..a298106 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java
@@ -29,7 +29,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.stream.Stream;
 
 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.migration.Migration;
@@ -42,21 +42,20 @@ import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2;
 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;
-
-public class AttachmentV2MigrationTest {
-    public static final AttachmentId ATTACHMENT_ID = AttachmentId.from("id1");
-    public static final AttachmentId ATTACHMENT_ID_2 = AttachmentId.from("id2");
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class AttachmentV2MigrationTest {
+    private static final AttachmentId ATTACHMENT_ID = 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 CassandraAttachmentDAO attachmentDAO;
     private CassandraAttachmentDAOV2 attachmentDAOV2;
@@ -65,16 +64,8 @@ public class AttachmentV2MigrationTest {
     private Attachment attachment1;
     private Attachment attachment2;
 
-    @BeforeClass
-    public static void setUpClass() {
-        CassandraModule modules = CassandraModule.aggregateModules(
-            CassandraAttachmentModule.MODULE,
-            CassandraBlobModule.MODULE);
-        cassandra = CassandraCluster.create(modules, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         attachmentDAO = new CassandraAttachmentDAO(cassandra.getConf(),
             CassandraUtils.WITH_DEFAULT_CONFIGURATION,
             CassandraConfiguration.DEFAULT_CONFIGURATION);
@@ -94,24 +85,14 @@ public class AttachmentV2MigrationTest {
             .build();
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void emptyMigrationShouldSucceed() {
+    void emptyMigrationShouldSucceed() {
         assertThat(migration.run())
             .isEqualTo(Migration.Result.COMPLETED);
     }
 
     @Test
-    public void migrationShouldSucceed() throws Exception {
+    void migrationShouldSucceed() throws Exception {
         attachmentDAO.storeAttachment(attachment1).join();
         attachmentDAO.storeAttachment(attachment2).join();
 
@@ -120,7 +101,7 @@ public class AttachmentV2MigrationTest {
     }
 
     @Test
-    public void migrationShouldMoveAttachmentsToV2() throws Exception {
+    void migrationShouldMoveAttachmentsToV2() throws Exception {
         attachmentDAO.storeAttachment(attachment1).join();
         attachmentDAO.storeAttachment(attachment2).join();
 
@@ -137,7 +118,7 @@ public class AttachmentV2MigrationTest {
     }
 
     @Test
-    public void migrationShouldRemoveAttachmentsFromV1() throws Exception {
+    void migrationShouldRemoveAttachmentsFromV1() throws Exception {
         attachmentDAO.storeAttachment(attachment1).join();
         attachmentDAO.storeAttachment(attachment2).join();
 
@@ -150,7 +131,7 @@ public class AttachmentV2MigrationTest {
     }
 
     @Test
-    public void runShouldReturnPartialWhenInitialReadFail() throws Exception {
+    void runShouldReturnPartialWhenInitialReadFail() {
         CassandraAttachmentDAO attachmentDAO = mock(CassandraAttachmentDAO.class);
         CassandraAttachmentDAOV2 attachmentDAOV2 = mock(CassandraAttachmentDAOV2.class);
         CassandraBlobsDAO blobsDAO = mock(CassandraBlobsDAO.class);
@@ -162,7 +143,7 @@ public class AttachmentV2MigrationTest {
     }
 
     @Test
-    public void runShouldReturnPartialWhenSavingBlobsFails() throws Exception {
+    void runShouldReturnPartialWhenSavingBlobsFails() {
         CassandraAttachmentDAO attachmentDAO = mock(CassandraAttachmentDAO.class);
         CassandraAttachmentDAOV2 attachmentDAOV2 = mock(CassandraAttachmentDAOV2.class);
         CassandraBlobsDAO blobsDAO = mock(CassandraBlobsDAO.class);
@@ -177,7 +158,7 @@ public class AttachmentV2MigrationTest {
     }
 
     @Test
-    public void runShouldReturnPartialWhenSavingAttachmentV2Fail() throws Exception {
+    void runShouldReturnPartialWhenSavingAttachmentV2Fail() {
         CassandraAttachmentDAO attachmentDAO = mock(CassandraAttachmentDAO.class);
         CassandraAttachmentDAOV2 attachmentDAOV2 = mock(CassandraAttachmentDAOV2.class);
         CassandraBlobsDAO blobsDAO = mock(CassandraBlobsDAO.class);
@@ -196,7 +177,7 @@ public class AttachmentV2MigrationTest {
     }
 
     @Test
-    public void runShouldReturnPartialWhenDeleteV1AttachmentFail() throws Exception {
+    void runShouldReturnPartialWhenDeleteV1AttachmentFail() {
         CassandraAttachmentDAO attachmentDAO = mock(CassandraAttachmentDAO.class);
         CassandraAttachmentDAOV2 attachmentDAOV2 = mock(CassandraAttachmentDAOV2.class);
         CassandraBlobsDAO blobsDAO = mock(CassandraBlobsDAO.class);
@@ -216,7 +197,7 @@ public class AttachmentV2MigrationTest {
     }
 
     @Test
-    public void runShouldReturnPartialWhenAtLeastOneAttachmentMigrationFails() throws Exception {
+    void runShouldReturnPartialWhenAtLeastOneAttachmentMigrationFails() {
         CassandraAttachmentDAO attachmentDAO = mock(CassandraAttachmentDAO.class);
         CassandraAttachmentDAOV2 attachmentDAOV2 = mock(CassandraAttachmentDAOV2.class);
         CassandraBlobsDAO blobsDAO = mock(CassandraBlobsDAO.class);

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java
index 92cdb5e..cf19f73 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java
@@ -22,7 +22,7 @@ package org.apache.james.mailbox.cassandra.mail.migration;
 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.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
@@ -39,42 +39,36 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.assertj.core.api.SoftAssertions;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class MailboxPathV2MigrationTest {
+class MailboxPathV2MigrationTest {
 
     private static final MailboxPath MAILBOX_PATH_1 = MailboxPath.forUser("bob", "Important");
     private static final int UID_VALIDITY_1 = 452;
     private static final SimpleMailbox MAILBOX_1 = new SimpleMailbox(MAILBOX_PATH_1, UID_VALIDITY_1);
     private static final CassandraId MAILBOX_ID_1 = CassandraId.timeBased();
 
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(
+        CassandraModule.aggregateModules(
+            CassandraMailboxModule.MODULE,
+            CassandraAclModule.MODULE));
 
     private CassandraMailboxPathDAOImpl daoV1;
     private CassandraMailboxPathV2DAO daoV2;
     private CassandraMailboxMapper mailboxMapper;
     private CassandraMailboxDAO mailboxDAO;
 
-    @BeforeClass
-    public static void setUpClass() {
+    @BeforeAll
+    static void setUpClass() {
         MAILBOX_1.setMailboxId(MAILBOX_ID_1);
-
-        cassandra = CassandraCluster.create(
-            CassandraModule.aggregateModules(
-                CassandraMailboxModule.MODULE,
-                CassandraAclModule.MODULE),
-            cassandraServer.getHost());
     }
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         daoV1 = new CassandraMailboxPathDAOImpl(
             cassandra.getConf(),
             cassandra.getTypesProvider(),
@@ -93,18 +87,8 @@ public class MailboxPathV2MigrationTest {
             new CassandraACLMapper(cassandra.getConf(), userMailboxRightsDAO, CassandraConfiguration.DEFAULT_CONFIGURATION));
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void newValuesShouldBeSavedInMostRecentDAO() throws Exception {
+    void newValuesShouldBeSavedInMostRecentDAO() throws Exception {
         mailboxMapper.save(MAILBOX_1);
 
         assertThat(daoV2.retrieveId(MAILBOX_PATH_1).join())
@@ -112,7 +96,7 @@ public class MailboxPathV2MigrationTest {
     }
 
     @Test
-    public void newValuesShouldNotBeSavedInOldDAO() throws Exception {
+    void newValuesShouldNotBeSavedInOldDAO() throws Exception {
         mailboxMapper.save(MAILBOX_1);
 
         assertThat(daoV1.retrieveId(MAILBOX_PATH_1).join())
@@ -120,7 +104,7 @@ public class MailboxPathV2MigrationTest {
     }
 
     @Test
-    public void readingOldValuesShouldMigrateThem() throws Exception {
+    void readingOldValuesShouldMigrateThem() throws Exception {
         daoV1.save(MAILBOX_PATH_1, MAILBOX_ID_1).join();
         mailboxDAO.save(MAILBOX_1).join();
 
@@ -134,7 +118,7 @@ public class MailboxPathV2MigrationTest {
     }
 
     @Test
-    public void migrationTaskShouldMoveDataToMostRecentDao() {
+    void migrationTaskShouldMoveDataToMostRecentDao() {
         daoV1.save(MAILBOX_PATH_1, MAILBOX_ID_1).join();
 
         new MailboxPathV2Migration(daoV1, daoV2).run();

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java
index 898d825..a37215e 100644
--- a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java
+++ b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java
@@ -21,42 +21,32 @@ package org.apache.james.blob.cassandra;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 
 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.init.configuration.CassandraConfiguration;
 import org.apache.james.blob.api.BlobId;
 import org.apache.james.blob.api.BlobStore;
 import org.apache.james.blob.api.BlobStoreContract;
 import org.apache.james.blob.api.HashBlobId;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.common.base.Strings;
 
-@ExtendWith(DockerCassandraExtension.class)
 public class CassandraBlobsDAOTest implements BlobStoreContract {
-
     private static final int CHUNK_SIZE = 10240;
     private static final int MULTIPLE_CHUNK_SIZE = 3;
 
-    private static CassandraCluster cassandra;
-    private CassandraBlobsDAO testee;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraBlobModule.MODULE);
 
-    @BeforeAll
-    static void setUpClass(DockerCassandra dockerCassandra) {
-        cassandra = CassandraCluster.create(CassandraBlobModule.MODULE, dockerCassandra.getHost());
-    }
+    private CassandraBlobsDAO testee;
 
     @BeforeEach
-    void setUp() {
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraBlobsDAO(cassandra.getConf(),
             CassandraConfiguration.builder()
                 .blobPartSize(CHUNK_SIZE)
@@ -64,16 +54,6 @@ public class CassandraBlobsDAOTest implements BlobStoreContract {
             new HashBlobId.Factory());
     }
 
-    @AfterEach
-    void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterAll
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Override
     public BlobStore testee() {
         return testee;
@@ -85,7 +65,7 @@ public class CassandraBlobsDAOTest implements BlobStoreContract {
     }
 
     @Test
-    public void readBytesShouldReturnSplitSavedDataByChunk() throws IOException {
+    void readBytesShouldReturnSplitSavedDataByChunk() {
         String longString = Strings.repeat("0123456789\n", MULTIPLE_CHUNK_SIZE);
         BlobId blobId = testee.save(longString.getBytes(StandardCharsets.UTF_8)).join();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java b/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java
index fa9818a..30df692 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryUrlStoreExtension.java
@@ -19,8 +19,7 @@
 
 package org.apache.james.mailrepository.cassandra;
 
-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.mailrepository.api.MailRepositoryUrlStore;
 import org.junit.jupiter.api.extension.AfterAllCallback;
@@ -32,30 +31,25 @@ import org.junit.jupiter.api.extension.ParameterResolutionException;
 import org.junit.jupiter.api.extension.ParameterResolver;
 
 public class CassandraMailRepositoryUrlStoreExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback, AfterEachCallback {
-    private final DockerCassandraRule cassandra;
-    private CassandraCluster cassandraCluster;
+    private final CassandraClusterExtension cassandraCluster;
 
     public CassandraMailRepositoryUrlStoreExtension() {
-        this.cassandra = new DockerCassandraRule();
+        cassandraCluster = new CassandraClusterExtension(CassandraMailRepositoryUrlModule.MODULE);
     }
 
     @Override
     public void beforeAll(ExtensionContext context) {
-        cassandra.start();
-        cassandraCluster = CassandraCluster.create(
-            CassandraMailRepositoryUrlModule.MODULE,
-            cassandra.getHost());
+        cassandraCluster.beforeAll(context);
     }
 
     @Override
     public void afterEach(ExtensionContext context) {
-        cassandraCluster.clearTables();
+        cassandraCluster.afterEach(context);
     }
 
     @Override
     public void afterAll(ExtensionContext context) {
-        cassandraCluster.closeCluster();
-        cassandra.stop();
+        cassandraCluster.afterAll(context);
     }
 
     @Override
@@ -67,7 +61,7 @@ public class CassandraMailRepositoryUrlStoreExtension implements ParameterResolv
     public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
         return new CassandraMailRepositoryUrlStore(
             new UrlsDao(
-                cassandraCluster.getConf(),
+                cassandraCluster.getCassandraCluster().getConf(),
                 CassandraUtils.WITH_DEFAULT_CONFIGURATION));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/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 4ddb6ba..5d38f61 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,132 +25,111 @@ import java.util.List;
 import java.util.Optional;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.core.User;
 import org.apache.james.sieve.cassandra.model.Script;
 import org.apache.james.sieverepository.api.ScriptName;
 import org.apache.james.sieverepository.api.ScriptSummary;
-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 CassandraSieveDAOTest {
-
-    public static final User USER = User.fromUsername("user");
-    public static final ScriptName SCRIPT_NAME = new ScriptName("scriptName");
-    public static final ScriptName SCRIPT_NAME2 = new ScriptName("scriptName2");
-    public static final Script SCRIPT = Script.builder()
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class CassandraSieveDAOTest {
+
+    private static final User USER = User.fromUsername("user");
+    private static final ScriptName SCRIPT_NAME = new ScriptName("scriptName");
+    private static final ScriptName SCRIPT_NAME2 = new ScriptName("scriptName2");
+    private static final Script SCRIPT = Script.builder()
         .name(SCRIPT_NAME)
         .content("content")
         .isActive(false)
         .build();
-    public static final Script SCRIPT2 = Script.builder()
+    private static final Script SCRIPT2 = Script.builder()
         .name(SCRIPT_NAME2)
         .content("alternative content")
         .isActive(true)
         .build();
-    public static final Script ACTIVE_SCRIPT = Script.builder()
+    private static final Script ACTIVE_SCRIPT = Script.builder()
         .copyOf(SCRIPT)
         .isActive(true)
         .build();
-    public static final Script SCRIPT_NEW_CONTENT = Script.builder()
+    private static final Script SCRIPT_NEW_CONTENT = Script.builder()
         .copyOf(SCRIPT)
         .content("newContent")
         .build();
 
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraSieveRepositoryModule.MODULE);
 
     private CassandraSieveDAO sieveDAO;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraSieveRepositoryModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         sieveDAO = new CassandraSieveDAO(cassandra.getConf());
     }
-
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
     
      @Test
-    public void getScriptShouldReturnEmptyByDefault() {
+    void getScriptShouldReturnEmptyByDefault() {
         assertThat(sieveDAO.getScript(USER, SCRIPT_NAME).join().isPresent())
             .isFalse();
     }
 
     @Test
-    public void getScriptShouldReturnStoredScript() {
+    void getScriptShouldReturnStoredScript() {
         sieveDAO.insertScript(USER, SCRIPT).join();
 
         Optional<Script> actual = sieveDAO.getScript(USER, SCRIPT_NAME).join();
 
-        assertThat(actual.isPresent()).isTrue();
-        assertThat(actual.get()).isEqualTo(SCRIPT);
+        assertThat(actual).contains(SCRIPT);
     }
 
     @Test
-    public void insertScriptShouldUpdateContent() {
+    void insertScriptShouldUpdateContent() {
         sieveDAO.insertScript(USER, SCRIPT).join();
 
         sieveDAO.insertScript(USER, SCRIPT_NEW_CONTENT).join();
 
         Optional<Script> actual = sieveDAO.getScript(USER, SCRIPT_NAME).join();
-        assertThat(actual.isPresent()).isTrue();
-        assertThat(actual.get()).isEqualTo(SCRIPT_NEW_CONTENT);
+        assertThat(actual).contains(SCRIPT_NEW_CONTENT);
     }
 
     @Test
-    public void insertScriptShouldUpdateActivate() {
+    void insertScriptShouldUpdateActivate() {
         sieveDAO.insertScript(USER, SCRIPT).join();
 
         sieveDAO.insertScript(USER, ACTIVE_SCRIPT).join();
 
         Optional<Script> actual = sieveDAO.getScript(USER, SCRIPT_NAME).join();
-        assertThat(actual.isPresent()).isTrue();
-        assertThat(actual.get()).isEqualTo(ACTIVE_SCRIPT);
+        assertThat(actual).contains(ACTIVE_SCRIPT);
     }
 
     @Test
-    public void deleteScriptInCassandraShouldWork() {
+    void deleteScriptInCassandraShouldWork() {
         sieveDAO.insertScript(USER, SCRIPT).join();
 
         sieveDAO.deleteScriptInCassandra(USER, SCRIPT_NAME).join();
 
         Optional<Script> actual = sieveDAO.getScript(USER, SCRIPT_NAME).join();
-        assertThat(actual.isPresent()).isFalse();
+        assertThat(actual).isEmpty();
     }
 
     @Test
-    public void deleteScriptInCassandraShouldWorkWhenNoneStore() {
+    void deleteScriptInCassandraShouldWorkWhenNoneStore() {
         sieveDAO.deleteScriptInCassandra(USER, SCRIPT_NAME).join();
 
         Optional<Script> actual = sieveDAO.getScript(USER, SCRIPT_NAME).join();
-        assertThat(actual.isPresent()).isFalse();
+        assertThat(actual).isEmpty();
     }
 
     @Test
-    public void listScriptsShouldReturnEmpty() {
+    void listScriptsShouldReturnEmpty() {
         List<ScriptSummary> scriptSummaryList = sieveDAO.listScripts(USER).join();
 
         assertThat(scriptSummaryList).isEmpty();
     }
 
     @Test
-    public void listScriptsShouldReturnSingleStoredValue() {
+    void listScriptsShouldReturnSingleStoredValue() {
         sieveDAO.insertScript(USER, SCRIPT).join();
         sieveDAO.insertScript(USER, SCRIPT2).join();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/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 56692d2..adca5b0 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
@@ -22,60 +22,41 @@ package org.apache.james.sieve.cassandra;
 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.core.User;
 import org.apache.james.core.quota.QuotaSize;
-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 CassandraSieveQuotaDAOTest {
+class CassandraSieveQuotaDAOTest {
+    private static final User USER = User.fromUsername("user");
+    private static final QuotaSize QUOTA_SIZE = QuotaSize.size(15L);
 
-    public static final User USER = User.fromUsername("user");
-    public static final QuotaSize QUOTA_SIZE = QuotaSize.size(15L);
-
-    @ClassRule public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraSieveRepositoryModule.MODULE);
 
     private CassandraSieveQuotaDAO sieveQuotaDAO;
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(CassandraSieveRepositoryModule.MODULE, cassandraServer.getHost());
-    }
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         sieveQuotaDAO = new CassandraSieveQuotaDAO(cassandra.getConf());
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void getQuotaShouldReturnEmptyByDefault() {
+    void getQuotaShouldReturnEmptyByDefault() {
         assertThat(sieveQuotaDAO.getQuota().join())
             .isEmpty();
     }
 
     @Test
-    public void getQuotaUserShouldReturnEmptyByDefault() {
+    void getQuotaUserShouldReturnEmptyByDefault() {
         assertThat(sieveQuotaDAO.getQuota(USER).join())
             .isEmpty();
     }
 
     @Test
-    public void getQuotaShouldReturnStoredValue() {
+    void getQuotaShouldReturnStoredValue() {
         sieveQuotaDAO.setQuota(QUOTA_SIZE).join();
 
         assertThat(sieveQuotaDAO.getQuota().join())
@@ -83,7 +64,7 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void getQuotaUserShouldReturnStoredValue() {
+    void getQuotaUserShouldReturnStoredValue() {
         sieveQuotaDAO.setQuota(USER, QUOTA_SIZE).join();
 
         assertThat(sieveQuotaDAO.getQuota(USER).join())
@@ -91,7 +72,7 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void removeQuotaShouldDeleteQuota() {
+    void removeQuotaShouldDeleteQuota() {
         sieveQuotaDAO.setQuota(QUOTA_SIZE).join();
 
         sieveQuotaDAO.removeQuota().join();
@@ -101,7 +82,7 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void removeQuotaUserShouldDeleteQuotaUser() {
+    void removeQuotaUserShouldDeleteQuotaUser() {
         sieveQuotaDAO.setQuota(USER, QUOTA_SIZE).join();
 
         sieveQuotaDAO.removeQuota(USER).join();
@@ -111,7 +92,7 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void removeQuotaShouldWorkWhenNoneStore() {
+    void removeQuotaShouldWorkWhenNoneStore() {
         sieveQuotaDAO.removeQuota().join();
 
         assertThat(sieveQuotaDAO.getQuota().join())
@@ -119,7 +100,7 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void removeQuotaUserShouldWorkWhenNoneStore() {
+    void removeQuotaUserShouldWorkWhenNoneStore() {
         sieveQuotaDAO.removeQuota(USER).join();
 
         assertThat(sieveQuotaDAO.getQuota(USER).join())
@@ -127,12 +108,12 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void spaceUsedByShouldReturnZeroByDefault() {
+    void spaceUsedByShouldReturnZeroByDefault() {
         assertThat(sieveQuotaDAO.spaceUsedBy(USER).join()).isEqualTo(0);
     }
 
     @Test
-    public void spaceUsedByShouldReturnStoredValue() {
+    void spaceUsedByShouldReturnStoredValue() {
         long spaceUsed = 18L;
 
         sieveQuotaDAO.updateSpaceUsed(USER, spaceUsed).join();
@@ -141,7 +122,7 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void updateSpaceUsedShouldBeAdditive() {
+    void updateSpaceUsedShouldBeAdditive() {
         long spaceUsed = 18L;
 
         sieveQuotaDAO.updateSpaceUsed(USER, spaceUsed).join();
@@ -151,7 +132,7 @@ public class CassandraSieveQuotaDAOTest {
     }
 
     @Test
-    public void updateSpaceUsedShouldWorkWithNegativeValues() {
+    void updateSpaceUsedShouldWorkWithNegativeValues() {
         long spaceUsed = 18L;
 
         sieveQuotaDAO.updateSpaceUsed(USER, spaceUsed).join();

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryCountDAOTest.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryCountDAOTest.java b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryCountDAOTest.java
index f5255d0..98b6fa2 100644
--- a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryCountDAOTest.java
+++ b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryCountDAOTest.java
@@ -22,51 +22,34 @@ package org.apache.james.mailrepository.cassandra;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraExtension;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.mailrepository.api.MailRepositoryUrl;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-@ExtendWith(DockerCassandraExtension.class)
-public class CassandraMailRepositoryCountDAOTest {
+class CassandraMailRepositoryCountDAOTest {
     static final MailRepositoryUrl URL = MailRepositoryUrl.from("proto://url");
     static final MailRepositoryUrl URL2 = MailRepositoryUrl.from("proto://url2");
 
-    static CassandraCluster cassandra;
-    CassandraMailRepositoryCountDAO testee;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraMailRepositoryModule.MODULE);
 
-    @BeforeAll
-    static void setUpClass(DockerCassandraExtension.DockerCassandra dockerCassandra) {
-        cassandra = CassandraCluster.create(CassandraMailRepositoryModule.MODULE, dockerCassandra.getHost());
-    }
+    CassandraMailRepositoryCountDAO testee;
 
     @BeforeEach
-    public void setUp() {
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraMailRepositoryCountDAO(cassandra.getConf());
     }
 
-    @AfterEach
-    void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterAll
-    static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void getCountShouldReturnZeroWhenEmpty() {
+    void getCountShouldReturnZeroWhenEmpty() {
         assertThat(testee.getCount(URL).join())
             .isEqualTo(0L);
     }
 
     @Test
-    public void getCountShouldReturnOneWhenIncrementedOneTime() {
+    void getCountShouldReturnOneWhenIncrementedOneTime() {
         testee.increment(URL).join();
 
         assertThat(testee.getCount(URL).join())
@@ -74,7 +57,7 @@ public class CassandraMailRepositoryCountDAOTest {
     }
 
     @Test
-    public void incrementShouldNotAffectOtherUrls() {
+    void incrementShouldNotAffectOtherUrls() {
         testee.increment(URL).join();
 
         assertThat(testee.getCount(URL2).join())
@@ -82,7 +65,7 @@ public class CassandraMailRepositoryCountDAOTest {
     }
 
     @Test
-    public void incrementCanBeAppliedSeveralTime() {
+    void incrementCanBeAppliedSeveralTime() {
         testee.increment(URL).join();
         testee.increment(URL).join();
 
@@ -91,7 +74,7 @@ public class CassandraMailRepositoryCountDAOTest {
     }
 
     @Test
-    public void decrementShouldDecreaseCount() {
+    void decrementShouldDecreaseCount() {
         testee.increment(URL).join();
         testee.increment(URL).join();
         testee.increment(URL).join();
@@ -103,7 +86,7 @@ public class CassandraMailRepositoryCountDAOTest {
     }
 
     @Test
-    public void decrementCanLeadToNegativeCount() {
+    void decrementCanLeadToNegativeCount() {
         testee.decrement(URL).join();
 
         assertThat(testee.getCount(URL).join())

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryKeysDAOTest.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryKeysDAOTest.java b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryKeysDAOTest.java
index 7763ae4..3c457af 100644
--- a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryKeysDAOTest.java
+++ b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryKeysDAOTest.java
@@ -22,49 +22,31 @@ package org.apache.james.mailrepository.cassandra;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraExtension;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.mailrepository.api.MailKey;
 import org.apache.james.mailrepository.api.MailRepositoryUrl;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-@ExtendWith(DockerCassandraExtension.class)
 class CassandraMailRepositoryKeysDAOTest {
-
     static final MailRepositoryUrl URL = MailRepositoryUrl.from("proto://url");
     static final MailRepositoryUrl URL2 = MailRepositoryUrl.from("proto://url2");
     static final MailKey KEY_1 = new MailKey("key1");
     static final MailKey KEY_2 = new MailKey("key2");
     static final MailKey KEY_3 = new MailKey("key3");
 
-    static CassandraCluster cassandra;
-    CassandraMailRepositoryKeysDAO testee;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraMailRepositoryModule.MODULE);
 
-    @BeforeAll
-    static void setUpClass(DockerCassandraExtension.DockerCassandra dockerCassandra) {
-        cassandra = CassandraCluster.create(CassandraMailRepositoryModule.MODULE, dockerCassandra.getHost());
-    }
+    CassandraMailRepositoryKeysDAO testee;
 
     @BeforeEach
-    void setUp() {
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraMailRepositoryKeysDAO(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);
     }
 
-    @AfterEach
-    void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterAll
-    static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
     void listShouldBeEmptyByDefault() {
         assertThat(testee.list(URL).join())

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
index e0635bf..55aa601 100644
--- a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
+++ b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertAll;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraExtension;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.blob.api.BlobId;
 import org.apache.james.blob.api.TestBlobId;
 import org.apache.james.mailrepository.api.MailKey;
@@ -32,53 +32,35 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.PerRecipientHeaders;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.google.common.collect.ImmutableList;
 
-@ExtendWith(DockerCassandraExtension.class)
-public class CassandraMailRepositoryMailDAOTest {
-
+class CassandraMailRepositoryMailDAOTest {
     static final MailRepositoryUrl URL = MailRepositoryUrl.from("proto://url");
     static final MailKey KEY_1 = new MailKey("key1");
     static final TestBlobId.Factory BLOB_ID_FACTORY = new TestBlobId.Factory();
 
-    static CassandraCluster cassandra;
-    CassandraMailRepositoryMailDAO testee;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(CassandraMailRepositoryModule.MODULE);
 
-    @BeforeAll
-    static void setUpClass(DockerCassandraExtension.DockerCassandra dockerCassandra) {
-        cassandra = CassandraCluster.create(CassandraMailRepositoryModule.MODULE, dockerCassandra.getHost());
-    }
+    CassandraMailRepositoryMailDAO testee;
 
     @BeforeEach
-    public void setUp() {
+    void setUp(CassandraCluster cassandra) {
         testee = new CassandraMailRepositoryMailDAO(cassandra.getConf(), BLOB_ID_FACTORY, cassandra.getTypesProvider());
     }
 
-    @AfterEach
-    void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterAll
-    static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void readShouldReturnEmptyWhenAbsent() {
+    void readShouldReturnEmptyWhenAbsent() {
         assertThat(testee.read(URL, KEY_1).join())
             .isEmpty();
     }
 
     @Test
-    public void readShouldReturnAllMailMetadata() throws Exception {
+    void readShouldReturnAllMailMetadata() throws Exception {
         BlobId blobIdBody = BLOB_ID_FACTORY.from("blobHeader");
         BlobId blobIdHeader = BLOB_ID_FACTORY.from("blobBody");
         String errorMessage = "error message";
@@ -127,7 +109,7 @@ public class CassandraMailRepositoryMailDAOTest {
     }
 
     @Test
-    public void storeShouldAcceptMailWithOnlyName() throws Exception {
+    void storeShouldAcceptMailWithOnlyName() throws Exception {
         BlobId blobIdBody = BLOB_ID_FACTORY.from("blobHeader");
         BlobId blobIdHeader = BLOB_ID_FACTORY.from("blobBody");
 
@@ -149,7 +131,7 @@ public class CassandraMailRepositoryMailDAOTest {
     }
 
     @Test
-    public void removeShouldDeleteMailMetaData() throws Exception {
+    void removeShouldDeleteMailMetaData() throws Exception {
         BlobId blobIdBody = BLOB_ID_FACTORY.from("blobHeader");
         BlobId blobIdHeader = BLOB_ID_FACTORY.from("blobBody");
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df6fe4fb/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryTest.java b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryTest.java
index 64fdfd5..d83677e 100644
--- a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryTest.java
+++ b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryTest.java
@@ -20,7 +20,7 @@
 package org.apache.james.mailrepository.cassandra;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraExtension;
+import org.apache.james.backends.cassandra.CassandraClusterExtension;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
 import org.apache.james.blob.api.HashBlobId;
@@ -30,32 +30,26 @@ import org.apache.james.blob.mail.MimeMessageStore;
 import org.apache.james.mailrepository.MailRepositoryContract;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailrepository.api.MailRepositoryUrl;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-@ExtendWith(DockerCassandraExtension.class)
 class CassandraMailRepositoryTest implements MailRepositoryContract {
     static final MailRepositoryUrl URL = MailRepositoryUrl.from("proto://url");
     static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
 
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(
+        CassandraModule.aggregateModules(
+            CassandraMailRepositoryModule.MODULE,
+            CassandraBlobModule.MODULE));
+
     CassandraMailRepository cassandraMailRepository;
-    static CassandraCluster cassandra;
 
-    @BeforeAll
-    static void setUpClass(DockerCassandraExtension.DockerCassandra dockerCassandra) {
-        CassandraModule modules = CassandraModule.aggregateModules(
-            CassandraMailRepositoryModule.MODULE,
-            CassandraBlobModule.MODULE);
-        cassandra = CassandraCluster.create(modules, dockerCassandra.getHost());
-    }
 
     @BeforeEach
-    void setup() {
+    void setup(CassandraCluster cassandra) {
         CassandraMailRepositoryMailDAO mailDAO = new CassandraMailRepositoryMailDAO(cassandra.getConf(), BLOB_ID_FACTORY, cassandra.getTypesProvider());
         CassandraMailRepositoryKeysDAO keysDAO = new CassandraMailRepositoryKeysDAO(cassandra.getConf(), CassandraUtils.WITH_DEFAULT_CONFIGURATION);
         CassandraMailRepositoryCountDAO countDAO = new CassandraMailRepositoryCountDAO(cassandra.getConf());
@@ -65,16 +59,6 @@ class CassandraMailRepositoryTest implements MailRepositoryContract {
             keysDAO, countDAO, mailDAO, MimeMessageStore.factory(blobsDAO).mimeMessageStore());
     }
 
-    @AfterEach
-    void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterAll
-    static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Override
     public MailRepository retrieveRepository() {
         return cassandraMailRepository;
@@ -83,7 +67,7 @@ class CassandraMailRepositoryTest implements MailRepositoryContract {
     @Test
     @Disabled("key is unique in Cassandra")
     @Override
-    public void sizeShouldBeIncrementedByOneWhenDuplicates() throws Exception {
+    public void sizeShouldBeIncrementedByOneWhenDuplicates() {
     }
 
 }
\ No newline at end of file


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