james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [10/12] james-project git commit: JAMES-2555 Migrate ReIndexuing tests to JUNIT 5
Date Fri, 12 Oct 2018 08:29:01 GMT
JAMES-2555 Migrate ReIndexuing tests to JUNIT 5


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

Branch: refs/heads/master
Commit: 02f8d6f73b03b004c39e58948e627b3f384d815f
Parents: 962683d
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Oct 11 16:47:50 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Oct 12 15:27:34 2018 +0700

----------------------------------------------------------------------
 mailbox/tools/indexer/pom.xml                   | 18 +++++++--
 .../indexer/CassandraReIndexerImplTest.java     | 40 +++++---------------
 .../tools/indexer/ReIndexerImplTest.java        | 12 +++---
 .../registrations/GlobalRegistrationTest.java   | 26 ++++++-------
 .../registrations/MailboxRegistrationTest.java  | 28 +++++++-------
 5 files changed, 56 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/02f8d6f7/mailbox/tools/indexer/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/pom.xml b/mailbox/tools/indexer/pom.xml
index 4395bba..34ab140 100644
--- a/mailbox/tools/indexer/pom.xml
+++ b/mailbox/tools/indexer/pom.xml
@@ -105,13 +105,23 @@
             <artifactId>javax.inject</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.assertj</groupId>
-            <artifactId>assertj-core</artifactId>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/02f8d6f7/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
index 7af0646..26f68cc 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
@@ -29,7 +29,7 @@ import java.nio.charset.StandardCharsets;
 import java.time.Duration;
 
 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.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
@@ -42,12 +42,9 @@ import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.apache.james.util.concurrency.ConcurrentTestRunner;
-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.base.Strings;
 
@@ -57,38 +54,21 @@ public class CassandraReIndexerImplTest {
     private CassandraMailboxManager mailboxManager;
     private ListeningMessageSearchIndex messageSearchIndex;
 
-    private ReIndexer reIndexer;
-
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private static CassandraCluster cassandra;
+    @RegisterExtension
+    static CassandraClusterExtension cassandraCluster = new CassandraClusterExtension(MailboxAggregateModule.MODULE_WITH_QUOTA);
 
-    @BeforeClass
-    public static void setUpClass() {
-        cassandra = CassandraCluster.create(MailboxAggregateModule.MODULE_WITH_QUOTA, cassandraServer.getHost());
-    }
+    private ReIndexer reIndexer;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp(CassandraCluster cassandra) {
         mailboxManager = CassandraMailboxManagerProvider.provideMailboxManager(cassandra.getConf(),
cassandra.getTypesProvider());
         MailboxSessionMapperFactory mailboxSessionMapperFactory = mailboxManager.getMapperFactory();
         messageSearchIndex = mock(ListeningMessageSearchIndex.class);
         reIndexer = new ReIndexerImpl(mailboxManager, messageSearchIndex, mailboxSessionMapperFactory);
     }
 
-    @After
-    public void tearDown() {
-        cassandra.clearTables();
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        cassandra.closeCluster();
-    }
-
     @Test
-    public void reIndexShouldBeWellPerformed() throws Exception {
+    void reIndexShouldBeWellPerformed() throws Exception {
         // Given a mailbox with 1000 messages * 150 KB
         MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
         mailboxManager.createMailbox(INBOX, systemSession);

http://git-wip-us.apache.org/repos/asf/james-project/blob/02f8d6f7/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
index cab234b..76f8a00 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
@@ -39,8 +39,8 @@ import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 
 public class ReIndexerImplTest {
@@ -52,8 +52,8 @@ public class ReIndexerImplTest {
 
     private ReIndexer reIndexer;
 
-    @Before
-    public void setUp() throws MailboxException {
+    @BeforeEach
+    void setUp() throws MailboxException {
         mailboxManager = new InMemoryIntegrationResources().createMailboxManager(new SimpleGroupMembershipResolver());
         MailboxSessionMapperFactory mailboxSessionMapperFactory = mailboxManager.getMapperFactory();
         messageSearchIndex = mock(ListeningMessageSearchIndex.class);
@@ -61,7 +61,7 @@ public class ReIndexerImplTest {
     }
 
     @Test
-    public void reIndexShouldBeWellPerformed() throws Exception {
+    void reIndexShouldBeWellPerformed() throws Exception {
         MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
         MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
         ComposedMessageId createdMessage = mailboxManager.getMailbox(INBOX, systemSession)
@@ -86,7 +86,7 @@ public class ReIndexerImplTest {
     }
 
     @Test
-    public void mailboxPathUserShouldBeUsedWhenReIndexing() throws Exception {
+    void mailboxPathUserShouldBeUsedWhenReIndexing() throws Exception {
         MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
         MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
         ComposedMessageId createdMessage = mailboxManager.getMailbox(INBOX, systemSession)

http://git-wip-us.apache.org/repos/asf/james-project/blob/02f8d6f7/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/GlobalRegistrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/GlobalRegistrationTest.java
b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/GlobalRegistrationTest.java
index 7ebd5d3..e0b06f7 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/GlobalRegistrationTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/GlobalRegistrationTest.java
@@ -31,41 +31,41 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.store.event.EventFactory;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class GlobalRegistrationTest {
     public static final MailboxPath INBOX = MailboxPath.forUser("btellier@apache.org", "INBOX");
-    public static final MailboxPath NEW_PATH = MailboxPath.forUser("btellier@apache.org",
"INBOX.new");
-    public static final int UID_VALIDITY = 45;
-    public static final SimpleMailbox MAILBOX = new SimpleMailbox(INBOX, UID_VALIDITY);
-    public static final SimpleMailbox NEW_MAILBOX = new SimpleMailbox(NEW_PATH, UID_VALIDITY);
+    private static final MailboxPath NEW_PATH = MailboxPath.forUser("btellier@apache.org",
"INBOX.new");
+    private static final int UID_VALIDITY = 45;
+    private static final SimpleMailbox MAILBOX = new SimpleMailbox(INBOX, UID_VALIDITY);
+    private static final SimpleMailbox NEW_MAILBOX = new SimpleMailbox(NEW_PATH, UID_VALIDITY);
 
     private GlobalRegistration globalRegistration;
     private EventFactory eventFactory;
     private MockMailboxSession session;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         eventFactory = new EventFactory();
         session = new MockMailboxSession("test");
         globalRegistration = new GlobalRegistration();
     }
 
     @Test
-    public void pathToIndexShouldNotBeChangedByDefault() {
+    void pathToIndexShouldNotBeChangedByDefault() {
         assertThat(globalRegistration.getPathToIndex(INBOX).get()).isEqualTo(INBOX);
     }
 
     @Test
-    public void pathToIndexShouldNotBeChangedByAddedEvents() {
+    void pathToIndexShouldNotBeChangedByAddedEvents() {
         MailboxListener.MailboxEvent event = eventFactory.mailboxAdded(session, MAILBOX);
         globalRegistration.event(event);
         assertThat(globalRegistration.getPathToIndex(INBOX).get()).isEqualTo(INBOX);
     }
 
     @Test
-    public void pathToIndexShouldBeNullifiedByDeletedEvents() {
+    void pathToIndexShouldBeNullifiedByDeletedEvents() {
         QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", Optional.empty());
         QuotaCount quotaCount = QuotaCount.count(123);
         QuotaSize quotaSize = QuotaSize.size(456);
@@ -75,11 +75,9 @@ public class GlobalRegistrationTest {
     }
 
     @Test
-    public void pathToIndexShouldBeModifiedByRenamedEvents() {
+    void pathToIndexShouldBeModifiedByRenamedEvents() {
         MailboxListener.MailboxEvent event = eventFactory.mailboxRenamed(session, INBOX,
NEW_MAILBOX);
         globalRegistration.event(event);
         assertThat(globalRegistration.getPathToIndex(INBOX).get()).isEqualTo(NEW_PATH);
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/02f8d6f7/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
index 33a19b7..3b9bad2 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
@@ -39,8 +39,8 @@ import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent.FlagsMessageEvent;
 import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent.MessageDeletedEvent;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
@@ -48,31 +48,31 @@ import com.google.common.collect.Lists;
 public class MailboxRegistrationTest {
 
     public static final MailboxPath INBOX = MailboxPath.forUser("btellier@apache.org", "INBOX");
-    public static final MessageUid UID = MessageUid.of(18);
-    public static final int UID_VALIDITY = 45;
-    public static final SimpleMailbox MAILBOX = new SimpleMailbox(INBOX, UID_VALIDITY);
-    public static final int MOD_SEQ = 21;
-    public static final int SIZE = 41;
-    public static final Flags NEW_FLAGS = new Flags(Flags.Flag.ANSWERED);
+    private static final MessageUid UID = MessageUid.of(18);
+    private static final int UID_VALIDITY = 45;
+    private static final SimpleMailbox MAILBOX = new SimpleMailbox(INBOX, UID_VALIDITY);
+    private static final int MOD_SEQ = 21;
+    private static final int SIZE = 41;
+    private static final Flags NEW_FLAGS = new Flags(Flags.Flag.ANSWERED);
     private MailboxRegistration mailboxRegistration;
     private EventFactory eventFactory;
     private MockMailboxSession session;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         session = new MockMailboxSession("test");
         eventFactory = new EventFactory();
         mailboxRegistration = new MailboxRegistration(INBOX);
     }
 
     @Test
-    public void reportedEventsShouldBeInitiallyEmpty() {
+    void reportedEventsShouldBeInitiallyEmpty() {
         assertThat(mailboxRegistration.getImpactingEvents(UID)).isEmpty();
     }
 
 
     @Test
-    public void addedEventsShouldNotBeReported() {
+    void addedEventsShouldNotBeReported() {
         TreeMap<MessageUid, MessageMetaData> treeMap = new TreeMap<>();
         treeMap.put(UID, new SimpleMessageMetaData(UID, MOD_SEQ, new Flags(), SIZE, new Date(),
new DefaultMessageId()));
         MailboxListener.MailboxEvent event = eventFactory.added(session, treeMap, MAILBOX,
ImmutableMap.<MessageUid, MailboxMessage>of());
@@ -81,7 +81,7 @@ public class MailboxRegistrationTest {
     }
 
     @Test
-    public void expungedEventsShouldBeReported() {
+    void expungedEventsShouldBeReported() {
         TreeMap<MessageUid, MessageMetaData> treeMap = new TreeMap<>();
         treeMap.put(UID, new SimpleMessageMetaData(UID, MOD_SEQ, new Flags(), SIZE, new Date(),
new DefaultMessageId()));
         MailboxListener.MailboxEvent event = eventFactory.expunged(session, treeMap, MAILBOX);
@@ -90,7 +90,7 @@ public class MailboxRegistrationTest {
     }
 
     @Test
-    public void flagsEventsShouldBeReported() {
+    void flagsEventsShouldBeReported() {
         MailboxListener.MailboxEvent event = eventFactory.flagsUpdated(session,
             Lists.newArrayList(UID),
             MAILBOX,


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