james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [11/21] james-project git commit: MAILBOX-342 Don't use mapper provider for MailboxMapperAclTest
Date Fri, 06 Jul 2018 09:27:37 GMT
MAILBOX-342 Don't use mapper provider for MailboxMapperAclTest

In Cassandra test by limiting loaded modules, 33s -> 13s


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

Branch: refs/heads/master
Commit: 6c8b5fc00685d1ae642e82a980ca28ce4b3c5d03
Parents: 10e9d87
Author: benwa <btellier@linagora.com>
Authored: Thu Jul 5 10:56:09 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Jul 6 16:25:50 2018 +0700

----------------------------------------------------------------------
 .../mail/CassandraMailboxMapperAclTest.java     | 45 ++++++++------------
 .../mail/MemoryMailboxMapperAclTest.java        | 18 ++++++--
 .../store/mail/model/MailboxMapperACLTest.java  | 17 +++-----
 3 files changed, 39 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6c8b5fc0/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperAclTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperAclTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperAclTest.java
index 251a508..6e65bac 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperAclTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperAclTest.java
@@ -22,21 +22,15 @@ package org.apache.james.mailbox.cassandra.mail;
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
-import org.apache.james.blob.cassandra.CassandraBlobModule;
+import org.apache.james.mailbox.cassandra.ids.CassandraId;
+import org.apache.james.mailbox.cassandra.mail.utils.GuiceUtils;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.MailboxMapperACLTest;
-import org.apache.james.mailbox.store.mail.model.MapperProvider;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -51,20 +45,11 @@ public class CassandraMailboxMapperAclTest extends MailboxMapperACLTest
{
     @Before
     public void setUp() throws Exception {
         CassandraModuleComposite modules = new CassandraModuleComposite(
-                new CassandraAclModule(),
-                new CassandraMailboxModule(),
-                new CassandraMessageModule(),
-                new CassandraMailboxCounterModule(),
-                new CassandraMailboxRecentsModule(),
-                new CassandraModSeqModule(),
-                new CassandraUidModule(),
-                new CassandraAttachmentModule(),
-                new CassandraAnnotationModule(),
-                new CassandraFirstUnseenModule(),
-                new CassandraApplicableFlagsModule(),
-                new CassandraDeletedMessageModule(),
-                new CassandraBlobModule());
-        this.cassandra = CassandraCluster.create(modules, cassandraServer.getIp(), cassandraServer.getBindingPort());
+            new CassandraAclModule(),
+            new CassandraMailboxModule(),
+            new CassandraModSeqModule(),
+            new CassandraUidModule());
+        this.cassandra = CassandraCluster.create(modules, cassandraServer.getHost());
         super.setUp();
     }
     
@@ -72,9 +57,15 @@ public class CassandraMailboxMapperAclTest extends MailboxMapperACLTest
{
     public void tearDown() {
         cassandra.close();
     }
-    
+
+    @Override
+    protected MailboxMapper createMailboxMapper() {
+        return GuiceUtils.testInjector(cassandra)
+            .getInstance(CassandraMailboxMapper.class);
+    }
+
     @Override
-    protected MapperProvider createMapperProvider() {
-        return new CassandraMapperProvider(cassandra);
+    protected MailboxId generateId() {
+        return CassandraId.timeBased();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/6c8b5fc0/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperAclTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperAclTest.java
b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperAclTest.java
index 10b037a..df6d73f 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperAclTest.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperAclTest.java
@@ -19,20 +19,30 @@
 
 package org.apache.james.mailbox.inmemory.mail;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.MailboxMapperACLTest;
-import org.apache.james.mailbox.store.mail.model.MapperProvider;
 import org.junit.Before;
 
 public class MemoryMailboxMapperAclTest extends MailboxMapperACLTest {
+    private final AtomicInteger counter = new AtomicInteger();
     
     @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
     }
-    
+
+    @Override
+    protected MailboxMapper createMailboxMapper() {
+        return new InMemoryMailboxMapper();
+    }
+
     @Override
-    protected MapperProvider createMapperProvider() {
-        return new InMemoryMapperProvider();
+    protected MailboxId generateId() {
+        return InMemoryId.of(counter.incrementAndGet());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/6c8b5fc0/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
index f8f0636..0a6fd6d 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
@@ -28,10 +28,10 @@ import org.apache.james.mailbox.model.MailboxACL.EntryKey;
 import org.apache.james.mailbox.model.MailboxACL.NameType;
 import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
 import org.apache.james.mailbox.model.MailboxACL.Right;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.junit.Assume;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -47,18 +47,15 @@ public abstract class MailboxMapperACLTest {
 
     @Rule
     public ExpectedException expected = ExpectedException.none();
-    private MailboxMapper mailboxMapper;
-    private MapperProvider mapperProvider;
 
-    protected abstract MapperProvider createMapperProvider();
+    private MailboxMapper mailboxMapper;
 
-    public void setUp() throws Exception {
-        this.mapperProvider = createMapperProvider();
-        Assume.assumeTrue(mapperProvider.getSupportedCapabilities().contains(MapperProvider.Capabilities.MAILBOX));
-        Assume.assumeTrue(mapperProvider.getSupportedCapabilities().contains(MapperProvider.Capabilities.ACL_STORAGE));
+    protected abstract MailboxMapper createMailboxMapper();
 
-        this.mailboxMapper = mapperProvider.createMailboxMapper();
+    protected abstract MailboxId generateId();
 
+    public void setUp() throws Exception {
+        mailboxMapper = createMailboxMapper();
         MailboxPath benwaInboxPath = MailboxPath.forUser("benwa", "INBOX");
         benwaInboxMailbox = createMailbox(benwaInboxPath);
         mailboxMapper.save(benwaInboxMailbox);
@@ -239,7 +236,7 @@ public abstract class MailboxMapperACLTest {
 
     private SimpleMailbox createMailbox(MailboxPath mailboxPath) {
         SimpleMailbox mailbox = new SimpleMailbox(mailboxPath, UID_VALIDITY);
-        mailbox.setMailboxId(mapperProvider.generateId());
+        mailbox.setMailboxId(generateId());
         return 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