You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/08/03 08:52:15 UTC

[02/20] james-project git commit: JAMES-2495 Lucene MPT tests can be run with InMemory mailbox impl

JAMES-2495 Lucene MPT tests can be run with InMemory mailbox impl


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

Branch: refs/heads/master
Commit: a58e7ddc193d500e684e77eb5afe7302fc27c0c7
Parents: 47968ea
Author: Matthieu Baechler <ma...@apache.org>
Authored: Wed Aug 1 17:04:16 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Aug 3 15:51:21 2018 +0700

----------------------------------------------------------------------
 .../lucenesearch/LuceneSearchTest.java          | 50 --------------
 .../lucenesearch/LuceneUidSearchTest.java       | 50 --------------
 .../host/LuceneSearchHostSystem.java            | 71 ++++++++------------
 3 files changed, 28 insertions(+), 143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a58e7ddc/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneSearchTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneSearchTest.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneSearchTest.java
deleted file mode 100644
index b5fe9ed..0000000
--- a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneSearchTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mpt.imapmailbox.lucenesearch;
-
-import org.apache.james.mpt.api.ImapHostSystem;
-import org.apache.james.mpt.imapmailbox.lucenesearch.host.LuceneSearchHostSystem;
-import org.apache.james.mpt.imapmailbox.suite.Search;
-import org.junit.After;
-import org.junit.Before;
-
-public class LuceneSearchTest extends Search {
-
-    private ImapHostSystem system;
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        system = new LuceneSearchHostSystem();
-        system.beforeTest();
-        super.setUp();
-    }
-    
-    @Override
-    protected ImapHostSystem createImapHostSystem() {
-        return system;
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        system.afterTest();
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a58e7ddc/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneUidSearchTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneUidSearchTest.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneUidSearchTest.java
deleted file mode 100644
index 942b73e..0000000
--- a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneUidSearchTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mpt.imapmailbox.lucenesearch;
-
-import org.apache.james.mpt.api.ImapHostSystem;
-import org.apache.james.mpt.imapmailbox.lucenesearch.host.LuceneSearchHostSystem;
-import org.apache.james.mpt.imapmailbox.suite.UidSearch;
-import org.junit.After;
-import org.junit.Before;
-
-public class LuceneUidSearchTest extends UidSearch {
-
-    private ImapHostSystem system;
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        system = new LuceneSearchHostSystem();
-        system.beforeTest();
-        super.setUp();
-    }
-    
-    @Override
-    protected ImapHostSystem createImapHostSystem() {
-        return system;
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        system.afterTest();
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a58e7ddc/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
index b5f5742..a085f9e 100644
--- a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
@@ -22,11 +22,8 @@ package org.apache.james.mpt.imapmailbox.lucenesearch.host;
 import java.io.File;
 import java.io.IOException;
 
-import javax.persistence.EntityManagerFactory;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.NotImplementedException;
-import org.apache.james.backends.jpa.JpaTestCluster;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.imap.api.process.ImapProcessor;
@@ -36,27 +33,20 @@ import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.SubscriptionManager;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.jpa.JPAId;
-import org.apache.james.mailbox.jpa.JPAId.Factory;
-import org.apache.james.mailbox.jpa.JPAMailboxFixture;
-import org.apache.james.mailbox.jpa.JPAMailboxSessionMapperFactory;
-import org.apache.james.mailbox.jpa.JPASubscriptionManager;
-import org.apache.james.mailbox.jpa.mail.JPAModSeqProvider;
-import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
-import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
+import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.InMemoryMessageId;
 import org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex;
-import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 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.DefaultMessageId;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.DefaultUserQuotaRootResolver;
 import org.apache.james.mailbox.store.quota.NoQuotaManager;
@@ -72,11 +62,10 @@ public class LuceneSearchHostSystem extends JamesImapHostSystem {
     public static final String META_DATA_DIRECTORY = "target/user-meta-data";
     private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
         Feature.MOD_SEQ_SEARCH);
-    private static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPAMailboxFixture.MAILBOX_PERSISTANCE_CLASSES);
 
 
     private File tempFile;
-    private OpenJPAMailboxManager mailboxManager;
+    private InMemoryMailboxManager mailboxManager;
 
     @Override
     public void beforeTest() throws Exception {
@@ -92,7 +81,6 @@ public class LuceneSearchHostSystem extends JamesImapHostSystem {
         resetUserMetaData();
         MailboxSession session = mailboxManager.createSystemSession("test");
         mailboxManager.startProcessingRequest(session);
-        mailboxManager.deleteEverything(session);
         mailboxManager.endProcessingRequest(session);
         mailboxManager.logout(session, false);
     }
@@ -106,44 +94,41 @@ public class LuceneSearchHostSystem extends JamesImapHostSystem {
     }
 
     private void initFields() {
-        EntityManagerFactory entityManagerFactory = JPA_TEST_CLUSTER.getEntityManagerFactory();
-        JVMMailboxPathLocker locker = new JVMMailboxPathLocker();
-        JPAUidProvider uidProvider = new JPAUidProvider(locker, entityManagerFactory);
-        JPAModSeqProvider modSeqProvider = new JPAModSeqProvider(locker, entityManagerFactory);
-        JPAMailboxSessionMapperFactory factory = new JPAMailboxSessionMapperFactory(entityManagerFactory, uidProvider, modSeqProvider);
-
+       
         try {
-            JPAId.Factory mailboxIdFactory = new Factory();
-            FSDirectory fsDirectory = FSDirectory.open(tempFile);
-            MessageId.Factory messageIdFactory = new DefaultMessageId.Factory();
-
-            MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
-            GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
-            MessageParser messageParser = new MessageParser();
+            DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
+            MailboxEventDispatcher dispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
+            
+            InMemoryMailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
+            StoreRightManager rightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), dispatcher);
+            JVMMailboxPathLocker locker = new JVMMailboxPathLocker();
+            InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
+            mailboxManager = new InMemoryMailboxManager(mapperFactory,
+                authenticator,
+                authorizator,
+                locker,
+                new MessageParser(),
+                messageIdFactory,
+                dispatcher,
+                delegatingMailboxListener,
+                new StoreMailboxAnnotationManager(mapperFactory, rightManager),
+                rightManager);
 
-            DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
-            MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
-            StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
-
-            StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(factory, storeRightManager);
-            mailboxManager = new OpenJPAMailboxManager(factory, authenticator, authorizator,
-                messageParser, new DefaultMessageId.Factory(), delegatingListener,
-                mailboxEventDispatcher, annotationManager, storeRightManager);
-
-            LuceneMessageSearchIndex searchIndex = new LuceneMessageSearchIndex(factory, mailboxIdFactory, fsDirectory, messageIdFactory);
+            FSDirectory fsDirectory = FSDirectory.open(tempFile);
+            LuceneMessageSearchIndex searchIndex = new LuceneMessageSearchIndex(mapperFactory, new InMemoryId.Factory(), fsDirectory, messageIdFactory);
             searchIndex.setEnableSuffixMatch(true);
             mailboxManager.setMessageSearchIndex(searchIndex);
 
             mailboxManager.init();
 
-            SubscriptionManager subscriptionManager = new JPASubscriptionManager(factory);
+            SubscriptionManager subscriptionManager = new StoreSubscriptionManager(mapperFactory);
 
             final ImapProcessor defaultImapProcessorFactory =
                 DefaultImapProcessorFactory.createDefaultProcessor(
                     mailboxManager,
                     subscriptionManager,
                     new NoQuotaManager(),
-                    new DefaultUserQuotaRootResolver(factory),
+                    new DefaultUserQuotaRootResolver(mapperFactory),
                     new DefaultMetricFactory());
 
             configure(new DefaultImapDecoderFactory().buildImapDecoder(),


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org