This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4d5b67219053f9dfc880d9a4b372677f412bea19 Author: Benoit Tellier <[email protected]> AuthorDate: Fri Mar 15 14:25:47 2019 +0700 JAMES-2687 Use InMemoryIntegrationResources for InMemoryMailboxManagerAttachmentTest --- .../mail/InMemoryMailboxManagerAttachmentTest.java | 51 ++++------------------ .../manager/InMemoryIntegrationResources.java | 9 +++- 2 files changed, 17 insertions(+), 43 deletions(-) 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 9be0b03..a4f7a17 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 @@ -26,63 +26,30 @@ import static org.mockito.Mockito.when; import java.io.InputStream; import org.apache.james.mailbox.MailboxManager; -import org.apache.james.mailbox.acl.GroupMembershipResolver; -import org.apache.james.mailbox.acl.UnionMailboxACLResolver; -import org.apache.james.mailbox.events.InVMEventBus; -import org.apache.james.mailbox.events.delivery.InVmEventDelivery; 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.model.MessageId; +import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources; import org.apache.james.mailbox.store.AbstractMailboxManagerAttachmentTest; -import org.apache.james.mailbox.store.Authenticator; -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.PreDeletionHooks; -import org.apache.james.mailbox.store.SessionProvider; -import org.apache.james.mailbox.store.StoreMailboxAnnotationManager; -import org.apache.james.mailbox.store.StoreRightManager; -import org.apache.james.mailbox.store.extractor.DefaultTextExtractor; import org.apache.james.mailbox.store.mail.AttachmentMapperFactory; import org.apache.james.mailbox.store.mail.model.impl.MessageParser; -import org.apache.james.mailbox.store.quota.QuotaComponents; -import org.apache.james.mailbox.store.search.MessageSearchIndex; -import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex; -import org.apache.james.metrics.api.NoopMetricFactory; import org.junit.Before; public class InMemoryMailboxManagerAttachmentTest extends AbstractMailboxManagerAttachmentTest { - - private InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory; private InMemoryMailboxManager mailboxManager; private InMemoryMailboxManager parseFailingMailboxManager; - @Override @Before public void setUp() throws Exception { - mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory(); - Authenticator noAuthenticator = null; - Authorizator noAuthorizator = null; - InVMEventBus eventBus = new InVMEventBus(new InVmEventDelivery(new NoopMetricFactory())); - MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory(); - GroupMembershipResolver groupMembershipResolver = null; - UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver(); - StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver, eventBus); - - SessionProvider sessionProvider = new SessionProvider(noAuthenticator, noAuthorizator); - QuotaComponents quotaComponents = QuotaComponents.disabled(sessionProvider, mailboxSessionMapperFactory); - MessageSearchIndex index = new SimpleMessageSearchIndex(mailboxSessionMapperFactory, mailboxSessionMapperFactory, new DefaultTextExtractor()); - - StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager); - mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, sessionProvider, new NoMailboxPathLocker(), - new MessageParser(), messageIdFactory, eventBus, annotationManager, storeRightManager, quotaComponents, index, PreDeletionHooks.NO_PRE_DELETION_HOOK); MessageParser failingMessageParser = mock(MessageParser.class); when(failingMessageParser.retrieveAttachments(any(InputStream.class))) .thenThrow(new RuntimeException("Message parser set to fail")); - parseFailingMailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, sessionProvider, new NoMailboxPathLocker(), - failingMessageParser, messageIdFactory, eventBus, annotationManager, storeRightManager, quotaComponents, index, PreDeletionHooks.NO_PRE_DELETION_HOOK); + + mailboxManager = new InMemoryIntegrationResources.Factory().create().getMailboxManager(); + parseFailingMailboxManager = new InMemoryIntegrationResources.Factory() + .withMessageParser(failingMessageParser) + .create().getMailboxManager(); + super.setUp(); } @@ -93,7 +60,7 @@ public class InMemoryMailboxManagerAttachmentTest extends AbstractMailboxManager @Override protected MailboxSessionMapperFactory getMailboxSessionMapperFactory() { - return mailboxSessionMapperFactory; + return mailboxManager.getMapperFactory(); } @Override @@ -103,6 +70,6 @@ public class InMemoryMailboxManagerAttachmentTest extends AbstractMailboxManager @Override protected AttachmentMapperFactory getAttachmentMapperFactory() { - return mailboxSessionMapperFactory; + return (AttachmentMapperFactory) mailboxManager.getMapperFactory(); } } 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 31510d4..31afd2b 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 @@ -76,6 +76,7 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM private Optional<EventBus> eventBus; private Optional<Integer> limitAnnotationCount; private Optional<Integer> limitAnnotationSize; + private Optional<MessageParser> messageParser; private Optional<Function<MailboxManagerPreInstanciationStage, MessageSearchIndex>> searchIndexInstanciator; private ImmutableSet.Builder<Function<MailboxManagerPreInstanciationStage, PreDeletionHook>> preDeletionHooksInstanciators; @@ -86,9 +87,15 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM this.limitAnnotationCount = Optional.empty(); this.limitAnnotationSize = Optional.empty(); this.searchIndexInstanciator = Optional.empty(); + this.messageParser = Optional.empty(); this.preDeletionHooksInstanciators = ImmutableSet.builder(); } + public Factory withMessageParser(MessageParser messageParser) { + this.messageParser = Optional.of(messageParser); + return this; + } + public Factory withAuthenticator(Authenticator authenticator) { this.authenticator = Optional.of(authenticator); return this; @@ -161,7 +168,7 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM mailboxSessionMapperFactory, sessionProvider, new JVMMailboxPathLocker(), - new MessageParser(), + messageParser.orElse(new MessageParser()), new InMemoryMessageId.Factory(), eventBus, annotationManager, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
