james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [01/15] james-project git commit: MAILBOX-317 Rework InMemoryMailboxManager constructor
Date Fri, 03 Nov 2017 02:33:18 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 541dbc384 -> 99c181977


MAILBOX-317 Rework InMemoryMailboxManager constructor

Passing the event system should not be optional. And It should not be class concern to init
the right system.

In the operation:
 - Delete one constructor
 - Implement logic in only one constructor (the other should only call it)


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

Branch: refs/heads/master
Commit: f879859b2e77bcc5064850c25ba7551b9080529b
Parents: b3eb1b2
Author: benwa <btellier@linagora.com>
Authored: Thu Nov 2 09:13:19 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Nov 3 09:32:31 2017 +0700

----------------------------------------------------------------------
 .../elasticsearch/ElasticSearchIntegrationTest.java      |  7 ++++---
 .../lucene/search/LuceneMessageSearchIndexTest.java      |  8 +++++---
 .../james/mailbox/inmemory/InMemoryMailboxManager.java   |  5 -----
 .../mail/InMemoryMailboxManagerAttachmentTest.java       | 11 ++++++++---
 .../inmemory/manager/InMemoryIntegrationResources.java   |  9 ++++++++-
 .../store/search/SimpleMessageSearchIndexTest.java       |  8 +++++---
 .../imapmailbox/inmemory/host/InMemoryHostSystem.java    |  8 +++++++-
 .../apache/james/transport/matchers/IsOverQuotaTest.java | 11 ++++++++---
 8 files changed, 45 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index cf3a9cc..d91e755 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -136,6 +136,8 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
                 MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS,
                 MailboxElasticSearchConstants.MESSAGE_TYPE),
             new MessageToElasticSearchJson(textExtractor, ZoneId.of("Europe/Paris"), IndexAttachments.YES));
+        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,
             new FakeAuthenticator(),
@@ -143,10 +145,9 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
             new JVMMailboxPathLocker(),
             new MessageParser(),
             messageIdFactory,
+            mailboxEventDispatcher,
+            delegatingListener,
             storeRightManager);
-        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
-        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
-        storeMailboxManager.setDelegatingMailboxListener(delegatingListener);
 
         messageIdManager = new StoreMessageIdManager(
             storeMailboxManager,

http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
index c66bd57..2c6daaa 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
@@ -54,6 +54,9 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
         UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
         SimpleGroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
         StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver,
groupMembershipResolver);
+
+        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,
             new FakeAuthenticator(),
@@ -61,10 +64,9 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
             new JVMMailboxPathLocker(),
             new MessageParser(),
             messageIdFactory,
+            mailboxEventDispatcher,
+            delegatingListener,
             storeRightManager);
-        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
-        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
-        storeMailboxManager.setDelegatingMailboxListener(delegatingListener);
 
         messageIdManager = new StoreMessageIdManager(
             storeMailboxManager,

http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
index 99dffd2..07f8f8a 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
@@ -51,11 +51,6 @@ public class InMemoryMailboxManager extends StoreMailboxManager {
             delegatingMailboxListener, storeRightManager);
     }
 
-    public InMemoryMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory,
Authenticator authenticator, Authorizator authorizator,
-                                  MailboxPathLocker locker, MessageParser messageParser,
MessageId.Factory messageIdFactory, StoreRightManager storeRightManager) {
-        super(mailboxSessionMapperFactory, authenticator, authorizator, locker, messageParser,
messageIdFactory, storeRightManager);
-    }
-
     public InMemoryMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory,
Authenticator authenticator,  Authorizator authorizator,
                                   MessageParser messageParser, MessageId.Factory messageIdFactory,
                                   int limitOfAnnotations, int limitAnnotationSize,

http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
index 92bc78d..56ea10a 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
@@ -38,6 +38,8 @@ import org.apache.james.mailbox.store.Authorizator;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.NoMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.junit.Before;
@@ -58,14 +60,17 @@ public class InMemoryMailboxManagerAttachmentTest extends AbstractMailboxManager
         GroupMembershipResolver groupMembershipResolver = null;
         UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
         StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory,
aclResolver, groupMembershipResolver);
-        mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator,
noAuthorizator, new NoMailboxPathLocker(), 
-                new MessageParser(), messageIdFactory, storeRightManager);
+
+        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+        mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator,
noAuthorizator, new NoMailboxPathLocker(),
+                new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener,
storeRightManager);
         mailboxManager.init();
         MessageParser failingMessageParser = mock(MessageParser.class);
         when(failingMessageParser.retrieveAttachments(any(InputStream.class)))
             .thenThrow(new RuntimeException("Message parser set to fail"));
         parseFailingMailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory,
noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
-            failingMessageParser, messageIdFactory, storeRightManager);
+            failingMessageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener,
storeRightManager);
         parseFailingMailboxManager.init();
         super.setUp();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index f560727..536751e 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -40,6 +40,8 @@ import org.apache.james.mailbox.store.NoMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.StoreMessageIdManager;
 import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
 import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -58,13 +60,18 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
         fakeAuthenticator.addUser(ManagerTestResources.OTHER_USER, ManagerTestResources.OTHER_USER_PASS);
         InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
         StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory,
new UnionMailboxACLResolver(), groupMembershipResolver);
-        final StoreMailboxManager manager = new InMemoryMailboxManager(
+
+        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+        StoreMailboxManager manager = new InMemoryMailboxManager(
             mailboxSessionMapperFactory,
             fakeAuthenticator,
             FakeAuthorizator.defaultReject(),
             new NoMailboxPathLocker(),
             new MessageParser(),
             new InMemoryMessageId.Factory(),
+            mailboxEventDispatcher,
+            delegatingListener,
             storeRightManager);
         manager.init();
         return manager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
index 31e35f0..e28f558 100644
--- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
+++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
@@ -53,6 +53,9 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
         UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
         SimpleGroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
         StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver,
groupMembershipResolver);
+
+        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,
             new FakeAuthenticator(),
@@ -60,10 +63,9 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
             new JVMMailboxPathLocker(),
             new MessageParser(),
             messageIdFactory,
+            mailboxEventDispatcher,
+            delegatingListener,
             storeRightManager);
-        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
-        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(new DefaultDelegatingMailboxListener());
-        storeMailboxManager.setDelegatingMailboxListener(delegatingListener);
 
         messageIdManager = new StoreMessageIdManager(
             storeMailboxManager,

http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
index 56451ee..0cac457 100644
--- a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
+++ b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
@@ -38,6 +38,8 @@ import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreRightManager;
 import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
 import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -72,8 +74,12 @@ public class InMemoryHostSystem extends JamesImapHostSystem {
 
         InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
         StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory,
aclResolver, groupMembershipResolver);
+
+        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
         mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, authenticator,
authorizator,
-                new JVMMailboxPathLocker(), messageParser, new InMemoryMessageId.Factory(),
storeRightManager);
+                new JVMMailboxPathLocker(), messageParser, new InMemoryMessageId.Factory(),
+                mailboxEventDispatcher, delegatingListener, storeRightManager);
         QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mailboxManager.getMapperFactory());
 
         perUserMaxQuotaManager = new InMemoryPerUserMaxQuotaManager();

http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
index ac46f78..c18771b 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
 
 import java.util.Collection;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
@@ -38,12 +39,13 @@ import org.apache.james.mailbox.store.FakeAuthenticator;
 import org.apache.james.mailbox.store.FakeAuthorizator;
 import org.apache.james.mailbox.store.NoMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
 import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
 import org.apache.james.mailbox.store.quota.StoreQuotaManager;
 import org.apache.james.user.api.UsersRepository;
-import org.apache.james.core.MailAddress;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMatcherConfig;
@@ -61,10 +63,13 @@ public class IsOverQuotaTest {
     public void setUp() throws Exception {
         InMemoryMailboxSessionMapperFactory factory = new InMemoryMailboxSessionMapperFactory();
         StoreRightManager storeRightManager = new StoreRightManager(factory, new UnionMailboxACLResolver(),
new SimpleGroupMembershipResolver());
+
+        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
         mailboxManager = new InMemoryMailboxManager(factory, new FakeAuthenticator(), FakeAuthorizator.defaultReject(),
             new NoMailboxPathLocker(), new MessageParser(),
-            new InMemoryMessageId.Factory(),
-            storeRightManager);
+            new InMemoryMessageId.Factory(), mailboxEventDispatcher,
+            delegatingListener, storeRightManager);
 
         quotaRootResolver = new DefaultQuotaRootResolver(factory);
         maxQuotaManager = new InMemoryPerUserMaxQuotaManager();


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