Author: btellier Date: Sat Nov 28 15:31:34 2015 New Revision: 1716989 URL: http://svn.apache.org/viewvc?rev=1716989&view=rev Log: MAILBOX-259 Add MPT tests for asynchronous event delivery
Added: james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTest.java james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTestModule.java james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryEventAsynchronousHostSystem.java Added: james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTest.java URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTest.java?rev=1716989&view=auto ============================================================================== --- james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTest.java (added) +++ james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTest.java Sat Nov 28 15:31:34 2015 @@ -0,0 +1,70 @@ +/**************************************************************** + * 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.inmemory; + +import org.apache.james.mpt.imapmailbox.suite.AuthenticatedState; +import org.apache.james.mpt.imapmailbox.suite.ConcurrentSessions; +import org.apache.james.mpt.imapmailbox.suite.Events; +import org.apache.james.mpt.imapmailbox.suite.Expunge; +import org.apache.james.mpt.imapmailbox.suite.Fetch; +import org.apache.james.mpt.imapmailbox.suite.FetchBodySection; +import org.apache.james.mpt.imapmailbox.suite.FetchBodyStructure; +import org.apache.james.mpt.imapmailbox.suite.FetchHeaders; +import org.apache.james.mpt.imapmailbox.suite.Listing; +import org.apache.james.mpt.imapmailbox.suite.NonAuthenticatedState; +import org.apache.james.mpt.imapmailbox.suite.PartialFetch; +import org.apache.james.mpt.imapmailbox.suite.QuotaTest; +import org.apache.james.mpt.imapmailbox.suite.Rename; +import org.apache.james.mpt.imapmailbox.suite.Search; +import org.apache.james.mpt.imapmailbox.suite.Security; +import org.apache.james.mpt.imapmailbox.suite.Select; +import org.apache.james.mpt.imapmailbox.suite.SelectedInbox; +import org.apache.james.mpt.imapmailbox.suite.SelectedState; +import org.apache.james.mpt.imapmailbox.suite.UidSearch; +import org.apache.onami.test.OnamiSuite; +import org.apache.onami.test.annotation.GuiceModules; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(OnamiSuite.class) +@Suite.SuiteClasses({ + AuthenticatedState.class, + ConcurrentSessions.class, + Events.class, + Expunge.class, + Fetch.class, + FetchBodySection.class, + FetchBodyStructure.class, + FetchHeaders.class, + Listing.class, + NonAuthenticatedState.class, + PartialFetch.class, + Rename.class, + Search.class, + Security.class, + Select.class, + SelectedInbox.class, + SelectedState.class, + UidSearch.class, + QuotaTest.class +}) +@GuiceModules({ InMemoryMailboxTestModule.class }) +public class InMemoryMailboxEventAsynchronousTest { + +} Added: james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTestModule.java URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTestModule.java?rev=1716989&view=auto ============================================================================== --- james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTestModule.java (added) +++ james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryMailboxEventAsynchronousTestModule.java Sat Nov 28 15:31:34 2015 @@ -0,0 +1,42 @@ +/**************************************************************** + * 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.inmemory; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.Singleton; +import org.apache.james.mpt.api.HostSystem; +import org.apache.james.mpt.api.ImapHostSystem; +import org.apache.james.mpt.imapmailbox.inmemory.host.InMemoryEventAsynchronousHostSystem; +import org.apache.james.mpt.imapmailbox.inmemory.host.InMemoryHostSystem; + +public class InMemoryMailboxEventAsynchronousTestModule extends AbstractModule { + + @Override + protected void configure() { + bind(HostSystem.class).to(ImapHostSystem.class); + } + + @Provides + @Singleton + public ImapHostSystem provideHostSystem() throws Exception { + return InMemoryEventAsynchronousHostSystem.build(); + } + +} Added: james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryEventAsynchronousHostSystem.java URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryEventAsynchronousHostSystem.java?rev=1716989&view=auto ============================================================================== --- james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryEventAsynchronousHostSystem.java (added) +++ james/project/trunk/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryEventAsynchronousHostSystem.java Sat Nov 28 15:31:34 2015 @@ -0,0 +1,125 @@ +/**************************************************************** + * 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.inmemory.host; + +import org.apache.james.imap.api.process.ImapProcessor; +import org.apache.james.imap.encode.main.DefaultImapEncoderFactory; +import org.apache.james.imap.main.DefaultImapDecoderFactory; +import org.apache.james.imap.processor.main.DefaultImapProcessorFactory; +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.inmemory.InMemoryId; +import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory; +import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager; +import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager; +import org.apache.james.mailbox.model.MailboxPath; +import org.apache.james.mailbox.quota.QuotaRootResolver; +import org.apache.james.mailbox.store.MockAuthenticator; +import org.apache.james.mailbox.store.StoreMailboxManager; +import org.apache.james.mailbox.store.StoreSubscriptionManager; +import org.apache.james.mailbox.store.event.AsynchronousEventDelivery; +import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener; +import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator; +import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver; +import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater; +import org.apache.james.mailbox.store.quota.StoreQuotaManager; +import org.apache.james.mpt.api.ImapFeatures; +import org.apache.james.mpt.api.ImapFeatures.Feature; +import org.apache.james.mpt.host.JamesImapHostSystem; +import org.apache.james.mpt.imapmailbox.MailboxCreationDelegate; + +public class InMemoryEventAsynchronousHostSystem extends JamesImapHostSystem { + + private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT); + + private StoreMailboxManager<InMemoryId> mailboxManager; + private MockAuthenticator userManager; + + public static JamesImapHostSystem build() throws Exception { + return new InMemoryEventAsynchronousHostSystem(); + } + + private InMemoryEventAsynchronousHostSystem() throws MailboxException { + initFields(); + } + + public boolean addUser(String user, String password) throws Exception { + userManager.addUser(user, password); + return true; + } + + @Override + protected void resetData() throws Exception { + initFields(); + } + + private void initFields() throws MailboxException { + userManager = new MockAuthenticator(); + InMemoryMailboxSessionMapperFactory factory = new InMemoryMailboxSessionMapperFactory(); + MailboxACLResolver aclResolver = new UnionMailboxACLResolver(); + GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver(); + + mailboxManager = new StoreMailboxManager<InMemoryId>(factory, userManager, aclResolver, groupMembershipResolver); + QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(factory); + + InMemoryPerUserMaxQuotaManager perUserMaxQuotaManager = new InMemoryPerUserMaxQuotaManager(); + perUserMaxQuotaManager.setDefaultMaxMessage(4096); + perUserMaxQuotaManager.setDefaultMaxStorage(5L * 1024L * 1024L * 1024L); + + InMemoryCurrentQuotaManager currentQuotaManager = new InMemoryCurrentQuotaManager( + new CurrentQuotaCalculator(factory, quotaRootResolver), + mailboxManager); + + StoreQuotaManager quotaManager = new StoreQuotaManager(); + quotaManager.setMaxQuotaManager(perUserMaxQuotaManager); + quotaManager.setCurrentQuotaManager(currentQuotaManager); + + ListeningCurrentQuotaUpdater quotaUpdater = new ListeningCurrentQuotaUpdater(); + quotaUpdater.setCurrentQuotaManager(currentQuotaManager); + quotaUpdater.setQuotaRootResolver(quotaRootResolver); + + mailboxManager.setQuotaRootResolver(quotaRootResolver); + mailboxManager.setQuotaManager(quotaManager); + mailboxManager.setQuotaUpdater(quotaUpdater); + + mailboxManager.setDelegatingMailboxListener(new DefaultDelegatingMailboxListener(new AsynchronousEventDelivery(10))); + + mailboxManager.init(); + + final ImapProcessor defaultImapProcessorFactory = DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager, new StoreSubscriptionManager(factory), quotaManager, quotaRootResolver); + configure(new DefaultImapDecoderFactory().buildImapDecoder(), + new DefaultImapEncoderFactory().buildImapEncoder(), + defaultImapProcessorFactory); + } + + @Override + public void createMailbox(MailboxPath mailboxPath) throws Exception{ + new MailboxCreationDelegate(mailboxManager).createMailbox(mailboxPath); + } + + @Override + public boolean supports(Feature... features) { + return SUPPORTED_FEATURES.supports(features); + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org