http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java ---------------------------------------------------------------------- diff --git a/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java b/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java index b406912..2e2ae1e 100644 --- a/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java +++ b/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java @@ -30,14 +30,17 @@ import java.util.HashMap; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.ParseException; -import org.apache.james.adapter.mailbox.SerializableQuota; import org.apache.james.cli.exceptions.InvalidArgumentNumberException; import org.apache.james.cli.exceptions.InvalidPortException; import org.apache.james.cli.exceptions.MissingCommandException; import org.apache.james.cli.exceptions.UnrecognizedCommandException; -import org.apache.james.cli.probe.ServerProbe; import org.apache.james.cli.type.CmdType; import org.apache.james.mailbox.model.Quota; +import org.apache.james.mailbox.store.mail.model.SerializableQuota; +import org.apache.james.mailbox.store.probe.MailboxProbe; +import org.apache.james.mailbox.store.probe.QuotaProbe; +import org.apache.james.mailbox.store.probe.SieveProbe; +import org.apache.james.probe.DataProbe; import org.apache.james.rrt.lib.Mappings; import org.apache.james.rrt.lib.MappingsImpl; import org.easymock.IMocksControl; @@ -51,15 +54,22 @@ public class ServerCmdTest { public static final String ADDITIONAL_ARGUMENT = "additionalArgument"; private IMocksControl control; - private ServerProbe serverProbe; + + private DataProbe dataProbe; + private MailboxProbe mailboxProbe; + private QuotaProbe quotaProbe; + private SieveProbe sieveProbe; private ServerCmd testee; @Before public void setup() { control = createControl(); - serverProbe = control.createMock(ServerProbe.class); - testee = new ServerCmd(serverProbe); + dataProbe = control.createMock(DataProbe.class); + mailboxProbe = control.createMock(MailboxProbe.class); + quotaProbe = control.createMock(QuotaProbe.class); + sieveProbe = control.createMock(SieveProbe.class); + testee = new ServerCmd(dataProbe, mailboxProbe, quotaProbe, sieveProbe); } @Test @@ -68,7 +78,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDDOMAIN.getCommand(), domain}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.addDomain(domain); + dataProbe.addDomain(domain); expectLastCall(); control.replay(); @@ -82,7 +92,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEDOMAIN.getCommand(), domain}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.removeDomain(domain); + dataProbe.removeDomain(domain); expectLastCall(); control.replay(); @@ -96,7 +106,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.CONTAINSDOMAIN.getCommand(), domain}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.containsDomain(domain)).andReturn(true); + expect(dataProbe.containsDomain(domain)).andReturn(true); control.replay(); testee.executeCommandLine(commandLine); @@ -108,7 +118,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTDOMAINS.getCommand()}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.listDomains()).andReturn(ImmutableList.<String> of()); + expect(dataProbe.listDomains()).andReturn(ImmutableList.<String> of()); control.replay(); testee.executeCommandLine(commandLine); @@ -122,7 +132,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDUSER.getCommand(), user, password}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.addUser(user, password); + dataProbe.addUser(user, password); expectLastCall(); control.replay(); @@ -136,7 +146,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEUSER.getCommand(), user}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.removeUser(user); + dataProbe.removeUser(user); expectLastCall(); control.replay(); @@ -150,7 +160,7 @@ public class ServerCmdTest { CommandLine commandLine = ServerCmd.parseCommandLine(arguments); String[] res = {}; - expect(serverProbe.listUsers()).andReturn(res); + expect(dataProbe.listUsers()).andReturn(res); control.replay(); testee.executeCommandLine(commandLine); @@ -162,7 +172,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTMAPPINGS.getCommand()}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.listMappings()).andReturn(new HashMap<String, Mappings>()); + expect(dataProbe.listMappings()).andReturn(new HashMap<String, Mappings>()); control.replay(); testee.executeCommandLine(commandLine); @@ -176,7 +186,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERDOMAINMAPPINGS.getCommand(), user, domain}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.listUserDomainMappings(user, domain)).andReturn(MappingsImpl.empty()); + expect(dataProbe.listUserDomainMappings(user, domain)).andReturn(MappingsImpl.empty()); control.replay(); testee.executeCommandLine(commandLine); @@ -191,7 +201,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDADDRESSMAPPING.getCommand(), user, domain, address}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.addAddressMapping(user, domain, address); + dataProbe.addAddressMapping(user, domain, address); expectLastCall(); control.replay(); @@ -207,7 +217,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEADDRESSMAPPING.getCommand(), user, domain, address}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.removeAddressMapping(user, domain, address); + dataProbe.removeAddressMapping(user, domain, address); expectLastCall(); control.replay(); @@ -223,7 +233,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.ADDREGEXMAPPING.getCommand(), user, domain, regex}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.addRegexMapping(user, domain, regex); + dataProbe.addRegexMapping(user, domain, regex); expectLastCall(); control.replay(); @@ -239,7 +249,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVEREGEXMAPPING.getCommand(), user, domain, regex}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.removeRegexMapping(user, domain, regex); + dataProbe.removeRegexMapping(user, domain, regex); expectLastCall(); control.replay(); @@ -254,7 +264,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETPASSWORD.getCommand(), user, password}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.setPassword(user, password); + dataProbe.setPassword(user, password); expectLastCall(); control.replay(); @@ -269,7 +279,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.COPYMAILBOX.getCommand(), srcBean, dstBean}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.copyMailbox(srcBean, dstBean); + mailboxProbe.copyMailbox(srcBean, dstBean); expectLastCall(); control.replay(); @@ -283,7 +293,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.DELETEUSERMAILBOXES.getCommand(), user}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.deleteUserMailboxesNames(user); + mailboxProbe.deleteUserMailboxesNames(user); expectLastCall(); control.replay(); @@ -299,7 +309,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.CREATEMAILBOX.getCommand(), namespace, user, name}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.createMailbox(namespace, user, name); + mailboxProbe.createMailbox(namespace, user, name); expectLastCall(); control.replay(); @@ -315,7 +325,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.DELETEMAILBOX.getCommand(), namespace, user, name}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.deleteMailbox(namespace, user, name); + mailboxProbe.deleteMailbox(namespace, user, name); expectLastCall(); control.replay(); @@ -329,7 +339,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.LISTUSERMAILBOXES.getCommand(), user}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.listUserMailboxes(user)).andReturn(new ArrayList<String>()); + expect(mailboxProbe.listUserMailboxes(user)).andReturn(new ArrayList<String>()); control.replay(); testee.executeCommandLine(commandLine); @@ -344,7 +354,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETQUOTAROOT.getCommand(), namespace, user, name}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getQuotaRoot(namespace, user, name)).andReturn(namespace + "&" + user); + expect(quotaProbe.getQuotaRoot(namespace, user, name)).andReturn(namespace + "&" + user); control.replay(); testee.executeCommandLine(commandLine); @@ -356,7 +366,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETDEFAULTMAXMESSAGECOUNTQUOTA.getCommand()}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getDefaultMaxMessageCount()).andReturn(1024L * 1024L); + expect(quotaProbe.getDefaultMaxMessageCount()).andReturn(1024L * 1024L); control.replay(); testee.executeCommandLine(commandLine); @@ -368,7 +378,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETDEFAULTMAXSTORAGEQUOTA.getCommand()}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getDefaultMaxStorage()).andReturn(1024L * 1024L * 1024L); + expect(quotaProbe.getDefaultMaxStorage()).andReturn(1024L * 1024L * 1024L); control.replay(); testee.executeCommandLine(commandLine); @@ -380,7 +390,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETDEFAULTMAXMESSAGECOUNTQUOTA.getCommand(), "1054"}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.setDefaultMaxMessageCount(1054); + quotaProbe.setDefaultMaxMessageCount(1054); expectLastCall(); control.replay(); @@ -393,7 +403,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETDEFAULTMAXSTORAGEQUOTA.getCommand(), "1G"}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.setDefaultMaxStorage(1024 * 1024 * 1024); + quotaProbe.setDefaultMaxStorage(1024 * 1024 * 1024); expectLastCall(); control.replay(); @@ -407,7 +417,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot, "1000"}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.setMaxMessageCount(quotaroot, 1000); + quotaProbe.setMaxMessageCount(quotaroot, 1000); expectLastCall(); control.replay(); @@ -421,7 +431,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETMAXSTORAGEQUOTA.getCommand(), quotaroot, "5M"}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.setMaxStorage(quotaroot, 5 * 1024 * 1024); + quotaProbe.setMaxStorage(quotaroot, 5 * 1024 * 1024); expectLastCall(); control.replay(); @@ -435,7 +445,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getMaxMessageCount(quotaroot)).andReturn(Quota.UNLIMITED); + expect(quotaProbe.getMaxMessageCount(quotaroot)).andReturn(Quota.UNLIMITED); control.replay(); testee.executeCommandLine(commandLine); @@ -448,7 +458,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETMAXSTORAGEQUOTA.getCommand(), quotaroot}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getMaxStorage(quotaroot)).andReturn(Quota.UNLIMITED); + expect(quotaProbe.getMaxStorage(quotaroot)).andReturn(Quota.UNLIMITED); control.replay(); testee.executeCommandLine(commandLine); @@ -461,7 +471,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSTORAGEQUOTA.getCommand(), quotaroot}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getStorageQuota(quotaroot)).andReturn(new SerializableQuota(Quota.UNLIMITED, Quota.UNKNOWN)); + expect(quotaProbe.getStorageQuota(quotaroot)).andReturn(new SerializableQuota(Quota.UNLIMITED, Quota.UNKNOWN)); control.replay(); testee.executeCommandLine(commandLine); @@ -474,7 +484,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETMESSAGECOUNTQUOTA.getCommand(), quotaroot}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getMessageCountQuota(quotaroot)).andReturn(new SerializableQuota(Quota.UNLIMITED, Quota.UNKNOWN)); + expect(quotaProbe.getMessageCountQuota(quotaroot)).andReturn(new SerializableQuota(Quota.UNLIMITED, Quota.UNKNOWN)); control.replay(); testee.executeCommandLine(commandLine); @@ -486,7 +496,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REINDEXALL.getCommand()}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.reIndexAll(); + mailboxProbe.reIndexAll(); expectLastCall(); control.replay(); @@ -502,7 +512,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REINDEXMAILBOX.getCommand(), namespace, user, name}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.reIndexMailbox(namespace, user, name); + mailboxProbe.reIndexMailbox(namespace, user, name); expectLastCall(); control.replay(); @@ -515,7 +525,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETSIEVEQUOTA.getCommand(), "2K"}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.setSieveQuota(2048); + sieveProbe.setSieveQuota(2048); expectLastCall(); control.replay(); @@ -529,7 +539,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.SETSIEVEUSERQUOTA.getCommand(), user, "1K"}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.setSieveQuota(user, 1024); + sieveProbe.setSieveQuota(user, 1024); expectLastCall(); control.replay(); @@ -542,7 +552,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSIEVEQUOTA.getCommand()}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getSieveQuota()).andReturn(18L); + expect(sieveProbe.getSieveQuota()).andReturn(18L); expectLastCall(); control.replay(); @@ -556,7 +566,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.GETSIEVEUSERQUOTA.getCommand(), user}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - expect(serverProbe.getSieveQuota(user)).andReturn(18L); + expect(sieveProbe.getSieveQuota(user)).andReturn(18L); expectLastCall(); control.replay(); @@ -569,7 +579,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEQUOTA.getCommand()}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.removeSieveQuota(); + sieveProbe.removeSieveQuota(); expectLastCall(); control.replay(); @@ -583,7 +593,7 @@ public class ServerCmdTest { String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEUSERQUOTA.getCommand(), user}; CommandLine commandLine = ServerCmd.parseCommandLine(arguments); - serverProbe.removeSieveQuota(user); + sieveProbe.removeSieveQuota(user); expectLastCall(); control.replay();
http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java index fc2384d..3282fe5 100644 --- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java +++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java @@ -19,6 +19,7 @@ package org.apache.james; +import org.apache.james.modules.MailboxModule; import org.apache.james.modules.data.CassandraDomainListModule; import org.apache.james.modules.data.CassandraJmapModule; import org.apache.james.modules.data.CassandraRecipientRewriteTableModule; @@ -66,7 +67,8 @@ public class CassandraJamesServerMain { new ElasticSearchMailboxModule(), new QuotaModule(), new ActiveMQQueueModule(), - new ESMetricReporterModule()); + new ESMetricReporterModule(), + new MailboxModule()); public static void main(String[] args) throws Exception { http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java index 238a934..ede63e2 100644 --- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java +++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java @@ -35,8 +35,8 @@ import org.apache.http.client.utils.URIBuilder; import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.modules.TestESMetricReporterModule; -import org.apache.james.utils.GuiceServerProbe; import org.apache.james.utils.JmapGuiceProbe; +import org.apache.james.utils.DataProbeImpl; import org.elasticsearch.client.Client; import org.elasticsearch.index.query.QueryBuilders; import org.junit.After; @@ -75,7 +75,7 @@ public class ESReporterTest { public void setup() throws Exception { server = cassandraJmap.jmapServer(); server.start(); - GuiceServerProbe serverProbe = server.getProbe(GuiceServerProbe.class); + DataProbeImpl serverProbe = server.getProbe(DataProbeImpl.class); serverProbe.addDomain(DOMAIN); serverProbe.addUser(USERNAME, PASSWORD); http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java index 20e4318..b9a5bd0 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java @@ -28,7 +28,6 @@ import org.apache.james.onami.lifecycle.Stager; import org.apache.james.utils.ConfigurationsPerformer; import org.apache.james.utils.GuiceProbe; import org.apache.james.utils.GuiceProbeProvider; -import org.apache.james.utils.GuiceServerProbe; import com.google.common.collect.Iterables; import com.google.inject.Guice; @@ -75,10 +74,6 @@ public class GuiceJamesServer { } } - public GuiceServerProbe serverProbe() { - return guiceProbeProvider.getProbe(GuiceServerProbe.class); - } - public <T extends GuiceProbe> T getProbe(Class<T> probe) { return guiceProbeProvider.getProbe(probe); } http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java index cf449a2..c06b7e5 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java @@ -35,7 +35,7 @@ import org.apache.james.modules.server.DNSServiceModule; import org.apache.james.modules.server.DropWizardMetricsModule; import org.apache.james.onami.lifecycle.PreDestroyModule; import org.apache.james.utils.GuiceProbe; -import org.apache.james.utils.GuiceServerProbe; +import org.apache.james.utils.DataProbeImpl; import com.google.inject.AbstractModule; import com.google.inject.Provides; @@ -61,7 +61,7 @@ public class CommonServicesModule extends AbstractModule { bind(FileSystemImpl.class).in(Scopes.SINGLETON); bind(FileSystem.class).to(FileSystemImpl.class); - Multibinder.newSetBinder(binder(), GuiceProbe.class).addBinding().to(GuiceServerProbe.class); + Multibinder.newSetBinder(binder(), GuiceProbe.class).addBinding().to(DataProbeImpl.class); } @Provides @Singleton @Named(CONFIGURATION_PATH) http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java new file mode 100644 index 0000000..8fdfccf --- /dev/null +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java @@ -0,0 +1,130 @@ +/**************************************************************** + * 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.utils; + +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; + +import org.apache.commons.lang.NotImplementedException; +import org.apache.james.domainlist.api.DomainList; +import org.apache.james.probe.DataProbe; +import org.apache.james.rrt.api.RecipientRewriteTable; +import org.apache.james.rrt.lib.Mappings; +import org.apache.james.user.api.UsersRepository; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; + +public class DataProbeImpl implements GuiceProbe, DataProbe { + + private final DomainList domainList; + private final UsersRepository usersRepository; + private final RecipientRewriteTable recipientRewriteTable; + + @Inject + private DataProbeImpl( + DomainList domainList, + UsersRepository usersRepository, + RecipientRewriteTable recipientRewriteTable) { + this.domainList = domainList; + this.usersRepository = usersRepository; + this.recipientRewriteTable = recipientRewriteTable; + } + + @Override + public void addUser(String userName, String password) throws Exception { + usersRepository.addUser(userName, password); + } + + @Override + public void removeUser(String username) throws Exception { + usersRepository.removeUser(username); + } + + @Override + public void setPassword(String userName, String password) throws Exception { + throw new NotImplementedException(); + } + + @Override + public String[] listUsers() throws Exception { + return Iterables.toArray(ImmutableList.copyOf(usersRepository.list()), String.class); + } + + @Override + public void addDomain(String domain) throws Exception { + domainList.addDomain(domain); + } + + + @Override + public boolean containsDomain(String domain) throws Exception { + return domainList.containsDomain(domain); + } + + @Override + public String getDefaultDomain() throws Exception { + return domainList.getDefaultDomain(); + } + + @Override + public void removeDomain(String domain) throws Exception { + domainList.removeDomain(domain); + } + + @Override + public List<String> listDomains() throws Exception { + return domainList.getDomains(); + } + + @Override + public Map<String, Mappings> listMappings() throws Exception { + return recipientRewriteTable.getAllMappings(); + } + + @Override + public Mappings listUserDomainMappings(String user, String domain) throws Exception { + throw new NotImplementedException(); + } + + @Override + public void addAddressMapping(String user, String domain, String toAddress) throws Exception { + recipientRewriteTable.addAddressMapping(user, domain, toAddress); + } + + @Override + public void removeAddressMapping(String user, String domain, String fromAddress) throws Exception { + recipientRewriteTable.removeAddressMapping(user, domain, fromAddress); + } + + @Override + public void addRegexMapping(String user, String domain, String regex) throws Exception { + recipientRewriteTable.addRegexMapping(user, domain, regex); + } + + + @Override + public void removeRegexMapping(String user, String domain, String regex) throws Exception { + recipientRewriteTable.removeRegexMapping(user, domain, regex); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java deleted file mode 100644 index bcd5296..0000000 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java +++ /dev/null @@ -1,46 +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.utils; - -import java.io.InputStream; -import java.util.Collection; -import java.util.Date; - -import javax.mail.Flags; - -import org.apache.james.cli.probe.ServerProbe; -import org.apache.james.mailbox.exception.BadCredentialsException; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.ComposedMessageId; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.store.mail.model.Mailbox; - -public interface ExtendedServerProbe extends ServerProbe { - - ComposedMessageId appendMessage(String username, MailboxPath mailboxPath, InputStream message, Date internalDate, boolean isRecent, Flags flags) - throws BadCredentialsException, MailboxException; - - Mailbox getMailbox(String namespace, String user, String name); - - void addActiveSieveScript(String user, String name, String script) throws Exception; - - Collection<String> listSubscriptions(String user) throws Exception; - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java deleted file mode 100644 index ec9bcc8..0000000 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java +++ /dev/null @@ -1,367 +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.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.inject.Inject; -import javax.mail.Flags; - -import org.apache.commons.lang.NotImplementedException; -import org.apache.james.adapter.mailbox.SerializableQuota; -import org.apache.james.domainlist.api.DomainList; -import org.apache.james.mailbox.MailboxManager; -import org.apache.james.mailbox.MailboxSession; -import org.apache.james.mailbox.MessageManager; -import org.apache.james.mailbox.SubscriptionManager; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.ComposedMessageId; -import org.apache.james.mailbox.model.MailboxConstants; -import org.apache.james.mailbox.model.MailboxMetaData; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; -import org.apache.james.mailbox.store.mail.MailboxMapper; -import org.apache.james.mailbox.store.mail.MailboxMapperFactory; -import org.apache.james.mailbox.store.mail.model.Mailbox; -import org.apache.james.rrt.api.RecipientRewriteTable; -import org.apache.james.rrt.lib.Mappings; -import org.apache.james.sieverepository.api.SieveRepository; -import org.apache.james.user.api.UsersRepository; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -public class GuiceServerProbe implements ExtendedServerProbe, GuiceProbe { - - private static final Logger LOGGER = LoggerFactory.getLogger(GuiceServerProbe.class); - - private final MailboxManager mailboxManager; - private final MailboxMapperFactory mailboxMapperFactory; - private final DomainList domainList; - private final UsersRepository usersRepository; - private final RecipientRewriteTable recipientRewriteTable; - private final SieveRepository sieveRepository; - private final SubscriptionManager subscriptionManager; - - @Inject - private GuiceServerProbe(MailboxManager mailboxManager, MailboxMapperFactory mailboxMapperFactory, - DomainList domainList, UsersRepository usersRepository, SieveRepository sieveRepository, - RecipientRewriteTable recipientRewriteTable, SubscriptionManager subscriptionManager) { - this.mailboxManager = mailboxManager; - this.mailboxMapperFactory = mailboxMapperFactory; - this.domainList = domainList; - this.usersRepository = usersRepository; - this.sieveRepository = sieveRepository; - this.recipientRewriteTable = recipientRewriteTable; - this.subscriptionManager = subscriptionManager; - } - - @Override - public void close() throws IOException { - } - - @Override - public void addUser(String userName, String password) throws Exception { - usersRepository.addUser(userName, password); - } - - @Override - public void removeUser(String username) throws Exception { - usersRepository.removeUser(username); - } - - @Override - public String[] listUsers() throws Exception { - return Iterables.toArray(ImmutableList.copyOf(usersRepository.list()), String.class); - } - - @Override - public void setPassword(String userName, String password) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void addDomain(String domain) throws Exception { - domainList.addDomain(domain); - } - - @Override - public boolean containsDomain(String domain) throws Exception { - return domainList.containsDomain(domain); - } - - @Override - public String getDefaultDomain() throws Exception { - return domainList.getDefaultDomain(); - } - - @Override - public void removeDomain(String domain) throws Exception { - domainList.removeDomain(domain); - } - - @Override - public List<String> listDomains() throws Exception { - return domainList.getDomains(); - } - - @Override - public Map<String, Mappings> listMappings() throws Exception { - return recipientRewriteTable.getAllMappings(); - } - - @Override - public void addAddressMapping(String user, String domain, String toAddress) throws Exception { - recipientRewriteTable.addAddressMapping(user, domain, toAddress); - } - - @Override - public void removeAddressMapping(String user, String domain, String fromAddress) throws Exception { - recipientRewriteTable.removeAddressMapping(user, domain, fromAddress); - } - - @Override - public Mappings listUserDomainMappings(String user, String domain) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void addRegexMapping(String user, String domain, String regex) throws Exception { - recipientRewriteTable.addRegexMapping(user, domain, regex); - } - - @Override - public void removeRegexMapping(String user, String domain, String regex) throws Exception { - recipientRewriteTable.removeRegexMapping(user, domain, regex); - } - - @Override - public void copyMailbox(String srcBean, String dstBean) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void deleteUserMailboxesNames(String user) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void createMailbox(String namespace, String user, String name) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - mailboxManager.startProcessingRequest(mailboxSession); - mailboxManager.createMailbox(new MailboxPath(namespace, user, name), mailboxSession); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - @Override - public Mailbox getMailbox(String namespace, String user, String name) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - MailboxMapper mailboxMapper = mailboxMapperFactory.getMailboxMapper(mailboxSession); - return mailboxMapper.findMailboxByPath(new MailboxPath(namespace, user, name)); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - private void closeSession(MailboxSession session) { - if (session != null) { - mailboxManager.endProcessingRequest(session); - try { - mailboxManager.logout(session, true); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } - } - } - - @Override - public Collection<String> listUserMailboxes(String user) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - mailboxManager.startProcessingRequest(mailboxSession); - return searchUserMailboxes(user, mailboxSession) - .stream() - .map(MailboxMetaData::getPath) - .map(MailboxPath::getName) - .collect(Collectors.toList()); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - private List<MailboxMetaData> searchUserMailboxes(String username, MailboxSession session) throws MailboxException { - return mailboxManager.search( - new MailboxQuery(new MailboxPath(MailboxConstants.USER_NAMESPACE, username, ""), - "*", - session.getPathDelimiter()), - session); - } - - @Override - public void deleteMailbox(String namespace, String user, String name) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - mailboxManager.startProcessingRequest(mailboxSession); - mailboxManager.deleteMailbox(new MailboxPath(namespace, user, name), mailboxSession); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - @Override - public String getQuotaRoot(String namespace, String user, String name) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public SerializableQuota getMessageCountQuota(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public SerializableQuota getStorageQuota(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getMaxMessageCount(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getMaxStorage(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getDefaultMaxMessageCount() throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getDefaultMaxStorage() throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setMaxMessageCount(String quotaRoot, long maxMessageCount) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setMaxStorage(String quotaRoot, long maxSize) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setDefaultMaxMessageCount(long maxDefaultMessageCount) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setDefaultMaxStorage(long maxDefaultSize) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public ComposedMessageId appendMessage(String username, MailboxPath mailboxPath, InputStream message, Date internalDate, boolean isRecent, Flags flags) - throws MailboxException { - - MailboxSession mailboxSession = mailboxManager.createSystemSession(username, LOGGER); - MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession); - return messageManager.appendMessage(message, internalDate, mailboxSession, isRecent, flags); - } - - @Override - public void reIndexMailbox(String namespace, String user, String name) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void reIndexAll() throws Exception { - throw new NotImplementedException(); - } - - @Override - public long getSieveQuota() throws Exception { - return sieveRepository.getQuota(); - } - - @Override - public void setSieveQuota(long quota) throws Exception { - sieveRepository.setQuota(quota); - } - - @Override - public void removeSieveQuota() throws Exception { - sieveRepository.removeQuota(); - } - - @Override - public long getSieveQuota(String user) throws Exception { - return sieveRepository.getQuota(user); - } - - @Override - public void setSieveQuota(String user, long quota) throws Exception { - sieveRepository.setQuota(user, quota); - } - - @Override - public void removeSieveQuota(String user) throws Exception { - sieveRepository.removeQuota(user); - } - - @Override - public void addActiveSieveScript(String user, String name, String script) throws Exception { - sieveRepository.putScript(user, name, script); - sieveRepository.setActive(user, name); - } - - @Override - public Collection<String> listSubscriptions(String user) throws Exception { - MailboxSession mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - return subscriptionManager.subscriptions(mailboxSession); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java index fa85594..0e21021 100644 --- a/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java +++ b/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java @@ -27,6 +27,7 @@ import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import java.nio.charset.Charset; +import org.apache.james.utils.DataProbeImpl; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -63,7 +64,7 @@ public abstract class AbstractJamesServerTest { public void hostnameShouldBeUsedAsDefaultDomain() throws Exception { String expectedDefaultDomain = InetAddress.getLocalHost().getHostName(); - assertThat(server.serverProbe().getDefaultDomain()).isEqualTo(expectedDefaultDomain); + assertThat(server.getProbe(DataProbeImpl.class).getDefaultDomain()).isEqualTo(expectedDefaultDomain); } @Test @@ -72,7 +73,7 @@ public abstract class AbstractJamesServerTest { server.start(); String expectedDefaultDomain = InetAddress.getLocalHost().getHostName(); - assertThat(server.serverProbe().getDefaultDomain()).isEqualTo(expectedDefaultDomain); + assertThat(server.getProbe(DataProbeImpl.class).getDefaultDomain()).isEqualTo(expectedDefaultDomain); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJmapJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJmapJamesServerTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJmapJamesServerTest.java index de03298..051fc46 100644 --- a/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJmapJamesServerTest.java +++ b/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJmapJamesServerTest.java @@ -30,6 +30,7 @@ import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import java.nio.charset.Charset; +import org.apache.james.utils.DataProbeImpl; import org.apache.james.utils.JmapGuiceProbe; import org.junit.After; import org.junit.Before; @@ -83,7 +84,7 @@ public abstract class AbstractJmapJamesServerTest { public void hostnameShouldBeUsedAsDefaultDomain() throws Exception { String expectedDefaultDomain = InetAddress.getLocalHost().getHostName(); - assertThat(server.serverProbe().getDefaultDomain()).isEqualTo(expectedDefaultDomain); + assertThat(server.getProbe(DataProbeImpl.class).getDefaultDomain()).isEqualTo(expectedDefaultDomain); } @Test @@ -92,7 +93,7 @@ public abstract class AbstractJmapJamesServerTest { server.start(); String expectedDefaultDomain = InetAddress.getLocalHost().getHostName(); - assertThat(server.serverProbe().getDefaultDomain()).isEqualTo(expectedDefaultDomain); + assertThat(server.getProbe(DataProbeImpl.class).getDefaultDomain()).isEqualTo(expectedDefaultDomain); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java index 4cec352..4235822 100644 --- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java +++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java @@ -19,6 +19,7 @@ package org.apache.james; +import org.apache.james.modules.MailboxModule; import org.apache.james.modules.data.JPADataModule; import org.apache.james.modules.data.SieveFileRepositoryModule; import org.apache.james.modules.mailbox.JPAMailboxModule; @@ -40,7 +41,7 @@ import com.google.inject.util.Modules; public class JPAJamesServerMain { - private static final Module protocols = Modules.combine( + public static final Module protocols = Modules.combine( new IMAPServerModule(), new ProtocolHandlerModule(), new POP3ServerModule(), @@ -55,7 +56,8 @@ public class JPAJamesServerMain { new SieveFileRepositoryModule(), new QuotaModule(), new ActiveMQQueueModule(), - new RawPostDequeueDecoratorModule()); + new RawPostDequeueDecoratorModule(), + new MailboxModule()); public static void main(String[] args) throws Exception { GuiceJamesServer server = new GuiceJamesServer() http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java index 0684be1..1977930 100644 --- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java +++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java @@ -31,7 +31,7 @@ public class JPAJamesServerTest extends AbstractJamesServerTest { @Override protected GuiceJamesServer createJamesServer() { return new GuiceJamesServer() - .combineWith(JPAJamesServerMain.jpaServerModule) + .combineWith(JPAJamesServerMain.jpaServerModule, JPAJamesServerMain.protocols) .overrideWith(new TestFilesystemModule(temporaryFolder), new TestJPAConfigurationModule()); } http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/mailbox/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/mailbox/pom.xml b/server/container/guice/mailbox/pom.xml index 6b88022..f60fd9f 100644 --- a/server/container/guice/mailbox/pom.xml +++ b/server/container/guice/mailbox/pom.xml @@ -131,7 +131,26 @@ </plugins> </build> <dependencies> - + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>apache-james-mailbox-api</artifactId> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>apache-james-mailbox-store</artifactId> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>james-server-guice-configuration</artifactId> + </dependency> + <dependency> + <groupId>com.google.inject</groupId> + <artifactId>guice</artifactId> + </dependency> + <dependency> + <groupId>com.google.inject.extensions</groupId> + <artifactId>guice-multibindings</artifactId> + </dependency> </dependencies> </profile> <profile> http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java new file mode 100644 index 0000000..b342aac --- /dev/null +++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java @@ -0,0 +1,33 @@ +/**************************************************************** + * 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.modules; + +import org.apache.james.utils.GuiceProbe; + +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; + +public class MailboxModule extends AbstractModule { + + @Override + protected void configure() { + Multibinder.newSetBinder(binder(), GuiceProbe.class).addBinding().to(MailboxProbeImpl.class); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java ---------------------------------------------------------------------- diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java new file mode 100644 index 0000000..b478977 --- /dev/null +++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java @@ -0,0 +1,181 @@ +/**************************************************************** + * 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.modules; + +import java.io.InputStream; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import javax.inject.Inject; +import javax.mail.Flags; + +import org.apache.commons.lang.NotImplementedException; +import org.apache.james.mailbox.MailboxManager; +import org.apache.james.mailbox.MailboxSession; +import org.apache.james.mailbox.MessageManager; +import org.apache.james.mailbox.SubscriptionManager; +import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.model.ComposedMessageId; +import org.apache.james.mailbox.model.MailboxConstants; +import org.apache.james.mailbox.model.MailboxMetaData; +import org.apache.james.mailbox.model.MailboxPath; +import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.store.mail.MailboxMapper; +import org.apache.james.mailbox.store.mail.MailboxMapperFactory; +import org.apache.james.mailbox.store.mail.model.Mailbox; +import org.apache.james.mailbox.store.probe.MailboxProbe; +import org.apache.james.utils.GuiceProbe; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Throwables; + +public class MailboxProbeImpl implements GuiceProbe, MailboxProbe { + + private static final Logger LOGGER = LoggerFactory.getLogger(MailboxProbeImpl.class); + private final MailboxManager mailboxManager; + private final MailboxMapperFactory mailboxMapperFactory; + private final SubscriptionManager subscriptionManager; + + @Inject + private MailboxProbeImpl(MailboxManager mailboxManager, MailboxMapperFactory mailboxMapperFactory, SubscriptionManager subscriptionManager) { + this.mailboxManager = mailboxManager; + this.mailboxMapperFactory = mailboxMapperFactory; + this.subscriptionManager = subscriptionManager; + } + + @Override + public void createMailbox(String namespace, String user, String name) { + MailboxSession mailboxSession = null; + try { + mailboxSession = mailboxManager.createSystemSession(user, LOGGER); + mailboxManager.startProcessingRequest(mailboxSession); + mailboxManager.createMailbox(new MailboxPath(namespace, user, name), mailboxSession); + } catch (MailboxException e) { + throw Throwables.propagate(e); + } finally { + closeSession(mailboxSession); + } + } + + + @Override + public Mailbox getMailbox(String namespace, String user, String name) { + MailboxSession mailboxSession = null; + try { + mailboxSession = mailboxManager.createSystemSession(user, LOGGER); + MailboxMapper mailboxMapper = mailboxMapperFactory.getMailboxMapper(mailboxSession); + return mailboxMapper.findMailboxByPath(new MailboxPath(namespace, user, name)); + } catch (MailboxException e) { + throw Throwables.propagate(e); + } finally { + closeSession(mailboxSession); + } + } + + private void closeSession(MailboxSession session) { + if (session != null) { + mailboxManager.endProcessingRequest(session); + try { + mailboxManager.logout(session, true); + } catch (MailboxException e) { + throw Throwables.propagate(e); + } + } + } + + @Override + public Collection<String> listUserMailboxes(String user) { + MailboxSession mailboxSession = null; + try { + mailboxSession = mailboxManager.createSystemSession(user, LOGGER); + mailboxManager.startProcessingRequest(mailboxSession); + return searchUserMailboxes(user, mailboxSession) + .stream() + .map(MailboxMetaData::getPath) + .map(MailboxPath::getName) + .collect(Collectors.toList()); + } catch (MailboxException e) { + throw Throwables.propagate(e); + } finally { + closeSession(mailboxSession); + } + } + + private List<MailboxMetaData> searchUserMailboxes(String username, MailboxSession session) throws MailboxException { + return mailboxManager.search( + new MailboxQuery(new MailboxPath(MailboxConstants.USER_NAMESPACE, username, ""), + "*", + session.getPathDelimiter()), + session); + } + + + @Override + public void deleteMailbox(String namespace, String user, String name) { + MailboxSession mailboxSession = null; + try { + mailboxSession = mailboxManager.createSystemSession(user, LOGGER); + mailboxManager.startProcessingRequest(mailboxSession); + mailboxManager.deleteMailbox(new MailboxPath(namespace, user, name), mailboxSession); + } catch (MailboxException e) { + throw Throwables.propagate(e); + } finally { + closeSession(mailboxSession); + } + } + + @Override + public ComposedMessageId appendMessage(String username, MailboxPath mailboxPath, InputStream message, Date internalDate, boolean isRecent, Flags flags) + throws MailboxException { + + MailboxSession mailboxSession = mailboxManager.createSystemSession(username, LOGGER); + MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession); + return messageManager.appendMessage(message, internalDate, mailboxSession, isRecent, flags); + } + + @Override + public void copyMailbox(String srcBean, String dstBean) throws Exception { + throw new NotImplementedException(); + } + + @Override + public void deleteUserMailboxesNames(String user) throws Exception { + throw new NotImplementedException(); + } + + @Override + public void reIndexMailbox(String namespace, String user, String name) throws Exception { + throw new NotImplementedException(); + } + + @Override + public void reIndexAll() throws Exception { + throw new NotImplementedException(); + } + + @Override + public Collection<String> listSubscriptions(String user) throws Exception { + MailboxSession mailboxSession = mailboxManager.createSystemSession(user, LOGGER); + return subscriptionManager.subscriptions(mailboxSession); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java ---------------------------------------------------------------------- diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java index 084d83e..ab47e0f 100644 --- a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java +++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java @@ -19,14 +19,21 @@ package org.apache.james; +import org.apache.james.modules.MailboxModule; import org.apache.james.modules.data.MemoryDataJmapModule; import org.apache.james.modules.data.MemoryDataModule; import org.apache.james.modules.mailbox.MemoryMailboxModule; import org.apache.james.modules.protocols.IMAPServerModule; import org.apache.james.modules.protocols.JMAPServerModule; +import org.apache.james.modules.protocols.LMTPServerModule; +import org.apache.james.modules.protocols.ManageSieveServerModule; +import org.apache.james.modules.protocols.POP3ServerModule; +import org.apache.james.modules.protocols.ProtocolHandlerModule; +import org.apache.james.modules.protocols.SMTPServerModule; import org.apache.james.modules.server.JMXServerModule; import org.apache.james.modules.server.MemoryMailQueueModule; import org.apache.james.modules.server.QuotaModule; +import org.apache.james.modules.server.WebAdminServerModule; import com.google.inject.Module; import com.google.inject.util.Modules; @@ -34,13 +41,20 @@ import com.google.inject.util.Modules; public class MemoryJamesServerMain { public static final Module inMemoryServerModule = Modules.combine( - new JMAPServerModule(), - new IMAPServerModule(), - new MemoryDataModule(), - new MemoryDataJmapModule(), - new MemoryMailboxModule(), - new QuotaModule(), - new MemoryMailQueueModule()); + new JMAPServerModule(), + new IMAPServerModule(), + new ProtocolHandlerModule(), + new POP3ServerModule(), + new SMTPServerModule(), + new LMTPServerModule(), + new ManageSieveServerModule(), + new WebAdminServerModule(), + new MemoryDataModule(), + new MemoryDataJmapModule(), + new MemoryMailboxModule(), + new QuotaModule(), + new MemoryMailQueueModule(), + new MailboxModule()); public static void main(String[] args) throws Exception { new GuiceJamesServer() http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/protocols/managedsieve/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/protocols/managedsieve/pom.xml b/server/container/guice/protocols/managedsieve/pom.xml index 6f97529..ee35b1d 100644 --- a/server/container/guice/protocols/managedsieve/pom.xml +++ b/server/container/guice/protocols/managedsieve/pom.xml @@ -133,6 +133,10 @@ <dependencies> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>apache-james-mailbox-store</artifactId> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>james-server-guice-configuration</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java index 539dba6..45bffdf 100644 --- a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java +++ b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java @@ -26,6 +26,7 @@ import org.apache.james.managesieve.core.CoreProcessor; import org.apache.james.managesieveserver.netty.ManageSieveServerFactory; import org.apache.james.utils.ConfigurationPerformer; import org.apache.james.utils.ConfigurationProvider; +import org.apache.james.utils.GuiceProbe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,6 +45,7 @@ public class ManageSieveServerModule extends AbstractModule { protected void configure() { bind(CoreCommands.class).to(CoreProcessor.class); Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(ManageSieveModuleConfigurationPerformer.class); + Multibinder.newSetBinder(binder(), GuiceProbe.class).addBinding().to(SieveProbeImpl.class); } @Singleton http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java ---------------------------------------------------------------------- diff --git a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java new file mode 100644 index 0000000..07c18bb --- /dev/null +++ b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/SieveProbeImpl.java @@ -0,0 +1,71 @@ +/**************************************************************** + * 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.modules.protocols; + +import javax.inject.Inject; + +import org.apache.james.mailbox.store.probe.SieveProbe; +import org.apache.james.sieverepository.api.SieveRepository; +import org.apache.james.utils.GuiceProbe; + +public class SieveProbeImpl implements GuiceProbe, SieveProbe { + + private final SieveRepository sieveRepository; + + @Inject + private SieveProbeImpl(SieveRepository sieveRepository) { + this.sieveRepository = sieveRepository; + } + + @Override + public long getSieveQuota() throws Exception { + return sieveRepository.getQuota(); + } + + @Override + public void setSieveQuota(long quota) throws Exception { + sieveRepository.setQuota(quota); + } + + @Override + public void removeSieveQuota() throws Exception { + sieveRepository.removeQuota(); + } + + @Override + public long getSieveQuota(String user) throws Exception { + return sieveRepository.getQuota(user); + } + + @Override + public void setSieveQuota(String user, long quota) throws Exception { + sieveRepository.setQuota(user, quota); + } + + @Override + public void removeSieveQuota(String user) throws Exception { + sieveRepository.removeQuota(user); + } + + @Override + public void addActiveSieveScript(String user, String name, String script) throws Exception { + sieveRepository.putScript(user, name, script); + sieveRepository.setActive(user, name); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java ---------------------------------------------------------------------- diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java index 767b339..dd779a3 100644 --- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java +++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagement.java @@ -24,6 +24,7 @@ import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.quota.MaxQuotaManager; import org.apache.james.mailbox.quota.QuotaManager; import org.apache.james.mailbox.quota.QuotaRootResolver; +import org.apache.james.mailbox.store.mail.model.SerializableQuota; public class QuotaManagement implements QuotaManagementMBean { http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java ---------------------------------------------------------------------- diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java index 07a8e40..95cea22 100644 --- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java +++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/QuotaManagementMBean.java @@ -20,6 +20,7 @@ package org.apache.james.adapter.mailbox; import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.store.mail.model.SerializableQuota; public interface QuotaManagementMBean { String getQuotaRoot(String namespace, String user, String name) throws MailboxException; http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/SerializableQuota.java ---------------------------------------------------------------------- diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/SerializableQuota.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/SerializableQuota.java deleted file mode 100644 index 17dd729..0000000 --- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/SerializableQuota.java +++ /dev/null @@ -1,49 +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.adapter.mailbox; - -import org.apache.james.mailbox.model.Quota; - -import java.io.Serializable; - -public class SerializableQuota implements Serializable { - - private final long max; - private final long used; - - public SerializableQuota(long max, long used) { - this.max = max; - this.used = used; - } - - public SerializableQuota(Quota quota) { - this.max = quota.getMax(); - this.used = quota.getUsed(); - } - - public long getMax() { - return max; - } - - public long getUsed() { - return used; - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java ---------------------------------------------------------------------- diff --git a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java new file mode 100644 index 0000000..6f45e61 --- /dev/null +++ b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java @@ -0,0 +1,59 @@ +/**************************************************************** + * 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.probe; + +import java.util.List; +import java.util.Map; + +import org.apache.james.rrt.lib.Mappings; + +public interface DataProbe { + + void addUser(String userName, String password) throws Exception; + + void removeUser(String username) throws Exception; + + void setPassword(String userName, String password) throws Exception; + + String[] listUsers() throws Exception; + + void addDomain(String domain) throws Exception; + + boolean containsDomain(String domain) throws Exception; + + String getDefaultDomain() throws Exception; + + void removeDomain(String domain) throws Exception; + + List<String> listDomains() throws Exception; + + Map<String, Mappings> listMappings() throws Exception; + + Mappings listUserDomainMappings(String user, String domain) throws Exception; + + void addAddressMapping(String user, String domain, String toAddress) throws Exception; + + void removeAddressMapping(String user, String domain, String fromAddress) throws Exception; + + void addRegexMapping(String user, String domain, String regex) throws Exception; + + void removeRegexMapping(String user, String domain, String regex) throws Exception; + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java index 9a64683..989beb5 100644 --- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java +++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java @@ -23,7 +23,10 @@ import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailets.configuration.CommonProcessors; import org.apache.james.mailets.configuration.MailetContainer; import org.apache.james.mailets.utils.SMTPMessageSender; +import org.apache.james.modules.MailboxProbeImpl; +import org.apache.james.probe.DataProbe; import org.apache.james.utils.IMAPMessageReader; +import org.apache.james.utils.DataProbeImpl; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -79,12 +82,13 @@ public class CommonMailetConfigurationTest { @Test public void simpleMailShouldBeSent() throws Exception { - jamesServer.getServerProbe().addDomain(DEFAULT_DOMAIN); + DataProbe dataProbe = jamesServer.getProbe(DataProbeImpl.class); + dataProbe.addDomain(DEFAULT_DOMAIN); String from = "user@" + DEFAULT_DOMAIN; - jamesServer.getServerProbe().addUser(from, PASSWORD); + dataProbe.addUser(from, PASSWORD); String recipient = "user2@" + DEFAULT_DOMAIN; - jamesServer.getServerProbe().addUser(recipient, PASSWORD); - jamesServer.getServerProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipient, "INBOX"); + dataProbe.addUser(recipient, PASSWORD); + jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, recipient, "INBOX"); try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, DEFAULT_DOMAIN); IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) { http://git-wip-us.apache.org/repos/asf/james-project/blob/793dae76/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java index 23ed827..3b0d101 100644 --- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java +++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java @@ -23,8 +23,10 @@ import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailets.configuration.CommonProcessors; import org.apache.james.mailets.configuration.MailetContainer; import org.apache.james.mailets.utils.SMTPMessageSender; -import org.apache.james.utils.GuiceServerProbe; +import org.apache.james.modules.MailboxProbeImpl; +import org.apache.james.probe.DataProbe; import org.apache.james.utils.IMAPMessageReader; +import org.apache.james.utils.DataProbeImpl; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -54,7 +56,7 @@ public class RecipientRewriteTableIntegrationTest { private TemporaryJamesServer jamesServer; private ConditionFactory calmlyAwait; - private GuiceServerProbe serverProbe; + private DataProbe dataProbe; @Before @@ -75,9 +77,9 @@ public class RecipientRewriteTableIntegrationTest { jamesServer = new TemporaryJamesServer(temporaryFolder, mailetContainer); Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS; calmlyAwait = Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await(); - serverProbe = jamesServer.getServerProbe(); + dataProbe = jamesServer.getProbe(DataProbeImpl.class); - serverProbe.addDomain(JAMES_APACHE_ORG); + dataProbe.addDomain(JAMES_APACHE_ORG); } @After @@ -87,13 +89,13 @@ public class RecipientRewriteTableIntegrationTest { @Test public void rrtServiceShouldDeliverEmailToMappingRecipients() throws Exception { - serverProbe.addUser(FROM, PASSWORD); + dataProbe.addUser(FROM, PASSWORD); createUserInbox(ANY_AT_JAMES); createUserInbox(OTHER_AT_JAMES); - serverProbe.addAddressMapping("touser", JAMES_APACHE_ORG, ANY_AT_JAMES); - serverProbe.addAddressMapping("touser", JAMES_APACHE_ORG, OTHER_AT_JAMES); + dataProbe.addAddressMapping("touser", JAMES_APACHE_ORG, ANY_AT_JAMES); + dataProbe.addAddressMapping("touser", JAMES_APACHE_ORG, OTHER_AT_JAMES); try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, JAMES_APACHE_ORG); IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) { @@ -106,14 +108,14 @@ public class RecipientRewriteTableIntegrationTest { @Test public void rrtServiceShouldNotDeliverEmailToRecipientWhenHaveMappingRecipients() throws Exception { - serverProbe.addUser(FROM, PASSWORD); + dataProbe.addUser(FROM, PASSWORD); createUserInbox(RECIPIENT); createUserInbox(ANY_AT_JAMES); createUserInbox(OTHER_AT_JAMES); - serverProbe.addAddressMapping("touser", JAMES_APACHE_ORG, ANY_AT_JAMES); - serverProbe.addAddressMapping("touser", JAMES_APACHE_ORG, OTHER_AT_JAMES); + dataProbe.addAddressMapping("touser", JAMES_APACHE_ORG, ANY_AT_JAMES); + dataProbe.addAddressMapping("touser", JAMES_APACHE_ORG, OTHER_AT_JAMES); try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, JAMES_APACHE_ORG); IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) { @@ -127,15 +129,15 @@ public class RecipientRewriteTableIntegrationTest { @Test public void rrtServiceShouldDeliverEmailToRecipientOnLocalWhenMappingContainsNonDomain() throws Exception { String nonDomainUser = "nondomain"; - String localUser = nonDomainUser + "@" + serverProbe.getDefaultDomain(); + String localUser = nonDomainUser + "@" + dataProbe.getDefaultDomain(); - serverProbe.addUser(FROM, PASSWORD); + dataProbe.addUser(FROM, PASSWORD); createUserInbox(localUser); createUserInbox(OTHER_AT_JAMES); - serverProbe.addAddressMapping("touser", JAMES_APACHE_ORG, nonDomainUser); - serverProbe.addAddressMapping("touser", JAMES_APACHE_ORG, OTHER_AT_JAMES); + dataProbe.addAddressMapping("touser", JAMES_APACHE_ORG, nonDomainUser); + dataProbe.addAddressMapping("touser", JAMES_APACHE_ORG, OTHER_AT_JAMES); try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, JAMES_APACHE_ORG); IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) { @@ -148,8 +150,8 @@ public class RecipientRewriteTableIntegrationTest { } private void createUserInbox(String username) throws Exception { - serverProbe.addUser(username, PASSWORD); - serverProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); + dataProbe.addUser(username, PASSWORD); + jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org