You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2016/03/23 20:46:44 UTC
[01/24] james-project git commit: JAMES-1693 MemoryUsersRepository is
supposed to support virtualHosting
Repository: james-project
Updated Branches:
refs/heads/master 70f69255d -> f89a2abd2
JAMES-1693 MemoryUsersRepository is supposed to support virtualHosting
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3413ec51
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3413ec51
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3413ec51
Branch: refs/heads/master
Commit: 3413ec5125e177a24b8849c1eff866ee4ac351ef
Parents: 940a0ec
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Feb 29 15:55:58 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:03:55 2016 +0100
----------------------------------------------------------------------
.../mpt/managesieve/file/host/FileHostSystem.java | 2 +-
.../james/user/memory/MemoryUsersRepository.java | 17 ++++++++++++++++-
.../user/memory/MemoryUsersRepositoryTest.java | 2 +-
3 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/3413ec51/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java b/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java
index 51a4641..2ed61f3 100644
--- a/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java
+++ b/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/host/FileHostSystem.java
@@ -39,7 +39,7 @@ public class FileHostSystem extends JamesManageSieveHostSystem {
}
public FileHostSystem() throws Exception {
- super(new MemoryUsersRepository(), createSieveRepository());
+ super(MemoryUsersRepository.withoutVirtualHosting(), createSieveRepository());
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/3413ec51/server/data/data-memory/src/main/java/org/apache/james/user/memory/MemoryUsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/user/memory/MemoryUsersRepository.java b/server/data/data-memory/src/main/java/org/apache/james/user/memory/MemoryUsersRepository.java
index 229c563..02d48b8 100644
--- a/server/data/data-memory/src/main/java/org/apache/james/user/memory/MemoryUsersRepository.java
+++ b/server/data/data-memory/src/main/java/org/apache/james/user/memory/MemoryUsersRepository.java
@@ -34,12 +34,27 @@ import java.util.Map;
public class MemoryUsersRepository extends AbstractUsersRepository {
+ public static MemoryUsersRepository withVirtualHosting() {
+ return new MemoryUsersRepository(true);
+ }
+
+ public static MemoryUsersRepository withoutVirtualHosting() {
+ return new MemoryUsersRepository(false);
+ }
+
private final Map<String, User> userByName;
+ private final boolean supportVirtualHosting;
private String algo;
- public MemoryUsersRepository() {
+ private MemoryUsersRepository(boolean supportVirtualHosting) {
this.userByName = new HashMap<String, User>();
this.algo = "MD5";
+ this.supportVirtualHosting = supportVirtualHosting;
+ }
+
+ @Override
+ public boolean supportVirtualHosting() {
+ return supportVirtualHosting;
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/3413ec51/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java b/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
index 8427736..4057eb7 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/user/memory/MemoryUsersRepositoryTest.java
@@ -26,6 +26,6 @@ public class MemoryUsersRepositoryTest extends AbstractUsersRepositoryTest {
@Override
protected AbstractUsersRepository getUsersRepository() throws Exception {
- return new MemoryUsersRepository();
+ return MemoryUsersRepository.withVirtualHosting();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[14/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
new file mode 100644
index 0000000..22d8e59
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
@@ -0,0 +1,75 @@
+/****************************************************************
+ * 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 org.apache.james.jmap.JMAPModule;
+import org.apache.james.jmap.JMAPServer;
+import org.apache.james.jmap.crypto.JamesSignatureHandler;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.utils.ConfigurationPerformer;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+import java.security.Security;
+
+public class JMAPServerModule<Id extends MailboxId> extends AbstractModule {
+
+ private final TypeLiteral<Id> type;
+
+ public JMAPServerModule(TypeLiteral<Id> type) {
+ this.type = type;
+ }
+
+ @Override
+ protected void configure() {
+ install(new JMAPModule<Id>(type));
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(JMAPModuleConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class JMAPModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final JMAPServer server;
+ private final JamesSignatureHandler signatureHandler;
+
+ @Inject
+ public JMAPModuleConfigurationPerformer(JMAPServer server, JamesSignatureHandler signatureHandler) {
+ this.server = server;
+ this.signatureHandler = signatureHandler;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ signatureHandler.init();
+ server.configure(null);
+ registerPEMWithSecurityProvider();
+ }
+
+ private void registerPEMWithSecurityProvider() {
+ Security.addProvider(new BouncyCastleProvider());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
new file mode 100644
index 0000000..a7b7c83
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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 org.apache.james.lmtpserver.netty.LMTPServerFactory;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class LMTPServerModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(LMTPServerModule.class);
+
+ @Override
+ protected void configure() {
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(LMTPModuleConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class LMTPModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final LMTPServerFactory lmtpServerFactory;
+
+ @Inject
+ public LMTPModuleConfigurationPerformer(ConfigurationProvider configurationProvider, LMTPServerFactory lmtpServerFactory) {
+ this.configurationProvider = configurationProvider;
+ this.lmtpServerFactory = lmtpServerFactory;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ lmtpServerFactory.setLog(LOGGER);
+ lmtpServerFactory.configure(configurationProvider.getConfiguration("lmtpserver"));
+ lmtpServerFactory.init();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
new file mode 100644
index 0000000..b03eb70
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
@@ -0,0 +1,63 @@
+/****************************************************************
+ * 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 org.apache.james.managesieve.api.commands.CoreCommands;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class ManageSieveServerModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveServerModule.class);
+
+ @Override
+ protected void configure() {
+ bind(CoreCommands.class).to(CoreProcessor.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(ManageSieveModuleConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class ManageSieveModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final ManageSieveServerFactory manageSieveServerFactory;
+
+ @Inject
+ public ManageSieveModuleConfigurationPerformer(ConfigurationProvider configurationProvider, ManageSieveServerFactory manageSieveServerFactory) {
+ this.configurationProvider = configurationProvider;
+ this.manageSieveServerFactory = manageSieveServerFactory;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ manageSieveServerFactory.setLog(LOGGER);
+ manageSieveServerFactory.configure(configurationProvider.getConfiguration("managesieveserver"));
+ manageSieveServerFactory.init();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
new file mode 100644
index 0000000..2bbe6a8
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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 org.apache.james.pop3server.netty.POP3ServerFactory;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class POP3ServerModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(POP3ServerModule.class);
+
+ @Override
+ protected void configure() {
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(POP3ModuleConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class POP3ModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final POP3ServerFactory pop3ServerFactory;
+
+ @Inject
+ public POP3ModuleConfigurationPerformer(ConfigurationProvider configurationProvider, POP3ServerFactory pop3ServerFactory) {
+ this.configurationProvider = configurationProvider;
+ this.pop3ServerFactory = pop3ServerFactory;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ pop3ServerFactory.setLog(LOGGER);
+ pop3ServerFactory.configure(configurationProvider.getConfiguration("pop3server"));
+ pop3ServerFactory.init();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
new file mode 100644
index 0000000..10d20d2
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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 org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
+import org.apache.james.utils.GuiceProtocolHandlerLoader;
+
+import com.google.inject.AbstractModule;
+
+public class ProtocolHandlerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(ProtocolHandlerLoader.class).to(GuiceProtocolHandlerLoader.class);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
new file mode 100644
index 0000000..6275822
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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 org.apache.james.smtpserver.SendMailHandler;
+import org.apache.james.smtpserver.netty.SMTPServerFactory;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class SMTPServerModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SMTPServerModule.class);
+
+ @Override
+ protected void configure() {
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(SMTPModuleConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class SMTPModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final SMTPServerFactory smtpServerFactory;
+ private final SendMailHandler sendMailHandler;
+
+ @Inject
+ public SMTPModuleConfigurationPerformer(ConfigurationProvider configurationProvider,
+ SMTPServerFactory smtpServerFactory,
+ SendMailHandler sendMailHandler) {
+ this.configurationProvider = configurationProvider;
+ this.smtpServerFactory = smtpServerFactory;
+ this.sendMailHandler = sendMailHandler;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ smtpServerFactory.setLog(LOGGER);
+ smtpServerFactory.configure(configurationProvider.getConfiguration("smtpserver"));
+ smtpServerFactory.init();
+ sendMailHandler.init(null);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
new file mode 100644
index 0000000..336dc55
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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.server;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.james.jmap.send.PostDequeueDecoratorFactory;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.queue.activemq.ActiveMQMailQueueFactory;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.james.utils.GuiceGenericType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+public class ActiveMQQueueModule<Id extends MailboxId> extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQQueueModule.class);
+ private final GuiceGenericType<Id> guiceGenericType;
+
+ public ActiveMQQueueModule(TypeLiteral<Id> type) {
+ guiceGenericType = new GuiceGenericType<>(type);
+ }
+
+ @Override
+ protected void configure() {
+ bind(MailQueueItemDecoratorFactory.class)
+ .to(guiceGenericType.newGenericType(PostDequeueDecoratorFactory.class))
+ .in(Singleton.class);
+ }
+
+ @Provides
+ @Singleton
+ ConnectionFactory provideEmbededActiveMQ(EmbeddedActiveMQ embeddedActiveMQ) {
+ return embeddedActiveMQ.getConnectionFactory();
+ }
+
+ @Provides
+ @Singleton
+ public MailQueueFactory createActiveMailQueueFactory(ActiveMQMailQueueFactory activeMQMailQueueFactory) {
+ activeMQMailQueueFactory.setUseJMX(true);
+ activeMQMailQueueFactory.setLog(LOGGER);
+ activeMQMailQueueFactory.init();
+ return activeMQMailQueueFactory;
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
new file mode 100644
index 0000000..a608906
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
@@ -0,0 +1,111 @@
+/****************************************************************
+ * 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.server;
+
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.mailetcontainer.api.MailProcessor;
+import org.apache.james.mailetcontainer.api.MailetLoader;
+import org.apache.james.mailetcontainer.api.MatcherLoader;
+import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean;
+import org.apache.james.mailetcontainer.impl.JamesMailSpooler;
+import org.apache.james.mailetcontainer.impl.JamesMailetContext;
+import org.apache.james.mailetcontainer.impl.camel.CamelCompositeProcessor;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.apache.james.utils.GuiceMailetLoader;
+import org.apache.james.utils.GuiceMatcherLoader;
+import org.apache.mailet.MailetContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class CamelMailetContainerModule extends AbstractModule {
+
+ private static final Logger CAMEL_LOGGER = LoggerFactory.getLogger(CamelCompositeProcessor.class);
+ private static final Logger SPOOLER_LOGGER = LoggerFactory.getLogger(JamesMailSpooler.class);
+ private static final Logger MAILET_LOGGER = LoggerFactory.getLogger(JamesMailetContext.class);
+
+ @Override
+ protected void configure() {
+ bind(MailProcessor.class).to(CamelCompositeProcessor.class).in(Singleton.class);
+ bind(MailSpoolerMBean.class).to(JamesMailSpooler.class);
+ bind(MailetLoader.class).to(GuiceMailetLoader.class);
+ bind(MatcherLoader.class).to(GuiceMatcherLoader.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MailetModuleConfigurationPerformer.class);
+ }
+
+ @Provides
+ @Singleton
+ private MailetContext provideMailetContext(MailProcessor processorList,
+ DNSService dns,
+ UsersRepository localusers,
+ DomainList domains) {
+ JamesMailetContext jamesMailetContext = new JamesMailetContext();
+ jamesMailetContext.setLog(MAILET_LOGGER);
+ jamesMailetContext.setDNSService(dns);
+ jamesMailetContext.setMailProcessor(processorList);
+ jamesMailetContext.setUsersRepository(localusers);
+ jamesMailetContext.setDomainList(domains);
+ return jamesMailetContext;
+ }
+
+ @Singleton
+ public static class MailetModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final CamelCompositeProcessor camelCompositeProcessor;
+ private final JamesMailSpooler jamesMailSpooler;
+ private final JamesMailetContext mailetContext;
+
+ @Inject
+ public MailetModuleConfigurationPerformer(ConfigurationProvider configurationProvider,
+ CamelCompositeProcessor camelCompositeProcessor,
+ JamesMailSpooler jamesMailSpooler,
+ JamesMailetContext mailetContext) {
+ this.configurationProvider = configurationProvider;
+ this.camelCompositeProcessor = camelCompositeProcessor;
+ this.jamesMailSpooler = jamesMailSpooler;
+ this.mailetContext = mailetContext;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ camelCompositeProcessor.setLog(CAMEL_LOGGER);
+ camelCompositeProcessor.setCamelContext(new DefaultCamelContext());
+ camelCompositeProcessor.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("processors"));
+ camelCompositeProcessor.init();
+ jamesMailSpooler.setLog(SPOOLER_LOGGER);
+ jamesMailSpooler.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("spooler"));
+ jamesMailSpooler.init();
+ mailetContext.setLog(MAILET_LOGGER);
+ mailetContext.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("context"));
+ mailetContext.setMailProcessor(camelCompositeProcessor);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
new file mode 100644
index 0000000..f9d3cff
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.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.server;
+
+import org.apache.james.utils.ConfigurationProvider;
+import org.apache.james.utils.FileConfigurationProvider;
+
+import com.google.inject.AbstractModule;
+
+public class ConfigurationProviderModule extends AbstractModule {
+
+ @Override
+ public void configure() {
+ bind(ConfigurationProvider.class).to(FileConfigurationProvider.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
new file mode 100644
index 0000000..5d3b49f
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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.server;
+
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.dnsservice.dnsjava.DNSJavaService;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class DNSServiceModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DNSServiceModule.class);
+
+ @Override
+ protected void configure() {
+ bind(DNSService.class).to(DNSJavaService.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(DNSServiceConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class DNSServiceConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final DNSJavaService dnsService;
+
+ @Inject
+ public DNSServiceConfigurationPerformer(ConfigurationProvider configurationProvider,
+ DNSJavaService dnsService) {
+ this.configurationProvider = configurationProvider;
+ this.dnsService = dnsService;
+ }
+
+ public void initModule() throws Exception {
+ dnsService.setLog(LOGGER);
+ dnsService.configure(configurationProvider.getConfiguration("dnsservice"));
+ dnsService.init();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
new file mode 100644
index 0000000..3c34f74
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
@@ -0,0 +1,107 @@
+/****************************************************************
+ * 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.server;
+
+import javax.annotation.PreDestroy;
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.ActiveMQPrefetchPolicy;
+import org.apache.activemq.blob.BlobTransferPolicy;
+import org.apache.activemq.broker.BrokerPlugin;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.jmx.ManagementContext;
+import org.apache.activemq.plugin.StatisticsBrokerPlugin;
+import org.apache.activemq.store.amq.AMQPersistenceAdapter;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.queue.activemq.FileSystemBlobTransferPolicy;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class EmbeddedActiveMQ {
+
+ private final ActiveMQConnectionFactory activeMQConnectionFactory;
+ private BrokerService brokerService;
+
+ @Inject private EmbeddedActiveMQ(FileSystem fileSystem) {
+ try {
+ launchEmbeddedBroker();
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ activeMQConnectionFactory = createActiveMQConnectionFactory(createBlobTransferPolicy(fileSystem));
+ }
+
+ public ConnectionFactory getConnectionFactory() {
+ return activeMQConnectionFactory;
+ }
+
+ @PreDestroy
+ public void stop() throws Exception {
+ brokerService.stop();
+ }
+
+ private ActiveMQConnectionFactory createActiveMQConnectionFactory(BlobTransferPolicy blobTransferPolicy) {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://james?create=false");
+ connectionFactory.setBlobTransferPolicy(blobTransferPolicy);
+ connectionFactory.setPrefetchPolicy(createActiveMQPrefetchPolicy());
+ return connectionFactory;
+ }
+
+ private ActiveMQPrefetchPolicy createActiveMQPrefetchPolicy() {
+ ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
+ prefetchPolicy.setQueuePrefetch(0);
+ prefetchPolicy.setTopicPrefetch(0);
+ return prefetchPolicy;
+ }
+
+ private BlobTransferPolicy createBlobTransferPolicy(FileSystem fileSystem) {
+ FileSystemBlobTransferPolicy blobTransferPolicy = new FileSystemBlobTransferPolicy();
+ blobTransferPolicy.setDefaultUploadUrl("file://var/store/activemq/blob-transfer");
+ blobTransferPolicy.setFileSystem(fileSystem);
+ return blobTransferPolicy;
+ }
+
+ private void launchEmbeddedBroker() throws Exception {
+ brokerService = new BrokerService();
+ brokerService.setBrokerName("james");
+ brokerService.setUseJmx(false);
+ brokerService.setPersistent(true);
+ brokerService.setDataDirectory("filesystem=file://var/store/activemq/brokers");
+ brokerService.setUseShutdownHook(false);
+ brokerService.setSchedulerSupport(false);
+ brokerService.setBrokerId("broker");
+ String[] uris = {"tcp://localhost:0"};
+ brokerService.setTransportConnectorURIs(uris);
+ ManagementContext managementContext = new ManagementContext();
+ managementContext.setCreateConnector(false);
+ brokerService.setManagementContext(managementContext);
+ brokerService.setPersistenceAdapter(new AMQPersistenceAdapter());
+ BrokerPlugin[] brokerPlugins = {new StatisticsBrokerPlugin()};
+ brokerService.setPlugins(brokerPlugins);
+ String[] transportConnectorsURIs = {"tcp://localhost:0"};
+ brokerService.setTransportConnectorURIs(transportConnectorsURIs);
+ brokerService.start();
+ System.out.println("Started : " + brokerService.isStarted());
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java
new file mode 100644
index 0000000..4b4e63d
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java
@@ -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.modules.server;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.rmi.registry.LocateRegistry;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.util.RestrictingRMISocketFactory;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableMap;
+
+public class JMXServer {
+
+ private final FileSystem fileSystem;
+ private final Set<String> registeredKeys;
+ private final Object lock;
+ private JMXConnectorServer jmxConnectorServer;
+ private boolean isStarted;
+
+ @Inject
+ public JMXServer(FileSystem fileSystem) {
+ this.fileSystem = fileSystem;
+ isStarted = false;
+ registeredKeys = new HashSet<>();
+ lock = new Object();
+ }
+
+ public void start() {
+ synchronized (lock) {
+ if (isStarted) {
+ return;
+ }
+ isStarted = true;
+ doStart();
+ }
+ }
+
+ @PreDestroy
+ public void stop() {
+ synchronized (lock) {
+ if (!isStarted) {
+ return;
+ }
+ isStarted = false;
+ doStop();
+ }
+ }
+
+ public void register(String key, Object remote) throws Exception {
+ ManagementFactory.getPlatformMBeanServer().registerMBean(remote, new ObjectName(key));
+ synchronized (lock) {
+ registeredKeys.add(key);
+ }
+ }
+
+ private void doStart() {
+ try {
+ PropertiesConfiguration configuration = new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "jmx.properties"));
+ String address = configuration.getString("jmx.address");
+ int port = configuration.getInt("jmx.port");
+ String serviceURL = "service:jmx:rmi://" + address + "/jndi/rmi://" + address+ ":" + port +"/jmxrmi";
+ RestrictingRMISocketFactory restrictingRMISocketFactory = new RestrictingRMISocketFactory(address);
+ LocateRegistry.createRegistry(port, restrictingRMISocketFactory, restrictingRMISocketFactory);
+
+ Map<String, ?> environment = ImmutableMap.of();
+ jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL(serviceURL),
+ environment,
+ ManagementFactory.getPlatformMBeanServer());
+
+ jmxConnectorServer.start();
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ private void doStop() {
+ try {
+ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+ registeredKeys.forEach(key -> {
+ try {
+ mBeanServer.unregisterMBean(new ObjectName(key));
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ });
+ registeredKeys.clear();
+ jmxConnectorServer.stop();
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java
new file mode 100644
index 0000000..f5ad703
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java
@@ -0,0 +1,103 @@
+/****************************************************************
+ * 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.server;
+
+import org.apache.james.adapter.mailbox.MailboxCopierManagement;
+import org.apache.james.adapter.mailbox.MailboxCopierManagementMBean;
+import org.apache.james.adapter.mailbox.MailboxManagerManagement;
+import org.apache.james.adapter.mailbox.MailboxManagerManagementMBean;
+import org.apache.james.adapter.mailbox.MailboxManagerResolver;
+import org.apache.james.domainlist.api.DomainListManagementMBean;
+import org.apache.james.domainlist.lib.DomainListManagement;
+import org.apache.james.mailbox.copier.MailboxCopier;
+import org.apache.james.mailbox.copier.MailboxCopierImpl;
+import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean;
+import org.apache.james.mailetcontainer.impl.JamesMailSpooler;
+import org.apache.james.rrt.api.RecipientRewriteTableManagementMBean;
+import org.apache.james.rrt.lib.RecipientRewriteTableManagement;
+import org.apache.james.user.api.UsersRepositoryManagementMBean;
+import org.apache.james.user.lib.UsersRepositoryManagement;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.GuiceMailboxManagerResolver;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Names;
+
+public class JMXServerModule extends AbstractModule {
+
+ private static final String JMX_COMPONENT_DOMAINLIST = "org.apache.james:type=component,name=domainlist";
+ private static final String JMX_COMPONENT_USERS_REPOSITORY = "org.apache.james:type=component,name=usersrepository";
+ private static final String JMX_COMPONENT_RECIPIENTREWRITETABLE = "org.apache.james:type=component,name=recipientrewritetable";
+ private static final String JMX_COMPONENT_NAME_MAILBOXMANAGERBEAN = "org.apache.james:type=component,name=mailboxmanagerbean";
+ private static final String JMX_COMPONENT_MAILBOXCOPIER = "org.apache.james:type=component,name=mailboxcopier";
+
+ @Override
+ protected void configure() {
+ bind(MailboxCopier.class).annotatedWith(Names.named("mailboxcopier")).to(MailboxCopierImpl.class);
+ bind(MailboxCopierManagementMBean.class).to(MailboxCopierManagement.class);
+ bind(MailboxManagerResolver.class).to(GuiceMailboxManagerResolver.class);
+ bind(DomainListManagementMBean.class).to(DomainListManagement.class);
+ bind(UsersRepositoryManagementMBean.class).to(UsersRepositoryManagement.class);
+ bind(MailboxManagerManagementMBean.class).to(MailboxManagerManagement.class);
+ bind(RecipientRewriteTableManagementMBean.class).to(RecipientRewriteTableManagement.class);
+ bind(MailSpoolerMBean.class).to(JamesMailSpooler.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(JMXModuleConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class JMXModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final JMXServer jmxServer;
+ private final DomainListManagementMBean domainListManagementMBean;
+ private final UsersRepositoryManagementMBean usersRepositoryManagementMBean;
+ private final RecipientRewriteTableManagementMBean recipientRewriteTableManagementMBean;
+ private final MailboxManagerManagementMBean mailboxManagerManagementMBean;
+ private final MailboxCopierManagementMBean mailboxCopierManagementMBean;
+
+ @Inject
+ public JMXModuleConfigurationPerformer(JMXServer jmxServer,
+ DomainListManagementMBean domainListManagementMBean,
+ UsersRepositoryManagementMBean usersRepositoryManagementMBean,
+ RecipientRewriteTableManagementMBean recipientRewriteTableManagementMBean,
+ MailboxManagerManagementMBean mailboxManagerManagementMBean,
+ MailboxCopierManagementMBean mailboxCopierManagementMBean) {
+ this.jmxServer = jmxServer;
+ this.domainListManagementMBean = domainListManagementMBean;
+ this.usersRepositoryManagementMBean = usersRepositoryManagementMBean;
+ this.recipientRewriteTableManagementMBean = recipientRewriteTableManagementMBean;
+ this.mailboxManagerManagementMBean = mailboxManagerManagementMBean;
+ this.mailboxCopierManagementMBean = mailboxCopierManagementMBean;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ jmxServer.start();
+ jmxServer.register(JMX_COMPONENT_DOMAINLIST, domainListManagementMBean);
+ jmxServer.register(JMX_COMPONENT_USERS_REPOSITORY, usersRepositoryManagementMBean);
+ jmxServer.register(JMX_COMPONENT_RECIPIENTREWRITETABLE, recipientRewriteTableManagementMBean);
+ jmxServer.register(JMX_COMPONENT_NAME_MAILBOXMANAGERBEAN, mailboxManagerManagementMBean);
+ jmxServer.register(JMX_COMPONENT_MAILBOXCOPIER, mailboxCopierManagementMBean);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
new file mode 100644
index 0000000..8e91d64
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.server;
+
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.mailrepository.api.MailRepository;
+import org.apache.james.mailrepository.api.MailRepositoryStore;
+import org.apache.james.mailrepository.file.FileMailRepository;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.apache.james.utils.InMemoryMailRepositoryStore;
+import org.apache.james.utils.MailRepositoryProvider;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class MailStoreRepositoryModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(MailRepositoryStore.class).to(InMemoryMailRepositoryStore.class);
+ Multibinder<MailRepositoryProvider> multibinder = Multibinder.newSetBinder(binder(), MailRepositoryProvider.class);
+ multibinder.addBinding().to(FileMailRepositoryProvider.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MailRepositoryStoreModuleConfigurationPerformer.class);
+ }
+
+ public static class FileMailRepositoryProvider implements MailRepositoryProvider {
+
+ private final FileSystem fileSystem;
+
+ @Inject
+ public FileMailRepositoryProvider(FileSystem fileSystem) {
+ this.fileSystem = fileSystem;
+ }
+
+
+ @Override
+ public String canonicalName() {
+ return FileMailRepository.class.getCanonicalName();
+ }
+
+ @Override
+ public MailRepository get() {
+ FileMailRepository fileMailRepository = new FileMailRepository();
+ fileMailRepository.setFileSystem(fileSystem);
+ fileMailRepository.setLog(LoggerFactory.getLogger(FileMailRepository.class));
+ return fileMailRepository;
+ }
+ }
+
+ @Singleton
+ public static class MailRepositoryStoreModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final InMemoryMailRepositoryStore javaMailRepositoryStore;
+
+ @Inject
+ public MailRepositoryStoreModuleConfigurationPerformer(ConfigurationProvider configurationProvider,
+ InMemoryMailRepositoryStore javaMailRepositoryStore) {
+ this.configurationProvider = configurationProvider;
+ this.javaMailRepositoryStore = javaMailRepositoryStore;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ javaMailRepositoryStore.configure(configurationProvider.getConfiguration("mailrepositorystore"));
+ javaMailRepositoryStore.init();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
new file mode 100644
index 0000000..f8e7815
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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.server;
+
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
+import org.apache.james.mailbox.store.quota.NoQuotaManager;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+
+public class QuotaModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(QuotaManager.class).to(NoQuotaManager.class);
+ bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java
new file mode 100644
index 0000000..229b479
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.server;
+
+import org.apache.james.managesieve.api.SieveParser;
+import org.apache.james.managesieve.jsieve.Parser;
+import org.apache.james.sieverepository.api.SieveRepository;
+import org.apache.james.sieverepository.file.SieveFileRepository;
+
+import com.google.inject.AbstractModule;
+
+public class SieveModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(SieveParser.class).to(Parser.class);
+ bind(SieveRepository.class).to(SieveFileRepository.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
new file mode 100644
index 0000000..ae2ef87
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
@@ -0,0 +1,27 @@
+/****************************************************************
+ * 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;
+
+
+public interface ConfigurationPerformer {
+
+ void initModule() throws Exception;
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java
new file mode 100644
index 0000000..cf3126e
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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 org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+
+public interface ConfigurationProvider {
+
+ HierarchicalConfiguration getConfiguration(String component)
+ throws ConfigurationException;
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
new file mode 100644
index 0000000..b188774
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.Set;
+
+import com.google.inject.Inject;
+
+public class ConfigurationsPerformer {
+
+ private final Set<ConfigurationPerformer> configurationPerformers;
+
+ @Inject
+ public ConfigurationsPerformer(Set<ConfigurationPerformer> configurationPerformers) throws Exception {
+ this.configurationPerformers = configurationPerformers;
+ }
+
+ public void initModules() throws Exception {
+ for(ConfigurationPerformer configurationPerformer : configurationPerformers) {
+ configurationPerformer.initModule();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/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
new file mode 100644
index 0000000..d7cf48c
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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.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.MailboxPath;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+
+public interface ExtendedServerProbe<Id extends MailboxId> extends ServerProbe {
+
+ void appendMessage(String username, MailboxPath mailboxPath, InputStream message, Date internalDate, boolean isRecent, Flags flags)
+ throws BadCredentialsException, MailboxException;
+
+ Mailbox<Id> getMailbox(String namespace, String user, String name);
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
new file mode 100644
index 0000000..b28a94a
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
@@ -0,0 +1,90 @@
+/****************************************************************
+ * 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.List;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.commons.cli.MissingArgumentException;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.modules.CommonServicesModule;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
+import com.google.inject.Singleton;
+
+@Singleton
+public class FileConfigurationProvider implements ConfigurationProvider {
+
+ private static final String CONFIGURATION_FILE_SUFFIX = ".xml";
+
+ private final FileSystem fileSystem;
+ private final String configurationPrefix;
+
+ @Inject
+ public FileConfigurationProvider(FileSystem fileSystem, @Named(CommonServicesModule.CONFIGURATION_PATH) String configurationPrefix) throws MissingArgumentException {
+ this.fileSystem = fileSystem;
+ this.configurationPrefix = configurationPrefix;
+ }
+
+ @Override
+ public HierarchicalConfiguration getConfiguration(String component) throws ConfigurationException {
+ Preconditions.checkNotNull(component);
+ List<String> configPathParts = Splitter.on(".").splitToList(component);
+ Preconditions.checkArgument(!configPathParts.isEmpty());
+ HierarchicalConfiguration config = getConfig(retrieveConfigInputStream(configPathParts.get(0)));
+ return selectHierarchicalConfigPart(config, Iterables.skip(configPathParts, 1));
+ }
+
+ private InputStream retrieveConfigInputStream(String configurationFileWithoutExtension) throws ConfigurationException {
+ Preconditions.checkArgument(!Strings.isNullOrEmpty(configurationFileWithoutExtension), "The configuration file name should not be empty or null");
+ try {
+ return fileSystem.getResource(configurationPrefix + configurationFileWithoutExtension + CONFIGURATION_FILE_SUFFIX);
+ } catch (IOException e) {
+ throw new ConfigurationException("Unable to locate configuration file " + configurationFileWithoutExtension + CONFIGURATION_FILE_SUFFIX, e);
+ }
+ }
+
+ private XMLConfiguration getConfig(InputStream configStream) throws ConfigurationException {
+ XMLConfiguration config = new XMLConfiguration();
+ config.setDelimiterParsingDisabled(true);
+ config.setAttributeSplittingDisabled(true);
+ config.load(configStream);
+ return config;
+ }
+
+ private HierarchicalConfiguration selectHierarchicalConfigPart(HierarchicalConfiguration config, Iterable<String> configsPathParts) {
+ HierarchicalConfiguration currentConfig = config;
+ for (String nextPathPart : configsPathParts) {
+ currentConfig = currentConfig.configurationAt(nextPathPart);
+ }
+ return currentConfig;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
new file mode 100644
index 0000000..645d9b0
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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 com.google.inject.Injector;
+
+public class GuiceGenericLoader<T> {
+
+ private final Injector injector;
+ private final String defaultPackageName;
+
+ public GuiceGenericLoader(Injector injector, String defaultPackageName) {
+ this.injector = injector;
+ this.defaultPackageName = defaultPackageName;
+ }
+
+ public T instanciate(String className) throws Exception {
+ @SuppressWarnings("unchecked")
+ Class<T> clazz = (Class<T>) ClassLoader.getSystemClassLoader().loadClass(constructFullName(className));
+ return injector.getInstance(clazz);
+ }
+
+ private String constructFullName(String name) {
+ if (! name.contains(".")) {
+ return defaultPackageName + name;
+ }
+ return name;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.java
new file mode 100644
index 0000000..2487810
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.java
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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.lang.reflect.Type;
+
+import com.google.inject.TypeLiteral;
+import com.google.inject.util.Types;
+
+public class GuiceGenericType<T> {
+
+ private final TypeLiteral<T> type;
+
+ public GuiceGenericType(TypeLiteral<T> type) {
+ this.type = type;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <V> TypeLiteral<V> newGenericType(Class<?> base) {
+ Type newType = Types.newParameterizedType(base, type.getType());
+ return (TypeLiteral<V>) TypeLiteral.get(newType);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
new file mode 100644
index 0000000..fe55c9c
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.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.utils;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.james.adapter.mailbox.MailboxManagerResolver;
+import org.apache.james.adapter.mailbox.MailboxManagerResolverException;
+import org.apache.james.mailbox.MailboxManager;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Inject;
+
+public class GuiceMailboxManagerResolver implements MailboxManagerResolver {
+
+ private final ImmutableMap<String, MailboxManager> managers;
+
+ @Inject
+ private GuiceMailboxManagerResolver(Set<MailboxManagerDefinition> managers) {
+ this.managers = indexManagersByName(managers);
+ }
+
+ private static ImmutableMap<String, MailboxManager> indexManagersByName(Set<MailboxManagerDefinition> managers) {
+ return ImmutableMap.copyOf(managers.stream().collect(
+ Collectors.toMap(MailboxManagerDefinition::getName, MailboxManagerDefinition::getManager)));
+ }
+
+ @Override
+ public Map<String, MailboxManager> getMailboxManagerBeans() {
+ return managers;
+ }
+
+ @Override
+ public MailboxManager resolveMailboxManager(String mailboxManagerClassName) {
+ return Optional.ofNullable(managers.get(mailboxManagerClassName)).orElseThrow(
+ () -> new MailboxManagerResolverException("Unable to find a mailbox manager with name " + mailboxManagerClassName));
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[22/24] james-project git commit: JAMES-1693 Simplify mailet
configuration for GUICE integration testing
Posted by ma...@apache.org.
JAMES-1693 Simplify mailet configuration for GUICE integration testing
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f13f173f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f13f173f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f13f173f
Branch: refs/heads/master
Commit: f13f173fc78cbefc8c0291d97f1eb1193e634362
Parents: fd282b4
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Mar 9 10:07:33 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:07:13 2016 +0100
----------------------------------------------------------------------
.../src/test/resources/mailetcontainer.xml | 56 --------------------
.../src/test/resources/mailetcontainer.xml | 56 --------------------
2 files changed, 112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f13f173f/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml b/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml
index 57c5784..426cab8 100644
--- a/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml
+++ b/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml
@@ -33,31 +33,6 @@
<processor state="root" enableJmx="false">
<mailet match="All" class="PostmasterAlias"/>
<mailet match="RelayLimit=30" class="Null"/>
- <!-- Hook on sievemanager@james.linagora.com
- Mail send to this address will get interpreted with SIEVE Manage -->
- <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
- <processor>sieve-manager-check</processor>
- </mailet>
- <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="All" class="SetMailAttribute">
- <spamChecked>true</spamChecked>
- </mailet>
- <mailet match="SMTPAuthSuccessful" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <!-- Check for delivery from a known spam server -->
- <!-- This set of matchers/mailets redirect all emails from known -->
- <!-- black holes, open relays, and spam servers to the spam processor -->
- <!-- For this set to function properly, the spam processor must be configured. -->
- <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
- <processor>spam</processor>
- <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
- </mailet>
<mailet match="All" class="ToProcessor">
<processor>transport</processor>
</mailet>
@@ -76,10 +51,6 @@
<name>X-UserIsAuth</name>
<value>true</value>
</mailet>
- <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
- <name>X-WasSigned</name>
- <value>true</value>
- </mailet>
<mailet match="All" class="RemoveMimeHeader">
<name>bcc</name>
</mailet>
@@ -134,33 +105,6 @@
</mailet>
</processor>
- <processor state="sieve-manager-check" enableJmx="false">
- <!-- Only local users can manage their scripts -->
- <mailet match="RecipientIsLocal" class="ToProcessor">
- <processor>sieve-manager</processor>
- </mailet>
- <!-- Notify other people about their failure -->
- <mailet match="All" class="Bounce">
- <inline>heads</inline>
- <attachment>none</attachment>
- <passThrough>false</passThrough>
- <prefix>[REJECTED]</prefix>
- <notice>
- You can't send messages to configure SIEVE on this serveur unless you are the official SIEVE manager.
- </notice>
- </mailet>
- <mailet match="All" class="Null"/>
- </processor>
-
- <processor state="sieve-manager">
- <mailet match="All" class="SetMailAttribute">
- <org.apache.james.SMTPAuthUser>true</org.apache.james.SMTPAuthUser>
- </mailet>
- <mailet match="All" class="org.apache.james.transport.mailets.managesieve.ManageSieveMailet">
- <helpURL>file:/root/james-server-app-3.0.0-beta5-SNAPSHOT/conf/managesieve.help.txt</helpURL>
- </mailet>
- <mailet match="All" class="Null"/>
- </processor>
</processors>
</mailetcontainer>
http://git-wip-us.apache.org/repos/asf/james-project/blob/f13f173f/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml b/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml
index 57c5784..426cab8 100644
--- a/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml
+++ b/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml
@@ -33,31 +33,6 @@
<processor state="root" enableJmx="false">
<mailet match="All" class="PostmasterAlias"/>
<mailet match="RelayLimit=30" class="Null"/>
- <!-- Hook on sievemanager@james.linagora.com
- Mail send to this address will get interpreted with SIEVE Manage -->
- <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
- <processor>sieve-manager-check</processor>
- </mailet>
- <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="All" class="SetMailAttribute">
- <spamChecked>true</spamChecked>
- </mailet>
- <mailet match="SMTPAuthSuccessful" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <!-- Check for delivery from a known spam server -->
- <!-- This set of matchers/mailets redirect all emails from known -->
- <!-- black holes, open relays, and spam servers to the spam processor -->
- <!-- For this set to function properly, the spam processor must be configured. -->
- <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
- <processor>spam</processor>
- <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
- </mailet>
<mailet match="All" class="ToProcessor">
<processor>transport</processor>
</mailet>
@@ -76,10 +51,6 @@
<name>X-UserIsAuth</name>
<value>true</value>
</mailet>
- <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
- <name>X-WasSigned</name>
- <value>true</value>
- </mailet>
<mailet match="All" class="RemoveMimeHeader">
<name>bcc</name>
</mailet>
@@ -134,33 +105,6 @@
</mailet>
</processor>
- <processor state="sieve-manager-check" enableJmx="false">
- <!-- Only local users can manage their scripts -->
- <mailet match="RecipientIsLocal" class="ToProcessor">
- <processor>sieve-manager</processor>
- </mailet>
- <!-- Notify other people about their failure -->
- <mailet match="All" class="Bounce">
- <inline>heads</inline>
- <attachment>none</attachment>
- <passThrough>false</passThrough>
- <prefix>[REJECTED]</prefix>
- <notice>
- You can't send messages to configure SIEVE on this serveur unless you are the official SIEVE manager.
- </notice>
- </mailet>
- <mailet match="All" class="Null"/>
- </processor>
-
- <processor state="sieve-manager">
- <mailet match="All" class="SetMailAttribute">
- <org.apache.james.SMTPAuthUser>true</org.apache.james.SMTPAuthUser>
- </mailet>
- <mailet match="All" class="org.apache.james.transport.mailets.managesieve.ManageSieveMailet">
- <helpURL>file:/root/james-server-app-3.0.0-beta5-SNAPSHOT/conf/managesieve.help.txt</helpURL>
- </mailet>
- <mailet match="All" class="Null"/>
- </processor>
</processors>
</mailetcontainer>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[07/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
deleted file mode 100644
index aeca639..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
+++ /dev/null
@@ -1,429 +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.jmap.methods;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.isEmptyOrNullString;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.nullValue;
-
-import java.io.ByteArrayInputStream;
-import java.util.Date;
-
-import javax.mail.Flags;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapAuthentication;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.api.access.AccessToken;
-import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Charsets;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.http.ContentType;
-
-public abstract class GetMailboxesMethodTest {
- private static final String NAME = "[0][0]";
- private static final String ARGUMENTS = "[0][1]";
-
- private TemporaryFolder temporaryFolder = new TemporaryFolder();
- private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
- private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
- private JmapServer jmapServer = jmapServer(temporaryFolder, embeddedElasticSearch, cassandra);
-
- protected abstract JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra);
-
- @Rule
- public RuleChain chain = RuleChain
- .outerRule(temporaryFolder)
- .around(embeddedElasticSearch)
- .around(jmapServer);
-
- private AccessToken accessToken;
- private String username;
-
- @Before
- public void setup() throws Exception {
- RestAssured.port = jmapServer.getPort();
- RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-
- String domain = "domain.tld";
- username = "username@" + domain;
- String password = "password";
- jmapServer.serverProbe().addDomain(domain);
- jmapServer.serverProbe().addUser(username, password);
- accessToken = JmapAuthentication.authenticateJamesUser(username, password);
- }
-
- @Test
- public void getMailboxesShouldErrorNotSupportedWhenRequestContainsNonNullAccountId() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"accountId\": \"1\"}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("error"))
- .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
- }
-
- @Test
- public void getMailboxesShouldReturnEmptyWhenIdsDoesntMatch() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"ids\": [\"notAMailboxId\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", hasSize(0));
- }
-
- @Test
- public void getMailboxesShouldReturnMailboxesWhenIdsMatch() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
-
- Mailbox<CassandraId> mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
- Mailbox<CassandraId> mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
-
- String mailboxId = mailbox.getMailboxId().serialize();
- String mailboxId2 = mailbox2.getMailboxId().serialize();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\", \"" + mailboxId2 + "\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", hasSize(2))
- .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId))
- .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2));
- }
-
- @Test
- public void getMailboxesShouldReturnOnlyMatchingMailboxesWhenIdsGiven() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
-
- Mailbox<CassandraId> mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
-
- String mailboxId = mailbox.getMailboxId().serialize();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId));
- }
-
- @Test
- public void getMailboxesShouldReturnEmptyWhenIdsIsEmpty() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"ids\": []}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", empty());
- }
-
- @Test
- public void getMailboxesShouldReturnAllMailboxesWhenIdsIsNull() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
-
- Mailbox<CassandraId> mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
- Mailbox<CassandraId> mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
-
- String mailboxId = mailbox.getMailboxId().serialize();
- String mailboxId2 = mailbox2.getMailboxId().serialize();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"ids\": null}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", hasSize(2))
- .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId))
- .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2));
- }
-
- @Test
- public void getMailboxesShouldErrorInvalidArgumentsWhenRequestIsInvalid() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"ids\": true}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("error"))
- .body(ARGUMENTS + ".type", equalTo("invalidArguments"))
- .body(ARGUMENTS + ".description", equalTo("Can not deserialize instance of java.util.ArrayList out of VALUE_TRUE token\n"
- + " at [Source: {\"ids\":true}; line: 1, column: 2] (through reference chain: org.apache.james.jmap.model.Builder[\"ids\"])"));
- }
-
- @Test
- public void getMailboxesShouldReturnEmptyListWhenNoMailboxes() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", empty());
- }
-
- @Test
- public void getMailboxesShouldReturnDefaultMailboxesWhenAuthenticatedUserDoesntHaveAnAccountYet() throws Exception {
-
- String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3QGRvbWFpbi50bGQiLCJuYW1lIjoiTmV3IFVzZXIif"
- + "Q.fxNWNzksXyCij2ooVi-QfGe9vTicF2N9FDtWSJdjWTjhwoQ_i0dgiT8clp4dtOJzy78hB2UkAW-iq7z3PR_Gz0qFah7EbYoEs"
- + "5lQs1UlhNGCRTvIsyR8qHUXtA6emw9x0nuMnswtyXhzoA-cEHCArrMxMeWhTYi2l4od3G8Irrvu1Yc5hKLwLgPdnImbKyB5a89T"
- + "vzuZE8-FVyMmhlaJA2T1GpbsaUnfE1ki_bBzqMHTD_Ob7oSVzz2UOiOeL-ombn1X9GbYQ2I-Ob4V84WHONYxw0VjPHlj9saZ2n7"
- + "2RJTBsIo6flJT-MchaEvTYBvuV_wlCCQYjI1g7mdeD6aXfw";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", "Bearer " + token)
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", hasSize(3))
- .body(ARGUMENTS + ".list.name", hasItems("INBOX", "Outbox", "Sent"));
- }
-
- @Test
- public void getMailboxesShouldErrorWithBadJWTToken() {
-
- String badAuthToken = "BADTOKENOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
- "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
- "DN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
- "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
- "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", "Bearer " + badAuthToken)
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void getMailboxesShouldReturnMailboxesWhenAvailable() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "name"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list[0].name", equalTo("name"))
- .body(ARGUMENTS + ".list[0].parentId", nullValue())
- .body(ARGUMENTS + ".list[0].role", nullValue())
- .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000))
- .body(ARGUMENTS + ".list[0].mustBeOnlyMailbox", equalTo(false))
- .body(ARGUMENTS + ".list[0].mayReadItems", equalTo(false))
- .body(ARGUMENTS + ".list[0].mayAddItems", equalTo(false))
- .body(ARGUMENTS + ".list[0].mayRemoveItems", equalTo(false))
- .body(ARGUMENTS + ".list[0].mayCreateChild", equalTo(false))
- .body(ARGUMENTS + ".list[0].mayRename", equalTo(false))
- .body(ARGUMENTS + ".list[0].mayDelete", equalTo(false))
- .body(ARGUMENTS + ".list[0].totalMessages", equalTo(1))
- .body(ARGUMENTS + ".list[0].unreadMessages", equalTo(1))
- .body(ARGUMENTS + ".list[0].unreadThreads", equalTo(0));
- }
-
- @Test
- public void getMailboxesShouldReturnFilteredMailboxesPropertiesWhenRequestContainsFilterProperties() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
- .body(ARGUMENTS + ".list[0].name", nullValue())
- .body(ARGUMENTS + ".list[0].parentId", nullValue())
- .body(ARGUMENTS + ".list[0].role", nullValue())
- .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000))
- .body(ARGUMENTS + ".list[0].mustBeOnlyMailbox", nullValue())
- .body(ARGUMENTS + ".list[0].mayReadItems", nullValue())
- .body(ARGUMENTS + ".list[0].mayAddItems", nullValue())
- .body(ARGUMENTS + ".list[0].mayRemoveItems", nullValue())
- .body(ARGUMENTS + ".list[0].mayCreateChild", nullValue())
- .body(ARGUMENTS + ".list[0].mayRename", nullValue())
- .body(ARGUMENTS + ".list[0].mayDelete", nullValue())
- .body(ARGUMENTS + ".list[0].totalMessages", nullValue())
- .body(ARGUMENTS + ".list[0].unreadMessages", equalTo(0))
- .body(ARGUMENTS + ".list[0].unreadThreads", nullValue());
- }
-
- @Test
- public void getMailboxesShouldReturnIdWhenRequestContainsEmptyPropertyListFilter() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"properties\" : []}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
- .body(ARGUMENTS + ".list[0].name", nullValue());
- }
-
- @Test
- public void getMailboxesShouldIgnoreUnknownPropertiesWhenRequestContainsUnknownPropertyListFilter() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"properties\" : [\"unknown\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
- .body(ARGUMENTS + ".list[0].name", nullValue());
- }
-
- @Test
- public void getMailboxesShouldReturnMailboxesWithSortOrder() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "trash");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", hasSize(2))
- .body(ARGUMENTS + ".list[0].name", equalTo("inbox"))
- .body(ARGUMENTS + ".list[0].sortOrder", equalTo(10))
- .body(ARGUMENTS + ".list[1].name", equalTo("trash"))
- .body(ARGUMENTS + ".list[1].sortOrder", equalTo(60));
- }
-
- @Test
- public void getMailboxesShouldReturnMailboxesWithRolesInLowerCase() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "outbox");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("mailboxes"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].role", equalTo("outbox"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
deleted file mode 100644
index 4013840..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
+++ /dev/null
@@ -1,516 +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.jmap.methods;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.RestAssured.with;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasSize;
-
-import java.io.ByteArrayInputStream;
-import java.time.LocalDate;
-import java.util.Date;
-import java.util.List;
-
-import javax.mail.Flags;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapAuthentication;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.api.access.AccessToken;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Charsets;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.http.ContentType;
-
-public abstract class GetMessageListMethodTest {
- private static final String NAME = "[0][0]";
- private static final String ARGUMENTS = "[0][1]";
-
- private TemporaryFolder temporaryFolder = new TemporaryFolder();
- private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
- private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
- private JmapServer jmapServer = jmapServer(temporaryFolder, embeddedElasticSearch, cassandra);
-
- protected abstract JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra);
-
- @Rule
- public RuleChain chain = RuleChain
- .outerRule(temporaryFolder)
- .around(embeddedElasticSearch)
- .around(jmapServer);
-
- private AccessToken accessToken;
- private String username;
- private String domain;
-
- @Before
- public void setup() throws Exception {
- RestAssured.port = jmapServer.getPort();
- RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-
- this.domain = "domain.tld";
- this.username = "username@" + domain;
- String password = "password";
- jmapServer.serverProbe().addDomain(domain);
- jmapServer.serverProbe().addUser(username, password);
- this.accessToken = JmapAuthentication.authenticateJamesUser(username, password);
- }
-
- @Test
- public void getMessageListShouldErrorInvalidArgumentsWhenRequestIsInvalid() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"filter\": true}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("error"))
- .body(ARGUMENTS + ".type", equalTo("invalidArguments"))
- .body(ARGUMENTS + ".description", equalTo("Can not instantiate value of type [simple type, class org.apache.james.jmap.model.FilterCondition$Builder] from Boolean value (true); no single-boolean/Boolean-arg constructor/factory method\n" +
- " at [Source: {\"filter\":true}; line: 1, column: 2] (through reference chain: org.apache.james.jmap.model.Builder[\"filter\"])"));
- }
-
- @Test
- public void getMessageListShouldReturnAllMessagesWhenSingleMailboxNoParameters() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
- }
-
- @Test
- public void getMessageListShouldReturnAllMessagesWhenMultipleMailboxesAndNoParameters() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox2|1"));
- }
-
- @Test
- public void getMessageListShouldReturnAllMessagesOfCurrentUserOnlyWhenMultipleMailboxesAndNoParameters() throws Exception {
- String otherUser = "other@" + domain;
- String password = "password";
- jmapServer.serverProbe().addUser(otherUser, password);
-
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, otherUser, "mailbox");
- jmapServer.serverProbe().appendMessage(otherUser, new MailboxPath(MailboxConstants.USER_NAMESPACE, otherUser, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox2|1"));
- }
-
- @Test
- public void getMessageListShouldFilterMessagesWhenInMailboxesFilterMatches() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String mailboxId =
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .post("/jmap")
- .path("[0][1].list[0].id");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
- }
-
- @Test
- public void getMessageListShouldFilterMessagesWhenMultipleInMailboxesFilterMatches() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
- embeddedElasticSearch.awaitForElasticSearch();
-
- List<String> mailboxIds =
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {}, \"#0\"]]")
- .post("/jmap")
- .path("[0][1].list.id");
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]", mailboxIds.get(0), mailboxIds.get(1)))
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
- }
-
- @Test
- public void getMessageListShouldFilterMessagesWhenInMailboxesFilterDoesntMatches() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"mailbox2\"]}}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(ARGUMENTS + ".messageIds", empty());
- }
-
- @Test
- public void getMessageListShouldSortMessagesWhenSortedByDateDefault() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"sort\":[\"date\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
- }
-
- @Test
- public void getMessageListShouldSortMessagesWhenSortedByDateAsc() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"sort\":[\"date asc\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|2", "username@domain.tld|mailbox|1"));
- }
-
- @Test
- public void getMessageListShouldSortMessagesWhenSortedByDateDesc() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"sort\":[\"date desc\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
- }
-
- @Test
- public void getMessageListShouldWorkWhenCollapseThreadIsFalse() {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"collapseThreads\":false}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"));
- }
-
- @Test
- public void getMessageListShouldWorkWhenCollapseThreadIsTrue() {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"collapseThreads\":true}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"));
- }
-
- @Test
- public void getMessageListShouldReturnAllMessagesWhenPositionIsNotGiven() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
- }
-
- @Test
- public void getMessageListShouldReturnSkipMessagesWhenPositionIsGiven() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"position\":1}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|2"));
- }
-
- @Test
- public void getMessageListShouldReturnAllMessagesWhenLimitIsNotGiven() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
- }
-
- @Test
- public void getMessageListShouldReturnLimitMessagesWhenLimitGiven() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"limit\":1}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
- }
-
- @Test
- public void getMessageListShouldReturnLimitMessagesWithDefaultValueWhenLimitIsNotGiven() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test4\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2", "username@domain.tld|mailbox|3"));
- }
-
- @Test
- public void getMessageListShouldChainFetchingMessagesWhenAskedFor() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- LocalDate date = LocalDate.now();
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"fetchMessages\":true}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body("[0][0]", equalTo("messageList"))
- .body("[1][0]", equalTo("messages"))
- .body("[0][1].messageIds", hasSize(1))
- .body("[0][1].messageIds[0]", equalTo("username@domain.tld|mailbox|1"))
- .body("[1][1].list", hasSize(1))
- .body("[1][1].list[0].id", equalTo("username@domain.tld|mailbox|1"));
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
deleted file mode 100644
index 234c6b9..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
+++ /dev/null
@@ -1,339 +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.jmap.methods;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.nullValue;
-
-import java.io.ByteArrayInputStream;
-import java.time.ZonedDateTime;
-import java.util.Date;
-
-import javax.mail.Flags;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapAuthentication;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.api.access.AccessToken;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.elasticsearch.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Charsets;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.http.ContentType;
-
-public abstract class GetMessagesMethodTest {
- private static final String NAME = "[0][0]";
- private static final String ARGUMENTS = "[0][1]";
-
- private TemporaryFolder temporaryFolder = new TemporaryFolder();
- private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
- private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
- private JmapServer jmapServer = jmapServer(temporaryFolder, embeddedElasticSearch, cassandra);
-
- protected abstract JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra);
-
- @Rule
- public RuleChain chain = RuleChain
- .outerRule(temporaryFolder)
- .around(embeddedElasticSearch)
- .around(jmapServer);
-
- private AccessToken accessToken;
- private String username;
-
- @Before
- public void setup() throws Exception {
- RestAssured.port = jmapServer.getPort();
- RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-
- String domain = "domain.tld";
- username = "username@" + domain;
- String password = "password";
- jmapServer.serverProbe().addDomain(domain);
- jmapServer.serverProbe().addUser(username, password);
- jmapServer.serverProbe().createMailbox("#private", "username", "inbox");
- accessToken = JmapAuthentication.authenticateJamesUser(username, password);
- }
-
- @Test
- public void getMessagesShouldErrorNotSupportedWhenRequestContainsNonNullAccountId() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"accountId\": \"1\"}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("error"))
- .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
- }
-
- @Test
- public void getMessagesShouldIgnoreUnknownArguments() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"WAT\": true}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(ARGUMENTS + ".notFound", empty())
- .body(ARGUMENTS + ".list", empty());
- }
-
- @Test
- public void getMessagesShouldErrorInvalidArgumentsWhenRequestContainsInvalidArgument() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": null}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("error"))
- .body(ARGUMENTS + ".type", equalTo("invalidArguments"))
- .body(ARGUMENTS + ".description", equalTo("N/A (through reference chain: org.apache.james.jmap.model.Builder[\"ids\"])"));
- }
-
- @Test
- public void getMessagesShouldReturnEmptyListWhenNoMessage() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": []}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", empty());
- }
-
- @Test
- public void getMessagesShouldReturnNoFoundIndicesWhenMessageNotFound() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"username|inbox|12\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".notFound", contains("username|inbox|12"));
- }
-
- @Test
- public void getMessagesShouldReturnMessagesWhenAvailable() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
-
- ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
- new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
-
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
- .body(ARGUMENTS + ".list[0].threadId", equalTo(username + "|inbox|1"))
- .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
- .body(ARGUMENTS + ".list[0].textBody", equalTo("testmail"))
- .body(ARGUMENTS + ".list[0].isUnread", equalTo(true))
- .body(ARGUMENTS + ".list[0].preview", equalTo("testmail"))
- .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("subject", "my test subject")))
- .body(ARGUMENTS + ".list[0].date", equalTo("2014-10-30T14:12:00Z"));
- }
-
- @Test
- public void getMessagesShouldReturnMessageWhenHtmlMessage() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
-
- ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
- new ByteArrayInputStream("Content-Type: text/html\r\nSubject: my test subject\r\n\r\nThis is a <b>HTML</b> mail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
-
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
- .body(ARGUMENTS + ".list[0].threadId", equalTo(username + "|inbox|1"))
- .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
- .body(ARGUMENTS + ".list[0].htmlBody", equalTo("This is a <b>HTML</b> mail"))
- .body(ARGUMENTS + ".list[0].isUnread", equalTo(true))
- .body(ARGUMENTS + ".list[0].preview", equalTo("This is a <b>HTML</b> mail"))
- .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("content-type", "text/html", "subject", "my test subject")))
- .body(ARGUMENTS + ".list[0].date", equalTo("2014-10-30T14:12:00Z"));
- }
-
- @Test
- public void getMessagesShouldReturnFilteredPropertiesMessagesWhenAsked() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
-
- ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
- new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
-
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"], \"properties\": [\"id\", \"subject\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
- .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
- .body(ARGUMENTS + ".list[0].textBody", nullValue())
- .body(ARGUMENTS + ".list[0].isUnread", nullValue())
- .body(ARGUMENTS + ".list[0].preview", nullValue())
- .body(ARGUMENTS + ".list[0].headers", nullValue())
- .body(ARGUMENTS + ".list[0].date", nullValue());
- }
-
- @Test
- public void getMessagesShouldReturnFilteredHeaderPropertyWhenAsked() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
-
- ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
- new ByteArrayInputStream(("From: user@domain.tld\r\n"
- + "header1: Header1Content\r\n"
- + "HEADer2: Header2Content\r\n"
- + "Subject: my test subject\r\n"
- + "\r\n"
- + "testmail").getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
-
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"], \"properties\": [\"headers.from\", \"headers.heADER2\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
- .body(ARGUMENTS + ".list[0].subject", nullValue())
- .body(ARGUMENTS + ".list[0].textBody", nullValue())
- .body(ARGUMENTS + ".list[0].isUnread", nullValue())
- .body(ARGUMENTS + ".list[0].preview", nullValue())
- .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("from", "user@domain.tld", "header2", "Header2Content")))
- .body(ARGUMENTS + ".list[0].date", nullValue());
- }
-
- @Test
- public void getMessagesShouldReturnNotFoundWhenIdDoesntMatch() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
-
- ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
- new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
-
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", empty())
- .body(ARGUMENTS + ".notFound", hasSize(1));
- }
-
- @Test
- public void getMessagesShouldReturnMandatoryPropertiesMessagesWhenNotAsked() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + username + "|mailbox|1\"], \"properties\": [\"subject\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].id", equalTo("username@domain.tld|mailbox|1"))
- .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"));
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[09/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
new file mode 100644
index 0000000..a90ae83
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -0,0 +1,1367 @@
+/****************************************************************
+ * 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.jmap.methods.integration;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.RestAssured.with;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.isEmptyOrNullString;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
+import static org.hamcrest.collection.IsMapWithSize.anEmptyMap;
+
+import java.io.ByteArrayInputStream;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import javax.mail.Flags;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.JmapAuthentication;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.hamcrest.Matchers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.jayway.awaitility.Awaitility;
+import com.jayway.awaitility.Duration;
+import com.jayway.awaitility.core.ConditionFactory;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+public abstract class SetMessagesMethodTest {
+
+ private static final String NAME = "[0][0]";
+ private static final String ARGUMENTS = "[0][1]";
+ private static final String SECOND_NAME = "[1][0]";
+ private static final String SECOND_ARGUMENTS = "[1][1]";
+ private static final String USERS_DOMAIN = "domain.tld";
+
+ private ConditionFactory calmlyAwait;
+
+ protected abstract GuiceJamesServer<?> createJmapServer();
+
+ protected abstract void await();
+
+ private AccessToken accessToken;
+ private String username;
+ private GuiceJamesServer<?> jmapServer;
+
+ @Before
+ public void setup() throws Throwable {
+ jmapServer = createJmapServer();
+ jmapServer.start();
+ RestAssured.port = jmapServer.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+
+ username = "username@" + USERS_DOMAIN;
+ String password = "password";
+ jmapServer.serverProbe().addDomain(USERS_DOMAIN);
+ jmapServer.serverProbe().addUser(username, password);
+ jmapServer.serverProbe().createMailbox("#private", username, "inbox");
+ accessToken = JmapAuthentication.authenticateJamesUser(username, password);
+
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "outbox");
+ await();
+
+ Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
+ calmlyAwait = Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ private String getOutboxId() {
+ // Find username's outbox (using getMailboxes command on /jmap endpoint)
+ return getAllMailboxesIds(accessToken).stream()
+ .filter(x -> x.get("role").equals("outbox"))
+ .map(x -> x.get("id"))
+ .findFirst().get();
+ }
+
+ private List<Map<String, String>> getAllMailboxesIds(AccessToken accessToken) {
+ return with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"properties\": [\"role\", \"id\"]}, \"#0\"]]")
+ .post("/jmap")
+ .andReturn()
+ .body()
+ .jsonPath()
+ .getList(ARGUMENTS + ".list");
+ }
+
+ @Test
+ public void setMessagesShouldReturnErrorNotSupportedWhenRequestContainsNonNullAccountId() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"accountId\": \"1\"}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
+ }
+
+ @Test
+ public void setMessagesShouldReturnErrorNotSupportedWhenRequestContainsNonNullIfInState() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"ifInState\": \"1\"}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
+ }
+
+ @Test
+ public void setMessagesShouldReturnNotDestroyedWhenUnknownMailbox() throws Exception {
+
+ String unknownMailboxMessageId = username + "|unknown|12345";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"destroy\": [\"" + unknownMailboxMessageId + "\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".destroyed", empty())
+ .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(unknownMailboxMessageId), Matchers.allOf(
+ hasEntry("type", "anErrorOccurred"),
+ hasEntry("description", "An error occurred while deleting message " + unknownMailboxMessageId),
+ hasEntry(equalTo("properties"), isEmptyOrNullString())))
+ );
+ }
+
+ @Test
+ public void setMessagesShouldReturnNotDestroyedWhenNoMatchingMessage() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ String messageId = username + "|mailbox|12345";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"destroy\": [\"" + messageId + "\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".destroyed", empty())
+ .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(messageId), Matchers.allOf(
+ hasEntry("type", "notFound"),
+ hasEntry("description", "The message " + messageId + " can't be found"),
+ hasEntry(equalTo("properties"), isEmptyOrNullString())))
+ );
+ }
+
+ @Test
+ public void setMessagesShouldReturnDestroyedWhenMatchingMessage() throws Exception {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notDestroyed", anEmptyMap())
+ .body(ARGUMENTS + ".destroyed", hasSize(1))
+ .body(ARGUMENTS + ".destroyed", contains(username + "|mailbox|1"));
+ }
+
+ @Test
+ public void setMessagesShouldDeleteMessageWhenMatchingMessage() throws Exception {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ // When
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200);
+
+ // Then
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + username + "|mailbox|1\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", empty());
+ }
+
+ @Test
+ public void setMessagesShouldReturnDestroyedNotDestroyWhenMixed() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String missingMessageId = username + "|mailbox|4";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\", \"" + missingMessageId + "\", \"" + username + "|mailbox|3\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".destroyed", hasSize(2))
+ .body(ARGUMENTS + ".notDestroyed", aMapWithSize(1))
+ .body(ARGUMENTS + ".destroyed", contains(username + "|mailbox|1", username + "|mailbox|3"))
+ .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(missingMessageId), Matchers.allOf(
+ hasEntry("type", "notFound"),
+ hasEntry("description", "The message " + missingMessageId + " can't be found")))
+ );
+ }
+
+ @Test
+ public void setMessagesShouldDeleteMatchingMessagesWhenMixed() throws Exception {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ // When
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\", \"" + username + "|mailbox|4\", \"" + username + "|mailbox|3\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200);
+
+ // Then
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + username + "|mailbox|1\", \"" + username + "|mailbox|2\", \"" + username + "|mailbox|3\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1));
+ }
+
+ @Test
+ public void setMessagesShouldReturnUpdatedIdAndNoErrorWhenIsUnreadPassedToFalse() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+
+ // When
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : false } } }, \"#0\"]]", presumedMessageId))
+ .when()
+ .post("/jmap")
+ // Then
+ .then()
+ .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
+ .log().ifValidationFails();
+ }
+
+ private ResponseSpecification getSetMessagesUpdateOKResponseAssertions(String messageId) {
+ ResponseSpecBuilder builder = new ResponseSpecBuilder()
+ .expectStatusCode(200)
+ .expectBody(NAME, equalTo("messagesSet"))
+ .expectBody(ARGUMENTS + ".updated", hasSize(1))
+ .expectBody(ARGUMENTS + ".updated", contains(messageId))
+ .expectBody(ARGUMENTS + ".error", isEmptyOrNullString())
+ .expectBody(ARGUMENTS + ".notUpdated", not(hasKey(messageId)));
+ return builder.build();
+ }
+
+ @Test
+ public void setMessagesShouldMarkAsReadWhenIsUnreadPassedToFalse() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : false } } }, \"#0\"]]", presumedMessageId))
+ // When
+ .when()
+ .post("/jmap");
+ // Then
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].isUnread", equalTo(false))
+ .log().ifValidationFails();
+ }
+
+ @Test
+ public void setMessagesShouldReturnUpdatedIdAndNoErrorWhenIsUnreadPassed() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags(Flags.Flag.SEEN));
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : true } } }, \"#0\"]]", presumedMessageId))
+ // When
+ .when()
+ .post("/jmap")
+ // Then
+ .then()
+ .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
+ .log().ifValidationFails();
+ }
+
+ @Test
+ public void setMessagesShouldMarkAsUnreadWhenIsUnreadPassed() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags(Flags.Flag.SEEN));
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : true } } }, \"#0\"]]", presumedMessageId))
+ // When
+ .when()
+ .post("/jmap");
+ // Then
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].isUnread", equalTo(true))
+ .log().ifValidationFails();
+ }
+
+
+ @Test
+ public void setMessagesShouldReturnUpdatedIdAndNoErrorWhenIsFlaggedPassed() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isFlagged\" : true } } }, \"#0\"]]", presumedMessageId))
+ // When
+ .when()
+ .post("/jmap")
+ // Then
+ .then()
+ .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
+ .log().ifValidationFails();
+ }
+
+ @Test
+ public void setMessagesShouldMarkAsFlaggedWhenIsFlaggedPassed() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isFlagged\" : true } } }, \"#0\"]]", presumedMessageId))
+ // When
+ .when()
+ .post("/jmap");
+ // Then
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].isFlagged", equalTo(true))
+ .log().ifValidationFails();
+ }
+
+ @Test
+ public void setMessagesShouldRejectUpdateWhenPropertyHasWrongType() throws MailboxException {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ await();
+
+ String messageId = username + "|mailbox|1";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : \"123\" } } }, \"#0\"]]", messageId))
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notUpdated", hasKey(messageId))
+ .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].type", equalTo("invalidProperties"))
+ .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties[0]", equalTo("isUnread"))
+ .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].description", equalTo("isUnread: Can not construct instance of java.lang.Boolean from String value '123': only \"true\" or \"false\" recognized\n" +
+ " at [Source: {\"isUnread\":\"123\"}; line: 1, column: 2] (through reference chain: org.apache.james.jmap.model.Builder[\"isUnread\"])"))
+ .body(ARGUMENTS + ".updated", hasSize(0));
+ }
+
+ @Test
+ @Ignore("Jackson json deserializer stops after first error found")
+ public void setMessagesShouldRejectUpdateWhenPropertiesHaveWrongTypes() throws MailboxException {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ await();
+
+ String messageId = username + "|mailbox|1";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : \"123\", \"isFlagged\" : 456 } } }, \"#0\"]]", messageId))
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notUpdated", hasKey(messageId))
+ .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].type", equalTo("invalidProperties"))
+ .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties", hasSize(2))
+ .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties[0]", equalTo("isUnread"))
+ .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties[1]", equalTo("isFlagged"))
+ .body(ARGUMENTS + ".updated", hasSize(0));
+ }
+
+ @Test
+ public void setMessagesShouldMarkMessageAsAnsweredWhenIsAnsweredPassed() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+ // When
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isAnswered\" : true } } }, \"#0\"]]", presumedMessageId))
+ .when()
+ .post("/jmap")
+ // Then
+ .then()
+ .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
+ .log().ifValidationFails();
+ }
+
+ @Test
+ public void setMessagesShouldMarkAsAnsweredWhenIsAnsweredPassed() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String presumedMessageId = username + "|mailbox|1";
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isAnswered\" : true } } }, \"#0\"]]", presumedMessageId))
+ // When
+ .when()
+ .post("/jmap");
+ // Then
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].isAnswered", equalTo(true))
+ .log().ifValidationFails();
+ }
+
+ @Test
+ public void setMessageShouldReturnNotFoundWhenUpdateUnknownMessage() {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ String nonExistingMessageId = username + "|mailbox|12345";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : true } } }, \"#0\"]]", nonExistingMessageId))
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notUpdated", hasKey(nonExistingMessageId))
+ .body(ARGUMENTS + ".notUpdated[\""+nonExistingMessageId+"\"].type", equalTo("notFound"))
+ .body(ARGUMENTS + ".notUpdated[\""+nonExistingMessageId+"\"].description", equalTo("message not found"))
+ .body(ARGUMENTS + ".updated", hasSize(0));
+ }
+
+ @Test
+ public void setMessageShouldReturnCreatedMessageWhenSendingMessage() {
+ String messageCreationId = "user|inbox|1";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notCreated", aMapWithSize(0))
+ // note that assertions on result message had to be split between
+ // string-typed values and boolean-typed value assertions on the same .created entry
+ // make sure only one creation has been processed
+ .body(ARGUMENTS + ".created", aMapWithSize(1))
+ // assert server-set attributes are returned
+ .body(ARGUMENTS + ".created", hasEntry(equalTo(messageCreationId), Matchers.allOf(
+ hasEntry(equalTo("id"), not(isEmptyOrNullString())),
+ hasEntry(equalTo("blobId"), not(isEmptyOrNullString())),
+ hasEntry(equalTo("threadId"), not(isEmptyOrNullString())),
+ hasEntry(equalTo("size"), not(isEmptyOrNullString()))
+ )))
+ // assert that message flags are all unset
+ .body(ARGUMENTS + ".created", hasEntry(equalTo(messageCreationId), Matchers.allOf(
+ hasEntry(equalTo("isDraft"), equalTo(false)),
+ hasEntry(equalTo("isUnread"), equalTo(false)),
+ hasEntry(equalTo("isFlagged"), equalTo(false)),
+ hasEntry(equalTo("isAnswered"), equalTo(false))
+ )))
+ ;
+ }
+
+ @Test
+ public void setMessagesShouldCreateMessageInOutboxWhenSendingMessage() throws MailboxException {
+ // Given
+ String messageCreationId = "user|inbox|1";
+ String presumedMessageId = "username@domain.tld|outbox|1";
+ String messageSubject = "Thank you for joining example.com!";
+ String outboxId = getOutboxId();
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"subject\": \"" + messageSubject + "\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + outboxId + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+
+ // Then
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].subject", equalTo(messageSubject))
+ .body(ARGUMENTS + ".list[0].mailboxIds", contains(outboxId))
+ ;
+ }
+
+ @Test
+ public void setMessagesShouldMoveMessageInSentWhenMessageIsSent() throws MailboxException {
+ // Given
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
+ String sentMailboxId = getAllMailboxesIds(accessToken).stream()
+ .filter(x -> x.get("role").equals("sent"))
+ .map(x -> x.get("id"))
+ .findFirst().get();
+
+ String messageCreationId = "user|inbox|1";
+ String messageSubject = "Thank you for joining example.com!";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"subject\": \"" + messageSubject + "\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+
+ // Then
+ calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> messageHasBeenMovedToSentBox(sentMailboxId));
+ }
+
+ private boolean messageHasBeenMovedToSentBox(String sentMailboxId) {
+ try {
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"fetchMessages\":true, \"filter\":{\"inMailboxes\":[\"" + sentMailboxId + "\"]}}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(SECOND_NAME, equalTo("messages"))
+ .body(SECOND_ARGUMENTS + ".list", hasSize(1));
+ return true;
+ } catch(AssertionError e) {
+ return false;
+ }
+ }
+
+ @Test
+ public void setMessagesShouldRejectWhenSendingMessageHasNoValidAddress() {
+ String messageCreationId = "user|inbox|1";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com@example.com\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+
+ .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].type", equalTo("invalidProperties"))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].description", endsWith("no recipient address set"))
+ .body(ARGUMENTS + ".created", aMapWithSize(0));
+ }
+
+ @Test
+ public void setMessagesShouldRejectWhenSendingMessageHasMissingFrom() {
+ String messageCreationId = "user|inbox|1";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].type", equalTo("invalidProperties"))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].description", endsWith("'from' address is mandatory"))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", hasSize(1))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", contains("from"))
+ .body(ARGUMENTS + ".created", aMapWithSize(0));
+ }
+
+ @Test
+ public void setMessagesShouldSucceedWhenSendingMessageWithOnlyFromAddress() {
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = "postmaster@example.com";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".created", aMapWithSize(1))
+ .body(ARGUMENTS + ".created", hasKey(messageCreationId))
+ .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].headers.from", equalTo(fromAddress))
+ .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.name", equalTo(fromAddress))
+ .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.email", equalTo(fromAddress));
+ }
+
+ @Test
+ public void setMessagesShouldSucceedWithHtmlBody() {
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = "postmaster@example.com";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"htmlBody\": \"Hello <i>someone</i>, and thank <b>you</b> for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".created", aMapWithSize(1))
+ .body(ARGUMENTS + ".created", hasKey(messageCreationId))
+ .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].headers.from", equalTo(fromAddress))
+ .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.name", equalTo(fromAddress))
+ .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.email", equalTo(fromAddress));
+ }
+
+ @Test
+ public void setMessagesShouldMoveToSentWhenSendingMessageWithOnlyFromAddress() {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
+ String sentMailboxId = getAllMailboxesIds(accessToken).stream()
+ .filter(x -> x.get("role").equals("sent"))
+ .map(x -> x.get("id"))
+ .findFirst().get();
+
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = "postmaster@example.com";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ // Given
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+ // Then
+ calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> messageHasBeenMovedToSentBox(sentMailboxId));
+ }
+
+
+ @Test
+ public void setMessagesShouldRejectWhenSendingMessageHasMissingSubject() {
+ String messageCreationId = "user|inbox|1";
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(requestBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].type", equalTo("invalidProperties"))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", hasSize(1))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", contains("subject"))
+ .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].description", endsWith("'subject' is missing"))
+ .body(ARGUMENTS + ".created", aMapWithSize(0));
+ }
+
+ @Test
+ public void setMessagesShouldDeliverMessageToRecipient() throws Exception {
+ // Sender
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
+ // Recipient
+ String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
+ String password = "password";
+ jmapServer.serverProbe().addUser(recipientAddress, password);
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
+ await();
+ AccessToken recipientToken = JmapAuthentication.authenticateJamesUser(recipientAddress, password);
+
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = username;
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"" + recipientAddress + "\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ // Given
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", this.accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+
+ // Then
+ calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInRecipientsMailboxes(recipientToken));
+ }
+
+ @Test
+ public void setMessagesShouldStripBccFromDeliveredEmail() throws Exception {
+ // Sender
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
+ // Recipient
+ String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
+ String password = "password";
+ jmapServer.serverProbe().addUser(recipientAddress, password);
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
+ await();
+ AccessToken recipientToken = JmapAuthentication.authenticateJamesUser(recipientAddress, password);
+
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = username;
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"recipient\", \"email\": \"" + recipientAddress + "\"}]," +
+ " \"bcc\": [{ \"name\": \"BOB\", \"email\": \"bob@" + USERS_DOMAIN + "\"}]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ // Given
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", this.accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+
+ // Then
+ calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInRecipientsMailboxes(recipientToken));
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", recipientToken.serialize())
+ .body("[[\"getMessageList\", {\"fetchMessages\": true, \"fetchMessageProperties\": [\"bcc\"] }, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(SECOND_NAME, equalTo("messages"))
+ .body(SECOND_ARGUMENTS + ".list", hasSize(1))
+ .body(SECOND_ARGUMENTS + ".list[0].bcc", empty());
+ }
+
+ @Test
+ public void setMessagesShouldKeepBccInSentMailbox() throws Exception {
+ // Sender
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
+ String sentMailboxId = getAllMailboxesIds(accessToken).stream()
+ .filter(x -> x.get("role").equals("sent"))
+ .map(x -> x.get("id"))
+ .findFirst().get();
+
+ // Recipient
+ String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
+ String password = "password";
+ jmapServer.serverProbe().addUser(recipientAddress, password);
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
+ await();
+
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = username;
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"recipient\", \"email\": \"" + recipientAddress + "\"}]," +
+ " \"bcc\": [{ \"name\": \"BOB\", \"email\": \"bob@" + USERS_DOMAIN + "\" }]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ // Given
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", this.accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+
+ // Then
+ calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> messageHasBeenMovedToSentBox(sentMailboxId));
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", this.accessToken.serialize())
+ .body("[[\"getMessageList\", {\"fetchMessages\":true, \"fetchMessageProperties\": [\"bcc\"], \"filter\":{\"inMailboxes\":[\"" + sentMailboxId + "\"]}}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(SECOND_NAME, equalTo("messages"))
+ .body(SECOND_ARGUMENTS + ".list", hasSize(1))
+ .body(SECOND_ARGUMENTS + ".list[0].bcc", hasSize(1));
+ }
+
+ @Test
+ public void setMessagesShouldSendMessageToBcc() throws Exception {
+ // Sender
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
+
+ // Recipient
+ String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
+ String password = "password";
+ jmapServer.serverProbe().addUser(recipientAddress, password);
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
+
+ String bccAddress = "bob" + "@" + USERS_DOMAIN;
+ jmapServer.serverProbe().addUser(bccAddress, password);
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, bccAddress, "inbox");
+ await();
+ AccessToken bccToken = JmapAuthentication.authenticateJamesUser(bccAddress, password);
+
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = username;
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"recipient\", \"email\": \"" + recipientAddress + "\"}]," +
+ " \"bcc\": [{ \"name\": \"BOB\", \"email\": \"" + bccAddress + "\" }]," +
+ " \"cc\": [{ \"name\": \"ALICE\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ // Given
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", this.accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+
+ // Then
+ calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInRecipientsMailboxes(bccToken));
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", bccToken.serialize())
+ .body("[[\"getMessageList\", {\"fetchMessages\": true, \"fetchMessageProperties\": [\"bcc\"] }, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .log().ifValidationFails()
+ .statusCode(200)
+ .body(SECOND_NAME, equalTo("messages"))
+ .body(SECOND_ARGUMENTS + ".list", hasSize(1))
+ .body(SECOND_ARGUMENTS + ".list[0].bcc", empty());
+ }
+
+ private boolean isAnyMessageFoundInRecipientsMailboxes(AccessToken recipientToken) {
+ try {
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", recipientToken.serialize())
+ .body("[[\"getMessageList\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", hasSize(1))
+ ;
+ return true;
+ } catch(AssertionError e) {
+ return false;
+ }
+ }
+
+
+ @Test
+ public void setMessagesShouldSendAReadableHtmlMessage() throws Exception {
+ // Sender
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
+ // Recipient
+ String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
+ String password = "password";
+ jmapServer.serverProbe().addUser(recipientAddress, password);
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
+ await();
+ AccessToken recipientToken = JmapAuthentication.authenticateJamesUser(recipientAddress, password);
+
+ String messageCreationId = "user|inbox|1";
+ String fromAddress = username;
+ String requestBody = "[" +
+ " [" +
+ " \"setMessages\","+
+ " {" +
+ " \"create\": { \"" + messageCreationId + "\" : {" +
+ " \"from\": { \"email\": \"" + fromAddress + "\"}," +
+ " \"to\": [{ \"name\": \"BOB\", \"email\": \"" + recipientAddress + "\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"htmlBody\": \"Hello <b>someone</b>, and thank you for joining example.com!\"," +
+ " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+
+ // Given
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", this.accessToken.serialize())
+ .body(requestBody)
+ // When
+ .when()
+ .post("/jmap");
+
+ // Then
+ calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isHtmlMessageReceived(recipientToken));
+ }
+
+ private boolean isHtmlMessageReceived(AccessToken recipientToken) {
+ try {
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", recipientToken.serialize())
+ .body("[[\"getMessageList\", {\"fetchMessages\": true, \"fetchMessageProperties\": [\"htmlBody\"]}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(SECOND_NAME, equalTo("messages"))
+ .body(SECOND_ARGUMENTS + ".list", hasSize(1))
+ .body(SECOND_ARGUMENTS + ".list[0].htmlBody", equalTo("Hello <b>someone</b>, and thank you for joining example.com!"))
+ ;
+ return true;
+ } catch(AssertionError e) {
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
new file mode 100644
index 0000000..84fbdd9
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>james-server</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>memory-jmap-integration-testing</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: JMAP :: Memory Integration testing</name>
+
+ <profiles>
+ <profile>
+ <id>noTest</id>
+ <activation>
+ <os>
+ <family>windows</family>
+ </os>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>disable-build-for-older-jdk</id>
+ <activation>
+ <jdk>(,1.8)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-install</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-resources</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testResources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-descriptor</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>build-for-jdk-8</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-jmap-integration-testing</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-memory-guice</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.restassured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>fully.qualified.MainClass</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>disable-animal-sniffer</id>
+ <activation>
+ <jdk>[1.6,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check_java_6</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMailboxesMethodTest.java
new file mode 100644
index 0000000..3680fb0
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMailboxesMethodTest.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.jmap.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.methods.integration.GetMailboxesMethodTest;
+import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class MemoryGetMailboxesMethodTest extends GetMailboxesMethodTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<InMemoryId>(){})
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessageListMethodTest.java
new file mode 100644
index 0000000..aa95f37
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessageListMethodTest.java
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.jmap.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.methods.integration.GetMessageListMethodTest;
+import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class MemoryGetMessageListMethodTest extends GetMessageListMethodTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<InMemoryId>(){})
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder));
+ }
+
+ @Override
+ protected void await() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessagesMethodTest.java
new file mode 100644
index 0000000..cfbf467
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetMessagesMethodTest.java
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.jmap.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.methods.integration.GetMessagesMethodTest;
+import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class MemoryGetMessagesMethodTest extends GetMessagesMethodTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<InMemoryId>(){})
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder));
+ }
+
+ @Override
+ protected void await() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapAuthenticationTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapAuthenticationTest.java
new file mode 100644
index 0000000..8b91003
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapAuthenticationTest.java
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.jmap.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.FixedDateZonedDateTimeProvider;
+import org.apache.james.jmap.JMAPAuthenticationTest;
+import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.apache.james.jmap.utils.ZonedDateTimeProvider;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class MemoryJmapAuthenticationTest extends JMAPAuthenticationTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer(FixedDateZonedDateTimeProvider zonedDateTimeProvider) {
+ return new GuiceJamesServer<>(new TypeLiteral<InMemoryId>(){})
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder),
+ (binder) -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetMessagesMethodTest.java
new file mode 100644
index 0000000..e4e65ff
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetMessagesMethodTest.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.jmap.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.jmap.methods.integration.SetMessagesMethodTest;
+import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class MemorySetMessagesMethodTest extends SetMessagesMethodTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<InMemoryId>(){})
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder));
+ }
+
+ @Override
+ protected void await() {
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[03/24] james-project git commit: JAMES-1693 Provide an InMemory
domain list
Posted by ma...@apache.org.
JAMES-1693 Provide an InMemory domain list
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e62f6f66
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e62f6f66
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e62f6f66
Branch: refs/heads/master
Commit: e62f6f66739ff21e9229d925cbcb6f82f0875d42
Parents: 70f6925
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Feb 29 11:00:58 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:03:55 2016 +0100
----------------------------------------------------------------------
server/data/data-memory/pom.xml | 6 ++
.../domainlist/memory/MemoryDomainList.java | 62 ++++++++++++++++++++
.../domainlist/memory/MemoryDomainListTest.java | 38 ++++++++++++
3 files changed, 106 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/e62f6f66/server/data/data-memory/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-memory/pom.xml b/server/data/data-memory/pom.xml
index e8fbcc1..fcd01e3 100644
--- a/server/data/data-memory/pom.xml
+++ b/server/data/data-memory/pom.xml
@@ -53,6 +53,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-dnsservice-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e62f6f66/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java b/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
new file mode 100644
index 0000000..f6da3f7
--- /dev/null
+++ b/server/data/data-memory/src/main/java/org/apache/james/domainlist/memory/MemoryDomainList.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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.domainlist.memory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.domainlist.lib.AbstractDomainList;
+
+import com.google.common.collect.ImmutableList;
+
+public class MemoryDomainList extends AbstractDomainList {
+
+ private final List<String> domains;
+
+ public MemoryDomainList() {
+ this.domains = new ArrayList<String>();
+ }
+
+ @Override
+ protected List<String> getDomainListInternal() throws DomainListException {
+ return ImmutableList.copyOf(domains);
+ }
+
+ @Override
+ public boolean containsDomain(String domain) throws DomainListException {
+ return domains.contains(domain.toLowerCase());
+ }
+
+ @Override
+ public void addDomain(String domain) throws DomainListException {
+ if (containsDomain(domain)) {
+ throw new DomainListException(domain.toLowerCase() + " already exists.");
+ }
+ domains.add(domain.toLowerCase());
+ }
+
+ @Override
+ public void removeDomain(String domain) throws DomainListException {
+ if (!domains.remove(domain.toLowerCase())) {
+ throw new DomainListException(domain.toLowerCase() + " was not found");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/e62f6f66/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java b/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
new file mode 100644
index 0000000..d23f6ef
--- /dev/null
+++ b/server/data/data-memory/src/test/java/org/apache/james/domainlist/memory/MemoryDomainListTest.java
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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.domainlist.memory;
+
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.lib.AbstractDomainListTest;
+import org.slf4j.LoggerFactory;
+
+public class MemoryDomainListTest extends AbstractDomainListTest {
+
+ @Override
+ protected DomainList createDomainList() {
+ MemoryDomainList testee = new MemoryDomainList();
+ testee.setLog(LoggerFactory.getLogger(getClass()));
+ testee.setDNSService(getDNSServer("localhost"));
+ testee.setAutoDetect(false);
+ testee.setAutoDetectIP(false);
+ return testee;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[24/24] james-project git commit: JAMES-1693 JMAP integration testing
compilation for specific backends should be activated by specific profiles
Posted by ma...@apache.org.
JAMES-1693 JMAP integration testing compilation for specific backends should be activated by specific profiles
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/82a88f6e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/82a88f6e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/82a88f6e
Branch: refs/heads/master
Commit: 82a88f6ea6864365c7e2240fd047ed024af7cdd0
Parents: 583b48f
Author: Benoit Tellier <bt...@linagora.com>
Authored: Tue Mar 8 16:29:07 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:07:13 2016 +0100
----------------------------------------------------------------------
server/pom.xml | 4 +-
.../cassandra-jmap-integration-testing/pom.xml | 4 +-
.../jmap-integration-testing-common/pom.xml | 4 +-
.../memory-jmap-integration-testing/pom.xml | 4 +-
.../protocols/jmap-integration-testing/pom.xml | 57 ++++++++++++++++++++
5 files changed, 64 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/82a88f6e/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index ae05069..5a4e8e6 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -92,9 +92,7 @@
<module>protocols/fetchmail</module>
<module>protocols/protocols-imap4</module>
<module>protocols/jmap</module>
- <module>protocols/jmap-integration-testing/cassandra-jmap-integration-testing</module>
- <module>protocols/jmap-integration-testing/memory-jmap-integration-testing</module>
- <module>protocols/jmap-integration-testing/jmap-integration-testing-common</module>
+ <module>protocols/jmap-integration-testing</module>
<module>protocols/protocols-library</module>
<module>protocols/protocols-lmtp</module>
<module>protocols/protocols-managesieve</module>
http://git-wip-us.apache.org/repos/asf/james-project/blob/82a88f6e/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
index c5b6f4e..c92330a 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
@@ -22,10 +22,10 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>james-server</artifactId>
+ <artifactId>jmap-integration-testing</artifactId>
<groupId>org.apache.james</groupId>
<version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>cassandra-jmap-integration-testing</artifactId>
http://git-wip-us.apache.org/repos/asf/james-project/blob/82a88f6e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
index 084c9e1..73613d4 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
@@ -22,10 +22,10 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>james-server</artifactId>
+ <artifactId>jmap-integration-testing</artifactId>
<groupId>org.apache.james</groupId>
<version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>james-server-jmap-integration-testing</artifactId>
http://git-wip-us.apache.org/repos/asf/james-project/blob/82a88f6e/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
index 84fbdd9..e6d15cc 100644
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
@@ -22,10 +22,10 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>james-server</artifactId>
+ <artifactId>jmap-integration-testing</artifactId>
<groupId>org.apache.james</groupId>
<version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>memory-jmap-integration-testing</artifactId>
http://git-wip-us.apache.org/repos/asf/james-project/blob/82a88f6e/server/protocols/jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/pom.xml
new file mode 100644
index 0000000..24bb2f1
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>james-server</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>jmap-integration-testing</artifactId>
+ <name>Apache James :: Server :: JMAP :: Integration testing</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>jmap-integration-testing-common</module>
+ </modules>
+
+ <profiles>
+ <profile>
+ <id>cassandra</id>
+ <modules>
+ <module>cassandra-jmap-integration-testing</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>inmemory</id>
+ <modules>
+ <module>memory-jmap-integration-testing</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
+
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[06/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/SetMessagesMethodTest.java
deleted file mode 100644
index 06216c7..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/SetMessagesMethodTest.java
+++ /dev/null
@@ -1,1372 +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.jmap.methods;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.RestAssured.with;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.endsWith;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasEntry;
-import static org.hamcrest.Matchers.hasKey;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.isEmptyOrNullString;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
-import static org.hamcrest.collection.IsMapWithSize.anEmptyMap;
-
-import java.io.ByteArrayInputStream;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import javax.mail.Flags;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapAuthentication;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.api.access.AccessToken;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.hamcrest.Matchers;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Charsets;
-import com.jayway.awaitility.Awaitility;
-import com.jayway.awaitility.Duration;
-import com.jayway.awaitility.core.ConditionFactory;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.builder.ResponseSpecBuilder;
-import com.jayway.restassured.http.ContentType;
-import com.jayway.restassured.specification.ResponseSpecification;
-
-public abstract class SetMessagesMethodTest {
-
- private static final String NAME = "[0][0]";
- private static final String ARGUMENTS = "[0][1]";
- private static final String SECOND_NAME = "[1][0]";
- private static final String SECOND_ARGUMENTS = "[1][1]";
- private static final String USERS_DOMAIN = "domain.tld";
-
- private final TemporaryFolder temporaryFolder = new TemporaryFolder();
- private final EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
- private final EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
- private final JmapServer jmapServer = jmapServer(temporaryFolder, embeddedElasticSearch, cassandra);
- private ConditionFactory calmlyAwait;
-
- protected abstract JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra);
-
- @Rule
- public RuleChain chain = RuleChain
- .outerRule(temporaryFolder)
- .around(embeddedElasticSearch)
- .around(jmapServer);
-
- private AccessToken accessToken;
- private String username;
-
- @Before
- public void setup() throws Exception {
- RestAssured.port = jmapServer.getPort();
- RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-
- username = "username@" + USERS_DOMAIN;
- String password = "password";
- jmapServer.serverProbe().addDomain(USERS_DOMAIN);
- jmapServer.serverProbe().addUser(username, password);
- jmapServer.serverProbe().createMailbox("#private", username, "inbox");
- accessToken = JmapAuthentication.authenticateJamesUser(username, password);
-
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "outbox");
- embeddedElasticSearch.awaitForElasticSearch();
-
- Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
- calmlyAwait = Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
- }
-
- private String getOutboxId() {
- // Find username's outbox (using getMailboxes command on /jmap endpoint)
- return getAllMailboxesIds(accessToken).stream()
- .filter(x -> x.get("role").equals("outbox"))
- .map(x -> x.get("id"))
- .findFirst().get();
- }
-
- private List<Map<String, String>> getAllMailboxesIds(AccessToken accessToken) {
- return with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMailboxes\", {\"properties\": [\"role\", \"id\"]}, \"#0\"]]")
- .post("/jmap")
- .andReturn()
- .body()
- .jsonPath()
- .getList(ARGUMENTS + ".list");
- }
-
- @Test
- public void setMessagesShouldReturnErrorNotSupportedWhenRequestContainsNonNullAccountId() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"accountId\": \"1\"}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("error"))
- .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
- }
-
- @Test
- public void setMessagesShouldReturnErrorNotSupportedWhenRequestContainsNonNullIfInState() throws Exception {
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"ifInState\": \"1\"}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("error"))
- .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
- }
-
- @Test
- public void setMessagesShouldReturnNotDestroyedWhenUnknownMailbox() throws Exception {
-
- String unknownMailboxMessageId = username + "|unknown|12345";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"destroy\": [\"" + unknownMailboxMessageId + "\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".destroyed", empty())
- .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(unknownMailboxMessageId), Matchers.allOf(
- hasEntry("type", "anErrorOccurred"),
- hasEntry("description", "An error occurred while deleting message " + unknownMailboxMessageId),
- hasEntry(equalTo("properties"), isEmptyOrNullString())))
- );
- }
-
- @Test
- public void setMessagesShouldReturnNotDestroyedWhenNoMatchingMessage() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- String messageId = username + "|mailbox|12345";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"destroy\": [\"" + messageId + "\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".destroyed", empty())
- .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(messageId), Matchers.allOf(
- hasEntry("type", "notFound"),
- hasEntry("description", "The message " + messageId + " can't be found"),
- hasEntry(equalTo("properties"), isEmptyOrNullString())))
- );
- }
-
- @Test
- public void setMessagesShouldReturnDestroyedWhenMatchingMessage() throws Exception {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".notDestroyed", anEmptyMap())
- .body(ARGUMENTS + ".destroyed", hasSize(1))
- .body(ARGUMENTS + ".destroyed", contains(username + "|mailbox|1"));
- }
-
- @Test
- public void setMessagesShouldDeleteMessageWhenMatchingMessage() throws Exception {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- // When
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200);
-
- // Then
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + username + "|mailbox|1\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", empty());
- }
-
- @Test
- public void setMessagesShouldReturnDestroyedNotDestroyWhenMixed() throws Exception {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String missingMessageId = username + "|mailbox|4";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\", \"" + missingMessageId + "\", \"" + username + "|mailbox|3\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".destroyed", hasSize(2))
- .body(ARGUMENTS + ".notDestroyed", aMapWithSize(1))
- .body(ARGUMENTS + ".destroyed", contains(username + "|mailbox|1", username + "|mailbox|3"))
- .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(missingMessageId), Matchers.allOf(
- hasEntry("type", "notFound"),
- hasEntry("description", "The message " + missingMessageId + " can't be found")))
- );
- }
-
- @Test
- public void setMessagesShouldDeleteMatchingMessagesWhenMixed() throws Exception {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- // When
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"setMessages\", {\"destroy\": [\"" + username + "|mailbox|1\", \"" + username + "|mailbox|4\", \"" + username + "|mailbox|3\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200);
-
- // Then
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + username + "|mailbox|1\", \"" + username + "|mailbox|2\", \"" + username + "|mailbox|3\"]}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1));
- }
-
- @Test
- public void setMessagesShouldReturnUpdatedIdAndNoErrorWhenIsUnreadPassedToFalse() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
-
- // When
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : false } } }, \"#0\"]]", presumedMessageId))
- .when()
- .post("/jmap")
- // Then
- .then()
- .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
- .log().ifValidationFails();
- }
-
- private ResponseSpecification getSetMessagesUpdateOKResponseAssertions(String messageId) {
- ResponseSpecBuilder builder = new ResponseSpecBuilder()
- .expectStatusCode(200)
- .expectBody(NAME, equalTo("messagesSet"))
- .expectBody(ARGUMENTS + ".updated", hasSize(1))
- .expectBody(ARGUMENTS + ".updated", contains(messageId))
- .expectBody(ARGUMENTS + ".error", isEmptyOrNullString())
- .expectBody(ARGUMENTS + ".notUpdated", not(hasKey(messageId)));
- return builder.build();
- }
-
- @Test
- public void setMessagesShouldMarkAsReadWhenIsUnreadPassedToFalse() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : false } } }, \"#0\"]]", presumedMessageId))
- // When
- .when()
- .post("/jmap");
- // Then
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].isUnread", equalTo(false))
- .log().ifValidationFails();
- }
-
- @Test
- public void setMessagesShouldReturnUpdatedIdAndNoErrorWhenIsUnreadPassed() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags(Flags.Flag.SEEN));
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : true } } }, \"#0\"]]", presumedMessageId))
- // When
- .when()
- .post("/jmap")
- // Then
- .then()
- .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
- .log().ifValidationFails();
- }
-
- @Test
- public void setMessagesShouldMarkAsUnreadWhenIsUnreadPassed() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags(Flags.Flag.SEEN));
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : true } } }, \"#0\"]]", presumedMessageId))
- // When
- .when()
- .post("/jmap");
- // Then
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
- .post("/jmap")
- .then()
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].isUnread", equalTo(true))
- .log().ifValidationFails();
- }
-
-
- @Test
- public void setMessagesShouldReturnUpdatedIdAndNoErrorWhenIsFlaggedPassed() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isFlagged\" : true } } }, \"#0\"]]", presumedMessageId))
- // When
- .when()
- .post("/jmap")
- // Then
- .then()
- .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
- .log().ifValidationFails();
- }
-
- @Test
- public void setMessagesShouldMarkAsFlaggedWhenIsFlaggedPassed() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isFlagged\" : true } } }, \"#0\"]]", presumedMessageId))
- // When
- .when()
- .post("/jmap");
- // Then
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
- .post("/jmap")
- .then()
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].isFlagged", equalTo(true))
- .log().ifValidationFails();
- }
-
- @Test
- public void setMessagesShouldRejectUpdateWhenPropertyHasWrongType() throws MailboxException {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- embeddedElasticSearch.awaitForElasticSearch();
-
- String messageId = username + "|mailbox|1";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : \"123\" } } }, \"#0\"]]", messageId))
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".notUpdated", hasKey(messageId))
- .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].type", equalTo("invalidProperties"))
- .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties[0]", equalTo("isUnread"))
- .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].description", equalTo("isUnread: Can not construct instance of java.lang.Boolean from String value '123': only \"true\" or \"false\" recognized\n" +
- " at [Source: {\"isUnread\":\"123\"}; line: 1, column: 2] (through reference chain: org.apache.james.jmap.model.Builder[\"isUnread\"])"))
- .body(ARGUMENTS + ".updated", hasSize(0));
- }
-
- @Test
- @Ignore("Jackson json deserializer stops after first error found")
- public void setMessagesShouldRejectUpdateWhenPropertiesHaveWrongTypes() throws MailboxException {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
-
- embeddedElasticSearch.awaitForElasticSearch();
-
- String messageId = username + "|mailbox|1";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : \"123\", \"isFlagged\" : 456 } } }, \"#0\"]]", messageId))
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".notUpdated", hasKey(messageId))
- .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].type", equalTo("invalidProperties"))
- .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties", hasSize(2))
- .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties[0]", equalTo("isUnread"))
- .body(ARGUMENTS + ".notUpdated[\""+messageId+"\"].properties[1]", equalTo("isFlagged"))
- .body(ARGUMENTS + ".updated", hasSize(0));
- }
-
- @Test
- public void setMessagesShouldMarkMessageAsAnsweredWhenIsAnsweredPassed() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
- // When
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isAnswered\" : true } } }, \"#0\"]]", presumedMessageId))
- .when()
- .post("/jmap")
- // Then
- .then()
- .spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId))
- .log().ifValidationFails();
- }
-
- @Test
- public void setMessagesShouldMarkAsAnsweredWhenIsAnsweredPassed() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
- new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
- embeddedElasticSearch.awaitForElasticSearch();
-
- String presumedMessageId = username + "|mailbox|1";
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isAnswered\" : true } } }, \"#0\"]]", presumedMessageId))
- // When
- .when()
- .post("/jmap");
- // Then
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
- .post("/jmap")
- .then()
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].isAnswered", equalTo(true))
- .log().ifValidationFails();
- }
-
- @Test
- public void setMessageShouldReturnNotFoundWhenUpdateUnknownMessage() {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
-
- String nonExistingMessageId = username + "|mailbox|12345";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : true } } }, \"#0\"]]", nonExistingMessageId))
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".notUpdated", hasKey(nonExistingMessageId))
- .body(ARGUMENTS + ".notUpdated[\""+nonExistingMessageId+"\"].type", equalTo("notFound"))
- .body(ARGUMENTS + ".notUpdated[\""+nonExistingMessageId+"\"].description", equalTo("message not found"))
- .body(ARGUMENTS + ".updated", hasSize(0));
- }
-
- @Test
- public void setMessageShouldReturnCreatedMessageWhenSendingMessage() {
- String messageCreationId = "user|inbox|1";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".notCreated", aMapWithSize(0))
- // note that assertions on result message had to be split between
- // string-typed values and boolean-typed value assertions on the same .created entry
- // make sure only one creation has been processed
- .body(ARGUMENTS + ".created", aMapWithSize(1))
- // assert server-set attributes are returned
- .body(ARGUMENTS + ".created", hasEntry(equalTo(messageCreationId), Matchers.allOf(
- hasEntry(equalTo("id"), not(isEmptyOrNullString())),
- hasEntry(equalTo("blobId"), not(isEmptyOrNullString())),
- hasEntry(equalTo("threadId"), not(isEmptyOrNullString())),
- hasEntry(equalTo("size"), not(isEmptyOrNullString()))
- )))
- // assert that message flags are all unset
- .body(ARGUMENTS + ".created", hasEntry(equalTo(messageCreationId), Matchers.allOf(
- hasEntry(equalTo("isDraft"), equalTo(false)),
- hasEntry(equalTo("isUnread"), equalTo(false)),
- hasEntry(equalTo("isFlagged"), equalTo(false)),
- hasEntry(equalTo("isAnswered"), equalTo(false))
- )))
- ;
- }
-
- @Test
- public void setMessagesShouldCreateMessageInOutboxWhenSendingMessage() throws MailboxException {
- // Given
- String messageCreationId = "user|inbox|1";
- String presumedMessageId = "username@domain.tld|outbox|1";
- String messageSubject = "Thank you for joining example.com!";
- String outboxId = getOutboxId();
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"subject\": \"" + messageSubject + "\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + outboxId + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
-
- // Then
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]")
- .post("/jmap")
- .then()
- .body(NAME, equalTo("messages"))
- .body(ARGUMENTS + ".list", hasSize(1))
- .body(ARGUMENTS + ".list[0].subject", equalTo(messageSubject))
- .body(ARGUMENTS + ".list[0].mailboxIds", contains(outboxId))
- ;
- }
-
- @Test
- public void setMessagesShouldMoveMessageInSentWhenMessageIsSent() throws MailboxException {
- // Given
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
- String sentMailboxId = getAllMailboxesIds(accessToken).stream()
- .filter(x -> x.get("role").equals("sent"))
- .map(x -> x.get("id"))
- .findFirst().get();
-
- String messageCreationId = "user|inbox|1";
- String messageSubject = "Thank you for joining example.com!";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"subject\": \"" + messageSubject + "\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
-
- // Then
- calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> messageHasBeenMovedToSentBox(sentMailboxId));
- }
-
- private boolean messageHasBeenMovedToSentBox(String sentMailboxId) {
- try {
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body("[[\"getMessageList\", {\"fetchMessages\":true, \"filter\":{\"inMailboxes\":[\"" + sentMailboxId + "\"]}}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(SECOND_NAME, equalTo("messages"))
- .body(SECOND_ARGUMENTS + ".list", hasSize(1));
- return true;
- } catch(AssertionError e) {
- return false;
- }
- }
-
- @Test
- public void setMessagesShouldRejectWhenSendingMessageHasNoValidAddress() {
- String messageCreationId = "user|inbox|1";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com@example.com\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
-
- .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].type", equalTo("invalidProperties"))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].description", endsWith("no recipient address set"))
- .body(ARGUMENTS + ".created", aMapWithSize(0));
- }
-
- @Test
- public void setMessagesShouldRejectWhenSendingMessageHasMissingFrom() {
- String messageCreationId = "user|inbox|1";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].type", equalTo("invalidProperties"))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].description", endsWith("'from' address is mandatory"))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", hasSize(1))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", contains("from"))
- .body(ARGUMENTS + ".created", aMapWithSize(0));
- }
-
- @Test
- public void setMessagesShouldSucceedWhenSendingMessageWithOnlyFromAddress() {
- String messageCreationId = "user|inbox|1";
- String fromAddress = "postmaster@example.com";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".created", aMapWithSize(1))
- .body(ARGUMENTS + ".created", hasKey(messageCreationId))
- .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].headers.from", equalTo(fromAddress))
- .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.name", equalTo(fromAddress))
- .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.email", equalTo(fromAddress));
- }
-
- @Test
- public void setMessagesShouldSucceedWithHtmlBody() {
- String messageCreationId = "user|inbox|1";
- String fromAddress = "postmaster@example.com";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"htmlBody\": \"Hello <i>someone</i>, and thank <b>you</b> for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".created", aMapWithSize(1))
- .body(ARGUMENTS + ".created", hasKey(messageCreationId))
- .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].headers.from", equalTo(fromAddress))
- .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.name", equalTo(fromAddress))
- .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].from.email", equalTo(fromAddress));
- }
-
- @Test
- public void setMessagesShouldMoveToSentWhenSendingMessageWithOnlyFromAddress() {
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
- String sentMailboxId = getAllMailboxesIds(accessToken).stream()
- .filter(x -> x.get("role").equals("sent"))
- .map(x -> x.get("id"))
- .findFirst().get();
-
- String messageCreationId = "user|inbox|1";
- String fromAddress = "postmaster@example.com";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- // Given
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
- // Then
- calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> messageHasBeenMovedToSentBox(sentMailboxId));
- }
-
-
- @Test
- public void setMessagesShouldRejectWhenSendingMessageHasMissingSubject() {
- String messageCreationId = "user|inbox|1";
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"name\": \"MAILER-DAEMON\", \"email\": \"postmaster@example.com\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", accessToken.serialize())
- .body(requestBody)
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(NAME, equalTo("messagesSet"))
- .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].type", equalTo("invalidProperties"))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", hasSize(1))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].properties", contains("subject"))
- .body(ARGUMENTS + ".notCreated[\""+messageCreationId+"\"].description", endsWith("'subject' is missing"))
- .body(ARGUMENTS + ".created", aMapWithSize(0));
- }
-
- @Test
- public void setMessagesShouldDeliverMessageToRecipient() throws Exception {
- // Sender
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
- // Recipient
- String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
- String password = "password";
- jmapServer.serverProbe().addUser(recipientAddress, password);
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
- embeddedElasticSearch.awaitForElasticSearch();
- AccessToken recipientToken = JmapAuthentication.authenticateJamesUser(recipientAddress, password);
-
- String messageCreationId = "user|inbox|1";
- String fromAddress = username;
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"" + recipientAddress + "\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- // Given
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", this.accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
-
- // Then
- calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInRecipientsMailboxes(recipientToken));
- }
-
- @Test
- public void setMessagesShouldStripBccFromDeliveredEmail() throws Exception {
- // Sender
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
- // Recipient
- String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
- String password = "password";
- jmapServer.serverProbe().addUser(recipientAddress, password);
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
- embeddedElasticSearch.awaitForElasticSearch();
- AccessToken recipientToken = JmapAuthentication.authenticateJamesUser(recipientAddress, password);
-
- String messageCreationId = "user|inbox|1";
- String fromAddress = username;
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"recipient\", \"email\": \"" + recipientAddress + "\"}]," +
- " \"bcc\": [{ \"name\": \"BOB\", \"email\": \"bob@" + USERS_DOMAIN + "\"}]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- // Given
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", this.accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
-
- // Then
- calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInRecipientsMailboxes(recipientToken));
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", recipientToken.serialize())
- .body("[[\"getMessageList\", {\"fetchMessages\": true, \"fetchMessageProperties\": [\"bcc\"] }, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(SECOND_NAME, equalTo("messages"))
- .body(SECOND_ARGUMENTS + ".list", hasSize(1))
- .body(SECOND_ARGUMENTS + ".list[0].bcc", empty());
- }
-
- @Test
- public void setMessagesShouldKeepBccInSentMailbox() throws Exception {
- // Sender
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
- String sentMailboxId = getAllMailboxesIds(accessToken).stream()
- .filter(x -> x.get("role").equals("sent"))
- .map(x -> x.get("id"))
- .findFirst().get();
-
- // Recipient
- String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
- String password = "password";
- jmapServer.serverProbe().addUser(recipientAddress, password);
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
- embeddedElasticSearch.awaitForElasticSearch();
-
- String messageCreationId = "user|inbox|1";
- String fromAddress = username;
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"recipient\", \"email\": \"" + recipientAddress + "\"}]," +
- " \"bcc\": [{ \"name\": \"BOB\", \"email\": \"bob@" + USERS_DOMAIN + "\" }]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- // Given
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", this.accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
-
- // Then
- calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> messageHasBeenMovedToSentBox(sentMailboxId));
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", this.accessToken.serialize())
- .body("[[\"getMessageList\", {\"fetchMessages\":true, \"fetchMessageProperties\": [\"bcc\"], \"filter\":{\"inMailboxes\":[\"" + sentMailboxId + "\"]}}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(SECOND_NAME, equalTo("messages"))
- .body(SECOND_ARGUMENTS + ".list", hasSize(1))
- .body(SECOND_ARGUMENTS + ".list[0].bcc", hasSize(1));
- }
-
- @Test
- public void setMessagesShouldSendMessageToBcc() throws Exception {
- // Sender
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
-
- // Recipient
- String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
- String password = "password";
- jmapServer.serverProbe().addUser(recipientAddress, password);
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
- embeddedElasticSearch.awaitForElasticSearch();
-
- String bccAddress = "bob" + "@" + USERS_DOMAIN;
- jmapServer.serverProbe().addUser(bccAddress, password);
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, bccAddress, "inbox");
- embeddedElasticSearch.awaitForElasticSearch();
- AccessToken bccToken = JmapAuthentication.authenticateJamesUser(bccAddress, password);
-
- String messageCreationId = "user|inbox|1";
- String fromAddress = username;
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"recipient\", \"email\": \"" + recipientAddress + "\"}]," +
- " \"bcc\": [{ \"name\": \"BOB\", \"email\": \"" + bccAddress + "\" }]," +
- " \"cc\": [{ \"name\": \"ALICE\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- // Given
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", this.accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
-
- // Then
- calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInRecipientsMailboxes(bccToken));
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", bccToken.serialize())
- .body("[[\"getMessageList\", {\"fetchMessages\": true, \"fetchMessageProperties\": [\"bcc\"] }, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .log().ifValidationFails()
- .statusCode(200)
- .body(SECOND_NAME, equalTo("messages"))
- .body(SECOND_ARGUMENTS + ".list", hasSize(1))
- .body(SECOND_ARGUMENTS + ".list[0].bcc", empty());
- }
-
- private boolean isAnyMessageFoundInRecipientsMailboxes(AccessToken recipientToken) {
- try {
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", recipientToken.serialize())
- .body("[[\"getMessageList\", {}, \"#0\"]]")
- .when()
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(NAME, equalTo("messageList"))
- .body(ARGUMENTS + ".messageIds", hasSize(1))
- ;
- return true;
- } catch(AssertionError e) {
- return false;
- }
- }
-
-
- @Test
- public void setMessagesShouldSendAReadableHtmlMessage() throws Exception {
- // Sender
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent");
- // Recipient
- String recipientAddress = "recipient" + "@" + USERS_DOMAIN;
- String password = "password";
- jmapServer.serverProbe().addUser(recipientAddress, password);
- jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox");
- embeddedElasticSearch.awaitForElasticSearch();
- AccessToken recipientToken = JmapAuthentication.authenticateJamesUser(recipientAddress, password);
-
- String messageCreationId = "user|inbox|1";
- String fromAddress = username;
- String requestBody = "[" +
- " [" +
- " \"setMessages\","+
- " {" +
- " \"create\": { \"" + messageCreationId + "\" : {" +
- " \"from\": { \"email\": \"" + fromAddress + "\"}," +
- " \"to\": [{ \"name\": \"BOB\", \"email\": \"" + recipientAddress + "\"}]," +
- " \"subject\": \"Thank you for joining example.com!\"," +
- " \"htmlBody\": \"Hello <b>someone</b>, and thank you for joining example.com!\"," +
- " \"mailboxIds\": [\"" + getOutboxId() + "\"]" +
- " }}" +
- " }," +
- " \"#0\"" +
- " ]" +
- "]";
-
- // Given
- given()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", this.accessToken.serialize())
- .body(requestBody)
- // When
- .when()
- .post("/jmap");
-
- // Then
- calmlyAwait.atMost(10, TimeUnit.SECONDS).until( () -> isHtmlMessageReceived(recipientToken));
- }
-
- private boolean isHtmlMessageReceived(AccessToken recipientToken) {
- try {
- with()
- .accept(ContentType.JSON)
- .contentType(ContentType.JSON)
- .header("Authorization", recipientToken.serialize())
- .body("[[\"getMessageList\", {\"fetchMessages\": true, \"fetchMessageProperties\": [\"htmlBody\"]}, \"#0\"]]")
- .post("/jmap")
- .then()
- .statusCode(200)
- .body(SECOND_NAME, equalTo("messages"))
- .body(SECOND_ARGUMENTS + ".list", hasSize(1))
- .body(SECOND_ARGUMENTS + ".list[0].htmlBody", equalTo("Hello <b>someone</b>, and thank you for joining example.com!"))
- ;
- return true;
- } catch(AssertionError e) {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMailboxesMethodTest.java
deleted file mode 100644
index 405d6c6..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMailboxesMethodTest.java
+++ /dev/null
@@ -1,35 +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.jmap.methods.cassandra;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.cassandra.CassandraJmapServer;
-import org.apache.james.jmap.methods.GetMailboxesMethodTest;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.rules.TemporaryFolder;
-
-public class CassandraGetMailboxesMethodTest extends GetMailboxesMethodTest {
-
- @Override
- protected JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
- return new CassandraJmapServer(CassandraJmapServer.defaultOverrideModule(temporaryFolder, embeddedElasticSearch, cassandra));
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessageListMethodTest.java
deleted file mode 100644
index 524f523..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessageListMethodTest.java
+++ /dev/null
@@ -1,35 +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.jmap.methods.cassandra;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.cassandra.CassandraJmapServer;
-import org.apache.james.jmap.methods.GetMessageListMethodTest;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.rules.TemporaryFolder;
-
-public class CassandraGetMessageListMethodTest extends GetMessageListMethodTest {
-
- @Override
- protected JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
- return new CassandraJmapServer(CassandraJmapServer.defaultOverrideModule(temporaryFolder, embeddedElasticSearch, cassandra));
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessagesMethodTest.java
deleted file mode 100644
index 04cdba8..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraGetMessagesMethodTest.java
+++ /dev/null
@@ -1,35 +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.jmap.methods.cassandra;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.cassandra.CassandraJmapServer;
-import org.apache.james.jmap.methods.GetMessagesMethodTest;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.rules.TemporaryFolder;
-
-public class CassandraGetMessagesMethodTest extends GetMessagesMethodTest {
-
- @Override
- protected JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
- return new CassandraJmapServer(CassandraJmapServer.defaultOverrideModule(temporaryFolder, embeddedElasticSearch, cassandra));
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraSetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraSetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraSetMessagesMethodTest.java
deleted file mode 100644
index 6d48f4b..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/cassandra/CassandraSetMessagesMethodTest.java
+++ /dev/null
@@ -1,35 +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.jmap.methods.cassandra;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.jmap.cassandra.CassandraJmapServer;
-import org.apache.james.jmap.methods.SetMessagesMethodTest;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.rules.TemporaryFolder;
-
-public class CassandraSetMessagesMethodTest extends SetMessagesMethodTest {
-
- @Override
- protected JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
- return new CassandraJmapServer(CassandraJmapServer.defaultOverrideModule(temporaryFolder, embeddedElasticSearch, cassandra));
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/dnsservice.xml b/server/protocols/jmap-integration-testing/src/test/resources/dnsservice.xml
deleted file mode 100644
index 0978a00..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/dnsservice.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.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.
- -->
-
-<dnsservice>
- <servers>
- <server>8.8.8.8</server>
- <server>62.210.16.6</server>
- </servers>
- <autodiscover>false</autodiscover>
- <authoritative>false</authoritative>
- <maxcachesize>50000</maxcachesize>
-</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/fakemailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/fakemailrepositorystore.xml b/server/protocols/jmap-integration-testing/src/test/resources/fakemailrepositorystore.xml
deleted file mode 100644
index 2d19a80..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/fakemailrepositorystore.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailrepositorystore>
- <mailrepositories>
- <mailrepository class="org.apache.james.mailrepository.None">
- <protocols>
- <protocol>file</protocol>
- </protocols>
- <config FIFO="false" CACHEKEYS="true"/>
- </mailrepository>
- </mailrepositories>
-</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/imapserver.xml b/server/protocols/jmap-integration-testing/src/test/resources/imapserver.xml
deleted file mode 100644
index ff478a9..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/imapserver.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.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.
--->
-
-
-<imapservers>
- <imapserver enabled="true">
- <jmxName>imapserver</jmxName>
- <bind>0.0.0.0:1143</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
- <imapserver enabled="true">
- <jmxName>imapserver-ssl</jmxName>
- <bind>0.0.0.0:1993</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
-</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/keystore b/server/protocols/jmap-integration-testing/src/test/resources/keystore
deleted file mode 100644
index 536a6c7..0000000
Binary files a/server/protocols/jmap-integration-testing/src/test/resources/keystore and /dev/null differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/lmtpserver.xml b/server/protocols/jmap-integration-testing/src/test/resources/lmtpserver.xml
deleted file mode 100644
index 5c4a9c7..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/lmtpserver.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.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.
- -->
-
-<lmtpservers>
-
- <lmtpserver enabled="true">
- <jmxName>lmtpserver</jmxName>
- <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
- <bind>127.0.0.1:1024</bind>
- <connectionBacklog>200</connectionBacklog>
- <connectiontimeout>1200</connectiontimeout>
- <!-- Set the maximum simultaneous incoming connections for this service -->
- <connectionLimit>0</connectionLimit>
- <!-- Set the maximum simultaneous incoming connections per IP for this service -->
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!-- This sets the maximum allowed message size (in kilobytes) for this -->
- <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
- <maxmessagesize>0</maxmessagesize>
- <handlerchain>
- <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </lmtpserver>
-
-</lmtpservers>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[15/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/pom.xml b/server/container/guice/guice-common/pom.xml
new file mode 100644
index 0000000..291aa47
--- /dev/null
+++ b/server/container/guice/guice-common/pom.xml
@@ -0,0 +1,291 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>james-server</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>james-server-guice-common</artifactId>
+
+ <name>Apache James :: Server :: Guice Common</name>
+ <description>Common modules for Guice implementation of James server</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>disable-build-for-older-jdk</id>
+ <activation>
+ <jdk>(,1.8)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-install</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-resources</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testResources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-descriptor</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>build-for-jdk-8</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-tool</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-mailet-standard</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-cli</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-data-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-data-file</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-data-library</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-dnsservice-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-dnsservice-dnsjava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-dnsservice-library</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-filesystem-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-jmap</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-mailets</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-mailetcontainer-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-mailetcontainer-camel</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-protocols-imap4</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-protocols-library</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-protocols-lmtp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-protocols-managesieve</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-protocols-pop3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-protocols-smtp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-queue-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-queue-activemq</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james.protocols</groupId>
+ <artifactId>protocols-imap</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james.protocols</groupId>
+ <artifactId>protocols-managesieve</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-multibindings</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.restassured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.onami.lifecycle</groupId>
+ <artifactId>org.apache.onami.lifecycle.jsr250</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-3.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>disable-animal-sniffer</id>
+ <activation>
+ <jdk>[1.6,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check_java_6</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/cassandra.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/cassandra.properties b/server/container/guice/guice-common/sample-configuration/cassandra.properties
new file mode 100644
index 0000000..1358332
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/cassandra.properties
@@ -0,0 +1,6 @@
+# Configuration file for cassandra mailbox
+
+cassandra.ip=172.17.0.2
+cassandra.port=9042
+cassandra.keyspace=apache_james
+cassandra.replication.factor=1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/dnsservice.xml b/server/container/guice/guice-common/sample-configuration/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/dnsservice.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/domainlist.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/domainlist.xml b/server/container/guice/guice-common/sample-configuration/domainlist.xml
new file mode 100644
index 0000000..8d00118
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/domainlist.xml
@@ -0,0 +1,28 @@
+<?xml version="1.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.
+ -->
+
+<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
+ <domainnames>
+ <domainname>james.apache.org</domainname>
+ </domainnames>
+ <autodetect>true</autodetect>
+ <autodetectIP>true</autodetectIP>
+ <defaultDomain>localhost</defaultDomain>
+</domainlist>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/elasticsearch.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/elasticsearch.properties b/server/container/guice/guice-common/sample-configuration/elasticsearch.properties
new file mode 100644
index 0000000..924404c
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/elasticsearch.properties
@@ -0,0 +1,26 @@
+# 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.
+
+# This template file can be used as example for James Server configuration
+# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+# Configuration file for ElasticSearch
+
+elasticsearch.masterHost=172.17.0.1
+elasticsearch.port=9300
+elasticsearch.nb.shards=1
+elasticsearch.nb.replica=0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/imapserver.xml b/server/container/guice/guice-common/sample-configuration/imapserver.xml
new file mode 100644
index 0000000..c03b978
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/imapserver.xml
@@ -0,0 +1,54 @@
+<?xml version="1.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.
+-->
+
+
+<imapservers>
+ <imapserver enabled="true">
+ <jmxName>imapserver</jmxName>
+ <bind>0.0.0.0:1143</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="true">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+ <imapserver enabled="true">
+ <jmxName>imapserver-ssl</jmxName>
+ <bind>0.0.0.0:1993</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="true" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/jcr-repository.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/jcr-repository.xml b/server/container/guice/guice-common/sample-configuration/jcr-repository.xml
new file mode 100644
index 0000000..c1b998a
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/jcr-repository.xml
@@ -0,0 +1,72 @@
+<?xml version="1.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.
+-->
+
+<!--
+ This template file can be used as example for James Server configuration
+ DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<!DOCTYPE Repository
+ PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 2.0//EN"
+ "http://jackrabbit.apache.org/dtd/repository-2.0.dtd">
+
+<Repository>
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/repository"/>
+ </FileSystem>
+ <DataStore class="org.apache.jackrabbit.core.data.FileDataStore"/>
+ <Security appName="Jackrabbit">
+ <SecurityManager class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager" workspaceName="security">
+ </SecurityManager>
+ <AccessManager class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
+ </AccessManager>
+ <LoginModule class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
+ <param name="anonymousId" value="anonymous"/>
+ <param name="adminId" value="admin"/>
+ </LoginModule>
+ </Security>
+ <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="james"/>
+ <Workspace name="${wsp.name}">
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}"/>
+ </FileSystem>
+ <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+ <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+ <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+ </PersistenceManager>
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${wsp.home}/index"/>
+ <param name="supportHighlighting" value="true"/>
+ </SearchIndex>
+ </Workspace>
+ <Versioning rootPath="${rep.home}/version">
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/version" />
+ </FileSystem>
+ <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+ <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
+ <param name="schemaObjectPrefix" value="version_"/>
+ </PersistenceManager>
+ </Versioning>
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${rep.home}/repository/index"/>
+ <param name="supportHighlighting" value="true"/>
+ </SearchIndex>
+</Repository>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/jmap.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/jmap.properties b/server/container/guice/guice-common/sample-configuration/jmap.properties
new file mode 100644
index 0000000..d785ccd
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/jmap.properties
@@ -0,0 +1,11 @@
+# Configuration file for JMAP
+
+tls.keystoreURL=file://conf/keystore
+tls.secret=james72laBalle
+
+#
+# If you wish to use OAuth authentication, you should provide a valid JWT public key.
+# The following entry specify the link to the URL of the public key file,
+# which should be a PEM format file.
+#
+jwt.publickeypem.url=
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/jmx.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/jmx.properties b/server/container/guice/guice-common/sample-configuration/jmx.properties
new file mode 100644
index 0000000..a1dbdf8
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/jmx.properties
@@ -0,0 +1,28 @@
+# 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.
+#
+
+# This template file can be used as example for James Server configuration
+# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+# This template file can be used as example for James Server configuration
+# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+# See http://james.apache.org/server/3/config.html for usage
+
+jmx.address=127.0.0.1
+jmx.port=9999
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/lmtpserver.xml b/server/container/guice/guice-common/sample-configuration/lmtpserver.xml
new file mode 100644
index 0000000..87a0caa
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/lmtpserver.xml
@@ -0,0 +1,41 @@
+<?xml version="1.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.
+ -->
+
+<lmtpservers>
+
+ <lmtpserver enabled="false">
+ <jmxName>lmtpserver</jmxName>
+ <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
+ <bind>127.0.0.1:1024</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <connectiontimeout>1200</connectiontimeout>
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!-- This sets the maximum allowed message size (in kilobytes) for this -->
+ <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+ <maxmessagesize>0</maxmessagesize>
+ <handlerchain>
+ <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </lmtpserver>
+
+</lmtpservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/mailetcontainer.xml b/server/container/guice/guice-common/sample-configuration/mailetcontainer.xml
new file mode 100644
index 0000000..968b59c
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/mailetcontainer.xml
@@ -0,0 +1,137 @@
+<?xml version="1.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.
+ -->
+
+<mailetcontainer enableJmx="true">
+
+ <context>
+ <postmaster>postmaster@james.minet.net</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="true">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+ <!-- Hook on sievemanager@james.linagora.com
+ Mail send to this address will get interpreted with SIEVE Manage -->
+ <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
+ <processor>sieve-manager-check</processor>
+ </mailet>
+ <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="All" class="SetMailAttribute">
+ <spamChecked>true</spamChecked>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <!-- Check for delivery from a known spam server -->
+ <!-- This set of matchers/mailets redirect all emails from known -->
+ <!-- black holes, open relays, and spam servers to the spam processor -->
+ <!-- For this set to function properly, the spam processor must be configured. -->
+ <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
+ <processor>spam</processor>
+ <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="true">
+ <mailet match="All" class="Bounce"/>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/error/</repositoryPath>
+ </mailet>
+ </processor>
+
+
+ <processor state="transport" enableJmx="true">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
+ <name>X-WasSigned</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RecipientRewriteTable" />
+ <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+ <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
+ <outgoingQueue>outgoing</outgoingQueue>
+ <delayTime>5000, 100000, 500000</delayTime>
+ <maxRetries>25</maxRetries>
+ <maxDnsProblemRetries>0</maxDnsProblemRetries>
+ <deliveryThreads>10</deliveryThreads>
+ <sendpartial>true</sendpartial>
+ <bounceProcessor>bounces</bounceProcessor>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>relay-denied</processor>
+ </mailet>
+ </processor>
+
+ <processor state="spam" enableJmx="true">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/spam/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="local-address-error" enableJmx="true">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/address-error/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="true">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
+ <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="true">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+ </processors>
+
+</mailetcontainer>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/mailrepositorystore.xml b/server/container/guice/guice-common/sample-configuration/mailrepositorystore.xml
new file mode 100644
index 0000000..acca810
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/mailrepositorystore.xml
@@ -0,0 +1,34 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <!-- File based repositories. These repositories store all message data -->
+ <!-- in the file system. -->
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <!-- Set if the messages should be listed sorted. False by default -->
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/pop3server.xml b/server/container/guice/guice-common/sample-configuration/pop3server.xml
new file mode 100644
index 0000000..c57c832
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/pop3server.xml
@@ -0,0 +1,42 @@
+<?xml version="1.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.
+ -->
+
+
+<pop3servers>
+ <pop3server enabled="false">
+ <jmxName>pop3server</jmxName>
+ <bind>0.0.0.0:1110</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectiontimeout>1200</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <handlerchain>
+ <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </pop3server>
+</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/recipientrewritetable.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/recipientrewritetable.xml b/server/container/guice/guice-common/sample-configuration/recipientrewritetable.xml
new file mode 100644
index 0000000..7e7f586
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/recipientrewritetable.xml
@@ -0,0 +1,27 @@
+<?xml version="1.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.
+ -->
+
+<!-- The default table for storing James' RecipientRewriteTable mappings. -->
+<recipientrewritetable class="org.apache.james.rrt.jpa.JPARecipientRewriteTable">
+ <recursiveMapping>true</recursiveMapping>
+ <mappingLimit>10</mappingLimit>
+ <mapping>some@domain=some</mapping>
+</recipientrewritetable>
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/smtpserver.xml b/server/container/guice/guice-common/sample-configuration/smtpserver.xml
new file mode 100644
index 0000000..c34fcd1
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/smtpserver.xml
@@ -0,0 +1,105 @@
+<?xml version="1.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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <authRequired>false</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:1465</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="true" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="true">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/sample-configuration/usersrepository.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/sample-configuration/usersrepository.xml b/server/container/guice/guice-common/sample-configuration/usersrepository.xml
new file mode 100644
index 0000000..fc76107
--- /dev/null
+++ b/server/container/guice/guice-common/sample-configuration/usersrepository.xml
@@ -0,0 +1,27 @@
+<?xml version="1.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.
+ -->
+
+<usersrepository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
+ <destination URL="file://users/"/>
+ <algorithm>MD5</algorithm>
+ <enableVirtualHosting>true</enableVirtualHosting>
+ <enableForwarding>true</enableForwarding>
+</usersrepository>
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/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
new file mode 100644
index 0000000..6071f61
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
@@ -0,0 +1,94 @@
+/****************************************************************
+ * 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;
+
+import java.util.Arrays;
+
+import javax.annotation.PreDestroy;
+
+import org.apache.james.jmap.JMAPServer;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.modules.CommonServicesModule;
+import org.apache.james.modules.MailetProcessingModule;
+import org.apache.james.modules.ProtocolsModule;
+import org.apache.james.utils.ConfigurationsPerformer;
+import org.apache.james.utils.ExtendedServerProbe;
+import org.apache.james.utils.GuiceGenericType;
+import org.apache.james.utils.GuiceServerProbe;
+import org.apache.onami.lifecycle.core.Stager;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+import com.google.inject.util.Modules;
+
+public class GuiceJamesServer<Id extends MailboxId> {
+
+ private final TypeLiteral<Id> type;
+ private final Module module;
+ private final GuiceGenericType<Id> guiceGenericType;
+ private Stager<PreDestroy> preDestroy;
+ private GuiceServerProbe<Id> serverProbe;
+ private int jmapPort;
+
+
+ public GuiceJamesServer(TypeLiteral<Id> type) {
+ this(type, Modules.combine(
+ new CommonServicesModule<>(type),
+ new ProtocolsModule<>(type),
+ new MailetProcessingModule()));
+ }
+
+ private GuiceJamesServer(TypeLiteral<Id> type, Module module) {
+ this.type = type;
+ this.guiceGenericType = new GuiceGenericType<>(type);
+ this.module = module;
+ }
+
+ public GuiceJamesServer<Id> combineWith(Module... modules) {
+ return new GuiceJamesServer<>(type, Modules.combine(Iterables.concat(Arrays.asList(module), Arrays.asList(modules))));
+ }
+
+ public GuiceJamesServer<Id> overrideWith(Module... overrides) {
+ return new GuiceJamesServer<>(type, Modules.override(module).with(overrides));
+ }
+
+ public void start() throws Exception {
+ Injector injector = Guice.createInjector(module);
+ injector.getInstance(ConfigurationsPerformer.class).initModules();
+ preDestroy = injector.getInstance(Key.get(new TypeLiteral<Stager<PreDestroy>>() {}));
+ serverProbe = injector.getInstance(Key.get(guiceGenericType.newGenericType(GuiceServerProbe.class)));
+ jmapPort = injector.getInstance(JMAPServer.class).getPort();
+ }
+
+ public void stop() {
+ preDestroy.stage();
+ }
+
+ public ExtendedServerProbe<Id> serverProbe() {
+ return serverProbe;
+ }
+
+ public int getJmapPort() {
+ return jmapPort;
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPCommonModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPCommonModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPCommonModule.java
new file mode 100644
index 0000000..d2ad4b0
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPCommonModule.java
@@ -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.jmap;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.jmap.api.AccessTokenManager;
+import org.apache.james.jmap.api.ContinuationTokenManager;
+import org.apache.james.jmap.api.access.AccessTokenRepository;
+import org.apache.james.jmap.crypto.AccessTokenManagerImpl;
+import org.apache.james.jmap.crypto.JamesSignatureHandler;
+import org.apache.james.jmap.crypto.SignatureHandler;
+import org.apache.james.jmap.crypto.SignedContinuationTokenManager;
+import org.apache.james.jmap.memory.access.MemoryAccessTokenRepository;
+import org.apache.james.jmap.send.MailFactory;
+import org.apache.james.jmap.send.MailSpool;
+import org.apache.james.jmap.utils.DefaultZonedDateTimeProvider;
+import org.apache.james.jmap.utils.ZonedDateTimeProvider;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.name.Names;
+
+public class JMAPCommonModule extends AbstractModule {
+
+ private static final long DEFAULT_TOKEN_EXPIRATION_IN_MS = TimeUnit.MILLISECONDS.convert(15, TimeUnit.MINUTES);
+
+ @Override
+ protected void configure() {
+ bind(SignatureHandler.class).to(JamesSignatureHandler.class);
+ bind(ZonedDateTimeProvider.class).to(DefaultZonedDateTimeProvider.class);
+ bind(ContinuationTokenManager.class).to(SignedContinuationTokenManager.class);
+
+ bindConstant().annotatedWith(Names.named(AccessTokenRepository.TOKEN_EXPIRATION_IN_MS)).to(DEFAULT_TOKEN_EXPIRATION_IN_MS);
+ bind(AccessTokenRepository.class).to(MemoryAccessTokenRepository.class);
+ bind(AccessTokenManager.class).to(AccessTokenManagerImpl.class);
+
+ bind(MailSpool.class).in(Singleton.class);
+ bind(MailFactory.class).in(Singleton.class);
+ }
+
+ @Provides
+ public List<AuthenticationStrategy> authStrategies(
+ AccessTokenAuthenticationStrategy accessTokenAuthenticationStrategy,
+ JWTAuthenticationStrategy jwtAuthenticationStrategy) {
+
+ return ImmutableList.of(
+ jwtAuthenticationStrategy,
+ accessTokenAuthenticationStrategy);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
new file mode 100644
index 0000000..9a5aee7
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
@@ -0,0 +1,127 @@
+/****************************************************************
+ * 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.jmap;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Optional;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.io.FileUtils;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.jmap.methods.RequestHandler;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+
+import com.github.fge.lambdas.Throwing;
+import com.google.common.base.Preconditions;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+
+public class JMAPModule<Id extends MailboxId> extends AbstractModule {
+ private static final int DEFAULT_JMAP_PORT = 80;
+ private final TypeLiteral<Id> type;
+
+ public JMAPModule(TypeLiteral<Id> type) {
+ this.type = type;
+ }
+
+ @Override
+ protected void configure() {
+ install(new JMAPCommonModule());
+ install(new MethodsModule<Id>(type));
+ bind(RequestHandler.class).in(Singleton.class);
+ Multibinder<ConfigurationPerformer> preconditions = Multibinder.newSetBinder(binder(), ConfigurationPerformer.class);
+ preconditions.addBinding().to(MailetConfigurationPrecondition.class);
+ preconditions.addBinding().to(MoveCapabilityPrecondition.class);
+ }
+
+ @Provides
+ @Singleton
+ JMAPConfiguration provideConfiguration(FileSystem fileSystem) throws ConfigurationException, IOException{
+ PropertiesConfiguration configuration = getConfiguration(fileSystem);
+ return JMAPConfiguration.builder()
+ .keystore(configuration.getString("tls.keystoreURL"))
+ .secret(configuration.getString("tls.secret"))
+ .jwtPublicKeyPem(loadPublicKey(fileSystem, Optional.ofNullable(configuration.getString("jwt.publickeypem.url"))))
+ .port(configuration.getInt("jmap.port", DEFAULT_JMAP_PORT))
+ .build();
+ }
+
+ private PropertiesConfiguration getConfiguration(FileSystem fileSystem) throws FileNotFoundException, ConfigurationException {
+ return new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "jmap.properties"));
+ }
+
+ private Optional<String> loadPublicKey(FileSystem fileSystem, Optional<String> jwtPublickeyPemUrl) {
+ return jwtPublickeyPemUrl.map(Throwing.function(url -> FileUtils.readFileToString(fileSystem.getFile(url))));
+ }
+
+ @Singleton
+ public static class MailetConfigurationPrecondition implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+
+ @Inject
+ public MailetConfigurationPrecondition(ConfigurationProvider configurationProvider) {
+ this.configurationProvider = configurationProvider;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ Optional<HierarchicalConfiguration> removeMimeHeaderMailet = configurationProvider.getConfiguration("mailetcontainer")
+ .configurationAt("processors")
+ .configurationsAt("processor")
+ .stream()
+ .filter(processor -> processor.getString("[@state]").equals("transport"))
+ .flatMap(transport -> transport.configurationsAt("mailet").stream())
+ .filter(mailet -> mailet.getString("[@class]").equals("RemoveMimeHeader"))
+ .filter(mailet -> mailet.getString("[@match]").equals("All"))
+ .filter(mailet -> mailet.getProperty("name").equals("bcc"))
+ .findAny();
+ if (!removeMimeHeaderMailet.isPresent()) {
+ throw new ConfigurationException("Missing RemoveMimeHeader in mailets configuration (mailetcontainer -> processors -> transport). Should be configured to remove Bcc header");
+ }
+ }
+ }
+
+ @Singleton
+ public static class MoveCapabilityPrecondition implements ConfigurationPerformer {
+
+ private final MailboxManager mailboxManager;
+
+ @Inject
+ public MoveCapabilityPrecondition(MailboxManager mailboxManager) {
+ this.mailboxManager = mailboxManager;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ Preconditions.checkArgument(mailboxManager.getSupportedCapabilities().contains(MailboxManager.Capabilities.Move),
+ "MOVE support in MailboxManager is required by JMAP Module");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/MethodsModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/MethodsModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/MethodsModule.java
new file mode 100644
index 0000000..897f4bf
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/MethodsModule.java
@@ -0,0 +1,74 @@
+/****************************************************************
+ * 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.jmap;
+
+import org.apache.james.jmap.json.ObjectMapperFactory;
+import org.apache.james.jmap.methods.GetMailboxesMethod;
+import org.apache.james.jmap.methods.GetMessageListMethod;
+import org.apache.james.jmap.methods.GetMessagesMethod;
+import org.apache.james.jmap.methods.JmapRequestParser;
+import org.apache.james.jmap.methods.JmapRequestParserImpl;
+import org.apache.james.jmap.methods.JmapResponseWriter;
+import org.apache.james.jmap.methods.JmapResponseWriterImpl;
+import org.apache.james.jmap.methods.Method;
+import org.apache.james.jmap.methods.SetMessagesCreationProcessor;
+import org.apache.james.jmap.methods.SetMessagesDestructionProcessor;
+import org.apache.james.jmap.methods.SetMessagesMethod;
+import org.apache.james.jmap.methods.SetMessagesProcessor;
+import org.apache.james.jmap.methods.SetMessagesUpdateProcessor;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.utils.GuiceGenericType;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Names;
+
+public class MethodsModule<Id extends MailboxId> extends AbstractModule {
+
+ private final GuiceGenericType<Id> guiceGenericType;
+
+ public MethodsModule(TypeLiteral<Id> type) {
+ this.guiceGenericType = new GuiceGenericType<>(type);
+ }
+
+ @Override
+ protected void configure() {
+ bind(JmapRequestParser.class).to(JmapRequestParserImpl.class).in(Singleton.class);
+ bind(JmapResponseWriter.class).to(JmapResponseWriterImpl.class).in(Singleton.class);
+ bind(ObjectMapperFactory.class).in(Singleton.class);
+
+ bindConstant().annotatedWith(Names.named(GetMessageListMethod.MAXIMUM_LIMIT)).to(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT);
+
+ Multibinder<Method> methods = Multibinder.newSetBinder(binder(), Method.class);
+ methods.addBinding().to(guiceGenericType.newGenericType(GetMailboxesMethod.class));
+ methods.addBinding().to(guiceGenericType.newGenericType(GetMessageListMethod.class));
+ methods.addBinding().to(guiceGenericType.newGenericType(GetMessagesMethod.class));
+ methods.addBinding().to(guiceGenericType.newGenericType(SetMessagesMethod.class));
+
+ Multibinder<SetMessagesProcessor<Id>> setMessagesProcessors =
+ Multibinder.newSetBinder(binder(), guiceGenericType.newGenericType(SetMessagesProcessor.class));
+ setMessagesProcessors.addBinding().to(guiceGenericType.newGenericType(SetMessagesUpdateProcessor.class));
+ setMessagesProcessors.addBinding().to(guiceGenericType.newGenericType(SetMessagesCreationProcessor.class));
+ setMessagesProcessors.addBinding().to(guiceGenericType.newGenericType(SetMessagesDestructionProcessor.class));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/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
new file mode 100644
index 0000000..175a92b
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
@@ -0,0 +1,79 @@
+/****************************************************************
+ * 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.util.Optional;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.commons.cli.MissingArgumentException;
+import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.core.filesystem.FileSystemImpl;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.filesystem.api.JamesDirectoriesProvider;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.modules.server.ConfigurationProviderModule;
+import org.apache.james.modules.server.DNSServiceModule;
+import org.apache.james.utils.ConfigurationProvider;
+import org.apache.james.utils.FileConfigurationProvider;
+import org.apache.james.utils.GuiceGenericType;
+import org.apache.james.utils.GuiceServerProbe;
+import org.apache.onami.lifecycle.jsr250.PreDestroyModule;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+public class CommonServicesModule<Id extends MailboxId> extends AbstractModule {
+
+ public static final String CONFIGURATION_PATH = "configurationPath";
+ private final GuiceGenericType<Id> guiceGenericType;
+
+ public CommonServicesModule(TypeLiteral<Id> type) {
+ guiceGenericType = new GuiceGenericType<>(type);
+ }
+
+ @Override
+ protected void configure() {
+ install(new ConfigurationProviderModule());
+ install(new PreDestroyModule());
+ install(new DNSServiceModule());
+
+ bind(FileSystem.class).to(FileSystemImpl.class);
+ bind(ConfigurationProvider.class).to(FileConfigurationProvider.class);
+ TypeLiteral<GuiceServerProbe<Id>> serverProbe = guiceGenericType.newGenericType(GuiceServerProbe.class);
+ bind(serverProbe).in(Singleton.class);
+ }
+
+ @Provides @Singleton @Named(CONFIGURATION_PATH)
+ public String configurationPath() {
+ return FileSystem.FILE_PROTOCOL_AND_CONF;
+ }
+
+ @Provides @Singleton
+ public JamesDirectoriesProvider directories() throws MissingArgumentException {
+ String rootDirectory = Optional
+ .ofNullable(System.getProperty("working.directory"))
+ .orElseThrow(() -> new MissingArgumentException("Server needs a working.directory env entry"));
+ return new JamesServerResourceLoader(rootDirectory);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/MailetProcessingModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/MailetProcessingModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/MailetProcessingModule.java
new file mode 100644
index 0000000..507549a
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/MailetProcessingModule.java
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.modules.server.CamelMailetContainerModule;
+import org.apache.james.modules.server.MailStoreRepositoryModule;
+import org.apache.james.modules.server.SieveModule;
+
+import com.google.inject.AbstractModule;
+
+public class MailetProcessingModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new SieveModule());
+ install(new MailStoreRepositoryModule());
+ install(new CamelMailetContainerModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/Names.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/Names.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/Names.java
new file mode 100644
index 0000000..b37ed14
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/Names.java
@@ -0,0 +1,24 @@
+/****************************************************************
+ * 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;
+
+public class Names {
+ public static final String MAILBOXMANAGER_NAME = "mailboxmanager";
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java
new file mode 100644
index 0000000..c03575f
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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.mailbox.store.mail.model.MailboxId;
+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 com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+
+public class ProtocolsModule<Id extends MailboxId> extends AbstractModule {
+
+ private final TypeLiteral<Id> type;
+
+ public ProtocolsModule(TypeLiteral<Id> type) {
+ this.type = type;
+ }
+
+ @Override
+ protected void configure() {
+ install(new JMAPServerModule<>(type));
+ install(new IMAPServerModule());
+ install(new ProtocolHandlerModule());
+ install(new POP3ServerModule());
+ install(new SMTPServerModule());
+ install(new LMTPServerModule());
+ install(new ManageSieveServerModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
new file mode 100644
index 0000000..2aea749
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
@@ -0,0 +1,103 @@
+/****************************************************************
+ * 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 org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.decode.ImapDecoder;
+import org.apache.james.imap.encode.ImapEncoder;
+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.imapserver.netty.IMAPServerFactory;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.modules.Names;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Named;
+
+public class IMAPServerModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(IMAPServerModule.class);
+
+ @Override
+ protected void configure() {
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(IMAPModuleConfigurationPerformer.class);
+ }
+
+ @Provides
+ @Singleton
+ ImapProcessor provideImapProcessor(
+ @Named(Names.MAILBOXMANAGER_NAME)MailboxManager mailboxManager,
+ SubscriptionManager subscriptionManager,
+ QuotaManager quotaManager,
+ QuotaRootResolver quotaRootResolver) {
+ return DefaultImapProcessorFactory.createXListSupportingProcessor(
+ mailboxManager,
+ subscriptionManager,
+ null,
+ quotaManager,
+ quotaRootResolver,
+ 120,
+ ImmutableSet.of("ACL", "MOVE"));
+ }
+
+ @Provides
+ @Singleton
+ ImapDecoder provideImapDecoder() {
+ return DefaultImapDecoderFactory.createDecoder();
+ }
+
+ @Provides
+ @Singleton
+ ImapEncoder provideImapEncoder() {
+ return new DefaultImapEncoderFactory().buildImapEncoder();
+ }
+
+ @Singleton
+ public static class IMAPModuleConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final IMAPServerFactory imapServerFactory;
+
+ @Inject
+ public IMAPModuleConfigurationPerformer(ConfigurationProvider configurationProvider, IMAPServerFactory imapServerFactory) {
+ this.configurationProvider = configurationProvider;
+ this.imapServerFactory = imapServerFactory;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ imapServerFactory.setLog(LOGGER);
+ imapServerFactory.configure(configurationProvider.getConfiguration("imapserver"));
+ imapServerFactory.init();
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[11/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
new file mode 100644
index 0000000..258f264
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
@@ -0,0 +1,103 @@
+<?xml version="1.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.
+ -->
+
+<mailetcontainer enableJmx="false">
+
+ <context>
+ <postmaster>postmaster@james.minet.net</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="false">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+ <!-- Hook on sievemanager@james.linagora.com
+ Mail send to this address will get interpreted with SIEVE Manage -->
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="false">
+ <mailet match="All" class="Bounce"/>
+ </processor>
+
+
+ <processor state="transport" enableJmx="false">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
+ <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+ <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
+ <outgoingQueue>outgoing</outgoingQueue>
+ <delayTime>5000, 100000, 500000</delayTime>
+ <maxRetries>25</maxRetries>
+ <maxDnsProblemRetries>0</maxDnsProblemRetries>
+ <deliveryThreads>10</deliveryThreads>
+ <sendpartial>true</sendpartial>
+ <bounceProcessor>bounces</bounceProcessor>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>relay-denied</processor>
+ </mailet>
+ </processor>
+
+ <processor state="spam" enableJmx="false">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/spam/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="local-address-error" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="false">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+
+ </processors>
+
+</mailetcontainer>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailrepositorystore.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/pop3server.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/pop3server.xml
new file mode 100644
index 0000000..e4187da
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/pop3server.xml
@@ -0,0 +1,42 @@
+<?xml version="1.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.
+ -->
+
+
+<pop3servers>
+ <pop3server enabled="true">
+ <jmxName>pop3server</jmxName>
+ <bind>0.0.0.0:1110</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectiontimeout>1200</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <handlerchain>
+ <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </pop3server>
+</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/smtpserver.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/smtpserver.xml
new file mode 100644
index 0000000..a3d4b8f
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/smtpserver.xml
@@ -0,0 +1,105 @@
+<?xml version="1.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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <authRequired>false</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:10465</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
new file mode 100644
index 0000000..084c9e1
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>james-server</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>james-server-jmap-integration-testing</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: JMAP :: Integration testing Common</name>
+
+ <profiles>
+ <profile>
+ <id>noTest</id>
+ <activation>
+ <os>
+ <family>windows</family>
+ </os>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>disable-build-for-older-jdk</id>
+ <activation>
+ <jdk>(,1.8)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-install</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-resources</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testResources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-descriptor</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>build-for-jdk-8</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>18.0</version> <!--$NO-MVN-MAN-VER$-->
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.restassured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-3.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>fully.qualified.MainClass</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>disable-animal-sniffer</id>
+ <activation>
+ <jdk>[1.6,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check_java_6</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
new file mode 100644
index 0000000..d1c0bc4
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
@@ -0,0 +1,45 @@
+/****************************************************************
+ * 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.jmap;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.apache.http.client.fluent.Request;
+import org.apache.http.client.fluent.Response;
+import org.apache.http.client.utils.URIBuilder;
+import org.junit.Rule;
+import org.junit.Test;
+import org.testcontainers.containers.GenericContainer;
+
+public class ContainerTest {
+
+ @Rule public GenericContainer container = new GenericContainer("nginx:1.7.1")
+ .withExposedPorts(80);
+
+ @Test
+ public void containerShouldBeReachableOnExposedPort() throws IOException, URISyntaxException {
+ String containerIpAddress = container.getContainerIpAddress();
+ Integer containerPort = container.getMappedPort(80);
+ Response response = Request.Get(new URIBuilder().setScheme("http").setHost(containerIpAddress).setPort(containerPort).build()).execute();
+ assertThat(response.returnResponse().getStatusLine().getStatusCode()).isEqualTo(200);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
new file mode 100644
index 0000000..3dddcec
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.jmap;
+
+import java.time.ZonedDateTime;
+
+import org.apache.james.jmap.utils.ZonedDateTimeProvider;
+
+public class FixedDateZonedDateTimeProvider implements ZonedDateTimeProvider {
+
+ private ZonedDateTime zonedDateTime;
+
+ public void setFixedDateTime(ZonedDateTime zonedDateTime) {
+ this.zonedDateTime = zonedDateTime;
+ }
+
+ @Override
+ public ZonedDateTime get() {
+ return zonedDateTime;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
new file mode 100644
index 0000000..e7ad88b
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
@@ -0,0 +1,474 @@
+/****************************************************************
+ * 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.jmap;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.RestAssured.with;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.isA;
+import static org.hamcrest.Matchers.notNullValue;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.UUID;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.model.ContinuationToken;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public abstract class JMAPAuthenticationTest {
+
+ private static final ZonedDateTime oldDate = ZonedDateTime.parse("2011-12-03T10:15:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
+ private static final ZonedDateTime newDate = ZonedDateTime.parse("2011-12-03T10:16:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
+ private static final ZonedDateTime afterExpirationDate = ZonedDateTime.parse("2011-12-03T10:30:31+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
+
+ protected abstract GuiceJamesServer<?> createJmapServer(FixedDateZonedDateTimeProvider zonedDateTimeProvider);
+
+ private UserCredentials userCredentials;
+ private FixedDateZonedDateTimeProvider zonedDateTimeProvider;
+ private GuiceJamesServer<?> jmapServer;
+
+ @Before
+ public void setup() throws Throwable {
+ zonedDateTimeProvider = new FixedDateZonedDateTimeProvider();
+ zonedDateTimeProvider.setFixedDateTime(oldDate);
+ jmapServer = createJmapServer(zonedDateTimeProvider);
+ jmapServer.start();
+ RestAssured.port = jmapServer.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+
+
+ userCredentials = UserCredentials.builder()
+ .username("user@domain.tld")
+ .password("password")
+ .build();
+
+
+ String domain = "domain.tld";
+ jmapServer.serverProbe().addDomain(domain);
+ jmapServer.serverProbe().addUser(userCredentials.getUsername(), userCredentials.getPassword());
+
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ @Test
+ public void mustReturnMalformedRequestWhenContentTypeIsMissing() {
+ given()
+ .accept(ContentType.JSON)
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ @Test
+ public void mustReturnMalformedRequestWhenContentTypeIsNotJson() {
+ given()
+ .contentType(ContentType.XML)
+ .accept(ContentType.JSON)
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ @Test
+ public void mustReturnMalformedRequestWhenAcceptIsMissing() {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ @Test
+ public void mustReturnMalformedRequestWhenAcceptIsNotJson() {
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.XML)
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ @Test
+ public void mustReturnMalformedRequestWhenCharsetIsNotUTF8() {
+ given()
+ .contentType("application/json; charset=ISO-8859-1")
+ .accept(ContentType.JSON)
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ @Test
+ public void mustReturnMalformedRequestWhenBodyIsEmpty() {
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ @Test
+ public void mustReturnMalformedRequestWhenBodyIsNotAcceptable() {
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"badAttributeName\": \"value\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ @Test
+ public void mustReturnJsonResponse() throws Exception {
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(200)
+ .contentType(ContentType.JSON);
+ }
+
+ @Test
+ public void methodShouldContainPasswordWhenValidResquest() throws Exception {
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(200)
+ .body("methods", hasItem(userCredentials.getPassword()));
+ }
+
+ @Test
+ public void mustReturnContinuationTokenWhenValidResquest() throws Exception {
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(200)
+ .body("continuationToken", isA(String.class));
+ }
+
+ @Test
+ public void mustReturnAuthenticationFailedWhenBadPassword() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"badpassword\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void mustReturnAuthenticationFailedWhenContinuationTokenIsRejectedByTheContinuationTokenManager() throws Exception {
+ ContinuationToken badContinuationToken = new ContinuationToken(userCredentials.getUsername(), newDate, "badSignature");
+
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + badContinuationToken.serialize() + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void mustReturnRestartAuthenticationWhenContinuationTokenIsExpired() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+ zonedDateTimeProvider.setFixedDateTime(afterExpirationDate);
+
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(403);
+ }
+
+ @Test
+ public void mustReturnAuthenticationFailedWhenUsersRepositoryException() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + "wrong password" + "\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void mustReturnCreatedWhenGoodPassword() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+ zonedDateTimeProvider.setFixedDateTime(newDate);
+
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(201);
+ }
+
+ @Test
+ public void mustSendJsonContainingAccessTokenAndEndpointsWhenGoodPassword() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+ zonedDateTimeProvider.setFixedDateTime(newDate);
+
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .body("accessToken", isA(String.class))
+ .body("api", equalTo("/jmap"))
+ .body("eventSource", both(isA(String.class)).and(notNullValue()))
+ .body("upload", both(isA(String.class)).and(notNullValue()))
+ .body("download", both(isA(String.class)).and(notNullValue()));
+ }
+
+ @Test
+ public void getMustReturnUnauthorizedWithoutAuthroizationHeader() throws Exception {
+ given()
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void getMustReturnUnauthorizedWithoutAValidAuthroizationHeader() throws Exception {
+ given()
+ .header("Authorization", UUID.randomUUID())
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void getMustReturnEndpointsWhenValidAuthorizationHeader() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+ String token = fromGoodAccessTokenRequest(continuationToken);
+
+ given()
+ .header("Authorization", token)
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(200)
+ .body("api", equalTo("/jmap"))
+ .body("eventSource", both(isA(String.class)).and(notNullValue()))
+ .body("upload", both(isA(String.class)).and(notNullValue()))
+ .body("download", both(isA(String.class)).and(notNullValue()));
+ }
+
+ @Test
+ public void getMustReturnEndpointsWhenValidJwtAuthorizationHeader() throws Exception {
+ String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
+ "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
+ "DN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
+ "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
+ "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
+
+ given()
+ .header("Authorization", "Bearer " + token)
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(200);
+ }
+
+ @Test
+ public void getMustReturnEndpointsWhenValidUnkwnonUserJwtAuthorizationHeader() throws Exception {
+ String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3IiwibmFtZSI6Ik5ldyBVc2VyIn0.ci8U04EOWKpi_y"
+ + "faKs8fnCBcu1mWs8fvf-t9SDP2kkvDDfD-ya4sEGn4ueCp2dA2ndefZfVu_IfvdlVtxqzSf0tQ-dFKrIe-OtSKhI2otjWctLtk9A"
+ + "G7jpWkXoDgr5IOVmsqg37Zxc2bgkLkC5FJqV6oCp51TNQTH6zZbXIUeuGFbHj2-iJeX8sACKTQB0llwc6TFm7GYUF03rv4DfJjqp"
+ + "Kd0g8RdnlevSOjV-gGzvKEItugtexS5pgOZ2GYcvqEUDb9EnQR7Qe2EzPAX_FCJfGhlv7bDQlTgOHHAjqw2lD4-zeAznw-3wlYLS"
+ + "zhi4ivvPjT-y2T5wnnhzeeYOpYOQ";
+
+ given()
+ .header("Authorization", "Bearer " + token)
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(200);
+ }
+
+ @Test
+ public void getMustReturnBadCredentialsWhenInvalidJwtAuthorizationHeader() throws Exception {
+ String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
+ "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
+ "EN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
+ "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
+ "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
+
+ given()
+ .header("Authorization", "Bearer " + token)
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void optionsRequestsShouldNeverRequireAuthentication() {
+ given()
+ .when()
+ .options("/authentication")
+ .then()
+ .statusCode(200);
+ }
+
+ @Test
+ public void getMustReturnEndpointsWhenCorrectAuthentication() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+ zonedDateTimeProvider.setFixedDateTime(newDate);
+
+ String accessToken = fromGoodAccessTokenRequest(continuationToken);
+
+ given()
+ .header("Authorization", accessToken)
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(200)
+ .body("api", isA(String.class));
+ }
+
+ @Test
+ public void deleteMustReturnUnauthenticatedWithoutAuthorizationHeader() throws Exception {
+ given()
+ .when()
+ .delete("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void deleteMustReturnUnauthenticatedWithoutAValidAuthroizationHeader() throws Exception {
+ given()
+ .header("Authorization", UUID.randomUUID())
+ .when()
+ .delete("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void deleteMustReturnOKNoContentOnValidAuthorizationToken() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+ String token = fromGoodAccessTokenRequest(continuationToken);
+ given()
+ .header("Authorization", token)
+ .when()
+ .delete("/authentication")
+ .then()
+ .statusCode(204);
+ }
+
+ @Test
+ public void deleteMustInvalidAuthorizationOnCorrectAuthorization() throws Exception {
+ String continuationToken = fromGoodContinuationTokenRequest();
+ zonedDateTimeProvider.setFixedDateTime(newDate);
+
+ String accessToken = fromGoodAccessTokenRequest(continuationToken);
+
+ goodDeleteAccessTokenRequest(accessToken);
+
+ given()
+ .header("Authorization", accessToken)
+ .when()
+ .get("/authentication")
+ .then()
+ .statusCode(401);
+ }
+
+ private String fromGoodContinuationTokenRequest() {
+ return with()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
+ .post("/authentication")
+ .body()
+ .path("continuationToken")
+ .toString();
+ }
+
+ private String fromGoodAccessTokenRequest(String continuationToken) {
+ return with()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
+ .post("/authentication")
+ .path("accessToken")
+ .toString();
+ }
+
+ private void goodDeleteAccessTokenRequest(String accessToken) {
+ with()
+ .header("Authorization", accessToken)
+ .delete("/authentication");
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java
new file mode 100644
index 0000000..b9fa503
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.jmap;
+
+import static com.jayway.restassured.RestAssured.with;
+
+import org.apache.james.jmap.api.access.AccessToken;
+
+import com.jayway.restassured.http.ContentType;
+
+public class JmapAuthentication {
+
+ public static AccessToken authenticateJamesUser(String username, String password) {
+ String continuationToken = getContinuationToken(username);
+
+ return AccessToken.fromString(
+ with()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + password + "\"}")
+ .post("/authentication")
+ .body()
+ .jsonPath()
+ .getString("accessToken")
+ );
+ }
+
+ private static String getContinuationToken(String username) {
+ return with()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"username\": \"" + username + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
+ .post("/authentication")
+ .body()
+ .path("continuationToken")
+ .toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/UserCredentials.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/UserCredentials.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/UserCredentials.java
new file mode 100644
index 0000000..25a1994
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/UserCredentials.java
@@ -0,0 +1,66 @@
+/****************************************************************
+ * 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.jmap;
+
+public class UserCredentials {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private String username;
+ private String password;
+
+ private Builder() {
+ }
+
+ public Builder username(String username) {
+ this.username = username;
+ return this;
+ }
+
+ public Builder password(String password) {
+ this.password = password;
+ return this;
+ }
+
+ public UserCredentials build() {
+ return new UserCredentials(username, password);
+ }
+ }
+
+ private final String username;
+ private final String password;
+
+ private UserCredentials(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
new file mode 100644
index 0000000..dfafe9f
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
@@ -0,0 +1,421 @@
+/****************************************************************
+ * 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.jmap.methods.integration;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.isEmptyOrNullString;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
+
+import java.io.ByteArrayInputStream;
+import java.util.Date;
+
+import javax.mail.Flags;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.JmapAuthentication;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public abstract class GetMailboxesMethodTest {
+ private static final String NAME = "[0][0]";
+ private static final String ARGUMENTS = "[0][1]";
+
+ protected abstract GuiceJamesServer<?> createJmapServer();
+
+ private AccessToken accessToken;
+ private String username;
+ private GuiceJamesServer<?> jmapServer;
+
+ @Before
+ public void setup() throws Throwable {
+ jmapServer = createJmapServer();
+ jmapServer.start();
+ RestAssured.port = jmapServer.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+
+ String domain = "domain.tld";
+ username = "username@" + domain;
+ String password = "password";
+ jmapServer.serverProbe().addDomain(domain);
+ jmapServer.serverProbe().addUser(username, password);
+ accessToken = JmapAuthentication.authenticateJamesUser(username, password);
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ @Test
+ public void getMailboxesShouldErrorNotSupportedWhenRequestContainsNonNullAccountId() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"accountId\": \"1\"}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
+ }
+
+ @Test
+ public void getMailboxesShouldReturnEmptyWhenIdsDoesntMatch() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"ids\": [\"notAMailboxId\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", hasSize(0));
+ }
+
+ @Test
+ public void getMailboxesShouldReturnMailboxesWhenIdsMatch() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
+
+ Mailbox<?> mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+ Mailbox<?> mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
+
+ String mailboxId = mailbox.getMailboxId().serialize();
+ String mailboxId2 = mailbox2.getMailboxId().serialize();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\", \"" + mailboxId2 + "\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", hasSize(2))
+ .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId))
+ .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2));
+ }
+
+ @Test
+ public void getMailboxesShouldReturnOnlyMatchingMailboxesWhenIdsGiven() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
+
+ Mailbox<?> mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+
+ String mailboxId = mailbox.getMailboxId().serialize();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId));
+ }
+
+ @Test
+ public void getMailboxesShouldReturnEmptyWhenIdsIsEmpty() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"ids\": []}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", empty());
+ }
+
+ @Test
+ public void getMailboxesShouldReturnAllMailboxesWhenIdsIsNull() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
+
+ Mailbox<?> mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
+ Mailbox<?> mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox");
+
+ String mailboxId = mailbox.getMailboxId().serialize();
+ String mailboxId2 = mailbox2.getMailboxId().serialize();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"ids\": null}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", hasSize(2))
+ .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId))
+ .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2));
+ }
+
+ @Test
+ public void getMailboxesShouldErrorInvalidArgumentsWhenRequestIsInvalid() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"ids\": true}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("invalidArguments"))
+ .body(ARGUMENTS + ".description", equalTo("Can not deserialize instance of java.util.ArrayList out of VALUE_TRUE token\n"
+ + " at [Source: {\"ids\":true}; line: 1, column: 2] (through reference chain: org.apache.james.jmap.model.Builder[\"ids\"])"));
+ }
+
+ @Test
+ public void getMailboxesShouldReturnEmptyListWhenNoMailboxes() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", empty());
+ }
+
+ @Test
+ public void getMailboxesShouldReturnDefaultMailboxesWhenAuthenticatedUserDoesntHaveAnAccountYet() throws Exception {
+
+ String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3QGRvbWFpbi50bGQiLCJuYW1lIjoiTmV3IFVzZXIif"
+ + "Q.fxNWNzksXyCij2ooVi-QfGe9vTicF2N9FDtWSJdjWTjhwoQ_i0dgiT8clp4dtOJzy78hB2UkAW-iq7z3PR_Gz0qFah7EbYoEs"
+ + "5lQs1UlhNGCRTvIsyR8qHUXtA6emw9x0nuMnswtyXhzoA-cEHCArrMxMeWhTYi2l4od3G8Irrvu1Yc5hKLwLgPdnImbKyB5a89T"
+ + "vzuZE8-FVyMmhlaJA2T1GpbsaUnfE1ki_bBzqMHTD_Ob7oSVzz2UOiOeL-ombn1X9GbYQ2I-Ob4V84WHONYxw0VjPHlj9saZ2n7"
+ + "2RJTBsIo6flJT-MchaEvTYBvuV_wlCCQYjI1g7mdeD6aXfw";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", "Bearer " + token)
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", hasSize(3))
+ .body(ARGUMENTS + ".list.name", hasItems("INBOX", "Outbox", "Sent"));
+ }
+
+ @Test
+ public void getMailboxesShouldErrorWithBadJWTToken() {
+
+ String badAuthToken = "BADTOKENOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
+ "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
+ "DN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
+ "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
+ "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", "Bearer " + badAuthToken)
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(401);
+ }
+
+ @Test
+ public void getMailboxesShouldReturnMailboxesWhenAvailable() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "name"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list[0].name", equalTo("name"))
+ .body(ARGUMENTS + ".list[0].parentId", nullValue())
+ .body(ARGUMENTS + ".list[0].role", nullValue())
+ .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000))
+ .body(ARGUMENTS + ".list[0].mustBeOnlyMailbox", equalTo(false))
+ .body(ARGUMENTS + ".list[0].mayReadItems", equalTo(false))
+ .body(ARGUMENTS + ".list[0].mayAddItems", equalTo(false))
+ .body(ARGUMENTS + ".list[0].mayRemoveItems", equalTo(false))
+ .body(ARGUMENTS + ".list[0].mayCreateChild", equalTo(false))
+ .body(ARGUMENTS + ".list[0].mayRename", equalTo(false))
+ .body(ARGUMENTS + ".list[0].mayDelete", equalTo(false))
+ .body(ARGUMENTS + ".list[0].totalMessages", equalTo(1))
+ .body(ARGUMENTS + ".list[0].unreadMessages", equalTo(1))
+ .body(ARGUMENTS + ".list[0].unreadThreads", equalTo(0));
+ }
+
+ @Test
+ public void getMailboxesShouldReturnFilteredMailboxesPropertiesWhenRequestContainsFilterProperties() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
+ .body(ARGUMENTS + ".list[0].name", nullValue())
+ .body(ARGUMENTS + ".list[0].parentId", nullValue())
+ .body(ARGUMENTS + ".list[0].role", nullValue())
+ .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000))
+ .body(ARGUMENTS + ".list[0].mustBeOnlyMailbox", nullValue())
+ .body(ARGUMENTS + ".list[0].mayReadItems", nullValue())
+ .body(ARGUMENTS + ".list[0].mayAddItems", nullValue())
+ .body(ARGUMENTS + ".list[0].mayRemoveItems", nullValue())
+ .body(ARGUMENTS + ".list[0].mayCreateChild", nullValue())
+ .body(ARGUMENTS + ".list[0].mayRename", nullValue())
+ .body(ARGUMENTS + ".list[0].mayDelete", nullValue())
+ .body(ARGUMENTS + ".list[0].totalMessages", nullValue())
+ .body(ARGUMENTS + ".list[0].unreadMessages", equalTo(0))
+ .body(ARGUMENTS + ".list[0].unreadThreads", nullValue());
+ }
+
+ @Test
+ public void getMailboxesShouldReturnIdWhenRequestContainsEmptyPropertyListFilter() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"properties\" : []}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
+ .body(ARGUMENTS + ".list[0].name", nullValue());
+ }
+
+ @Test
+ public void getMailboxesShouldIgnoreUnknownPropertiesWhenRequestContainsUnknownPropertyListFilter() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {\"properties\" : [\"unknown\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
+ .body(ARGUMENTS + ".list[0].name", nullValue());
+ }
+
+ @Test
+ public void getMailboxesShouldReturnMailboxesWithSortOrder() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "trash");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", hasSize(2))
+ .body(ARGUMENTS + ".list[0].name", equalTo("inbox"))
+ .body(ARGUMENTS + ".list[0].sortOrder", equalTo(10))
+ .body(ARGUMENTS + ".list[1].name", equalTo("trash"))
+ .body(ARGUMENTS + ".list[1].sortOrder", equalTo(60));
+ }
+
+ @Test
+ public void getMailboxesShouldReturnMailboxesWithRolesInLowerCase() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "outbox");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("mailboxes"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].role", equalTo("outbox"));
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[16/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
new file mode 100644
index 0000000..d2b642d
--- /dev/null
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -0,0 +1,291 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server</artifactId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>james-server-cassandra-guice</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: Cassandra - guice injection</name>
+ <description>An advanced email server - Cassandra backend with guice injection</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>disable-build-for-older-jdk</id>
+ <activation>
+ <jdk>(,1.8)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-install</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-resources</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testResources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-descriptor</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>build-for-jdk-8</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/${project.build.finalName}.lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>${project.build.finalName}.lib/</classpathPrefix>
+ <mainClass>org.apache.james.CassandraJamesServerMain</mainClass>
+ <useUniqueVersions>false</useUniqueVersions>
+ </manifest>
+ </archive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-backends-cassandra</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-cassandra</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-cassandra</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-tika</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-data-cassandra</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.restassured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.nurkiewicz.asyncretry</groupId>
+ <artifactId>asyncretry</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-3.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.cassandraunit</groupId>
+ <artifactId>cassandra-unit</artifactId>
+ <version>${cassandra-unit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>disable-animal-sniffer</id>
+ <activation>
+ <jdk>[1.6,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check_java_6</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/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
new file mode 100644
index 0000000..7057e7c
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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;
+
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.modules.data.CassandraDomainListModule;
+import org.apache.james.modules.data.CassandraRecipientRewriteTableModule;
+import org.apache.james.modules.data.CassandraUsersRepositoryModule;
+import org.apache.james.modules.mailbox.CassandraMailboxModule;
+import org.apache.james.modules.mailbox.CassandraSessionModule;
+import org.apache.james.modules.mailbox.ElasticSearchMailboxModule;
+import org.apache.james.modules.server.ActiveMQQueueModule;
+import org.apache.james.modules.server.JMXServerModule;
+import org.apache.james.modules.server.QuotaModule;
+
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+import com.google.inject.util.Modules;
+
+public class CassandraJamesServerMain {
+
+ public static final TypeLiteral<CassandraId> cassandraId = new TypeLiteral<CassandraId>(){};
+ public static final Module cassandraServerModule = Modules.combine(
+ new CassandraUsersRepositoryModule(),
+ new CassandraDomainListModule(),
+ new CassandraRecipientRewriteTableModule(),
+ new CassandraMailboxModule(),
+ new CassandraSessionModule(),
+ new ElasticSearchMailboxModule(),
+ new QuotaModule(),
+ new ActiveMQQueueModule<>(cassandraId));
+
+
+ public static void main(String[] args) throws Exception {
+ GuiceJamesServer<CassandraId> server =
+ new GuiceJamesServer<>(cassandraId)
+ .combineWith(cassandraServerModule, new JMXServerModule());
+ server.start();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
new file mode 100644
index 0000000..4f815f2
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
@@ -0,0 +1,65 @@
+/****************************************************************
+ * 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.data;
+
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.cassandra.CassandraDomainList;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Scopes;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class CassandraDomainListModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DomainList.class);
+
+ @Override
+ public void configure() {
+ bind(CassandraDomainList.class).in(Scopes.SINGLETON);
+ bind(DomainList.class).to(CassandraDomainList.class);
+ Multibinder.newSetBinder(binder(), CassandraModule.class).addBinding().to(org.apache.james.domainlist.cassandra.CassandraDomainListModule.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(CassandraDomainListConfigurationPerformer.class);
+ }
+
+ @Singleton
+ public static class CassandraDomainListConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final CassandraDomainList cassandraDomainList;
+
+ @Inject
+ public CassandraDomainListConfigurationPerformer(ConfigurationProvider configurationProvider, CassandraDomainList cassandraDomainList) {
+ this.configurationProvider = configurationProvider;
+ this.cassandraDomainList = cassandraDomainList;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ cassandraDomainList.setLog(LOGGER);
+ cassandraDomainList.configure(configurationProvider.getConfiguration("domainlist"));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
new file mode 100644
index 0000000..d261a7d
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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.data;
+
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.cassandra.CassandraRRTModule;
+import org.apache.james.rrt.cassandra.CassandraRecipientRewriteTable;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Scopes;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+public class CassandraRecipientRewriteTableModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(RecipientRewriteTable.class);
+
+ @Override
+ public void configure() {
+ bind(CassandraRecipientRewriteTable.class).in(Scopes.SINGLETON);
+ bind(RecipientRewriteTable.class).to(CassandraRecipientRewriteTable.class);
+ Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
+ cassandraDataDefinitions.addBinding().to(CassandraRRTModule.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(CassandraRecipientRewriteTablePerformer.class);
+ }
+
+ @Singleton
+ public static class CassandraRecipientRewriteTablePerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final CassandraRecipientRewriteTable recipientRewriteTable;
+
+ @Inject
+ public CassandraRecipientRewriteTablePerformer(ConfigurationProvider configurationProvider, CassandraRecipientRewriteTable recipientRewriteTable) {
+ this.configurationProvider = configurationProvider;
+ this.recipientRewriteTable = recipientRewriteTable;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ recipientRewriteTable.setLog(LOGGER);
+ recipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable"));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
new file mode 100644
index 0000000..a776626
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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.data;
+
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.cassandra.CassandraUsersRepository;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+public class CassandraUsersRepositoryModule extends AbstractModule {
+
+ @Override
+ public void configure() {
+ bind(UsersRepository.class).to(CassandraUsersRepository.class);
+ Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.user.cassandra.CassandraUsersRepositoryModule.class);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
new file mode 100644
index 0000000..98b6da8
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -0,0 +1,97 @@
+/****************************************************************
+ * 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.mailbox;
+
+import javax.inject.Singleton;
+
+import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxPathLocker;
+import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
+import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
+import org.apache.james.mailbox.cassandra.CassandraSubscriptionManager;
+import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
+import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.store.Authenticator;
+import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
+import org.apache.james.mailbox.store.NoMailboxPathLocker;
+import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
+import org.apache.james.mailbox.store.mail.MessageMapperFactory;
+import org.apache.james.mailbox.store.mail.ModSeqProvider;
+import org.apache.james.mailbox.store.mail.UidProvider;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.modules.Names;
+import org.apache.james.utils.MailboxManagerDefinition;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Named;
+
+public class CassandraMailboxModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<MessageMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<MailboxMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
+ bind(MailboxMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<MailboxSessionMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<MailboxSessionMapperFactory<? extends MailboxId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<ModSeqProvider<CassandraId>>(){}).to(new TypeLiteral<CassandraModSeqProvider>(){});
+ bind(new TypeLiteral<UidProvider<CassandraId>>(){}).to(new TypeLiteral<CassandraUidProvider>(){});
+
+ bind(SubscriptionManager.class).to(CassandraSubscriptionManager.class);
+ bind(MailboxSessionMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class);
+ bind(MailboxPathLocker.class).to(NoMailboxPathLocker.class);
+ bind(Authenticator.class).to(UserRepositoryAuthenticator.class);
+ bind(MailboxManager.class).to(CassandraMailboxManager.class);
+
+ Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAclModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMessageModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule.class);
+ cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule.class);
+
+ Multibinder.newSetBinder(binder(), MailboxManagerDefinition.class).addBinding().to(CassandraMailboxManagerDefinition.class);
+ }
+
+ @Provides @Named(Names.MAILBOXMANAGER_NAME) @Singleton
+ public MailboxManager provideMailboxManager(CassandraMailboxManager cassandraMailboxManager) throws MailboxException {
+ cassandraMailboxManager.init();
+ return cassandraMailboxManager;
+ }
+
+ @Singleton
+ private static class CassandraMailboxManagerDefinition extends MailboxManagerDefinition {
+ @Inject
+ private CassandraMailboxManagerDefinition(CassandraMailboxManager manager) {
+ super("cassandra-mailboxmanager", manager);
+ }
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
new file mode 100644
index 0000000..f40cf41
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
@@ -0,0 +1,99 @@
+/****************************************************************
+ * 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.mailbox;
+
+import java.io.FileNotFoundException;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
+import org.apache.james.backends.cassandra.init.ClusterFactory;
+import org.apache.james.backends.cassandra.init.ClusterWithKeyspaceCreatedFactory;
+import org.apache.james.backends.cassandra.init.SessionWithInitializedTablesFactory;
+import org.apache.james.filesystem.api.FileSystem;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.exceptions.NoHostAvailableException;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
+
+public class CassandraSessionModule extends AbstractModule {
+
+ private static final int DEFAULT_CONNECTION_MAX_RETRIES = 10;
+ private static final int DEFAULT_CONNECTION_MIN_DELAY = 5000;
+
+ @Override
+ protected void configure() {
+ bind(ScheduledExecutorService.class).toProvider(ScheduledExecutorServiceProvider.class);
+ }
+
+ @Provides
+ @Singleton
+ CassandraModule composeDataDefinitions(Set<CassandraModule> modules) {
+ return new CassandraModuleComposite(modules.toArray(new CassandraModule[0]));
+ }
+
+ @Provides
+ @Singleton
+ Session provideSession(FileSystem fileSystem, Cluster cluster, CassandraModule cassandraModule)
+ throws FileNotFoundException, ConfigurationException{
+ PropertiesConfiguration configuration = getConfiguration(fileSystem);
+ String keyspace = configuration.getString("cassandra.keyspace");
+ return new SessionWithInitializedTablesFactory(cassandraModule).createSession(cluster, keyspace);
+ }
+
+ @Provides
+ @Singleton
+ Cluster provideCluster(FileSystem fileSystem, AsyncRetryExecutor executor) throws FileNotFoundException, ConfigurationException, ExecutionException, InterruptedException {
+ PropertiesConfiguration configuration = getConfiguration(fileSystem);
+
+ return getRetryer(executor, configuration)
+ .getWithRetry(ctx -> ClusterWithKeyspaceCreatedFactory.clusterWithInitializedKeyspace(
+ ClusterFactory.createClusterForSingleServerWithoutPassWord(
+ configuration.getString("cassandra.ip"),
+ configuration.getInt("cassandra.port")),
+ configuration.getString("cassandra.keyspace"),
+ configuration.getInt("cassandra.replication.factor")))
+ .get();
+ }
+
+ private static AsyncRetryExecutor getRetryer(AsyncRetryExecutor executor, PropertiesConfiguration configuration) {
+ return executor.retryOn(NoHostAvailableException.class)
+ .withProportionalJitter()
+ .withMaxRetries(configuration.getInt("cassandra.retryConnection.maxRetries", DEFAULT_CONNECTION_MAX_RETRIES))
+ .withMinDelay(configuration.getInt("cassandra.retryConnection.minDelay", DEFAULT_CONNECTION_MIN_DELAY));
+ }
+
+ @Provides
+ private AsyncRetryExecutor provideAsyncRetryExecutor(ScheduledExecutorService scheduler) {
+ return new AsyncRetryExecutor(scheduler);
+ }
+
+ private PropertiesConfiguration getConfiguration(FileSystem fileSystem) throws FileNotFoundException, ConfigurationException {
+ return new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "cassandra.properties"));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
new file mode 100644
index 0000000..7fc7638
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
@@ -0,0 +1,81 @@
+/****************************************************************
+ * 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.mailbox;
+
+import java.io.FileNotFoundException;
+import java.util.concurrent.ExecutionException;
+
+import javax.inject.Singleton;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.ClientProvider;
+import org.apache.james.mailbox.elasticsearch.ClientProviderImpl;
+import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
+import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
+import org.apache.james.mailbox.store.extractor.TextExtractor;
+import org.apache.james.mailbox.store.search.MessageSearchIndex;
+import org.apache.james.mailbox.tika.extractor.TikaTextExtractor;
+import org.elasticsearch.client.transport.NoNodeAvailableException;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
+
+public class ElasticSearchMailboxModule extends AbstractModule {
+
+ private static final int DEFAULT_CONNECTION_MAX_RETRIES = 7;
+ private static final int DEFAULT_CONNECTION_MIN_DELAY = 3000;
+
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<MessageSearchIndex<CassandraId>>(){}).to(new TypeLiteral<ElasticSearchListeningMessageSearchIndex<CassandraId>>() {});
+ bind(TextExtractor.class).to(TikaTextExtractor.class);
+ }
+
+ @Provides
+ @Singleton
+ protected ClientProvider provideClientProvider(FileSystem fileSystem, AsyncRetryExecutor executor) throws ConfigurationException, FileNotFoundException, ExecutionException, InterruptedException {
+ PropertiesConfiguration propertiesReader = new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "elasticsearch.properties"));
+
+ ClientProvider clientProvider = new ClientProviderImpl(propertiesReader.getString("elasticsearch.masterHost"),
+ propertiesReader.getInt("elasticsearch.port"));
+ getRetryer(executor, propertiesReader)
+ .getWithRetry(ctx -> IndexCreationFactory.createIndex(clientProvider,
+ propertiesReader.getInt("elasticsearch.nb.shards"),
+ propertiesReader.getInt("elasticsearch.nb.replica")))
+ .get();
+ NodeMappingFactory.applyMapping(clientProvider);
+ return clientProvider;
+ }
+
+ private static AsyncRetryExecutor getRetryer(AsyncRetryExecutor executor, PropertiesConfiguration configuration) {
+ return executor
+ .withProportionalJitter()
+ .retryOn(NoNodeAvailableException.class)
+ .withMaxRetries(configuration.getInt("elasticsearch.retryConnection.maxRetries", DEFAULT_CONNECTION_MAX_RETRIES))
+ .withMinDelay(configuration.getInt("elasticsearch.retryConnection.minDelay", DEFAULT_CONNECTION_MIN_DELAY));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.java
new file mode 100644
index 0000000..48fe3f1
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.java
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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.mailbox;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+import javax.annotation.PreDestroy;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.inject.Provider;
+
+@VisibleForTesting
+class ScheduledExecutorServiceProvider implements Provider<ScheduledExecutorService> {
+
+ private final ScheduledExecutorService scheduler;
+
+ @VisibleForTesting
+ ScheduledExecutorServiceProvider() {
+ scheduler = Executors.newSingleThreadScheduledExecutor();
+ }
+
+ @Override
+ public ScheduledExecutorService get() {
+ return scheduler;
+ }
+
+ @PreDestroy
+ private void stop() {
+ scheduler.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java
new file mode 100644
index 0000000..3ca0fe3
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.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;
+
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.jmap.methods.GetMessageListMethod;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestFilesystemModule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.datastax.driver.core.Session;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+public class CassandraJamesServerTest extends AbstractJamesServerTest<CassandraId> {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
+
+ @Rule
+ public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<CassandraId> createJamesServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<CassandraId>(){})
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new TestElasticSearchModule(embeddedElasticSearch),
+ new TestFilesystemModule(temporaryFolder),
+ new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT),
+ new AbstractModule() {
+
+ @Override
+ protected void configure() {
+ }
+
+ @Provides
+ @Singleton
+ Session provideSession(CassandraModule cassandraModule) {
+ CassandraCluster cassandra = CassandraCluster.create(cassandraModule);
+ return cassandra.getConf();
+ }
+ });
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
new file mode 100644
index 0000000..6da278f
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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 com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import org.apache.james.mailbox.elasticsearch.ClientProvider;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
+import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
+
+import javax.inject.Singleton;
+
+public class TestElasticSearchModule extends AbstractModule{
+
+ private final EmbeddedElasticSearch embeddedElasticSearch;
+
+ public TestElasticSearchModule(EmbeddedElasticSearch embeddedElasticSearch) {
+ this.embeddedElasticSearch = embeddedElasticSearch;
+ }
+
+ @Override
+ protected void configure() {
+
+ }
+
+ @Provides
+ @Singleton
+ protected ClientProvider provideClientProvider() {
+ return NodeMappingFactory.applyMapping(
+ IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()))
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/dnsservice.xml b/server/container/guice/cassandra-guice/src/test/resources/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/dnsservice.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/fakemailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/fakemailrepositorystore.xml b/server/container/guice/cassandra-guice/src/test/resources/fakemailrepositorystore.xml
new file mode 100644
index 0000000..2d19a80
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/fakemailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.None">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/imapserver.xml b/server/container/guice/cassandra-guice/src/test/resources/imapserver.xml
new file mode 100644
index 0000000..ff478a9
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/imapserver.xml
@@ -0,0 +1,54 @@
+<?xml version="1.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.
+-->
+
+
+<imapservers>
+ <imapserver enabled="true">
+ <jmxName>imapserver</jmxName>
+ <bind>0.0.0.0:1143</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+ <imapserver enabled="true">
+ <jmxName>imapserver-ssl</jmxName>
+ <bind>0.0.0.0:1993</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/keystore b/server/container/guice/cassandra-guice/src/test/resources/keystore
new file mode 100644
index 0000000..536a6c7
Binary files /dev/null and b/server/container/guice/cassandra-guice/src/test/resources/keystore differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/lmtpserver.xml b/server/container/guice/cassandra-guice/src/test/resources/lmtpserver.xml
new file mode 100644
index 0000000..5c4a9c7
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/lmtpserver.xml
@@ -0,0 +1,41 @@
+<?xml version="1.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.
+ -->
+
+<lmtpservers>
+
+ <lmtpserver enabled="true">
+ <jmxName>lmtpserver</jmxName>
+ <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
+ <bind>127.0.0.1:1024</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <connectiontimeout>1200</connectiontimeout>
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!-- This sets the maximum allowed message size (in kilobytes) for this -->
+ <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+ <maxmessagesize>0</maxmessagesize>
+ <handlerchain>
+ <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </lmtpserver>
+
+</lmtpservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml b/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml
new file mode 100644
index 0000000..57c5784
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/mailetcontainer.xml
@@ -0,0 +1,168 @@
+<?xml version="1.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.
+ -->
+
+<mailetcontainer enableJmx="false">
+
+ <context>
+ <postmaster>postmaster@james.minet.net</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="false">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+ <!-- Hook on sievemanager@james.linagora.com
+ Mail send to this address will get interpreted with SIEVE Manage -->
+ <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
+ <processor>sieve-manager-check</processor>
+ </mailet>
+ <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="All" class="SetMailAttribute">
+ <spamChecked>true</spamChecked>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <!-- Check for delivery from a known spam server -->
+ <!-- This set of matchers/mailets redirect all emails from known -->
+ <!-- black holes, open relays, and spam servers to the spam processor -->
+ <!-- For this set to function properly, the spam processor must be configured. -->
+ <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
+ <processor>spam</processor>
+ <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="false">
+ <mailet match="All" class="Bounce"/>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/error/</repositoryPath>
+ </mailet>
+ </processor>
+
+
+ <processor state="transport" enableJmx="false">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
+ <name>X-WasSigned</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
+ <mailet match="All" class="RecipientRewriteTable" />
+ <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+ <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
+ <outgoingQueue>outgoing</outgoingQueue>
+ <delayTime>5000, 100000, 500000</delayTime>
+ <maxRetries>25</maxRetries>
+ <maxDnsProblemRetries>0</maxDnsProblemRetries>
+ <deliveryThreads>10</deliveryThreads>
+ <sendpartial>true</sendpartial>
+ <bounceProcessor>bounces</bounceProcessor>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>relay-denied</processor>
+ </mailet>
+ </processor>
+
+ <processor state="spam" enableJmx="false">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/spam/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="local-address-error" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/address-error/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
+ <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="false">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+
+ <processor state="sieve-manager-check" enableJmx="false">
+ <!-- Only local users can manage their scripts -->
+ <mailet match="RecipientIsLocal" class="ToProcessor">
+ <processor>sieve-manager</processor>
+ </mailet>
+ <!-- Notify other people about their failure -->
+ <mailet match="All" class="Bounce">
+ <inline>heads</inline>
+ <attachment>none</attachment>
+ <passThrough>false</passThrough>
+ <prefix>[REJECTED]</prefix>
+ <notice>
+ You can't send messages to configure SIEVE on this serveur unless you are the official SIEVE manager.
+ </notice>
+ </mailet>
+ <mailet match="All" class="Null"/>
+ </processor>
+
+ <processor state="sieve-manager">
+ <mailet match="All" class="SetMailAttribute">
+ <org.apache.james.SMTPAuthUser>true</org.apache.james.SMTPAuthUser>
+ </mailet>
+ <mailet match="All" class="org.apache.james.transport.mailets.managesieve.ManageSieveMailet">
+ <helpURL>file:/root/james-server-app-3.0.0-beta5-SNAPSHOT/conf/managesieve.help.txt</helpURL>
+ </mailet>
+ <mailet match="All" class="Null"/>
+ </processor>
+ </processors>
+
+</mailetcontainer>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/mailrepositorystore.xml b/server/container/guice/cassandra-guice/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/mailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/managesieveserver.xml b/server/container/guice/cassandra-guice/src/test/resources/managesieveserver.xml
new file mode 100644
index 0000000..ec57e09
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/managesieveserver.xml
@@ -0,0 +1,65 @@
+<?xml version="1.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.
+ -->
+
+<!--
+ This template file can be used as example for James Server configuration
+ DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<managesieveservers>
+
+ <managesieveserver enabled="true">
+
+ <jmxName>managesieveserver</jmxName>
+
+ <bind>0.0.0.0:4190</bind>
+
+ <connectionBacklog>200</connectionBacklog>
+
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <!-- The algorithm is optional and only needs to be specified when using something other
+ than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
+ <algorithm>SunX509</algorithm>
+ </tls>
+
+ <!-- connection timeout in secconds -->
+ <connectiontimeout>360</connectiontimeout>
+
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+
+ </managesieveserver>
+
+</managesieveservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/pop3server.xml b/server/container/guice/cassandra-guice/src/test/resources/pop3server.xml
new file mode 100644
index 0000000..e4187da
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/pop3server.xml
@@ -0,0 +1,42 @@
+<?xml version="1.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.
+ -->
+
+
+<pop3servers>
+ <pop3server enabled="true">
+ <jmxName>pop3server</jmxName>
+ <bind>0.0.0.0:1110</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectiontimeout>1200</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <handlerchain>
+ <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </pop3server>
+</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/smtpserver.xml b/server/container/guice/cassandra-guice/src/test/resources/smtpserver.xml
new file mode 100644
index 0000000..a3d4b8f
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/resources/smtpserver.xml
@@ -0,0 +1,105 @@
+<?xml version="1.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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <authRequired>false</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:10465</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[17/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
deleted file mode 100644
index 066f57a..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
+++ /dev/null
@@ -1,164 +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.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.stream.Collectors;
-
-import javax.inject.Singleton;
-
-import org.apache.commons.configuration.CombinedConfiguration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.DefaultConfigurationBuilder;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.lifecycle.api.Configurable;
-import org.apache.james.lifecycle.api.LogEnabled;
-import org.apache.james.mailrepository.api.MailRepository;
-import org.apache.james.mailrepository.api.MailRepositoryStore;
-import org.apache.james.repository.api.Initializable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Inject;
-
-@Singleton
-public class InMemoryMailRepositoryStore implements MailRepositoryStore {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryMailRepositoryStore.class);
-
- private final Set<MailRepositoryProvider> mailRepositories;
- private final ConcurrentMap<String, MailRepository> destinationToRepositoryAssociations;
- private final Map<String, MailRepositoryProvider> protocolToRepositoryProvider;
- private final Map<String, HierarchicalConfiguration> perProtocolMailRepositoryDefaultConfiguration;
- private HierarchicalConfiguration configuration;
-
- @Inject
- public InMemoryMailRepositoryStore(Set<MailRepositoryProvider> mailRepositories) {
- this.mailRepositories = mailRepositories;
- this.destinationToRepositoryAssociations = new ConcurrentHashMap<>();
- this.protocolToRepositoryProvider = new HashMap<>();
- this.perProtocolMailRepositoryDefaultConfiguration = new HashMap<>();
- }
-
- @Override
- public List<String> getUrls() {
- return destinationToRepositoryAssociations.keySet()
- .stream()
- .collect(Collectors.toList());
- }
-
- public void configure(HierarchicalConfiguration configuration) throws ConfigurationException {
- this.configuration = configuration;
- }
-
- public void init() throws Exception {
- LOGGER.info("JamesMailStore init... " + this);
- List<HierarchicalConfiguration> registeredClasses = configuration.configurationsAt("mailrepositories.mailrepository");
- for (HierarchicalConfiguration registeredClass : registeredClasses) {
- readConfigurationEntry(registeredClass);
- }
- }
-
- @Override
- public MailRepository select(String destination) throws MailRepositoryStoreException {
- MailRepository mailRepository = destinationToRepositoryAssociations.get(destination);
- if (mailRepository != null) {
- return mailRepository;
- }
- String protocol = retrieveProtocol(destination);
- mailRepository = retrieveMailRepository(protocol);
- mailRepository = initialiseNewRepository(mailRepository, createRepositoryCombinedConfig(destination, protocol));
- destinationToRepositoryAssociations.putIfAbsent(destination, mailRepository);
- return mailRepository;
- }
-
- private void readConfigurationEntry(HierarchicalConfiguration repositoryConfiguration) throws ConfigurationException {
- String className = repositoryConfiguration.getString("[@class]");
- MailRepositoryProvider usedMailRepository = mailRepositories.stream()
- .filter(mailRepositoryProvider -> mailRepositoryProvider.canonicalName().equals(className))
- .findAny()
- .orElseThrow(() -> new ConfigurationException("MailRepository " + className + " has not been registered"));
- for (String protocol : repositoryConfiguration.getStringArray("protocols.protocol")) {
- protocolToRepositoryProvider.put(protocol, usedMailRepository);
- registerRepositoryDefaultConfiguration(repositoryConfiguration, protocol);
- }
- }
-
- private void registerRepositoryDefaultConfiguration(HierarchicalConfiguration repositoryConfiguration, String protocol) {
- HierarchicalConfiguration defConf = null;
- if (repositoryConfiguration.getKeys("config").hasNext()) {
- defConf = repositoryConfiguration.configurationAt("config");
- }
- if (defConf != null) {
- perProtocolMailRepositoryDefaultConfiguration.put(protocol, defConf);
- }
- }
-
- private CombinedConfiguration createRepositoryCombinedConfig(String destination, String protocol) {
- final CombinedConfiguration config = new CombinedConfiguration();
- HierarchicalConfiguration defaultProtocolConfig = perProtocolMailRepositoryDefaultConfiguration.get(protocol);
- if (defaultProtocolConfig != null) {
- config.addConfiguration(defaultProtocolConfig);
- }
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- builder.addProperty("[@destinationURL]", destination);
- config.addConfiguration(builder);
- return config;
- }
-
- private MailRepository initialiseNewRepository(MailRepository mailRepository, CombinedConfiguration config) throws MailRepositoryStoreException {
- try {
- if (mailRepository instanceof LogEnabled) {
- ((LogEnabled) mailRepository).setLog(LOGGER);
- }
- if (mailRepository instanceof Configurable) {
- ((Configurable) mailRepository).configure(config);
- }
- if (mailRepository instanceof Initializable) {
- ((Initializable) mailRepository).init();
- }
- return mailRepository;
- } catch (Exception e) {
- throw new MailRepositoryStoreException("Cannot init mail repository", e);
- }
- }
-
- private MailRepository retrieveMailRepository(String protocol) throws MailRepositoryStoreException {
- MailRepositoryProvider repositoryProvider = protocolToRepositoryProvider.get(protocol);
- if (repositoryProvider == null) {
- throw new MailRepositoryStoreException("No Mail Repository associated with " + protocol);
- }
- return repositoryProvider.get();
- }
-
- private String retrieveProtocol(String destination) throws MailRepositoryStoreException {
- int protocolSeparatorPosition = destination.indexOf(':');
- if (protocolSeparatorPosition == -1) {
- throw new MailRepositoryStoreException("Destination is malformed. Must be a valid URL: " + destination);
- }
- return destination.substring(0, protocolSeparatorPosition);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.java
deleted file mode 100644
index 52b7d15..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailRepositoryProvider.java
+++ /dev/null
@@ -1,29 +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 org.apache.james.mailrepository.api.MailRepository;
-
-import javax.inject.Provider;
-
-public interface MailRepositoryProvider extends Provider<MailRepository> {
-
- String canonicalName();
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java
deleted file mode 100644
index 211398a..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java
+++ /dev/null
@@ -1,57 +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 org.apache.james.mailbox.MailboxManager;
-
-import com.google.common.base.Objects;
-
-public class MailboxManagerDefinition {
-
- private final String name;
- private final MailboxManager manager;
-
- public MailboxManagerDefinition(String name, MailboxManager manager) {
- this.name = name;
- this.manager = manager;
- }
-
- public MailboxManager getManager() {
- return manager;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(name, manager);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MailboxManagerDefinition) {
- MailboxManagerDefinition other = (MailboxManagerDefinition) obj;
- return Objects.equal(name, other.name) && Objects.equal(manager, other.manager);
- }
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.java
deleted file mode 100644
index e859ff7..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/PropertiesReader.java
+++ /dev/null
@@ -1,43 +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 com.google.common.base.Throwables;
-
-import java.io.IOException;
-import java.util.Properties;
-
-public class PropertiesReader {
-
- private final Properties properties;
-
- public PropertiesReader(String fileName) {
- properties = new Properties();
- try {
- properties.load(ClassLoader.getSystemResourceAsStream(fileName));
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- public String getProperty(String key) {
- return properties.getProperty(key);
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java
deleted file mode 100644
index 9b7127e..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/CassandraJamesServerTest.java
+++ /dev/null
@@ -1,157 +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;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import java.nio.charset.Charset;
-
-import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.jmap.methods.GetMessageListMethod;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.modules.TestElasticSearchModule;
-import org.apache.james.modules.TestFilesystemModule;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Charsets;
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.util.Modules;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.http.ContentType;
-
-public class CassandraJamesServerTest {
-
- private static final int IMAP_PORT = 1143; // You need to be root (superuser) to bind to ports under 1024.
- private static final int IMAP_PORT_SSL = 1993;
- private static final int POP3_PORT = 1110;
- private static final int SMTP_PORT = 1025;
- private static final int LMTP_PORT = 1024;
- public static final int BUFFER_SIZE = 1000;
-
- private CassandraJamesServer server;
- private TemporaryFolder temporaryFolder = new TemporaryFolder();
- private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
- private SocketChannel socketChannel;
-
- @Rule
- public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
- @Before
- public void setup() throws Exception {
- server = new CassandraJamesServer(createModule());
- socketChannel = SocketChannel.open();
-
- server.start();
-
- RestAssured.port = server.getJmapPort();
- RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
- }
-
- private Module createModule() {
- return Modules.override(CassandraJamesServerMain.defaultModule)
- .with(new TestElasticSearchModule(embeddedElasticSearch),
- new TestFilesystemModule(temporaryFolder),
- new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT),
- new AbstractModule() {
-
- @Override
- protected void configure() {
- }
-
- @Provides
- @Singleton
- com.datastax.driver.core.Session provideSession(CassandraModule cassandraModule) {
- CassandraCluster cassandra = CassandraCluster.create(cassandraModule);
- return cassandra.getConf();
- }
-
- });
- }
-
- @After
- public void tearDown() throws Exception {
- server.stop();
- }
-
- @Test
- public void connectIMAPServerShouldSendShabangOnConnect() throws Exception {
- socketChannel.connect(new InetSocketAddress("127.0.0.1", IMAP_PORT));
- assertThat(getServerConnectionResponse(socketChannel)).startsWith("* OK JAMES IMAP4rev1 Server");
- }
-
- @Test
- public void connectOnSecondaryIMAPServerIMAPServerShouldSendShabangOnConnect() throws Exception {
- socketChannel.connect(new InetSocketAddress("127.0.0.1", IMAP_PORT_SSL));
- assertThat(getServerConnectionResponse(socketChannel)).startsWith("* OK JAMES IMAP4rev1 Server");
- }
-
- @Test
- public void connectPOP3ServerShouldSendShabangOnConnect() throws Exception {
- socketChannel.connect(new InetSocketAddress("127.0.0.1", POP3_PORT));
- assertThat(getServerConnectionResponse(socketChannel)).contains("POP3 server (JAMES POP3 Server ) ready");
- }
-
- @Test
- public void connectSMTPServerShouldSendShabangOnConnect() throws Exception {
- socketChannel.connect(new InetSocketAddress("127.0.0.1", SMTP_PORT));
- assertThat(getServerConnectionResponse(socketChannel)).startsWith("220 JAMES Linagora's SMTP awesome Server");
- }
-
- @Test
- public void connectLMTPServerShouldSendShabangOnConnect() throws Exception {
- socketChannel.connect(new InetSocketAddress("127.0.0.1", LMTP_PORT));
- assertThat(getServerConnectionResponse(socketChannel)).contains("LMTP Server (JAMES Protocols Server) ready");
- }
-
- @Test
- public void connectJMAPServerShouldRespondBadRequest() throws Exception {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"badAttributeName\": \"value\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- private String getServerConnectionResponse(SocketChannel socketChannel) throws IOException {
- ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
- socketChannel.read(byteBuffer);
- byte[] bytes = byteBuffer.array();
- return new String(bytes, Charset.forName("UTF-8"));
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java b/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
deleted file mode 100644
index 6da278f..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
+++ /dev/null
@@ -1,52 +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.modules;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import org.apache.james.mailbox.elasticsearch.ClientProvider;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
-
-import javax.inject.Singleton;
-
-public class TestElasticSearchModule extends AbstractModule{
-
- private final EmbeddedElasticSearch embeddedElasticSearch;
-
- public TestElasticSearchModule(EmbeddedElasticSearch embeddedElasticSearch) {
- this.embeddedElasticSearch = embeddedElasticSearch;
- }
-
- @Override
- protected void configure() {
-
- }
-
- @Provides
- @Singleton
- protected ClientProvider provideClientProvider() {
- return NodeMappingFactory.applyMapping(
- IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()))
- );
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java b/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java
deleted file mode 100644
index 9f5bba4..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestFilesystemModule.java
+++ /dev/null
@@ -1,61 +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.modules;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.function.Supplier;
-
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.filesystem.api.JamesDirectoriesProvider;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Throwables;
-import com.google.inject.AbstractModule;
-import com.google.inject.name.Names;
-
-public class TestFilesystemModule extends AbstractModule {
-
- private final Supplier<File> workingDirectory;
-
- private static File createTempDir(TemporaryFolder temporaryFolder) {
- try {
- return temporaryFolder.newFolder();
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- public TestFilesystemModule(TemporaryFolder temporaryFolder) {
- this(() -> TestFilesystemModule.createTempDir(temporaryFolder));
- }
-
- public TestFilesystemModule(Supplier<File> workingDirectory) {
- this.workingDirectory = workingDirectory;
- }
-
- @Override
- protected void configure() {
- bind(JamesDirectoriesProvider.class).toInstance(new JamesServerResourceLoader(workingDirectory.get().getAbsolutePath()));
- bindConstant().annotatedWith(Names.named(CommonServicesModule.CONFIGURATION_PATH)).to(FileSystem.CLASSPATH_PROTOCOL);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java b/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
deleted file mode 100644
index 6512fac..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
+++ /dev/null
@@ -1,68 +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.modules;
-
-import java.io.FileNotFoundException;
-import java.util.Optional;
-
-import javax.inject.Singleton;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.jmap.JMAPConfiguration;
-import org.apache.james.jmap.methods.GetMessageListMethod;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
-
-public class TestJMAPServerModule extends AbstractModule{
-
- private static final String PUBLIC_PEM_KEY = "-----BEGIN PUBLIC KEY-----\n" +
- "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlChO/nlVP27MpdkG0Bh\n" +
- "16XrMRf6M4NeyGa7j5+1UKm42IKUf3lM28oe82MqIIRyvskPc11NuzSor8HmvH8H\n" +
- "lhDs5DyJtx2qp35AT0zCqfwlaDnlDc/QDlZv1CoRZGpQk1Inyh6SbZwYpxxwh0fi\n" +
- "+d/4RpE3LBVo8wgOaXPylOlHxsDizfkL8QwXItyakBfMO6jWQRrj7/9WDhGf4Hi+\n" +
- "GQur1tPGZDl9mvCoRHjFrD5M/yypIPlfMGWFVEvV5jClNMLAQ9bYFuOc7H1fEWw6\n" +
- "U1LZUUbJW9/CH45YXz82CYqkrfbnQxqRb2iVbVjs/sHopHd1NTiCfUtwvcYJiBVj\n" +
- "kwIDAQAB\n" +
- "-----END PUBLIC KEY-----";
-
- private final int maximumLimit;
-
- public TestJMAPServerModule(int maximumLimit) {
- this.maximumLimit = maximumLimit;
- }
-
- @Override
- protected void configure() {
- bindConstant().annotatedWith(Names.named(GetMessageListMethod.MAXIMUM_LIMIT)).to(maximumLimit);
- }
-
- @Provides
- @Singleton
- JMAPConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException{
- return JMAPConfiguration.builder()
- .keystore("keystore")
- .secret("james72laBalle")
- .jwtPublicKeyPem(Optional.of(PUBLIC_PEM_KEY))
- .randomPort()
- .build();
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
deleted file mode 100644
index 4fe0360..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
+++ /dev/null
@@ -1,119 +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 static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.commons.cli.MissingArgumentException;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.core.filesystem.FileSystemImpl;
-import org.apache.james.filesystem.api.FileSystem;
-import org.junit.Before;
-import org.junit.Test;
-
-public class FileConfigurationProviderTest {
-
- private static final String CONFIG_KEY_1 = "test2";
- private static final String CONFIG_KEY_2 = "property";
- private static final String CONFIG_KEY_4 = "james";
- private static final String CONFIG_KEY_5 = "internal";
- private static final String VALUE_1 = "0";
- private static final String VALUE_2 = "awesome";
- private static final String VALUE_3 = "james";
- private static final String FAKE_CONFIG_KEY = "fake";
- private static final String ROOT_CONFIG_KEY = "test";
- private static final String CONFIG_SEPARATOR = ".";
-
- private FileConfigurationProvider configurationProvider;
-
- @Before
- public void setUp() throws MissingArgumentException {
- FileSystemImpl fileSystem = new FileSystemImpl(new JamesServerResourceLoader("../"));
- configurationProvider = new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyArgumentShouldThrow() throws Exception {
- configurationProvider.getConfiguration("");
- }
-
- @Test(expected = NullPointerException.class)
- public void nullArgumentShouldThrow() throws Exception {
- configurationProvider.getConfiguration(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void configSeparatorArgumentShouldThrow() throws Exception {
- configurationProvider.getConfiguration(CONFIG_SEPARATOR);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyFileNameShouldThrow() throws Exception {
- configurationProvider.getConfiguration(CONFIG_SEPARATOR + ROOT_CONFIG_KEY);
- }
-
- @Test
- public void getConfigurationShouldLoadCorrespondingXMLFile() throws Exception {
- HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(ROOT_CONFIG_KEY);
- assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_1,
- String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_2),
- String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_5, CONFIG_KEY_2));
- assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_1)).isEqualTo(VALUE_1);
- }
-
- @Test
- public void getConfigurationShouldLoadCorrespondingXMLFilePart() throws Exception {
- HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(
- String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4));
- assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2,
- String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2));
- assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2);
- }
-
- @Test
- public void getConfigurationShouldLoadCorrespondingXMLFileWhenAPathIsProvidedPart() throws Exception {
- HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(
- String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4, CONFIG_KEY_5));
- assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2);
- assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_3);
- }
-
- @Test
- public void multiplesSeparatorsShouldBeTolerated() throws Exception {
- HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(
- ROOT_CONFIG_KEY + CONFIG_SEPARATOR + CONFIG_SEPARATOR + CONFIG_KEY_4);
- assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2,
- String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2));
- assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2);
- }
-
- @Test(expected = ConfigurationException.class)
- public void getConfigurationShouldThrowOnNonExistingXMLFile() throws Exception {
- assertThat(configurationProvider.getConfiguration(FAKE_CONFIG_KEY)).isNotNull();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void getConfigurationShouldThrowOnNonExistingXMLFilePart() throws Exception {
- configurationProvider.getConfiguration(String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, FAKE_CONFIG_KEY));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
deleted file mode 100644
index d8582b3..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
+++ /dev/null
@@ -1,109 +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 static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.core.filesystem.FileSystemImpl;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailrepository.api.MailRepositoryStore;
-import org.apache.james.mailrepository.file.FileMailRepository;
-import org.apache.james.modules.server.MailStoreRepositoryModule;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.Sets;
-
-public class InMemoryMailRepositoryStoreTest {
-
- private InMemoryMailRepositoryStore repositoryStore;
- private FileSystemImpl fileSystem;
-
- @Before
- public void setUp() throws Exception {
- fileSystem = new FileSystemImpl(new JamesServerResourceLoader("../"));
- repositoryStore = new InMemoryMailRepositoryStore(Sets.newHashSet(
- new MailStoreRepositoryModule.FileMailRepositoryProvider(
- fileSystem)));
- repositoryStore.configure(new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL).getConfiguration("mailrepositorystore"));
- repositoryStore.init();
- }
-
- @Test(expected = MailRepositoryStore.MailRepositoryStoreException.class)
- public void selectingANonRegisteredProtocolShouldFail() throws Exception {
- repositoryStore.select("proto://repo");
- }
-
- @Test
- public void selectingARegisteredProtocolShouldWork() throws Exception {
- assertThat(repositoryStore.select("file://repo")).isInstanceOf(FileMailRepository.class);
- }
-
- @Test
- public void selectingTwiceARegisteredProtocolWithSameDestinationShouldReturnTheSameResult() throws Exception {
- assertThat(repositoryStore.select("file://repo")).isEqualTo(repositoryStore.select("file://repo"));
- }
-
- @Test
- public void selectingTwiceARegisteredProtocolWithDifferentDestinationShouldReturnDifferentResults() throws Exception {
- assertThat(repositoryStore.select("file://repo")).isNotEqualTo(repositoryStore.select("file://repo1"));
- }
-
- @Test(expected = ConfigurationException.class)
- public void configureShouldThrowWhenNonValidClassesAreProvided() throws Exception {
- try {
- repositoryStore = new InMemoryMailRepositoryStore(Sets.newHashSet(
- new MailStoreRepositoryModule.FileMailRepositoryProvider(
- fileSystem)));
- repositoryStore.configure(new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL).getConfiguration("fakemailrepositorystore"));
- } catch (ConfigurationException e) {
- fail("Unexpected failure : ", e);
- }
- repositoryStore.init();
- }
-
- @Test
- public void getUrlsShouldBeEmptyIfNoSelectWerePerformed() {
- assertThat(repositoryStore.getUrls()).isEmpty();
- }
-
- @Test
- public void getUrlsShouldReturnUsedUrls() throws Exception {
- String url1 = "file://repo1";
- String url2 = "file://repo2";
- String url3 = "file://repo3";
- repositoryStore.select(url1);
- repositoryStore.select(url2);
- repositoryStore.select(url3);
- assertThat(repositoryStore.getUrls()).containsOnly(url1, url2, url3);
- }
-
- @Test
- public void getUrlsResultsShouldNotBeDuplicated() throws Exception {
- String url1 = "file://repo1";
- repositoryStore.select(url1);
- repositoryStore.select(url1);
- assertThat(repositoryStore.getUrls()).containsExactly(url1);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.java b/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.java
deleted file mode 100644
index 1d3de34..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/utils/PropertiesReadTest.java
+++ /dev/null
@@ -1,44 +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 static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.Test;
-
-public class PropertiesReadTest {
-
- @Test
- public void getPropertyShouldWork() throws Exception {
- PropertiesReader propertiesReader = new PropertiesReader("test.properties");
- assertThat(propertiesReader.getProperty("cassandra.ip")).isEqualTo("127.0.0.1");
- }
-
- @Test
- public void getAbsentPropertyShouldReturnNull() throws Exception {
- PropertiesReader propertiesReader = new PropertiesReader("test.properties");
- assertThat(propertiesReader.getProperty("cassandra.isslow")).isNull();
- }
-
- @Test(expected = RuntimeException.class)
- public void buildingAPropertiesReaderOnNonExistingValuesShouldThrow() throws Exception {
- new PropertiesReader("fake.properties");
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/dnsservice.xml b/server/container/cassandra-guice/src/test/resources/dnsservice.xml
deleted file mode 100644
index 0978a00..0000000
--- a/server/container/cassandra-guice/src/test/resources/dnsservice.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.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.
- -->
-
-<dnsservice>
- <servers>
- <server>8.8.8.8</server>
- <server>62.210.16.6</server>
- </servers>
- <autodiscover>false</autodiscover>
- <authoritative>false</authoritative>
- <maxcachesize>50000</maxcachesize>
-</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml b/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml
deleted file mode 100644
index 2d19a80..0000000
--- a/server/container/cassandra-guice/src/test/resources/fakemailrepositorystore.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailrepositorystore>
- <mailrepositories>
- <mailrepository class="org.apache.james.mailrepository.None">
- <protocols>
- <protocol>file</protocol>
- </protocols>
- <config FIFO="false" CACHEKEYS="true"/>
- </mailrepository>
- </mailrepositories>
-</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/imapserver.xml b/server/container/cassandra-guice/src/test/resources/imapserver.xml
deleted file mode 100644
index ff478a9..0000000
--- a/server/container/cassandra-guice/src/test/resources/imapserver.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.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.
--->
-
-
-<imapservers>
- <imapserver enabled="true">
- <jmxName>imapserver</jmxName>
- <bind>0.0.0.0:1143</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
- <imapserver enabled="true">
- <jmxName>imapserver-ssl</jmxName>
- <bind>0.0.0.0:1993</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
-</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/keystore b/server/container/cassandra-guice/src/test/resources/keystore
deleted file mode 100644
index 536a6c7..0000000
Binary files a/server/container/cassandra-guice/src/test/resources/keystore and /dev/null differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/lmtpserver.xml b/server/container/cassandra-guice/src/test/resources/lmtpserver.xml
deleted file mode 100644
index 5c4a9c7..0000000
--- a/server/container/cassandra-guice/src/test/resources/lmtpserver.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.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.
- -->
-
-<lmtpservers>
-
- <lmtpserver enabled="true">
- <jmxName>lmtpserver</jmxName>
- <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
- <bind>127.0.0.1:1024</bind>
- <connectionBacklog>200</connectionBacklog>
- <connectiontimeout>1200</connectiontimeout>
- <!-- Set the maximum simultaneous incoming connections for this service -->
- <connectionLimit>0</connectionLimit>
- <!-- Set the maximum simultaneous incoming connections per IP for this service -->
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!-- This sets the maximum allowed message size (in kilobytes) for this -->
- <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
- <maxmessagesize>0</maxmessagesize>
- <handlerchain>
- <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </lmtpserver>
-
-</lmtpservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml b/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml
deleted file mode 100644
index 57c5784..0000000
--- a/server/container/cassandra-guice/src/test/resources/mailetcontainer.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailetcontainer enableJmx="false">
-
- <context>
- <postmaster>postmaster@james.minet.net</postmaster>
- </context>
-
- <spooler>
- <threads>20</threads>
- </spooler>
-
- <processors>
- <processor state="root" enableJmx="false">
- <mailet match="All" class="PostmasterAlias"/>
- <mailet match="RelayLimit=30" class="Null"/>
- <!-- Hook on sievemanager@james.linagora.com
- Mail send to this address will get interpreted with SIEVE Manage -->
- <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
- <processor>sieve-manager-check</processor>
- </mailet>
- <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="All" class="SetMailAttribute">
- <spamChecked>true</spamChecked>
- </mailet>
- <mailet match="SMTPAuthSuccessful" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <!-- Check for delivery from a known spam server -->
- <!-- This set of matchers/mailets redirect all emails from known -->
- <!-- black holes, open relays, and spam servers to the spam processor -->
- <!-- For this set to function properly, the spam processor must be configured. -->
- <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
- <processor>spam</processor>
- <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
- </mailet>
- <mailet match="All" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- </processor>
-
- <processor state="error" enableJmx="false">
- <mailet match="All" class="Bounce"/>
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/error/</repositoryPath>
- </mailet>
- </processor>
-
-
- <processor state="transport" enableJmx="false">
- <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
- <name>X-UserIsAuth</name>
- <value>true</value>
- </mailet>
- <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
- <name>X-WasSigned</name>
- <value>true</value>
- </mailet>
- <mailet match="All" class="RemoveMimeHeader">
- <name>bcc</name>
- </mailet>
- <mailet match="All" class="RecipientRewriteTable" />
- <mailet match="RecipientIsLocal" class="LocalDelivery"/>
- <mailet match="HostIsLocal" class="ToProcessor">
- <processor>local-address-error</processor>
- <notice>550 - Requested action not taken: no such user here</notice>
- </mailet>
- <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
- <outgoingQueue>outgoing</outgoingQueue>
- <delayTime>5000, 100000, 500000</delayTime>
- <maxRetries>25</maxRetries>
- <maxDnsProblemRetries>0</maxDnsProblemRetries>
- <deliveryThreads>10</deliveryThreads>
- <sendpartial>true</sendpartial>
- <bounceProcessor>bounces</bounceProcessor>
- </mailet>
- <mailet match="All" class="ToProcessor">
- <processor>relay-denied</processor>
- </mailet>
- </processor>
-
- <processor state="spam" enableJmx="false">
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/spam/</repositoryPath>
- </mailet>
- </processor>
-
- <processor state="local-address-error" enableJmx="false">
- <mailet match="All" class="Bounce">
- <attachment>none</attachment>
- </mailet>
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/address-error/</repositoryPath>
- </mailet>
- </processor>
-
- <processor state="relay-denied" enableJmx="false">
- <mailet match="All" class="Bounce">
- <attachment>none</attachment>
- </mailet>
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
- <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
- </mailet>
- </processor>
-
- <processor state="bounces" enableJmx="false">
- <mailet match="All" class="DSNBounce">
- <passThrough>false</passThrough>
- </mailet>
- </processor>
-
- <processor state="sieve-manager-check" enableJmx="false">
- <!-- Only local users can manage their scripts -->
- <mailet match="RecipientIsLocal" class="ToProcessor">
- <processor>sieve-manager</processor>
- </mailet>
- <!-- Notify other people about their failure -->
- <mailet match="All" class="Bounce">
- <inline>heads</inline>
- <attachment>none</attachment>
- <passThrough>false</passThrough>
- <prefix>[REJECTED]</prefix>
- <notice>
- You can't send messages to configure SIEVE on this serveur unless you are the official SIEVE manager.
- </notice>
- </mailet>
- <mailet match="All" class="Null"/>
- </processor>
-
- <processor state="sieve-manager">
- <mailet match="All" class="SetMailAttribute">
- <org.apache.james.SMTPAuthUser>true</org.apache.james.SMTPAuthUser>
- </mailet>
- <mailet match="All" class="org.apache.james.transport.mailets.managesieve.ManageSieveMailet">
- <helpURL>file:/root/james-server-app-3.0.0-beta5-SNAPSHOT/conf/managesieve.help.txt</helpURL>
- </mailet>
- <mailet match="All" class="Null"/>
- </processor>
- </processors>
-
-</mailetcontainer>
-
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml b/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml
deleted file mode 100644
index 3ca4a1d..0000000
--- a/server/container/cassandra-guice/src/test/resources/mailrepositorystore.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailrepositorystore>
- <mailrepositories>
- <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
- <protocols>
- <protocol>file</protocol>
- </protocols>
- <config FIFO="false" CACHEKEYS="true"/>
- </mailrepository>
- </mailrepositories>
-</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/managesieveserver.xml b/server/container/cassandra-guice/src/test/resources/managesieveserver.xml
deleted file mode 100644
index ec57e09..0000000
--- a/server/container/cassandra-guice/src/test/resources/managesieveserver.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.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.
- -->
-
-<!--
- This template file can be used as example for James Server configuration
- DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
--->
-
-<!-- See http://james.apache.org/server/3/config.html for usage -->
-
-<managesieveservers>
-
- <managesieveserver enabled="true">
-
- <jmxName>managesieveserver</jmxName>
-
- <bind>0.0.0.0:4190</bind>
-
- <connectionBacklog>200</connectionBacklog>
-
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <!-- The algorithm is optional and only needs to be specified when using something other
- than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
- <algorithm>SunX509</algorithm>
- </tls>
-
- <!-- connection timeout in secconds -->
- <connectiontimeout>360</connectiontimeout>
-
- <!-- Set the maximum simultaneous incoming connections for this service -->
- <connectionLimit>0</connectionLimit>
-
- <!-- Set the maximum simultaneous incoming connections per IP for this service -->
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
-
- </managesieveserver>
-
-</managesieveservers>
-
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/pop3server.xml b/server/container/cassandra-guice/src/test/resources/pop3server.xml
deleted file mode 100644
index e4187da..0000000
--- a/server/container/cassandra-guice/src/test/resources/pop3server.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.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.
- -->
-
-
-<pop3servers>
- <pop3server enabled="true">
- <jmxName>pop3server</jmxName>
- <bind>0.0.0.0:1110</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectiontimeout>1200</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <handlerchain>
- <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
- </handlerchain>
- </pop3server>
-</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/smtpserver.xml b/server/container/cassandra-guice/src/test/resources/smtpserver.xml
deleted file mode 100644
index a3d4b8f..0000000
--- a/server/container/cassandra-guice/src/test/resources/smtpserver.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.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.
- -->
-
-<smtpservers>
- <smtpserver enabled="true">
- <jmxName>smtpserver-global</jmxName>
- <bind>0.0.0.0:1025</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <authRequired>false</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <verifyIdentity>true</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
- <smtpserver enabled="true">
- <jmxName>smtpserver-TLS</jmxName>
- <bind>0.0.0.0:10465</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!--
- Authorize only local users
- -->
- <authRequired>true</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <!-- Trust authenticated users -->
- <verifyIdentity>false</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
- <smtpserver enabled="true">
- <jmxName>smtpserver-authenticated</jmxName>
- <bind>0.0.0.0:1587</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!--
- Authorize only local users
- -->
- <authRequired>true</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <!-- Trust authenticated users -->
- <verifyIdentity>false</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
-</smtpservers>
-
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/test.properties b/server/container/cassandra-guice/src/test/resources/test.properties
deleted file mode 100644
index b4db9c1..0000000
--- a/server/container/cassandra-guice/src/test/resources/test.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# Configuration file for cassandra mailbox
-
-cassandra.ip=127.0.0.1
-cassandra.port=9142
-cassandra.keyspace=apache_james
-cassandra.replication.factor=1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/test/resources/test.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/test.xml b/server/container/cassandra-guice/src/test/resources/test.xml
deleted file mode 100644
index 8d89ecc..0000000
--- a/server/container/cassandra-guice/src/test/resources/test.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.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.
- -->
-<test>
- <test2>0</test2>
- <james>
- <property>awesome</property>
- <internal>
- <property>james</property>
- </internal>
- </james>
-</test>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/cassandra-guice/README.adoc
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/README.adoc b/server/container/guice/cassandra-guice/README.adoc
new file mode 100644
index 0000000..e3648ff
--- /dev/null
+++ b/server/container/guice/cassandra-guice/README.adoc
@@ -0,0 +1,45 @@
+= Guice-Cassandra Module How-to
+
+== Building
+
+=== Requirements
+
+ * Java 8 SDK
+ * Docker
+ * Maven
+
+=== Building the artifacts
+
+An usual compilation using maven will produce two artifacts into target directory :
+
+ * james-server-cassandra-guice-${version}.jar
+ * james-server-cassandra-guice-${version}.lib
+
+== Running
+
+=== Requirements
+
+ * Cassandra
+ * ElasticSearch 1.5.2
+
+=== James Launch
+
+To run james, you have to create a directory containing required configuration files.
+
+A sample directory (appropriately named sample-directory) is provided with some
+default value you may need to replace.
+
+You also need to generate a keystore with the following command :
+[source]
+----
+$ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore
+----
+
+You need to have a Cassandra and an ElasticSearch instance running.
+
+Once everything is set up, you just have to run the jar with :
+
+[source]
+----
+$ java -Dworking.directory=sample-configuration -jar target/james-server-cassandra-guice-${version}.jar
+----
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[02/24] james-project git commit: JAMES-1693 Provide an InMemory RRT
Posted by ma...@apache.org.
JAMES-1693 Provide an InMemory RRT
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/940a0ec5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/940a0ec5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/940a0ec5
Branch: refs/heads/master
Commit: 940a0ec5ab70770e55fc7ac6c5c8c8df12a32be8
Parents: e62f6f6
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Feb 29 12:06:02 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:03:55 2016 +0100
----------------------------------------------------------------------
server/data/data-memory/pom.xml | 26 +--
.../rrt/memory/MemoryRecipientRewriteTable.java | 163 +++++++++++++++++++
.../InMemoryRecipientRewriteTableTest.java | 86 ++++++++++
.../james/rrt/memory/InMemoryStepdefs.java | 48 ++++++
.../james/rrt/memory/RewriteTablesTest.java | 32 ++++
5 files changed, 343 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/940a0ec5/server/data/data-memory/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-memory/pom.xml b/server/data/data-memory/pom.xml
index fcd01e3..aa35b9f 100644
--- a/server/data/data-memory/pom.xml
+++ b/server/data/data-memory/pom.xml
@@ -43,10 +43,6 @@
<artifactId>james-server-data-library</artifactId>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.james</groupId>
<artifactId>james-server-data-library</artifactId>
<type>test-jar</type>
@@ -59,23 +55,29 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>info.cukes</groupId>
+ <artifactId>cucumber-java</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>${assertj-1.version}</version>
+ <groupId>info.cukes</groupId>
+ <artifactId>cucumber-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
- <artifactId>cucumber-java</artifactId>
+ <artifactId>cucumber-picocontainer</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>info.cukes</groupId>
- <artifactId>cucumber-junit</artifactId>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-1.version}</version>
<scope>test</scope>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/940a0ec5/server/data/data-memory/src/main/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/main/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTable.java b/server/data/data-memory/src/main/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTable.java
new file mode 100644
index 0000000..4445207
--- /dev/null
+++ b/server/data/data-memory/src/main/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTable.java
@@ -0,0 +1,163 @@
+/****************************************************************
+ * 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.rrt.memory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimaps;
+
+public class MemoryRecipientRewriteTable extends AbstractRecipientRewriteTable {
+
+ private static class InMemoryMappingEntry {
+ private final String user;
+ private final String domain;
+ private final String mapping;
+
+ public InMemoryMappingEntry(String user, String domain, String mapping) {
+ this.user = user;
+ this.domain = domain;
+ this.mapping = mapping;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public String getMapping() {
+ return mapping;
+ }
+
+ public String asKey() {
+ return getUser() + "@" + getDomain();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || this.getClass() != o.getClass()) {
+ return false;
+ }
+
+ InMemoryMappingEntry that = (InMemoryMappingEntry) o;
+
+ return Objects.equal(this.user, that.user)
+ && Objects.equal(this.domain, that.domain)
+ && Objects.equal(this.mapping, that.mapping);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(user, domain, mapping);
+ }
+ }
+
+ private final List<InMemoryMappingEntry> mappingEntries;
+
+ public MemoryRecipientRewriteTable() {
+ mappingEntries = new ArrayList<InMemoryMappingEntry>();
+ }
+
+ @Override
+ protected void addMappingInternal(String user, String domain, String mapping) throws RecipientRewriteTableException {
+ mappingEntries.add(new InMemoryMappingEntry(getFixedUser(user), getFixedDomain(domain), mapping));
+ }
+
+ @Override
+ protected void removeMappingInternal(String user, String domain, String mapping) throws RecipientRewriteTableException {
+ mappingEntries.remove(new InMemoryMappingEntry(getFixedUser(user), getFixedDomain(domain), mapping));
+ }
+
+ @Override
+ protected Mappings getUserDomainMappingsInternal(String user, String domain) throws RecipientRewriteTableException {
+ return retrieveMappings(user, domain)
+ .orNull();
+ }
+
+ @Override
+ protected String mapAddressInternal(String user, String domain) throws RecipientRewriteTableException {
+ Mappings mappings = retrieveMappings(user, domain)
+ .or(retrieveMappings(WILDCARD, domain)
+ .or(retrieveMappings(user, WILDCARD)
+ .or(MappingsImpl.empty())));
+
+ return !mappings.isEmpty() ? mappings.serialize() : null;
+ }
+
+ @Override
+ protected Map<String, Mappings> getAllMappingsInternal() throws RecipientRewriteTableException {
+ if (mappingEntries.isEmpty()) {
+ return null;
+ }
+ Map<String, Collection<Mappings>> userMappingsMap = Multimaps.transformEntries(
+ Multimaps.index(mappingEntries, new Function<InMemoryMappingEntry, String>() {
+ public String apply(InMemoryMappingEntry mappingEntry) {
+ return mappingEntry.asKey();
+ }
+ }), new Maps.EntryTransformer<String, InMemoryMappingEntry, Mappings>() {
+ public Mappings transformEntry(String s, InMemoryMappingEntry mappingEntry) {
+ return MappingsImpl.fromRawString(mappingEntry.getMapping());
+ }
+ }).asMap();
+ return Maps.transformEntries(userMappingsMap, new Maps.EntryTransformer<String, Collection<Mappings>, Mappings>() {
+ public Mappings transformEntry(String s, Collection<Mappings> mappingsList) {
+ Mappings result = MappingsImpl.empty();
+ for (Mappings mappings : mappingsList) {
+ result = result.union(mappings);
+ }
+ return result;
+ }
+ });
+ }
+
+ private Optional<Mappings> retrieveMappings(final String user, final String domain) {
+ List<String> userEntries = Lists.newArrayList(
+ Iterables.transform(
+ Iterables.filter(mappingEntries, new Predicate<InMemoryMappingEntry>() {
+ public boolean apply(InMemoryMappingEntry mappingEntry) {
+ return user.equals(mappingEntry.getUser()) && domain.equals(mappingEntry.getDomain());
+ }
+ }), new Function<InMemoryMappingEntry, String>() {
+ @Override
+ public String apply(InMemoryMappingEntry mappingEntry) {
+ return mappingEntry.getMapping();
+ }
+ }));
+ return MappingsImpl.fromCollection(userEntries).toOptional();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/940a0ec5/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryRecipientRewriteTableTest.java b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryRecipientRewriteTableTest.java
new file mode 100644
index 0000000..80032d9
--- /dev/null
+++ b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryRecipientRewriteTableTest.java
@@ -0,0 +1,86 @@
+/****************************************************************
+ * 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.rrt.memory;
+
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.slf4j.LoggerFactory;
+
+public class InMemoryRecipientRewriteTableTest extends AbstractRecipientRewriteTableTest {
+
+ @Override
+ protected AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
+ AbstractRecipientRewriteTable rrt = new MemoryRecipientRewriteTable();
+ rrt.setLog(LoggerFactory.getLogger("MockLog"));
+ rrt.configure(new DefaultConfigurationBuilder());
+ return rrt;
+ }
+
+ @Override
+ protected boolean addMapping(String user, String domain, String mapping, int type) throws RecipientRewriteTableException {
+ try {
+ switch (type) {
+ case ERROR_TYPE:
+ virtualUserTable.addErrorMapping(user, domain, mapping);
+ return true;
+ case REGEX_TYPE:
+ virtualUserTable.addRegexMapping(user, domain, mapping);
+ return true;
+ case ADDRESS_TYPE:
+ virtualUserTable.addAddressMapping(user, domain, mapping);
+ return true;
+ case ALIASDOMAIN_TYPE:
+ virtualUserTable.addAliasDomainMapping(domain, mapping);
+ return true;
+ default:
+ return false;
+ }
+ } catch (RecipientRewriteTableException e) {
+ return false;
+ }
+ }
+
+ @Override
+ protected boolean removeMapping(String user, String domain, String mapping, int type) throws RecipientRewriteTableException {
+ try {
+ switch (type) {
+ case ERROR_TYPE:
+ virtualUserTable.removeErrorMapping(user, domain, mapping);
+ return true;
+ case REGEX_TYPE:
+ virtualUserTable.removeRegexMapping(user, domain, mapping);
+ return true;
+ case ADDRESS_TYPE:
+ virtualUserTable.removeAddressMapping(user, domain, mapping);
+ return true;
+ case ALIASDOMAIN_TYPE:
+ virtualUserTable.removeAliasDomainMapping(domain, mapping);
+ return true;
+ default:
+ return false;
+ }
+ } catch (RecipientRewriteTableException e) {
+ return false;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/940a0ec5/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryStepdefs.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryStepdefs.java b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryStepdefs.java
new file mode 100644
index 0000000..118d3fd
--- /dev/null
+++ b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/InMemoryStepdefs.java
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.rrt.memory;
+
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.RewriteTablesStepdefs;
+import org.slf4j.LoggerFactory;
+
+import cucumber.api.java.Before;
+
+public class InMemoryStepdefs {
+
+ private final RewriteTablesStepdefs mainStepdefs;
+
+ public InMemoryStepdefs(RewriteTablesStepdefs mainStepdefs) {
+ this.mainStepdefs = mainStepdefs;
+ }
+
+ @Before
+ public void setup() throws Throwable {
+ mainStepdefs.rewriteTable = getRecipientRewriteTable();
+ }
+
+ private AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception {
+ MemoryRecipientRewriteTable rrt = new MemoryRecipientRewriteTable();
+ rrt.setLog(LoggerFactory.getLogger("MockLog"));
+ rrt.configure(new DefaultConfigurationBuilder());
+ return rrt;
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/940a0ec5/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/RewriteTablesTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/RewriteTablesTest.java b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/RewriteTablesTest.java
new file mode 100644
index 0000000..ee218f9
--- /dev/null
+++ b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/RewriteTablesTest.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.rrt.memory;
+
+import org.junit.runner.RunWith;
+
+import cucumber.api.CucumberOptions;
+import cucumber.api.junit.Cucumber;
+
+@RunWith(Cucumber.class)
+@CucumberOptions(
+ features = { "classpath:cucumber/" },
+ glue = { "org.apache.james.rrt.lib", "org.apache.james.rrt.memory" }
+ )
+public class RewriteTablesTest {
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[13/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailetLoader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailetLoader.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailetLoader.java
new file mode 100644
index 0000000..f979ac2
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailetLoader.java
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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 javax.mail.MessagingException;
+
+import org.apache.james.mailetcontainer.api.MailetLoader;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+public class GuiceMailetLoader implements MailetLoader {
+
+ private static final String STANDARD_PACKAGE = "org.apache.james.transport.mailets.";
+
+ private final GuiceGenericLoader<Mailet> genericLoader;
+
+ @Inject
+ public GuiceMailetLoader(Injector injector) {
+ this.genericLoader = new GuiceGenericLoader<>(injector, STANDARD_PACKAGE);
+ }
+
+ @Override
+ public Mailet getMailet(MailetConfig config) throws MessagingException {
+ try {
+ Mailet result = genericLoader.instanciate(config.getMailetName());
+ result.init(config);
+ return result;
+ } catch (Exception e) {
+ throw new MessagingException("Can not load mailet " + config.getMailetName(), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java
new file mode 100644
index 0000000..10e7cd6
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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 javax.mail.MessagingException;
+
+import org.apache.james.mailetcontainer.api.MatcherLoader;
+import org.apache.mailet.Matcher;
+import org.apache.mailet.MatcherConfig;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+public class GuiceMatcherLoader implements MatcherLoader {
+
+ private static final String STANDARD_PACKAGE = "org.apache.james.transport.matchers.";
+
+ private final GuiceGenericLoader<Matcher> genericLoader;
+
+ @Inject
+ public GuiceMatcherLoader(Injector injector) {
+ this.genericLoader = new GuiceGenericLoader<>(injector, STANDARD_PACKAGE);
+ }
+
+ @Override
+ public Matcher getMatcher(MatcherConfig config) throws MessagingException {
+ try {
+ Matcher result = genericLoader.instanciate(config.getMatcherName());
+ result.init(config);
+ return result;
+ } catch (Exception e) {
+ throw new MessagingException("Can not load matcher " + config.getMatcherName(), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java
new file mode 100644
index 0000000..281f341
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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 org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.protocols.api.handler.ProtocolHandler;
+import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
+
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+public class GuiceProtocolHandlerLoader implements ProtocolHandlerLoader {
+
+ private final Injector injector;
+
+ @Inject
+ public GuiceProtocolHandlerLoader(Injector injector) {
+ this.injector = injector;
+ }
+
+ @Override
+ public ProtocolHandler load(String name, Configuration config) throws LoadingException {
+ ProtocolHandler handler = createProtocolHandler(name);
+ try {
+ handler.init(config);
+ } catch (ConfigurationException e) {
+ throw Throwables.propagate(e);
+ }
+ return handler;
+ }
+
+ private ProtocolHandler createProtocolHandler(String name) throws LoadingException {
+ try {
+ @SuppressWarnings("unchecked")
+ Class<ProtocolHandler> clazz = (Class<ProtocolHandler>) ClassLoader.getSystemClassLoader().loadClass(name);
+ return injector.getInstance(clazz);
+ } catch (ClassNotFoundException e) {
+ throw new LoadingException("Can not load " + name);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/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
new file mode 100644
index 0000000..a2d687e
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceServerProbe.java
@@ -0,0 +1,344 @@
+/****************************************************************
+ * 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.exception.MailboxException;
+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.mail.model.MailboxId;
+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<Id extends MailboxId> implements ExtendedServerProbe<Id> {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GuiceServerProbe.class);
+
+ private final MailboxManager mailboxManager;
+ private final MailboxMapperFactory<Id> mailboxMapperFactory;
+ private final DomainList domainList;
+ private final UsersRepository usersRepository;
+ private final SieveRepository sieveRepository;
+
+ @Inject
+ private GuiceServerProbe(MailboxManager mailboxManager, MailboxMapperFactory<Id> mailboxMapperFactory,
+ DomainList domainList, UsersRepository usersRepository, SieveRepository sieveRepository) {
+ this.mailboxManager = mailboxManager;
+ this.mailboxMapperFactory = mailboxMapperFactory;
+ this.domainList = domainList;
+ this.usersRepository = usersRepository;
+ this.sieveRepository = sieveRepository;
+ }
+
+ @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 void removeDomain(String domain) throws Exception {
+ domainList.removeDomain(domain);
+ }
+
+ @Override
+ public String[] listDomains() throws Exception {
+ return domainList.getDomains();
+ }
+
+ @Override
+ public Map<String, Mappings> listMappings() throws Exception {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void addAddressMapping(String user, String domain, String toAddress) throws Exception {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void removeAddressMapping(String user, String domain, String fromAddress) throws Exception {
+ throw new NotImplementedException();
+ }
+
+ @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 {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void removeRegexMapping(String user, String domain, String regex) throws Exception {
+ throw new NotImplementedException();
+ }
+
+ @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<Id> getMailbox(String namespace, String user, String name) {
+ MailboxSession mailboxSession = null;
+ try {
+ mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
+ MailboxMapper<Id> 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 void 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);
+ 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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
new file mode 100644
index 0000000..066f57a
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
@@ -0,0 +1,164 @@
+/****************************************************************
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.stream.Collectors;
+
+import javax.inject.Singleton;
+
+import org.apache.commons.configuration.CombinedConfiguration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.lifecycle.api.LogEnabled;
+import org.apache.james.mailrepository.api.MailRepository;
+import org.apache.james.mailrepository.api.MailRepositoryStore;
+import org.apache.james.repository.api.Initializable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+
+@Singleton
+public class InMemoryMailRepositoryStore implements MailRepositoryStore {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryMailRepositoryStore.class);
+
+ private final Set<MailRepositoryProvider> mailRepositories;
+ private final ConcurrentMap<String, MailRepository> destinationToRepositoryAssociations;
+ private final Map<String, MailRepositoryProvider> protocolToRepositoryProvider;
+ private final Map<String, HierarchicalConfiguration> perProtocolMailRepositoryDefaultConfiguration;
+ private HierarchicalConfiguration configuration;
+
+ @Inject
+ public InMemoryMailRepositoryStore(Set<MailRepositoryProvider> mailRepositories) {
+ this.mailRepositories = mailRepositories;
+ this.destinationToRepositoryAssociations = new ConcurrentHashMap<>();
+ this.protocolToRepositoryProvider = new HashMap<>();
+ this.perProtocolMailRepositoryDefaultConfiguration = new HashMap<>();
+ }
+
+ @Override
+ public List<String> getUrls() {
+ return destinationToRepositoryAssociations.keySet()
+ .stream()
+ .collect(Collectors.toList());
+ }
+
+ public void configure(HierarchicalConfiguration configuration) throws ConfigurationException {
+ this.configuration = configuration;
+ }
+
+ public void init() throws Exception {
+ LOGGER.info("JamesMailStore init... " + this);
+ List<HierarchicalConfiguration> registeredClasses = configuration.configurationsAt("mailrepositories.mailrepository");
+ for (HierarchicalConfiguration registeredClass : registeredClasses) {
+ readConfigurationEntry(registeredClass);
+ }
+ }
+
+ @Override
+ public MailRepository select(String destination) throws MailRepositoryStoreException {
+ MailRepository mailRepository = destinationToRepositoryAssociations.get(destination);
+ if (mailRepository != null) {
+ return mailRepository;
+ }
+ String protocol = retrieveProtocol(destination);
+ mailRepository = retrieveMailRepository(protocol);
+ mailRepository = initialiseNewRepository(mailRepository, createRepositoryCombinedConfig(destination, protocol));
+ destinationToRepositoryAssociations.putIfAbsent(destination, mailRepository);
+ return mailRepository;
+ }
+
+ private void readConfigurationEntry(HierarchicalConfiguration repositoryConfiguration) throws ConfigurationException {
+ String className = repositoryConfiguration.getString("[@class]");
+ MailRepositoryProvider usedMailRepository = mailRepositories.stream()
+ .filter(mailRepositoryProvider -> mailRepositoryProvider.canonicalName().equals(className))
+ .findAny()
+ .orElseThrow(() -> new ConfigurationException("MailRepository " + className + " has not been registered"));
+ for (String protocol : repositoryConfiguration.getStringArray("protocols.protocol")) {
+ protocolToRepositoryProvider.put(protocol, usedMailRepository);
+ registerRepositoryDefaultConfiguration(repositoryConfiguration, protocol);
+ }
+ }
+
+ private void registerRepositoryDefaultConfiguration(HierarchicalConfiguration repositoryConfiguration, String protocol) {
+ HierarchicalConfiguration defConf = null;
+ if (repositoryConfiguration.getKeys("config").hasNext()) {
+ defConf = repositoryConfiguration.configurationAt("config");
+ }
+ if (defConf != null) {
+ perProtocolMailRepositoryDefaultConfiguration.put(protocol, defConf);
+ }
+ }
+
+ private CombinedConfiguration createRepositoryCombinedConfig(String destination, String protocol) {
+ final CombinedConfiguration config = new CombinedConfiguration();
+ HierarchicalConfiguration defaultProtocolConfig = perProtocolMailRepositoryDefaultConfiguration.get(protocol);
+ if (defaultProtocolConfig != null) {
+ config.addConfiguration(defaultProtocolConfig);
+ }
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+ builder.addProperty("[@destinationURL]", destination);
+ config.addConfiguration(builder);
+ return config;
+ }
+
+ private MailRepository initialiseNewRepository(MailRepository mailRepository, CombinedConfiguration config) throws MailRepositoryStoreException {
+ try {
+ if (mailRepository instanceof LogEnabled) {
+ ((LogEnabled) mailRepository).setLog(LOGGER);
+ }
+ if (mailRepository instanceof Configurable) {
+ ((Configurable) mailRepository).configure(config);
+ }
+ if (mailRepository instanceof Initializable) {
+ ((Initializable) mailRepository).init();
+ }
+ return mailRepository;
+ } catch (Exception e) {
+ throw new MailRepositoryStoreException("Cannot init mail repository", e);
+ }
+ }
+
+ private MailRepository retrieveMailRepository(String protocol) throws MailRepositoryStoreException {
+ MailRepositoryProvider repositoryProvider = protocolToRepositoryProvider.get(protocol);
+ if (repositoryProvider == null) {
+ throw new MailRepositoryStoreException("No Mail Repository associated with " + protocol);
+ }
+ return repositoryProvider.get();
+ }
+
+ private String retrieveProtocol(String destination) throws MailRepositoryStoreException {
+ int protocolSeparatorPosition = destination.indexOf(':');
+ if (protocolSeparatorPosition == -1) {
+ throw new MailRepositoryStoreException("Destination is malformed. Must be a valid URL: " + destination);
+ }
+ return destination.substring(0, protocolSeparatorPosition);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailRepositoryProvider.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailRepositoryProvider.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailRepositoryProvider.java
new file mode 100644
index 0000000..035f574
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailRepositoryProvider.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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 javax.inject.Provider;
+
+import org.apache.james.mailrepository.api.MailRepository;
+
+public interface MailRepositoryProvider extends Provider<MailRepository> {
+
+ String canonicalName();
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java
new file mode 100644
index 0000000..211398a
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/MailboxManagerDefinition.java
@@ -0,0 +1,57 @@
+/****************************************************************
+ * 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 org.apache.james.mailbox.MailboxManager;
+
+import com.google.common.base.Objects;
+
+public class MailboxManagerDefinition {
+
+ private final String name;
+ private final MailboxManager manager;
+
+ public MailboxManagerDefinition(String name, MailboxManager manager) {
+ this.name = name;
+ this.manager = manager;
+ }
+
+ public MailboxManager getManager() {
+ return manager;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, manager);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof MailboxManagerDefinition) {
+ MailboxManagerDefinition other = (MailboxManagerDefinition) obj;
+ return Objects.equal(name, other.name) && Objects.equal(manager, other.manager);
+ }
+ return false;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/PropertiesReader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/PropertiesReader.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/PropertiesReader.java
new file mode 100644
index 0000000..cbf981d
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/PropertiesReader.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.util.Properties;
+
+import com.google.common.base.Throwables;
+
+public class PropertiesReader {
+
+ private final Properties properties;
+
+ public PropertiesReader(String fileName) {
+ properties = new Properties();
+ try {
+ properties.load(ClassLoader.getSystemResourceAsStream(fileName));
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public String getProperty(String key) {
+ return properties.getProperty(key);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/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
new file mode 100644
index 0000000..cdb408c
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/AbstractJamesServerTest.java
@@ -0,0 +1,117 @@
+/****************************************************************
+ * 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;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
+import java.nio.charset.Charset;
+
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public abstract class AbstractJamesServerTest<Id extends MailboxId> {
+
+ private static final int IMAP_PORT = 1143; // You need to be root (superuser) to bind to ports under 1024.
+ private static final int IMAP_PORT_SSL = 1993;
+ private static final int POP3_PORT = 1110;
+ private static final int SMTP_PORT = 1025;
+ private static final int LMTP_PORT = 1024;
+
+ private GuiceJamesServer<Id> server;
+ private SocketChannel socketChannel;
+
+ @Before
+ public void setup() throws Exception {
+ server = createJamesServer();
+ socketChannel = SocketChannel.open();
+ server.start();
+
+ RestAssured.port = server.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+ }
+
+ protected abstract GuiceJamesServer<Id> createJamesServer();
+
+ @After
+ public void tearDown() throws Exception {
+ server.stop();
+ }
+
+ @Test
+ public void connectIMAPServerShouldSendShabangOnConnect() throws Exception {
+ socketChannel.connect(new InetSocketAddress("127.0.0.1", IMAP_PORT));
+ assertThat(getServerConnectionResponse(socketChannel)).startsWith("* OK JAMES IMAP4rev1 Server");
+ }
+
+ @Test
+ public void connectOnSecondaryIMAPServerIMAPServerShouldSendShabangOnConnect() throws Exception {
+ socketChannel.connect(new InetSocketAddress("127.0.0.1", IMAP_PORT_SSL));
+ assertThat(getServerConnectionResponse(socketChannel)).startsWith("* OK JAMES IMAP4rev1 Server");
+ }
+
+ @Test
+ public void connectPOP3ServerShouldSendShabangOnConnect() throws Exception {
+ socketChannel.connect(new InetSocketAddress("127.0.0.1", POP3_PORT));
+ assertThat(getServerConnectionResponse(socketChannel)).contains("POP3 server (JAMES POP3 Server ) ready");
+ }
+
+ @Test
+ public void connectSMTPServerShouldSendShabangOnConnect() throws Exception {
+ socketChannel.connect(new InetSocketAddress("127.0.0.1", SMTP_PORT));
+ assertThat(getServerConnectionResponse(socketChannel)).startsWith("220 JAMES Linagora's SMTP awesome Server");
+ }
+
+ @Test
+ public void connectLMTPServerShouldSendShabangOnConnect() throws Exception {
+ socketChannel.connect(new InetSocketAddress("127.0.0.1", LMTP_PORT));
+ assertThat(getServerConnectionResponse(socketChannel)).contains("LMTP Server (JAMES Protocols Server) ready");
+ }
+
+ @Test
+ public void connectJMAPServerShouldRespondBadRequest() throws Exception {
+ given()
+ .contentType(ContentType.JSON)
+ .accept(ContentType.JSON)
+ .body("{\"badAttributeName\": \"value\"}")
+ .when()
+ .post("/authentication")
+ .then()
+ .statusCode(400);
+ }
+
+ private String getServerConnectionResponse(SocketChannel socketChannel) throws IOException {
+ ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
+ socketChannel.read(byteBuffer);
+ byte[] bytes = byteBuffer.array();
+ return new String(bytes, Charset.forName("UTF-8"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java
new file mode 100644
index 0000000..9f5bba4
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestFilesystemModule.java
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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.File;
+import java.io.IOException;
+import java.util.function.Supplier;
+
+import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.filesystem.api.JamesDirectoriesProvider;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.common.base.Throwables;
+import com.google.inject.AbstractModule;
+import com.google.inject.name.Names;
+
+public class TestFilesystemModule extends AbstractModule {
+
+ private final Supplier<File> workingDirectory;
+
+ private static File createTempDir(TemporaryFolder temporaryFolder) {
+ try {
+ return temporaryFolder.newFolder();
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public TestFilesystemModule(TemporaryFolder temporaryFolder) {
+ this(() -> TestFilesystemModule.createTempDir(temporaryFolder));
+ }
+
+ public TestFilesystemModule(Supplier<File> workingDirectory) {
+ this.workingDirectory = workingDirectory;
+ }
+
+ @Override
+ protected void configure() {
+ bind(JamesDirectoriesProvider.class).toInstance(new JamesServerResourceLoader(workingDirectory.get().getAbsolutePath()));
+ bindConstant().annotatedWith(Names.named(CommonServicesModule.CONFIGURATION_PATH)).to(FileSystem.CLASSPATH_PROTOCOL);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestJMAPServerModule.java b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
new file mode 100644
index 0000000..6512fac
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/TestJMAPServerModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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.FileNotFoundException;
+import java.util.Optional;
+
+import javax.inject.Singleton;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.jmap.JMAPConfiguration;
+import org.apache.james.jmap.methods.GetMessageListMethod;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.name.Names;
+
+public class TestJMAPServerModule extends AbstractModule{
+
+ private static final String PUBLIC_PEM_KEY = "-----BEGIN PUBLIC KEY-----\n" +
+ "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlChO/nlVP27MpdkG0Bh\n" +
+ "16XrMRf6M4NeyGa7j5+1UKm42IKUf3lM28oe82MqIIRyvskPc11NuzSor8HmvH8H\n" +
+ "lhDs5DyJtx2qp35AT0zCqfwlaDnlDc/QDlZv1CoRZGpQk1Inyh6SbZwYpxxwh0fi\n" +
+ "+d/4RpE3LBVo8wgOaXPylOlHxsDizfkL8QwXItyakBfMO6jWQRrj7/9WDhGf4Hi+\n" +
+ "GQur1tPGZDl9mvCoRHjFrD5M/yypIPlfMGWFVEvV5jClNMLAQ9bYFuOc7H1fEWw6\n" +
+ "U1LZUUbJW9/CH45YXz82CYqkrfbnQxqRb2iVbVjs/sHopHd1NTiCfUtwvcYJiBVj\n" +
+ "kwIDAQAB\n" +
+ "-----END PUBLIC KEY-----";
+
+ private final int maximumLimit;
+
+ public TestJMAPServerModule(int maximumLimit) {
+ this.maximumLimit = maximumLimit;
+ }
+
+ @Override
+ protected void configure() {
+ bindConstant().annotatedWith(Names.named(GetMessageListMethod.MAXIMUM_LIMIT)).to(maximumLimit);
+ }
+
+ @Provides
+ @Singleton
+ JMAPConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException{
+ return JMAPConfiguration.builder()
+ .keystore("keystore")
+ .secret("james72laBalle")
+ .jwtPublicKeyPem(Optional.of(PUBLIC_PEM_KEY))
+ .randomPort()
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
new file mode 100644
index 0000000..4fe0360
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
@@ -0,0 +1,119 @@
+/****************************************************************
+ * 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 static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.cli.MissingArgumentException;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.core.filesystem.FileSystemImpl;
+import org.apache.james.filesystem.api.FileSystem;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FileConfigurationProviderTest {
+
+ private static final String CONFIG_KEY_1 = "test2";
+ private static final String CONFIG_KEY_2 = "property";
+ private static final String CONFIG_KEY_4 = "james";
+ private static final String CONFIG_KEY_5 = "internal";
+ private static final String VALUE_1 = "0";
+ private static final String VALUE_2 = "awesome";
+ private static final String VALUE_3 = "james";
+ private static final String FAKE_CONFIG_KEY = "fake";
+ private static final String ROOT_CONFIG_KEY = "test";
+ private static final String CONFIG_SEPARATOR = ".";
+
+ private FileConfigurationProvider configurationProvider;
+
+ @Before
+ public void setUp() throws MissingArgumentException {
+ FileSystemImpl fileSystem = new FileSystemImpl(new JamesServerResourceLoader("../"));
+ configurationProvider = new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void emptyArgumentShouldThrow() throws Exception {
+ configurationProvider.getConfiguration("");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void nullArgumentShouldThrow() throws Exception {
+ configurationProvider.getConfiguration(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void configSeparatorArgumentShouldThrow() throws Exception {
+ configurationProvider.getConfiguration(CONFIG_SEPARATOR);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void emptyFileNameShouldThrow() throws Exception {
+ configurationProvider.getConfiguration(CONFIG_SEPARATOR + ROOT_CONFIG_KEY);
+ }
+
+ @Test
+ public void getConfigurationShouldLoadCorrespondingXMLFile() throws Exception {
+ HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(ROOT_CONFIG_KEY);
+ assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_1,
+ String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_2),
+ String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_5, CONFIG_KEY_2));
+ assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_1)).isEqualTo(VALUE_1);
+ }
+
+ @Test
+ public void getConfigurationShouldLoadCorrespondingXMLFilePart() throws Exception {
+ HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(
+ String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4));
+ assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2,
+ String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2));
+ assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2);
+ }
+
+ @Test
+ public void getConfigurationShouldLoadCorrespondingXMLFileWhenAPathIsProvidedPart() throws Exception {
+ HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(
+ String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4, CONFIG_KEY_5));
+ assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2);
+ assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_3);
+ }
+
+ @Test
+ public void multiplesSeparatorsShouldBeTolerated() throws Exception {
+ HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(
+ ROOT_CONFIG_KEY + CONFIG_SEPARATOR + CONFIG_SEPARATOR + CONFIG_KEY_4);
+ assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2,
+ String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2));
+ assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2);
+ }
+
+ @Test(expected = ConfigurationException.class)
+ public void getConfigurationShouldThrowOnNonExistingXMLFile() throws Exception {
+ assertThat(configurationProvider.getConfiguration(FAKE_CONFIG_KEY)).isNotNull();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void getConfigurationShouldThrowOnNonExistingXMLFilePart() throws Exception {
+ configurationProvider.getConfiguration(String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, FAKE_CONFIG_KEY));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
new file mode 100644
index 0000000..d8582b3
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/InMemoryMailRepositoryStoreTest.java
@@ -0,0 +1,109 @@
+/****************************************************************
+ * 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 static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.core.filesystem.FileSystemImpl;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.mailrepository.api.MailRepositoryStore;
+import org.apache.james.mailrepository.file.FileMailRepository;
+import org.apache.james.modules.server.MailStoreRepositoryModule;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.Sets;
+
+public class InMemoryMailRepositoryStoreTest {
+
+ private InMemoryMailRepositoryStore repositoryStore;
+ private FileSystemImpl fileSystem;
+
+ @Before
+ public void setUp() throws Exception {
+ fileSystem = new FileSystemImpl(new JamesServerResourceLoader("../"));
+ repositoryStore = new InMemoryMailRepositoryStore(Sets.newHashSet(
+ new MailStoreRepositoryModule.FileMailRepositoryProvider(
+ fileSystem)));
+ repositoryStore.configure(new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL).getConfiguration("mailrepositorystore"));
+ repositoryStore.init();
+ }
+
+ @Test(expected = MailRepositoryStore.MailRepositoryStoreException.class)
+ public void selectingANonRegisteredProtocolShouldFail() throws Exception {
+ repositoryStore.select("proto://repo");
+ }
+
+ @Test
+ public void selectingARegisteredProtocolShouldWork() throws Exception {
+ assertThat(repositoryStore.select("file://repo")).isInstanceOf(FileMailRepository.class);
+ }
+
+ @Test
+ public void selectingTwiceARegisteredProtocolWithSameDestinationShouldReturnTheSameResult() throws Exception {
+ assertThat(repositoryStore.select("file://repo")).isEqualTo(repositoryStore.select("file://repo"));
+ }
+
+ @Test
+ public void selectingTwiceARegisteredProtocolWithDifferentDestinationShouldReturnDifferentResults() throws Exception {
+ assertThat(repositoryStore.select("file://repo")).isNotEqualTo(repositoryStore.select("file://repo1"));
+ }
+
+ @Test(expected = ConfigurationException.class)
+ public void configureShouldThrowWhenNonValidClassesAreProvided() throws Exception {
+ try {
+ repositoryStore = new InMemoryMailRepositoryStore(Sets.newHashSet(
+ new MailStoreRepositoryModule.FileMailRepositoryProvider(
+ fileSystem)));
+ repositoryStore.configure(new FileConfigurationProvider(fileSystem, FileSystem.CLASSPATH_PROTOCOL).getConfiguration("fakemailrepositorystore"));
+ } catch (ConfigurationException e) {
+ fail("Unexpected failure : ", e);
+ }
+ repositoryStore.init();
+ }
+
+ @Test
+ public void getUrlsShouldBeEmptyIfNoSelectWerePerformed() {
+ assertThat(repositoryStore.getUrls()).isEmpty();
+ }
+
+ @Test
+ public void getUrlsShouldReturnUsedUrls() throws Exception {
+ String url1 = "file://repo1";
+ String url2 = "file://repo2";
+ String url3 = "file://repo3";
+ repositoryStore.select(url1);
+ repositoryStore.select(url2);
+ repositoryStore.select(url3);
+ assertThat(repositoryStore.getUrls()).containsOnly(url1, url2, url3);
+ }
+
+ @Test
+ public void getUrlsResultsShouldNotBeDuplicated() throws Exception {
+ String url1 = "file://repo1";
+ repositoryStore.select(url1);
+ repositoryStore.select(url1);
+ assertThat(repositoryStore.getUrls()).containsExactly(url1);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/java/org/apache/james/utils/PropertiesReadTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/PropertiesReadTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/PropertiesReadTest.java
new file mode 100644
index 0000000..1d3de34
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/PropertiesReadTest.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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 static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class PropertiesReadTest {
+
+ @Test
+ public void getPropertyShouldWork() throws Exception {
+ PropertiesReader propertiesReader = new PropertiesReader("test.properties");
+ assertThat(propertiesReader.getProperty("cassandra.ip")).isEqualTo("127.0.0.1");
+ }
+
+ @Test
+ public void getAbsentPropertyShouldReturnNull() throws Exception {
+ PropertiesReader propertiesReader = new PropertiesReader("test.properties");
+ assertThat(propertiesReader.getProperty("cassandra.isslow")).isNull();
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void buildingAPropertiesReaderOnNonExistingValuesShouldThrow() throws Exception {
+ new PropertiesReader("fake.properties");
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/resources/fakemailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/resources/fakemailrepositorystore.xml b/server/container/guice/guice-common/src/test/resources/fakemailrepositorystore.xml
new file mode 100644
index 0000000..2d19a80
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/resources/fakemailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.None">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/resources/mailrepositorystore.xml b/server/container/guice/guice-common/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/resources/mailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/resources/test.properties b/server/container/guice/guice-common/src/test/resources/test.properties
new file mode 100644
index 0000000..b4db9c1
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/resources/test.properties
@@ -0,0 +1,6 @@
+# Configuration file for cassandra mailbox
+
+cassandra.ip=127.0.0.1
+cassandra.port=9142
+cassandra.keyspace=apache_james
+cassandra.replication.factor=1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/test/resources/test.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/resources/test.xml b/server/container/guice/guice-common/src/test/resources/test.xml
new file mode 100644
index 0000000..8d89ecc
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/resources/test.xml
@@ -0,0 +1,28 @@
+<?xml version="1.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.
+ -->
+<test>
+ <test2>0</test2>
+ <james>
+ <property>awesome</property>
+ <internal>
+ <property>james</property>
+ </internal>
+ </james>
+</test>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/README.adoc
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/README.adoc b/server/container/guice/memory-guice/README.adoc
new file mode 100644
index 0000000..b896354
--- /dev/null
+++ b/server/container/guice/memory-guice/README.adoc
@@ -0,0 +1,38 @@
+= Guice-Memory Module How-to
+
+== Building
+
+=== Requirements
+
+ * Java 8 SDK
+ * Docker
+ * Maven
+
+=== Building the artifacts
+
+An usual compilation using maven will produce two artifacts into target directory :
+
+ * james-server-memory-guice-${version}.jar
+ * james-server-memory-guice-${version}.lib
+
+== Running
+
+=== James Launch
+
+To run james, you have to create a directory containing required configuration files.
+
+A sample directory (appropriately named sample-directory) is provided with some
+default values you may need to replace.
+
+You also need to generate a keystore with the following command :
+[source]
+----
+$ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore
+----
+
+Once everything is set up, you just have to run the jar with :
+
+[source]
+----
+$ java -Dworking.directory=sample-configuration -jar target/james-server-memory-guice-${version}.jar
+----
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
new file mode 100644
index 0000000..83aec4a
--- /dev/null
+++ b/server/container/guice/memory-guice/pom.xml
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server</artifactId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>james-server-memory-guice</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: Memory - guice injection</name>
+ <description>An advanced email server - Memory backend with guice injection</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>disable-build-for-older-jdk</id>
+ <activation>
+ <jdk>(,1.8)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-install</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-resources</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testResources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-descriptor</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>build-for-jdk-8</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/${project.build.finalName}.lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>${project.build.finalName}.lib/</classpathPrefix>
+ <mainClass>org.apache.james.MemoryJamesServerMain</mainClass>
+ <useUniqueVersions>false</useUniqueVersions>
+ </manifest>
+ </archive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-tika</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-data-memory</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency><dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-mailet-base</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.restassured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-3.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>disable-animal-sniffer</id>
+ <activation>
+ <jdk>[1.6,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check_java_6</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/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
new file mode 100644
index 0000000..991ba1e
--- /dev/null
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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;
+
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.modules.data.MemoryDataModule;
+import org.apache.james.modules.mailbox.MemoryMailboxModule;
+import org.apache.james.modules.server.ActiveMQQueueModule;
+import org.apache.james.modules.server.JMXServerModule;
+import org.apache.james.modules.server.QuotaModule;
+
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+import com.google.inject.util.Modules;
+
+public class MemoryJamesServerMain {
+
+ private static final TypeLiteral<InMemoryId> inMemoryId = new TypeLiteral<InMemoryId>(){};
+
+ public static final Module inMemoryServerModule = Modules.combine(
+ new MemoryDataModule(),
+ new MemoryMailboxModule(),
+ new QuotaModule(),
+ new ActiveMQQueueModule<>(inMemoryId));
+
+ public static void main(String[] args) throws Exception {
+ new GuiceJamesServer<>(inMemoryId)
+ .combineWith(inMemoryServerModule, new JMXServerModule())
+ .start();
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[05/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/mailetcontainer.xml b/server/protocols/jmap-integration-testing/src/test/resources/mailetcontainer.xml
deleted file mode 100644
index 258f264..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/mailetcontainer.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailetcontainer enableJmx="false">
-
- <context>
- <postmaster>postmaster@james.minet.net</postmaster>
- </context>
-
- <spooler>
- <threads>20</threads>
- </spooler>
-
- <processors>
- <processor state="root" enableJmx="false">
- <mailet match="All" class="PostmasterAlias"/>
- <mailet match="RelayLimit=30" class="Null"/>
- <!-- Hook on sievemanager@james.linagora.com
- Mail send to this address will get interpreted with SIEVE Manage -->
- <mailet match="All" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- </processor>
-
- <processor state="error" enableJmx="false">
- <mailet match="All" class="Bounce"/>
- </processor>
-
-
- <processor state="transport" enableJmx="false">
- <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
- <name>X-UserIsAuth</name>
- <value>true</value>
- </mailet>
- <mailet match="All" class="RemoveMimeHeader">
- <name>bcc</name>
- </mailet>
- <mailet match="RecipientIsLocal" class="LocalDelivery"/>
- <mailet match="HostIsLocal" class="ToProcessor">
- <processor>local-address-error</processor>
- <notice>550 - Requested action not taken: no such user here</notice>
- </mailet>
- <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
- <outgoingQueue>outgoing</outgoingQueue>
- <delayTime>5000, 100000, 500000</delayTime>
- <maxRetries>25</maxRetries>
- <maxDnsProblemRetries>0</maxDnsProblemRetries>
- <deliveryThreads>10</deliveryThreads>
- <sendpartial>true</sendpartial>
- <bounceProcessor>bounces</bounceProcessor>
- </mailet>
- <mailet match="All" class="ToProcessor">
- <processor>relay-denied</processor>
- </mailet>
- </processor>
-
- <processor state="spam" enableJmx="false">
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/spam/</repositoryPath>
- </mailet>
- </processor>
-
- <processor state="local-address-error" enableJmx="false">
- <mailet match="All" class="Bounce">
- <attachment>none</attachment>
- </mailet>
- </processor>
-
- <processor state="relay-denied" enableJmx="false">
- <mailet match="All" class="Bounce">
- <attachment>none</attachment>
- </mailet>
- </processor>
-
- <processor state="bounces" enableJmx="false">
- <mailet match="All" class="DSNBounce">
- <passThrough>false</passThrough>
- </mailet>
- </processor>
-
- </processors>
-
-</mailetcontainer>
-
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/mailrepositorystore.xml b/server/protocols/jmap-integration-testing/src/test/resources/mailrepositorystore.xml
deleted file mode 100644
index 3ca4a1d..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/mailrepositorystore.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailrepositorystore>
- <mailrepositories>
- <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
- <protocols>
- <protocol>file</protocol>
- </protocols>
- <config FIFO="false" CACHEKEYS="true"/>
- </mailrepository>
- </mailrepositories>
-</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/pop3server.xml b/server/protocols/jmap-integration-testing/src/test/resources/pop3server.xml
deleted file mode 100644
index e4187da..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/pop3server.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.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.
- -->
-
-
-<pop3servers>
- <pop3server enabled="true">
- <jmxName>pop3server</jmxName>
- <bind>0.0.0.0:1110</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectiontimeout>1200</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <handlerchain>
- <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
- </handlerchain>
- </pop3server>
-</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/smtpserver.xml b/server/protocols/jmap-integration-testing/src/test/resources/smtpserver.xml
deleted file mode 100644
index a3d4b8f..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/smtpserver.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.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.
- -->
-
-<smtpservers>
- <smtpserver enabled="true">
- <jmxName>smtpserver-global</jmxName>
- <bind>0.0.0.0:1025</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <authRequired>false</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <verifyIdentity>true</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
- <smtpserver enabled="true">
- <jmxName>smtpserver-TLS</jmxName>
- <bind>0.0.0.0:10465</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!--
- Authorize only local users
- -->
- <authRequired>true</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <!-- Trust authenticated users -->
- <verifyIdentity>false</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
- <smtpserver enabled="true">
- <jmxName>smtpserver-authenticated</jmxName>
- <bind>0.0.0.0:1587</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!--
- Authorize only local users
- -->
- <authRequired>true</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <!-- Trust authenticated users -->
- <verifyIdentity>false</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
-</smtpservers>
-
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/test.properties b/server/protocols/jmap-integration-testing/src/test/resources/test.properties
deleted file mode 100644
index b4db9c1..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/test.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# Configuration file for cassandra mailbox
-
-cassandra.ip=127.0.0.1
-cassandra.port=9142
-cassandra.keyspace=apache_james
-cassandra.replication.factor=1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/resources/test.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/resources/test.xml b/server/protocols/jmap-integration-testing/src/test/resources/test.xml
deleted file mode 100644
index 8d89ecc..0000000
--- a/server/protocols/jmap-integration-testing/src/test/resources/test.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.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.
- -->
-<test>
- <test2>0</test2>
- <james>
- <property>awesome</property>
- <internal>
- <property>james</property>
- </internal>
- </james>
-</test>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[21/24] james-project git commit: JAMES-1693 Dockerfiles should be
updated to match Guice projects re-organization
Posted by ma...@apache.org.
JAMES-1693 Dockerfiles should be updated to match Guice projects re-organization
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/fd282b4c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/fd282b4c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/fd282b4c
Branch: refs/heads/master
Commit: fd282b4ca0ff81601e47bc07552023e3a1aa73e0
Parents: 82a88f6
Author: Benoit Tellier <bt...@linagora.com>
Authored: Tue Mar 8 17:57:46 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:07:13 2016 +0100
----------------------------------------------------------------------
dockerfiles/compilation/java-8/compile.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/fd282b4c/dockerfiles/compilation/java-8/compile.sh
----------------------------------------------------------------------
diff --git a/dockerfiles/compilation/java-8/compile.sh b/dockerfiles/compilation/java-8/compile.sh
index f90baf5..696f4db 100755
--- a/dockerfiles/compilation/java-8/compile.sh
+++ b/dockerfiles/compilation/java-8/compile.sh
@@ -53,8 +53,8 @@ fi
if [ $? -eq 0 ]; then
cp server/app/target/james-server-app-*-app.zip $DESTINATION
- cp server/container/cassandra-guice/target/james-server-cassandra-guice-*-SNAPSHOT.jar $DESTINATION
- cp -r server/container/cassandra-guice/target/james-server-cassandra-guice-*-SNAPSHOT.lib $DESTINATION
+ cp server/container/guice/cassandra-guice/target/james-server-cassandra-guice-*-SNAPSHOT.jar $DESTINATION
+ cp -r server/container/guice/cassandra-guice/target/james-server-cassandra-guice-*-SNAPSHOT.lib $DESTINATION
cp server/container/cli/target/james-server-cli-*.jar $DESTINATION
cp -r server/container/cli/target/james-server-cli-*.lib $DESTINATION
fi
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[08/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java
new file mode 100644
index 0000000..0b9a51b
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.jmap.servers;
+
+import org.apache.james.modules.TestFilesystemModule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.AbstractModule;
+
+public class MemoryJmapServerModule extends AbstractModule {
+
+ private static final int LIMIT_TO_3_MESSAGES = 3;
+ private TemporaryFolder temporaryFolder;
+
+ public MemoryJmapServerModule(TemporaryFolder temporaryFolder) {
+ this.temporaryFolder = temporaryFolder;
+ }
+
+ @Override
+ protected void configure() {
+ install(new TestFilesystemModule(temporaryFolder));
+ install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml
new file mode 100644
index 0000000..ff478a9
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml
@@ -0,0 +1,54 @@
+<?xml version="1.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.
+-->
+
+
+<imapservers>
+ <imapserver enabled="true">
+ <jmxName>imapserver</jmxName>
+ <bind>0.0.0.0:1143</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+ <imapserver enabled="true">
+ <jmxName>imapserver-ssl</jmxName>
+ <bind>0.0.0.0:1993</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore
new file mode 100644
index 0000000..536a6c7
Binary files /dev/null and b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.xml
new file mode 100644
index 0000000..5c4a9c7
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.xml
@@ -0,0 +1,41 @@
+<?xml version="1.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.
+ -->
+
+<lmtpservers>
+
+ <lmtpserver enabled="true">
+ <jmxName>lmtpserver</jmxName>
+ <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
+ <bind>127.0.0.1:1024</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <connectiontimeout>1200</connectiontimeout>
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!-- This sets the maximum allowed message size (in kilobytes) for this -->
+ <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+ <maxmessagesize>0</maxmessagesize>
+ <handlerchain>
+ <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </lmtpserver>
+
+</lmtpservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
new file mode 100644
index 0000000..258f264
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
@@ -0,0 +1,103 @@
+<?xml version="1.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.
+ -->
+
+<mailetcontainer enableJmx="false">
+
+ <context>
+ <postmaster>postmaster@james.minet.net</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="false">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+ <!-- Hook on sievemanager@james.linagora.com
+ Mail send to this address will get interpreted with SIEVE Manage -->
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="false">
+ <mailet match="All" class="Bounce"/>
+ </processor>
+
+
+ <processor state="transport" enableJmx="false">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
+ <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+ <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
+ <outgoingQueue>outgoing</outgoingQueue>
+ <delayTime>5000, 100000, 500000</delayTime>
+ <maxRetries>25</maxRetries>
+ <maxDnsProblemRetries>0</maxDnsProblemRetries>
+ <deliveryThreads>10</deliveryThreads>
+ <sendpartial>true</sendpartial>
+ <bounceProcessor>bounces</bounceProcessor>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>relay-denied</processor>
+ </mailet>
+ </processor>
+
+ <processor state="spam" enableJmx="false">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/spam/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="local-address-error" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="false">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+
+ </processors>
+
+</mailetcontainer>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml
new file mode 100644
index 0000000..ec57e09
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml
@@ -0,0 +1,65 @@
+<?xml version="1.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.
+ -->
+
+<!--
+ This template file can be used as example for James Server configuration
+ DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<managesieveservers>
+
+ <managesieveserver enabled="true">
+
+ <jmxName>managesieveserver</jmxName>
+
+ <bind>0.0.0.0:4190</bind>
+
+ <connectionBacklog>200</connectionBacklog>
+
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <!-- The algorithm is optional and only needs to be specified when using something other
+ than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
+ <algorithm>SunX509</algorithm>
+ </tls>
+
+ <!-- connection timeout in secconds -->
+ <connectiontimeout>360</connectiontimeout>
+
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+
+ </managesieveserver>
+
+</managesieveservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.xml
new file mode 100644
index 0000000..e4187da
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.xml
@@ -0,0 +1,42 @@
+<?xml version="1.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.
+ -->
+
+
+<pop3servers>
+ <pop3server enabled="true">
+ <jmxName>pop3server</jmxName>
+ <bind>0.0.0.0:1110</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectiontimeout>1200</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <handlerchain>
+ <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </pop3server>
+</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml
new file mode 100644
index 0000000..a3d4b8f
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml
@@ -0,0 +1,105 @@
+<?xml version="1.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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <authRequired>false</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:10465</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/pom.xml
deleted file mode 100644
index 9afcc41..0000000
--- a/server/protocols/jmap-integration-testing/pom.xml
+++ /dev/null
@@ -1,269 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>james-server</artifactId>
- <groupId>org.apache.james</groupId>
- <version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <artifactId>james-server-jmap-integration-testing</artifactId>
- <packaging>jar</packaging>
-
- <name>Apache James :: Server :: JMAP :: Integration testing</name>
-
- <profiles>
- <profile>
- <id>noTest</id>
- <activation>
- <os>
- <family>windows</family>
- </os>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>disable-build-for-older-jdk</id>
- <activation>
- <jdk>(,1.8)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>default-jar</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>jar</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>test-jar</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-compile</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testCompile</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>default-test</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <executions>
- <execution>
- <id>default-install</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>default-resources</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testResources</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-descriptor</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>build-for-jdk-8</id>
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-elasticsearch</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-cassandra-guice</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-cassandra-guice</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-protocols-library</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>18.0</version> <!--$NO-MVN-MAN-VER$-->
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.inject.extensions</groupId>
- <artifactId>guice-multibindings</artifactId>
- </dependency>
- <dependency>
- <groupId>com.jayway.restassured</groupId>
- <artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>${assertj-3.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.cassandraunit</groupId>
- <artifactId>cassandra-unit</artifactId>
- <version>${cassandra-unit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <version>2.0.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>testcontainers</artifactId>
- <version>1.0.2</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>fully.qualified.MainClass</mainClass>
- </manifest>
- </archive>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>disable-animal-sniffer</id>
- <activation>
- <jdk>[1.6,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>check_java_6</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java
deleted file mode 100644
index b53f416..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java
+++ /dev/null
@@ -1,39 +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.jmap;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.cassandra.CassandraJmapServer;
-import org.apache.james.jmap.utils.ZonedDateTimeProvider;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.inject.util.Modules;
-
-public class CassandraJmapAuthenticationTest extends JMAPAuthenticationTest {
-
- @Override
- protected JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra, ZonedDateTimeProvider zonedDateTimeProvider) {
- return new CassandraJmapServer(
- Modules.combine(
- CassandraJmapServer.defaultOverrideModule(temporaryFolder, embeddedElasticSearch, cassandra),
- (binder) -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider)));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.java
deleted file mode 100644
index 7a8c488..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.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.jmap;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.fluent.Request;
-import org.apache.http.client.fluent.Response;
-import org.apache.http.client.utils.URIBuilder;
-import org.junit.Rule;
-import org.junit.Test;
-import org.testcontainers.containers.GenericContainer;
-
-public class ContainerTest {
-
- @Rule public GenericContainer container = new GenericContainer("nginx:1.7.1")
- .withExposedPorts(80);
-
- @Test
- public void containerShouldBeReachableOnExposedPort() throws ClientProtocolException, IOException, URISyntaxException {
- String containerIpAddress = container.getContainerIpAddress();
- Integer containerPort = container.getMappedPort(80);
- Response response = Request.Get(new URIBuilder().setScheme("http").setHost(containerIpAddress).setPort(containerPort).build()).execute();
- assertThat(response.returnResponse().getStatusLine().getStatusCode()).isEqualTo(200);
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
deleted file mode 100644
index 3dddcec..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
+++ /dev/null
@@ -1,39 +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.jmap;
-
-import java.time.ZonedDateTime;
-
-import org.apache.james.jmap.utils.ZonedDateTimeProvider;
-
-public class FixedDateZonedDateTimeProvider implements ZonedDateTimeProvider {
-
- private ZonedDateTime zonedDateTime;
-
- public void setFixedDateTime(ZonedDateTime zonedDateTime) {
- this.zonedDateTime = zonedDateTime;
- }
-
- @Override
- public ZonedDateTime get() {
- return zonedDateTime;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
deleted file mode 100644
index a99f840..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
+++ /dev/null
@@ -1,478 +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.jmap;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.RestAssured.with;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.*;
-
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.UUID;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.model.ContinuationToken;
-import org.apache.james.jmap.utils.ZonedDateTimeProvider;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Charsets;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.http.ContentType;
-
-public abstract class JMAPAuthenticationTest {
-
- private static final ZonedDateTime oldDate = ZonedDateTime.parse("2011-12-03T10:15:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
- private static final ZonedDateTime newDate = ZonedDateTime.parse("2011-12-03T10:16:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
- private static final ZonedDateTime afterExpirationDate = ZonedDateTime.parse("2011-12-03T10:30:31+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
-
- private TemporaryFolder temporaryFolder = new TemporaryFolder();
- private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
- private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
- private FixedDateZonedDateTimeProvider zonedDateTimeProvider = new FixedDateZonedDateTimeProvider();
- private JmapServer jmapServer = jmapServer(temporaryFolder, embeddedElasticSearch, cassandra, zonedDateTimeProvider);
-
-
-
- protected abstract JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra, ZonedDateTimeProvider zonedDateTimeProvider);
-
- @Rule
- public RuleChain chain = RuleChain
- .outerRule(temporaryFolder)
- .around(embeddedElasticSearch)
- .around(jmapServer);
-
- private UserCredentials userCredentials;
-
- @Before
- public void setup() throws Exception {
- RestAssured.port = jmapServer.getPort();
- RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-
-
- userCredentials = UserCredentials.builder()
- .username("user@domain.tld")
- .password("password")
- .build();
-
-
- String domain = "domain.tld";
- jmapServer.serverProbe().addDomain(domain);
- jmapServer.serverProbe().addUser(userCredentials.getUsername(), userCredentials.getPassword());
-
- zonedDateTimeProvider.setFixedDateTime(oldDate);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenContentTypeIsMissing() {
- given()
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenContentTypeIsNotJson() {
- given()
- .contentType(ContentType.XML)
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenAcceptIsMissing() {
- given()
- .contentType(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenAcceptIsNotJson() {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.XML)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenCharsetIsNotUTF8() {
- given()
- .contentType("application/json; charset=ISO-8859-1")
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenBodyIsEmpty() {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenBodyIsNotAcceptable() {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"badAttributeName\": \"value\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnJsonResponse() throws Exception {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(200)
- .contentType(ContentType.JSON);
- }
-
- @Test
- public void methodShouldContainPasswordWhenValidResquest() throws Exception {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(200)
- .body("methods", hasItem(userCredentials.getPassword()));
- }
-
- @Test
- public void mustReturnContinuationTokenWhenValidResquest() throws Exception {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(200)
- .body("continuationToken", isA(String.class));
- }
-
- @Test
- public void mustReturnAuthenticationFailedWhenBadPassword() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"badpassword\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void mustReturnAuthenticationFailedWhenContinuationTokenIsRejectedByTheContinuationTokenManager() throws Exception {
- ContinuationToken badContinuationToken = new ContinuationToken(userCredentials.getUsername(), newDate, "badSignature");
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + badContinuationToken.serialize() + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void mustReturnRestartAuthenticationWhenContinuationTokenIsExpired() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(afterExpirationDate);
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(403);
- }
-
- @Test
- public void mustReturnAuthenticationFailedWhenUsersRepositoryException() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + "wrong password" + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void mustReturnCreatedWhenGoodPassword() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(201);
- }
-
- @Test
- public void mustSendJsonContainingAccessTokenAndEndpointsWhenGoodPassword() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .body("accessToken", isA(String.class))
- .body("api", equalTo("/jmap"))
- .body("eventSource", both(isA(String.class)).and(notNullValue()))
- .body("upload", both(isA(String.class)).and(notNullValue()))
- .body("download", both(isA(String.class)).and(notNullValue()));
- }
-
- @Test
- public void getMustReturnUnauthorizedWithoutAuthroizationHeader() throws Exception {
- given()
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void getMustReturnUnauthorizedWithoutAValidAuthroizationHeader() throws Exception {
- given()
- .header("Authorization", UUID.randomUUID())
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void getMustReturnEndpointsWhenValidAuthorizationHeader() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- String token = fromGoodAccessTokenRequest(continuationToken);
-
- given()
- .header("Authorization", token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200)
- .body("api", equalTo("/jmap"))
- .body("eventSource", both(isA(String.class)).and(notNullValue()))
- .body("upload", both(isA(String.class)).and(notNullValue()))
- .body("download", both(isA(String.class)).and(notNullValue()));
- }
-
- @Test
- public void getMustReturnEndpointsWhenValidJwtAuthorizationHeader() throws Exception {
- String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
- "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
- "DN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
- "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
- "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
-
- given()
- .header("Authorization", "Bearer " + token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void getMustReturnEndpointsWhenValidUnkwnonUserJwtAuthorizationHeader() throws Exception {
- String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3IiwibmFtZSI6Ik5ldyBVc2VyIn0.ci8U04EOWKpi_y"
- + "faKs8fnCBcu1mWs8fvf-t9SDP2kkvDDfD-ya4sEGn4ueCp2dA2ndefZfVu_IfvdlVtxqzSf0tQ-dFKrIe-OtSKhI2otjWctLtk9A"
- + "G7jpWkXoDgr5IOVmsqg37Zxc2bgkLkC5FJqV6oCp51TNQTH6zZbXIUeuGFbHj2-iJeX8sACKTQB0llwc6TFm7GYUF03rv4DfJjqp"
- + "Kd0g8RdnlevSOjV-gGzvKEItugtexS5pgOZ2GYcvqEUDb9EnQR7Qe2EzPAX_FCJfGhlv7bDQlTgOHHAjqw2lD4-zeAznw-3wlYLS"
- + "zhi4ivvPjT-y2T5wnnhzeeYOpYOQ";
-
- given()
- .header("Authorization", "Bearer " + token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void getMustReturnBadCredentialsWhenInvalidJwtAuthorizationHeader() throws Exception {
- String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
- "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
- "EN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
- "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
- "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
-
- given()
- .header("Authorization", "Bearer " + token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void optionsRequestsShouldNeverRequireAuthentication() {
- given()
- .when()
- .options("/authentication")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void getMustReturnEndpointsWhenCorrectAuthentication() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- String accessToken = fromGoodAccessTokenRequest(continuationToken);
-
- given()
- .header("Authorization", accessToken)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200)
- .body("api", isA(String.class));
- }
-
- @Test
- public void deleteMustReturnUnauthenticatedWithoutAuthorizationHeader() throws Exception {
- given()
- .when()
- .delete("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void deleteMustReturnUnauthenticatedWithoutAValidAuthroizationHeader() throws Exception {
- given()
- .header("Authorization", UUID.randomUUID())
- .when()
- .delete("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void deleteMustReturnOKNoContentOnValidAuthorizationToken() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- String token = fromGoodAccessTokenRequest(continuationToken);
- given()
- .header("Authorization", token)
- .when()
- .delete("/authentication")
- .then()
- .statusCode(204);
- }
-
- @Test
- public void deleteMustInvalidAuthorizationOnCorrectAuthorization() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- String accessToken = fromGoodAccessTokenRequest(continuationToken);
-
- goodDeleteAccessTokenRequest(accessToken);
-
- given()
- .header("Authorization", accessToken)
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- private String fromGoodContinuationTokenRequest() {
- return with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .post("/authentication")
- .body()
- .path("continuationToken")
- .toString();
- }
-
- private String fromGoodAccessTokenRequest(String continuationToken) {
- return with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .post("/authentication")
- .path("accessToken")
- .toString();
- }
-
- private void goodDeleteAccessTokenRequest(String accessToken) {
- with()
- .header("Authorization", accessToken)
- .delete("/authentication");
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java
deleted file mode 100644
index b9fa503..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java
+++ /dev/null
@@ -1,55 +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.jmap;
-
-import static com.jayway.restassured.RestAssured.with;
-
-import org.apache.james.jmap.api.access.AccessToken;
-
-import com.jayway.restassured.http.ContentType;
-
-public class JmapAuthentication {
-
- public static AccessToken authenticateJamesUser(String username, String password) {
- String continuationToken = getContinuationToken(username);
-
- return AccessToken.fromString(
- with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + password + "\"}")
- .post("/authentication")
- .body()
- .jsonPath()
- .getString("accessToken")
- );
- }
-
- private static String getContinuationToken(String username) {
- return with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + username + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .post("/authentication")
- .body()
- .path("continuationToken")
- .toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java
deleted file mode 100644
index 69c136b..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java
+++ /dev/null
@@ -1,31 +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.jmap;
-
-import org.apache.james.utils.ExtendedServerProbe;
-import org.junit.rules.TestRule;
-
-public interface JmapServer extends TestRule {
-
- int getPort();
-
- ExtendedServerProbe serverProbe();
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java
deleted file mode 100644
index 25a1994..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java
+++ /dev/null
@@ -1,66 +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.jmap;
-
-public class UserCredentials {
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private String username;
- private String password;
-
- private Builder() {
- }
-
- public Builder username(String username) {
- this.username = username;
- return this;
- }
-
- public Builder password(String password) {
- this.password = password;
- return this;
- }
-
- public UserCredentials build() {
- return new UserCredentials(username, password);
- }
- }
-
- private final String username;
- private final String password;
-
- private UserCredentials(String username, String password) {
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java
deleted file mode 100644
index f81037c..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java
+++ /dev/null
@@ -1,109 +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.jmap.cassandra;
-
-import javax.inject.Singleton;
-
-import org.apache.james.CassandraJamesServer;
-import org.apache.james.CassandraJamesServerMain;
-import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.modules.TestElasticSearchModule;
-import org.apache.james.modules.TestFilesystemModule;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.utils.ExtendedServerProbe;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-import com.google.inject.util.Modules;
-
-public class CassandraJmapServer implements JmapServer {
-
- private static final int LIMIT_TO_3_MESSAGES = 3;
-
- private CassandraJamesServer server;
-
- private final Module module;
-
- public static Module defaultOverrideModule(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
- return Modules.combine(new TestElasticSearchModule(embeddedElasticSearch),
- new TestFilesystemModule(temporaryFolder),
- new TestJMAPServerModule(LIMIT_TO_3_MESSAGES),
- new AbstractModule() {
-
- @Override
- protected void configure() {
- bind(EmbeddedCassandra.class).toInstance(cassandra);
- }
-
- @Provides
- @Singleton
- com.datastax.driver.core.Session provideSession(CassandraCluster initializedCassandra) {
- return initializedCassandra.getConf();
- }
- });
- }
-
-
- public CassandraJmapServer(Module overrideModule) {
- this.module = Modules.override(CassandraJamesServerMain.defaultModule).with(overrideModule);
- }
-
- @Override
- public Statement apply(Statement base, Description description) {
- return new Statement() {
-
- @Override
- public void evaluate() throws Throwable {
- try {
- before();
- base.evaluate();
- } finally {
- after();
- }
- }
- };
- }
-
- private void before() throws Throwable {
- server = new CassandraJamesServer(module);
- server.start();
- }
-
- private void after() {
- server.stop();
- }
-
- @Override
- public int getPort() {
- return server.getJmapPort();
- }
-
- @Override
- public ExtendedServerProbe serverProbe() {
- return server.serverProbe();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[23/24] james-project git commit: JAMES-1693 Guice compilation for
specific backends should be activated by specific profiles
Posted by ma...@apache.org.
JAMES-1693 Guice compilation for specific backends should be activated by specific profiles
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/583b48f5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/583b48f5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/583b48f5
Branch: refs/heads/master
Commit: 583b48f5312f6638e4bedab9d4773c9bba1fbee7
Parents: 517a4cf
Author: Benoit Tellier <bt...@linagora.com>
Authored: Tue Mar 8 16:24:35 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:07:13 2016 +0100
----------------------------------------------------------------------
server/container/guice/cassandra-guice/pom.xml | 4 +-
server/container/guice/guice-common/pom.xml | 4 +-
server/container/guice/memory-guice/pom.xml | 4 +-
server/container/guice/pom.xml | 57 +++++++++++++++++++++
server/pom.xml | 4 +-
5 files changed, 64 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/583b48f5/server/container/guice/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index d2b642d..31d62da 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -24,9 +24,9 @@
<parent>
<groupId>org.apache.james</groupId>
- <artifactId>james-server</artifactId>
+ <artifactId>james-server-guice</artifactId>
<version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>james-server-cassandra-guice</artifactId>
http://git-wip-us.apache.org/repos/asf/james-project/blob/583b48f5/server/container/guice/guice-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/pom.xml b/server/container/guice/guice-common/pom.xml
index 291aa47..ed86fb0 100644
--- a/server/container/guice/guice-common/pom.xml
+++ b/server/container/guice/guice-common/pom.xml
@@ -3,10 +3,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>james-server</artifactId>
+ <artifactId>james-server-guice</artifactId>
<groupId>org.apache.james</groupId>
<version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/james-project/blob/583b48f5/server/container/guice/memory-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index 83aec4a..393d866 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -24,9 +24,9 @@
<parent>
<groupId>org.apache.james</groupId>
- <artifactId>james-server</artifactId>
+ <artifactId>james-server-guice</artifactId>
<version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>james-server-memory-guice</artifactId>
http://git-wip-us.apache.org/repos/asf/james-project/blob/583b48f5/server/container/guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml
new file mode 100644
index 0000000..8c695e8
--- /dev/null
+++ b/server/container/guice/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>james-server</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>james-server-guice</artifactId>
+ <name>Apache James :: Server :: Guice</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>guice-common</module>
+ </modules>
+
+ <profiles>
+ <profile>
+ <id>cassandra</id>
+ <modules>
+ <module>cassandra-guice</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>inmemory</id>
+ <modules>
+ <module>memory-guice</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/583b48f5/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index 910d58f..ae05069 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -58,9 +58,7 @@
<module>karaf/features</module>
<module>karaf/integration</module>
- <module>container/guice/cassandra-guice</module>
- <module>container/guice/memory-guice</module>
- <module>container/guice/guice-common</module>
+ <module>container/guice</module>
<module>container/cli</module>
<module>container/core</module>
<module>container/filesystem-api</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[18/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
deleted file mode 100644
index a608906..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
+++ /dev/null
@@ -1,111 +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.modules.server;
-
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.mailetcontainer.api.MailProcessor;
-import org.apache.james.mailetcontainer.api.MailetLoader;
-import org.apache.james.mailetcontainer.api.MatcherLoader;
-import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean;
-import org.apache.james.mailetcontainer.impl.JamesMailSpooler;
-import org.apache.james.mailetcontainer.impl.JamesMailetContext;
-import org.apache.james.mailetcontainer.impl.camel.CamelCompositeProcessor;
-import org.apache.james.user.api.UsersRepository;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.apache.james.utils.GuiceMailetLoader;
-import org.apache.james.utils.GuiceMatcherLoader;
-import org.apache.mailet.MailetContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class CamelMailetContainerModule extends AbstractModule {
-
- private static final Logger CAMEL_LOGGER = LoggerFactory.getLogger(CamelCompositeProcessor.class);
- private static final Logger SPOOLER_LOGGER = LoggerFactory.getLogger(JamesMailSpooler.class);
- private static final Logger MAILET_LOGGER = LoggerFactory.getLogger(JamesMailetContext.class);
-
- @Override
- protected void configure() {
- bind(MailProcessor.class).to(CamelCompositeProcessor.class).in(Singleton.class);
- bind(MailSpoolerMBean.class).to(JamesMailSpooler.class);
- bind(MailetLoader.class).to(GuiceMailetLoader.class);
- bind(MatcherLoader.class).to(GuiceMatcherLoader.class);
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MailetModuleConfigurationPerformer.class);
- }
-
- @Provides
- @Singleton
- private MailetContext provideMailetContext(MailProcessor processorList,
- DNSService dns,
- UsersRepository localusers,
- DomainList domains) {
- JamesMailetContext jamesMailetContext = new JamesMailetContext();
- jamesMailetContext.setLog(MAILET_LOGGER);
- jamesMailetContext.setDNSService(dns);
- jamesMailetContext.setMailProcessor(processorList);
- jamesMailetContext.setUsersRepository(localusers);
- jamesMailetContext.setDomainList(domains);
- return jamesMailetContext;
- }
-
- @Singleton
- public static class MailetModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final CamelCompositeProcessor camelCompositeProcessor;
- private final JamesMailSpooler jamesMailSpooler;
- private final JamesMailetContext mailetContext;
-
- @Inject
- public MailetModuleConfigurationPerformer(ConfigurationProvider configurationProvider,
- CamelCompositeProcessor camelCompositeProcessor,
- JamesMailSpooler jamesMailSpooler,
- JamesMailetContext mailetContext) {
- this.configurationProvider = configurationProvider;
- this.camelCompositeProcessor = camelCompositeProcessor;
- this.jamesMailSpooler = jamesMailSpooler;
- this.mailetContext = mailetContext;
- }
-
- @Override
- public void initModule() throws Exception {
- camelCompositeProcessor.setLog(CAMEL_LOGGER);
- camelCompositeProcessor.setCamelContext(new DefaultCamelContext());
- camelCompositeProcessor.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("processors"));
- camelCompositeProcessor.init();
- jamesMailSpooler.setLog(SPOOLER_LOGGER);
- jamesMailSpooler.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("spooler"));
- jamesMailSpooler.init();
- mailetContext.setLog(MAILET_LOGGER);
- mailetContext.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("context"));
- mailetContext.setMailProcessor(camelCompositeProcessor);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
deleted file mode 100644
index f9d3cff..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
+++ /dev/null
@@ -1,33 +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.modules.server;
-
-import org.apache.james.utils.ConfigurationProvider;
-import org.apache.james.utils.FileConfigurationProvider;
-
-import com.google.inject.AbstractModule;
-
-public class ConfigurationProviderModule extends AbstractModule {
-
- @Override
- public void configure() {
- bind(ConfigurationProvider.class).to(FileConfigurationProvider.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
deleted file mode 100644
index 5d3b49f..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
+++ /dev/null
@@ -1,62 +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.modules.server;
-
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.dnsservice.dnsjava.DNSJavaService;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class DNSServiceModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DNSServiceModule.class);
-
- @Override
- protected void configure() {
- bind(DNSService.class).to(DNSJavaService.class);
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(DNSServiceConfigurationPerformer.class);
- }
-
- @Singleton
- public static class DNSServiceConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final DNSJavaService dnsService;
-
- @Inject
- public DNSServiceConfigurationPerformer(ConfigurationProvider configurationProvider,
- DNSJavaService dnsService) {
- this.configurationProvider = configurationProvider;
- this.dnsService = dnsService;
- }
-
- public void initModule() throws Exception {
- dnsService.setLog(LOGGER);
- dnsService.configure(configurationProvider.getConfiguration("dnsservice"));
- dnsService.init();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
deleted file mode 100644
index 3c34f74..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
+++ /dev/null
@@ -1,107 +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.modules.server;
-
-import javax.annotation.PreDestroy;
-import javax.jms.ConnectionFactory;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.blob.BlobTransferPolicy;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.ManagementContext;
-import org.apache.activemq.plugin.StatisticsBrokerPlugin;
-import org.apache.activemq.store.amq.AMQPersistenceAdapter;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.queue.activemq.FileSystemBlobTransferPolicy;
-
-import com.google.common.base.Throwables;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-@Singleton
-public class EmbeddedActiveMQ {
-
- private final ActiveMQConnectionFactory activeMQConnectionFactory;
- private BrokerService brokerService;
-
- @Inject private EmbeddedActiveMQ(FileSystem fileSystem) {
- try {
- launchEmbeddedBroker();
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- activeMQConnectionFactory = createActiveMQConnectionFactory(createBlobTransferPolicy(fileSystem));
- }
-
- public ConnectionFactory getConnectionFactory() {
- return activeMQConnectionFactory;
- }
-
- @PreDestroy
- public void stop() throws Exception {
- brokerService.stop();
- }
-
- private ActiveMQConnectionFactory createActiveMQConnectionFactory(BlobTransferPolicy blobTransferPolicy) {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://james?create=false");
- connectionFactory.setBlobTransferPolicy(blobTransferPolicy);
- connectionFactory.setPrefetchPolicy(createActiveMQPrefetchPolicy());
- return connectionFactory;
- }
-
- private ActiveMQPrefetchPolicy createActiveMQPrefetchPolicy() {
- ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
- prefetchPolicy.setQueuePrefetch(0);
- prefetchPolicy.setTopicPrefetch(0);
- return prefetchPolicy;
- }
-
- private BlobTransferPolicy createBlobTransferPolicy(FileSystem fileSystem) {
- FileSystemBlobTransferPolicy blobTransferPolicy = new FileSystemBlobTransferPolicy();
- blobTransferPolicy.setDefaultUploadUrl("file://var/store/activemq/blob-transfer");
- blobTransferPolicy.setFileSystem(fileSystem);
- return blobTransferPolicy;
- }
-
- private void launchEmbeddedBroker() throws Exception {
- brokerService = new BrokerService();
- brokerService.setBrokerName("james");
- brokerService.setUseJmx(false);
- brokerService.setPersistent(true);
- brokerService.setDataDirectory("filesystem=file://var/store/activemq/brokers");
- brokerService.setUseShutdownHook(false);
- brokerService.setSchedulerSupport(false);
- brokerService.setBrokerId("broker");
- String[] uris = {"tcp://localhost:0"};
- brokerService.setTransportConnectorURIs(uris);
- ManagementContext managementContext = new ManagementContext();
- managementContext.setCreateConnector(false);
- brokerService.setManagementContext(managementContext);
- brokerService.setPersistenceAdapter(new AMQPersistenceAdapter());
- BrokerPlugin[] brokerPlugins = {new StatisticsBrokerPlugin()};
- brokerService.setPlugins(brokerPlugins);
- String[] transportConnectorsURIs = {"tcp://localhost:0"};
- brokerService.setTransportConnectorURIs(transportConnectorsURIs);
- brokerService.start();
- System.out.println("Started : " + brokerService.isStarted());
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java
deleted file mode 100644
index 4b4e63d..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java
+++ /dev/null
@@ -1,125 +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.modules.server;
-
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.rmi.registry.LocateRegistry;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.util.RestrictingRMISocketFactory;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableMap;
-
-public class JMXServer {
-
- private final FileSystem fileSystem;
- private final Set<String> registeredKeys;
- private final Object lock;
- private JMXConnectorServer jmxConnectorServer;
- private boolean isStarted;
-
- @Inject
- public JMXServer(FileSystem fileSystem) {
- this.fileSystem = fileSystem;
- isStarted = false;
- registeredKeys = new HashSet<>();
- lock = new Object();
- }
-
- public void start() {
- synchronized (lock) {
- if (isStarted) {
- return;
- }
- isStarted = true;
- doStart();
- }
- }
-
- @PreDestroy
- public void stop() {
- synchronized (lock) {
- if (!isStarted) {
- return;
- }
- isStarted = false;
- doStop();
- }
- }
-
- public void register(String key, Object remote) throws Exception {
- ManagementFactory.getPlatformMBeanServer().registerMBean(remote, new ObjectName(key));
- synchronized (lock) {
- registeredKeys.add(key);
- }
- }
-
- private void doStart() {
- try {
- PropertiesConfiguration configuration = new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "jmx.properties"));
- String address = configuration.getString("jmx.address");
- int port = configuration.getInt("jmx.port");
- String serviceURL = "service:jmx:rmi://" + address + "/jndi/rmi://" + address+ ":" + port +"/jmxrmi";
- RestrictingRMISocketFactory restrictingRMISocketFactory = new RestrictingRMISocketFactory(address);
- LocateRegistry.createRegistry(port, restrictingRMISocketFactory, restrictingRMISocketFactory);
-
- Map<String, ?> environment = ImmutableMap.of();
- jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL(serviceURL),
- environment,
- ManagementFactory.getPlatformMBeanServer());
-
- jmxConnectorServer.start();
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- }
-
- private void doStop() {
- try {
- MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
- registeredKeys.forEach(key -> {
- try {
- mBeanServer.unregisterMBean(new ObjectName(key));
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- });
- registeredKeys.clear();
- jmxConnectorServer.stop();
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java
deleted file mode 100644
index 019b546..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java
+++ /dev/null
@@ -1,114 +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.modules.server;
-
-import org.apache.james.adapter.mailbox.MailboxCopierManagement;
-import org.apache.james.adapter.mailbox.MailboxCopierManagementMBean;
-import org.apache.james.adapter.mailbox.MailboxManagerManagement;
-import org.apache.james.adapter.mailbox.MailboxManagerManagementMBean;
-import org.apache.james.adapter.mailbox.MailboxManagerResolver;
-import org.apache.james.domainlist.api.DomainListManagementMBean;
-import org.apache.james.domainlist.lib.DomainListManagement;
-import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
-import org.apache.james.mailbox.copier.MailboxCopier;
-import org.apache.james.mailbox.copier.MailboxCopierImpl;
-import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean;
-import org.apache.james.mailetcontainer.impl.JamesMailSpooler;
-import org.apache.james.rrt.api.RecipientRewriteTableManagementMBean;
-import org.apache.james.rrt.lib.RecipientRewriteTableManagement;
-import org.apache.james.user.api.UsersRepositoryManagementMBean;
-import org.apache.james.user.lib.UsersRepositoryManagement;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.GuiceMailboxManagerResolver;
-import org.apache.james.utils.MailboxManagerDefinition;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Names;
-
-public class JMXServerModule extends AbstractModule {
-
- private static final String JMX_COMPONENT_DOMAINLIST = "org.apache.james:type=component,name=domainlist";
- private static final String JMX_COMPONENT_USERS_REPOSITORY = "org.apache.james:type=component,name=usersrepository";
- private static final String JMX_COMPONENT_RECIPIENTREWRITETABLE = "org.apache.james:type=component,name=recipientrewritetable";
- private static final String JMX_COMPONENT_NAME_MAILBOXMANAGERBEAN = "org.apache.james:type=component,name=mailboxmanagerbean";
- private static final String JMX_COMPONENT_MAILBOXCOPIER = "org.apache.james:type=component,name=mailboxcopier";
-
- @Override
- protected void configure() {
- bind(MailboxCopier.class).annotatedWith(Names.named("mailboxcopier")).to(MailboxCopierImpl.class);
- bind(MailboxCopierManagementMBean.class).to(MailboxCopierManagement.class);
- bind(MailboxManagerResolver.class).to(GuiceMailboxManagerResolver.class);
- bind(DomainListManagementMBean.class).to(DomainListManagement.class);
- bind(UsersRepositoryManagementMBean.class).to(UsersRepositoryManagement.class);
- bind(MailboxManagerManagementMBean.class).to(MailboxManagerManagement.class);
- bind(RecipientRewriteTableManagementMBean.class).to(RecipientRewriteTableManagement.class);
- bind(MailSpoolerMBean.class).to(JamesMailSpooler.class);
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(JMXModuleConfigurationPerformer.class);
- Multibinder.newSetBinder(binder(), MailboxManagerDefinition.class).addBinding().to(CassandraMailboxManagerDefinition.class);
- }
-
- @Singleton
- private static class CassandraMailboxManagerDefinition extends MailboxManagerDefinition {
- @Inject
- private CassandraMailboxManagerDefinition(CassandraMailboxManager manager) {
- super("cassandra-mailboxmanager", manager);
- }
- }
-
- @Singleton
- public static class JMXModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final JMXServer jmxServer;
- private final DomainListManagementMBean domainListManagementMBean;
- private final UsersRepositoryManagementMBean usersRepositoryManagementMBean;
- private final RecipientRewriteTableManagementMBean recipientRewriteTableManagementMBean;
- private final MailboxManagerManagementMBean mailboxManagerManagementMBean;
- private final MailboxCopierManagementMBean mailboxCopierManagementMBean;
-
- @Inject
- public JMXModuleConfigurationPerformer(JMXServer jmxServer,
- DomainListManagementMBean domainListManagementMBean,
- UsersRepositoryManagementMBean usersRepositoryManagementMBean,
- RecipientRewriteTableManagementMBean recipientRewriteTableManagementMBean,
- MailboxManagerManagementMBean mailboxManagerManagementMBean,
- MailboxCopierManagementMBean mailboxCopierManagementMBean) {
- this.jmxServer = jmxServer;
- this.domainListManagementMBean = domainListManagementMBean;
- this.usersRepositoryManagementMBean = usersRepositoryManagementMBean;
- this.recipientRewriteTableManagementMBean = recipientRewriteTableManagementMBean;
- this.mailboxManagerManagementMBean = mailboxManagerManagementMBean;
- this.mailboxCopierManagementMBean = mailboxCopierManagementMBean;
- }
-
- @Override
- public void initModule() throws Exception {
- jmxServer.start();
- jmxServer.register(JMX_COMPONENT_DOMAINLIST, domainListManagementMBean);
- jmxServer.register(JMX_COMPONENT_USERS_REPOSITORY, usersRepositoryManagementMBean);
- jmxServer.register(JMX_COMPONENT_RECIPIENTREWRITETABLE, recipientRewriteTableManagementMBean);
- jmxServer.register(JMX_COMPONENT_NAME_MAILBOXMANAGERBEAN, mailboxManagerManagementMBean);
- jmxServer.register(JMX_COMPONENT_MAILBOXCOPIER, mailboxCopierManagementMBean);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
deleted file mode 100644
index 8e91d64..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
+++ /dev/null
@@ -1,91 +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.modules.server;
-
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailrepository.api.MailRepository;
-import org.apache.james.mailrepository.api.MailRepositoryStore;
-import org.apache.james.mailrepository.file.FileMailRepository;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.apache.james.utils.InMemoryMailRepositoryStore;
-import org.apache.james.utils.MailRepositoryProvider;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class MailStoreRepositoryModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(MailRepositoryStore.class).to(InMemoryMailRepositoryStore.class);
- Multibinder<MailRepositoryProvider> multibinder = Multibinder.newSetBinder(binder(), MailRepositoryProvider.class);
- multibinder.addBinding().to(FileMailRepositoryProvider.class);
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MailRepositoryStoreModuleConfigurationPerformer.class);
- }
-
- public static class FileMailRepositoryProvider implements MailRepositoryProvider {
-
- private final FileSystem fileSystem;
-
- @Inject
- public FileMailRepositoryProvider(FileSystem fileSystem) {
- this.fileSystem = fileSystem;
- }
-
-
- @Override
- public String canonicalName() {
- return FileMailRepository.class.getCanonicalName();
- }
-
- @Override
- public MailRepository get() {
- FileMailRepository fileMailRepository = new FileMailRepository();
- fileMailRepository.setFileSystem(fileSystem);
- fileMailRepository.setLog(LoggerFactory.getLogger(FileMailRepository.class));
- return fileMailRepository;
- }
- }
-
- @Singleton
- public static class MailRepositoryStoreModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final InMemoryMailRepositoryStore javaMailRepositoryStore;
-
- @Inject
- public MailRepositoryStoreModuleConfigurationPerformer(ConfigurationProvider configurationProvider,
- InMemoryMailRepositoryStore javaMailRepositoryStore) {
- this.configurationProvider = configurationProvider;
- this.javaMailRepositoryStore = javaMailRepositoryStore;
- }
-
- @Override
- public void initModule() throws Exception {
- javaMailRepositoryStore.configure(configurationProvider.getConfiguration("mailrepositorystore"));
- javaMailRepositoryStore.init();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java
deleted file mode 100644
index f8e7815..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java
+++ /dev/null
@@ -1,38 +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.modules.server;
-
-import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.NoQuotaManager;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
-
-public class QuotaModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(QuotaManager.class).to(NoQuotaManager.class);
- bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java
deleted file mode 100644
index 229b479..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java
+++ /dev/null
@@ -1,37 +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.modules.server;
-
-import org.apache.james.managesieve.api.SieveParser;
-import org.apache.james.managesieve.jsieve.Parser;
-import org.apache.james.sieverepository.api.SieveRepository;
-import org.apache.james.sieverepository.file.SieveFileRepository;
-
-import com.google.inject.AbstractModule;
-
-public class SieveModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(SieveParser.class).to(Parser.class);
- bind(SieveRepository.class).to(SieveFileRepository.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
deleted file mode 100644
index ae2ef87..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
+++ /dev/null
@@ -1,27 +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;
-
-
-public interface ConfigurationPerformer {
-
- void initModule() throws Exception;
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java
deleted file mode 100644
index cf3126e..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java
+++ /dev/null
@@ -1,30 +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 org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-
-public interface ConfigurationProvider {
-
- HierarchicalConfiguration getConfiguration(String component)
- throws ConfigurationException;
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
deleted file mode 100644
index f64d640..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
+++ /dev/null
@@ -1,41 +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 com.google.inject.Inject;
-
-import java.util.Set;
-
-public class ConfigurationsPerformer {
-
- private final Set<ConfigurationPerformer> configurationPerformers;
-
- @Inject
- public ConfigurationsPerformer(Set<ConfigurationPerformer> configurationPerformers) throws Exception {
- this.configurationPerformers = configurationPerformers;
- }
-
- public void initModules() throws Exception {
- for(ConfigurationPerformer configurationPerformer : configurationPerformers) {
- configurationPerformer.initModule();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java
deleted file mode 100644
index fc27b61..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java
+++ /dev/null
@@ -1,40 +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.Date;
-
-import javax.mail.Flags;
-
-import org.apache.james.cli.probe.ServerProbe;
-import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.mailbox.exception.BadCredentialsException;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-
-public interface ExtendedServerProbe extends ServerProbe {
-
- void appendMessage(String username, MailboxPath mailboxPath, InputStream message, Date internalDate, boolean isRecent, Flags flags)
- throws BadCredentialsException, MailboxException;
-
- Mailbox<CassandraId> getMailbox(String namespace, String user, String name);
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
deleted file mode 100644
index b28a94a..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
+++ /dev/null
@@ -1,90 +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.List;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.apache.commons.cli.MissingArgumentException;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.modules.CommonServicesModule;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
-import com.google.inject.Singleton;
-
-@Singleton
-public class FileConfigurationProvider implements ConfigurationProvider {
-
- private static final String CONFIGURATION_FILE_SUFFIX = ".xml";
-
- private final FileSystem fileSystem;
- private final String configurationPrefix;
-
- @Inject
- public FileConfigurationProvider(FileSystem fileSystem, @Named(CommonServicesModule.CONFIGURATION_PATH) String configurationPrefix) throws MissingArgumentException {
- this.fileSystem = fileSystem;
- this.configurationPrefix = configurationPrefix;
- }
-
- @Override
- public HierarchicalConfiguration getConfiguration(String component) throws ConfigurationException {
- Preconditions.checkNotNull(component);
- List<String> configPathParts = Splitter.on(".").splitToList(component);
- Preconditions.checkArgument(!configPathParts.isEmpty());
- HierarchicalConfiguration config = getConfig(retrieveConfigInputStream(configPathParts.get(0)));
- return selectHierarchicalConfigPart(config, Iterables.skip(configPathParts, 1));
- }
-
- private InputStream retrieveConfigInputStream(String configurationFileWithoutExtension) throws ConfigurationException {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(configurationFileWithoutExtension), "The configuration file name should not be empty or null");
- try {
- return fileSystem.getResource(configurationPrefix + configurationFileWithoutExtension + CONFIGURATION_FILE_SUFFIX);
- } catch (IOException e) {
- throw new ConfigurationException("Unable to locate configuration file " + configurationFileWithoutExtension + CONFIGURATION_FILE_SUFFIX, e);
- }
- }
-
- private XMLConfiguration getConfig(InputStream configStream) throws ConfigurationException {
- XMLConfiguration config = new XMLConfiguration();
- config.setDelimiterParsingDisabled(true);
- config.setAttributeSplittingDisabled(true);
- config.load(configStream);
- return config;
- }
-
- private HierarchicalConfiguration selectHierarchicalConfigPart(HierarchicalConfiguration config, Iterable<String> configsPathParts) {
- HierarchicalConfiguration currentConfig = config;
- for (String nextPathPart : configsPathParts) {
- currentConfig = currentConfig.configurationAt(nextPathPart);
- }
- return currentConfig;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
deleted file mode 100644
index 645d9b0..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
+++ /dev/null
@@ -1,47 +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 com.google.inject.Injector;
-
-public class GuiceGenericLoader<T> {
-
- private final Injector injector;
- private final String defaultPackageName;
-
- public GuiceGenericLoader(Injector injector, String defaultPackageName) {
- this.injector = injector;
- this.defaultPackageName = defaultPackageName;
- }
-
- public T instanciate(String className) throws Exception {
- @SuppressWarnings("unchecked")
- Class<T> clazz = (Class<T>) ClassLoader.getSystemClassLoader().loadClass(constructFullName(className));
- return injector.getInstance(clazz);
- }
-
- private String constructFullName(String name) {
- if (! name.contains(".")) {
- return defaultPackageName + name;
- }
- return name;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
deleted file mode 100644
index fe55c9c..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
+++ /dev/null
@@ -1,59 +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.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.apache.james.adapter.mailbox.MailboxManagerResolver;
-import org.apache.james.adapter.mailbox.MailboxManagerResolverException;
-import org.apache.james.mailbox.MailboxManager;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Inject;
-
-public class GuiceMailboxManagerResolver implements MailboxManagerResolver {
-
- private final ImmutableMap<String, MailboxManager> managers;
-
- @Inject
- private GuiceMailboxManagerResolver(Set<MailboxManagerDefinition> managers) {
- this.managers = indexManagersByName(managers);
- }
-
- private static ImmutableMap<String, MailboxManager> indexManagersByName(Set<MailboxManagerDefinition> managers) {
- return ImmutableMap.copyOf(managers.stream().collect(
- Collectors.toMap(MailboxManagerDefinition::getName, MailboxManagerDefinition::getManager)));
- }
-
- @Override
- public Map<String, MailboxManager> getMailboxManagerBeans() {
- return managers;
- }
-
- @Override
- public MailboxManager resolveMailboxManager(String mailboxManagerClassName) {
- return Optional.ofNullable(managers.get(mailboxManagerClassName)).orElseThrow(
- () -> new MailboxManagerResolverException("Unable to find a mailbox manager with name " + mailboxManagerClassName));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java
deleted file mode 100644
index 3efdce6..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java
+++ /dev/null
@@ -1,52 +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 com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.apache.james.mailetcontainer.api.MailetLoader;
-import org.apache.mailet.Mailet;
-import org.apache.mailet.MailetConfig;
-
-import javax.mail.MessagingException;
-
-public class GuiceMailetLoader implements MailetLoader {
-
- private static final String STANDARD_PACKAGE = "org.apache.james.transport.mailets.";
-
- private final GuiceGenericLoader<Mailet> genericLoader;
-
- @Inject
- public GuiceMailetLoader(Injector injector) {
- this.genericLoader = new GuiceGenericLoader<>(injector, STANDARD_PACKAGE);
- }
-
- @Override
- public Mailet getMailet(MailetConfig config) throws MessagingException {
- try {
- Mailet result = genericLoader.instanciate(config.getMailetName());
- result.init(config);
- return result;
- } catch (Exception e) {
- throw new MessagingException("Can not load mailet " + config.getMailetName(), e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java
deleted file mode 100644
index a6d966b..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java
+++ /dev/null
@@ -1,52 +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 com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.apache.james.mailetcontainer.api.MatcherLoader;
-import org.apache.mailet.Matcher;
-import org.apache.mailet.MatcherConfig;
-
-import javax.mail.MessagingException;
-
-public class GuiceMatcherLoader implements MatcherLoader {
-
- private static final String STANDARD_PACKAGE = "org.apache.james.transport.matchers.";
-
- private final GuiceGenericLoader<Matcher> genericLoader;
-
- @Inject
- public GuiceMatcherLoader(Injector injector) {
- this.genericLoader = new GuiceGenericLoader<>(injector, STANDARD_PACKAGE);
- }
-
- @Override
- public Matcher getMatcher(MatcherConfig config) throws MessagingException {
- try {
- Matcher result = genericLoader.instanciate(config.getMatcherName());
- result.init(config);
- return result;
- } catch (Exception e) {
- throw new MessagingException("Can not load matcher " + config.getMatcherName(), e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java
deleted file mode 100644
index e677ce3..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java
+++ /dev/null
@@ -1,60 +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 com.google.common.base.Throwables;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.api.handler.ProtocolHandler;
-import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
-
-public class GuiceProtocolHandlerLoader implements ProtocolHandlerLoader {
-
- private final Injector injector;
-
- @Inject
- public GuiceProtocolHandlerLoader(Injector injector) {
- this.injector = injector;
- }
-
- @Override
- public ProtocolHandler load(String name, Configuration config) throws LoadingException {
- ProtocolHandler handler = createProtocolHandler(name);
- try {
- handler.init(config);
- } catch (ConfigurationException e) {
- throw Throwables.propagate(e);
- }
- return handler;
- }
-
- private ProtocolHandler createProtocolHandler(String name) throws LoadingException {
- try {
- @SuppressWarnings("unchecked")
- Class<ProtocolHandler> clazz = (Class<ProtocolHandler>) ClassLoader.getSystemClassLoader().loadClass(name);
- return injector.getInstance(clazz);
- } catch (ClassNotFoundException e) {
- throw new LoadingException("Can not load " + name);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java
deleted file mode 100644
index 43850fe..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java
+++ /dev/null
@@ -1,344 +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.cassandra.CassandraId;
-import org.apache.james.mailbox.exception.MailboxException;
-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.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 {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(GuiceServerProbe.class);
-
- private final MailboxManager mailboxManager;
- private final MailboxMapperFactory<CassandraId> mailboxMapperFactory;
- private final DomainList domainList;
- private final UsersRepository usersRepository;
- private final SieveRepository sieveRepository;
-
- @Inject
- private GuiceServerProbe(MailboxManager mailboxManager, MailboxMapperFactory<CassandraId> mailboxMapperFactory,
- DomainList domainList, UsersRepository usersRepository, SieveRepository sieveRepository) {
- this.mailboxManager = mailboxManager;
- this.mailboxMapperFactory = mailboxMapperFactory;
- this.domainList = domainList;
- this.usersRepository = usersRepository;
- this.sieveRepository = sieveRepository;
- }
-
- @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 void removeDomain(String domain) throws Exception {
- domainList.removeDomain(domain);
- }
-
- @Override
- public String[] listDomains() throws Exception {
- return domainList.getDomains();
- }
-
- @Override
- public Map<String, Mappings> listMappings() throws Exception {
- throw new NotImplementedException();
- }
-
- @Override
- public void addAddressMapping(String user, String domain, String toAddress) throws Exception {
- throw new NotImplementedException();
- }
-
- @Override
- public void removeAddressMapping(String user, String domain, String fromAddress) throws Exception {
- throw new NotImplementedException();
- }
-
- @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 {
- throw new NotImplementedException();
- }
-
- @Override
- public void removeRegexMapping(String user, String domain, String regex) throws Exception {
- throw new NotImplementedException();
- }
-
- @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<CassandraId> getMailbox(String namespace, String user, String name) {
- MailboxSession mailboxSession = null;
- try {
- mailboxSession = mailboxManager.createSystemSession(user, LOGGER);
- MailboxMapper<CassandraId> 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 void 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);
- 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);
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[04/24] james-project git commit: JAMES-1693 Add an in memory
implementation for mail queues and use it with guice in memory implementation
Posted by ma...@apache.org.
JAMES-1693 Add an in memory implementation for mail queues and use it with guice in memory implementation
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f89a2abd
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f89a2abd
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f89a2abd
Branch: refs/heads/master
Commit: f89a2abd2d135b070e5ba0297c8f8685de0cbe2f
Parents: f13f173
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Mar 9 14:49:35 2016 +0700
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:07:13 2016 +0100
----------------------------------------------------------------------
.../org/apache/james/MemoryJamesServerMain.java | 4 +-
.../modules/server/MemoryMailQueueFactory.java | 130 +++++++++++++++++++
.../modules/server/MemoryMailQueueModule.java | 47 +++++++
.../server/MemoryMailQueueFactoryTest.java | 122 +++++++++++++++++
4 files changed, 301 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f89a2abd/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 991ba1e..b3dffbc 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
@@ -22,8 +22,8 @@ package org.apache.james;
import org.apache.james.mailbox.inmemory.InMemoryId;
import org.apache.james.modules.data.MemoryDataModule;
import org.apache.james.modules.mailbox.MemoryMailboxModule;
-import org.apache.james.modules.server.ActiveMQQueueModule;
import org.apache.james.modules.server.JMXServerModule;
+import org.apache.james.modules.server.MemoryMailQueueModule;
import org.apache.james.modules.server.QuotaModule;
import com.google.inject.Module;
@@ -38,7 +38,7 @@ public class MemoryJamesServerMain {
new MemoryDataModule(),
new MemoryMailboxModule(),
new QuotaModule(),
- new ActiveMQQueueModule<>(inMemoryId));
+ new MemoryMailQueueModule<>(inMemoryId));
public static void main(String[] args) throws Exception {
new GuiceJamesServer<>(inMemoryId)
http://git-wip-us.apache.org/repos/asf/james-project/blob/f89a2abd/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java
new file mode 100644
index 0000000..39846ed
--- /dev/null
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.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.modules.server;
+
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.mailet.Mail;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class MemoryMailQueueFactory implements MailQueueFactory {
+
+ private final ConcurrentHashMap<String, MailQueue> mailQueues;
+ private final MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory;
+
+ @Inject
+ public MemoryMailQueueFactory(MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory) {
+ this.mailQueues = new ConcurrentHashMap<>();
+ this.mailQueueItemDecoratorFactory = mailQueueItemDecoratorFactory;
+ }
+
+ @Override
+ public MailQueue getQueue(String name) {
+ return Optional.ofNullable(mailQueues.get(name))
+ .orElseGet(() -> tryInsertNewMailQueue(name));
+ }
+
+ private MailQueue tryInsertNewMailQueue(String name) {
+ MailQueue newMailQueue = new MemoryMailQueue(name, mailQueueItemDecoratorFactory);
+ return Optional.ofNullable(mailQueues.putIfAbsent(name, newMailQueue))
+ .orElse(newMailQueue);
+ }
+
+ public static class MemoryMailQueue implements MailQueue {
+
+ private final LinkedBlockingDeque<MemoryMailQueueItem> mailItems;
+ private final MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory;
+ private final String name;
+
+ public MemoryMailQueue(String name,MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory) {
+ this.mailItems = new LinkedBlockingDeque<>();
+ this.name = name;
+ this.mailQueueItemDecoratorFactory = mailQueueItemDecoratorFactory;
+ }
+
+ @Override
+ public void enQueue(Mail mail, long delay, TimeUnit unit) throws MailQueueException {
+ enQueue(mail);
+ }
+
+ @Override
+ public void enQueue(Mail mail) throws MailQueueException {
+ mailItems.addFirst(new MemoryMailQueueItem(mail));
+ }
+
+ @Override
+ public MailQueueItem deQueue() throws MailQueueException {
+ while (true) {
+ try {
+ MemoryMailQueueItem item = mailItems.take();
+ return mailQueueItemDecoratorFactory.decorate(item);
+ } catch (InterruptedException e) {
+ Throwables.propagate(e);
+ }
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ MemoryMailQueue that = (MemoryMailQueue) o;
+
+ return Objects.equal(this.name, that.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name);
+ }
+ }
+
+ public static class MemoryMailQueueItem implements MailQueue.MailQueueItem {
+
+ private final Mail mail;
+
+ public MemoryMailQueueItem(Mail mail) {
+ this.mail = mail;
+ }
+
+ @Override
+ public Mail getMail() {
+ return mail;
+ }
+
+ @Override
+ public void done(boolean success) throws MailQueue.MailQueueException {
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f89a2abd/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueModule.java
new file mode 100644
index 0000000..c41f101
--- /dev/null
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueModule.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.server;
+
+import org.apache.james.jmap.send.PostDequeueDecoratorFactory;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.james.utils.GuiceGenericType;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+public class MemoryMailQueueModule<Id extends MailboxId> extends AbstractModule {
+
+ private final GuiceGenericType<Id> guiceGenericType;
+
+ public MemoryMailQueueModule(TypeLiteral<Id> type) {
+ guiceGenericType = new GuiceGenericType<>(type);
+ }
+
+ @Override
+ protected void configure() {
+ bind(MailQueueFactory.class).to(MemoryMailQueueFactory.class);
+ bind(MailQueueItemDecoratorFactory.class)
+ .to(guiceGenericType.newGenericType(PostDequeueDecoratorFactory.class))
+ .in(Singleton.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f89a2abd/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java
new file mode 100644
index 0000000..560378f
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java
@@ -0,0 +1,122 @@
+/****************************************************************
+ * 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.server;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.james.modules.server.MemoryMailQueueFactory;
+import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.api.MailQueue.MailQueueItem;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.test.FakeMail;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Throwables;
+
+public class MemoryMailQueueFactoryTest {
+
+ public static final String KEY = "key";
+ public static final String BIS = "bis";
+
+ private MemoryMailQueueFactory memoryMailQueueFactory;
+ private ExecutorService executorService;
+
+ @Before
+ public void setUp() {
+ memoryMailQueueFactory = new MemoryMailQueueFactory(mailQueueItem -> new MailQueueItemDecoratorFactory.MailQueueItemDecorator(mailQueueItem) {
+ @Override
+ public Mail getMail() {
+ return mailQueueItem.getMail();
+ }
+
+ @Override
+ public void done(boolean success) throws MailQueue.MailQueueException {
+
+ }
+ });
+ executorService = Executors.newFixedThreadPool(2);
+ }
+
+ @After
+ public void tearDown() {
+ executorService.shutdownNow();
+ }
+
+ @Test
+ public void getQueueShouldNotReturnNull() {
+ assertThat(memoryMailQueueFactory.getQueue(KEY)).isNotNull();
+ }
+
+ @Test
+ public void getQueueShouldReturnTwoTimeTheSameResultWhenUsedWithTheSameKey() {
+ assertThat(memoryMailQueueFactory.getQueue(KEY)).isEqualTo(memoryMailQueueFactory.getQueue(KEY));
+ }
+
+ @Test
+ public void getQueueShouldNotReturnTheSameQueueForTwoDifferentNames() {
+ assertThat(memoryMailQueueFactory.getQueue(KEY)).isNotEqualTo(memoryMailQueueFactory.getQueue(BIS));
+ }
+
+ @Test
+ public void dequeueShouldWork() throws Exception{
+ Mail mail = new FakeMail();
+ memoryMailQueueFactory.getQueue(KEY).enQueue(mail);
+ assertThat(memoryMailQueueFactory.getQueue(KEY).deQueue().getMail()).isEqualTo(mail);
+ }
+
+ @Test
+ public void dequeueShouldWorkWithMultipleMessages() throws Exception{
+ Mail mail1 = new FakeMail();
+ Mail mail2 = new FakeMail();
+ memoryMailQueueFactory.getQueue(KEY).enQueue(mail1);
+ memoryMailQueueFactory.getQueue(KEY).enQueue(mail2);
+ assertThat(memoryMailQueueFactory.getQueue(KEY).deQueue().getMail()).isEqualTo(mail2);
+ assertThat(memoryMailQueueFactory.getQueue(KEY).deQueue().getMail()).isEqualTo(mail1);
+ }
+
+ @Test(timeout = 20000)
+ public void deQueueShouldWaitForAMailToBeEnqueued() throws Exception {
+ CountDownLatch latch = new CountDownLatch(1);
+ Mail mail = new FakeMail();
+ executorService.submit(() -> {
+ try {
+ latch.await();
+ memoryMailQueueFactory.getQueue(KEY).enQueue(mail);
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ });
+ Future<MailQueueItem> tryDequeue = executorService.submit(() -> memoryMailQueueFactory.getQueue(KEY).deQueue());
+ assertThatThrownBy(() -> tryDequeue.get(100, TimeUnit.MILLISECONDS)).isInstanceOf(TimeoutException.class);
+ latch.countDown();
+ assertThat(tryDequeue.get().getMail()).isEqualTo(mail);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[12/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java
new file mode 100644
index 0000000..e905de8
--- /dev/null
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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.data;
+
+import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.memory.MemoryDomainList;
+import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.memory.MemoryRecipientRewriteTable;
+import org.apache.james.user.api.UsersRepository;
+import org.apache.james.user.memory.MemoryUsersRepository;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Scopes;
+import com.google.inject.Singleton;
+
+public class MemoryDataModule extends AbstractModule {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MemoryDataModule.class);
+
+ @Override
+ protected void configure() {
+ bind(MemoryDomainList.class).in(Scopes.SINGLETON);
+ bind(DomainList.class).to(MemoryDomainList.class);
+
+ bind(MemoryRecipientRewriteTable.class).in(Scopes.SINGLETON);
+ bind(RecipientRewriteTable.class).to(MemoryRecipientRewriteTable.class);
+
+ bind(MemoryUsersRepository.class).toInstance(MemoryUsersRepository.withVirtualHosting());
+ bind(UsersRepository.class).to(MemoryUsersRepository.class);
+ }
+
+ @Singleton
+ public static class MemoryDataConfigurationPerformer implements ConfigurationPerformer {
+
+ private final ConfigurationProvider configurationProvider;
+ private final MemoryDomainList memoryDomainList;
+ private final MemoryRecipientRewriteTable memoryRecipientRewriteTable;
+
+ @Inject
+ public MemoryDataConfigurationPerformer(ConfigurationProvider configurationProvider, MemoryDomainList memoryDomainList, MemoryRecipientRewriteTable memoryRecipientRewriteTable) {
+ this.configurationProvider = configurationProvider;
+ this.memoryDomainList = memoryDomainList;
+ this.memoryRecipientRewriteTable = memoryRecipientRewriteTable;
+ }
+
+ @Override
+ public void initModule() throws Exception {
+ memoryDomainList.setLog(LOGGER);
+ memoryDomainList.configure(configurationProvider.getConfiguration("domainlist"));
+ memoryRecipientRewriteTable.setLog(LOGGER);
+ memoryRecipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable"));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
new file mode 100644
index 0000000..85d6db9
--- /dev/null
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -0,0 +1,101 @@
+/****************************************************************
+ * 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.mailbox;
+
+import javax.inject.Singleton;
+
+import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxPathLocker;
+import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.acl.GroupMembershipResolver;
+import org.apache.james.mailbox.acl.MailboxACLResolver;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
+import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.mail.InMemoryModSeqProvider;
+import org.apache.james.mailbox.inmemory.mail.InMemoryUidProvider;
+import org.apache.james.mailbox.store.Authenticator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
+import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mailbox.store.extractor.TextExtractor;
+import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
+import org.apache.james.mailbox.store.mail.MessageMapperFactory;
+import org.apache.james.mailbox.store.mail.ModSeqProvider;
+import org.apache.james.mailbox.store.mail.UidProvider;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.store.search.MessageSearchIndex;
+import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
+import org.apache.james.mailbox.store.user.SubscriptionMapperFactory;
+import org.apache.james.mailbox.tika.extractor.TikaTextExtractor;
+import org.apache.james.modules.Names;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Scopes;
+import com.google.inject.TypeLiteral;
+import com.google.inject.name.Named;
+
+public class MemoryMailboxModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+
+ bind(new TypeLiteral<MessageMapperFactory<InMemoryId>>(){}).to(InMemoryMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<MailboxMapperFactory<InMemoryId>>(){}).to(InMemoryMailboxSessionMapperFactory.class);
+ bind(MailboxMapperFactory.class).to(InMemoryMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<MailboxSessionMapperFactory<InMemoryId>>(){}).to(InMemoryMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<MailboxSessionMapperFactory<? extends MailboxId>>(){}).to(InMemoryMailboxSessionMapperFactory.class);
+ bind(new TypeLiteral<ModSeqProvider<InMemoryId>>(){}).to(new TypeLiteral<InMemoryModSeqProvider>(){});
+ bind(new TypeLiteral<UidProvider<InMemoryId>>(){}).to(new TypeLiteral<InMemoryUidProvider>(){});
+
+ bind(SubscriptionManager.class).to(StoreSubscriptionManager.class);
+ bind(SubscriptionMapperFactory.class).to(InMemoryMailboxSessionMapperFactory.class);
+ bind(MailboxSessionMapperFactory.class).to(InMemoryMailboxSessionMapperFactory.class);
+ bind(MailboxPathLocker.class).to(JVMMailboxPathLocker.class);
+ bind(Authenticator.class).to(UserRepositoryAuthenticator.class);
+ bind(MailboxManager.class).to(InMemoryMailboxManager.class);
+ bind(MailboxACLResolver.class).to(UnionMailboxACLResolver.class);
+ bind(GroupMembershipResolver.class).to(SimpleGroupMembershipResolver.class);
+
+ bind(new TypeLiteral<MessageSearchIndex<InMemoryId>>(){}).to(new TypeLiteral<SimpleMessageSearchIndex<InMemoryId>>() {});
+ bind(TextExtractor.class).to(TikaTextExtractor.class);
+
+ bind(InMemoryMailboxSessionMapperFactory.class).in(Scopes.SINGLETON);
+ bind(new TypeLiteral<InMemoryModSeqProvider>(){}).in(Scopes.SINGLETON);
+ bind(new TypeLiteral<InMemoryUidProvider>(){}).in(Scopes.SINGLETON);
+ bind(StoreSubscriptionManager.class).in(Scopes.SINGLETON);
+ bind(JVMMailboxPathLocker.class).in(Scopes.SINGLETON);
+ bind(UserRepositoryAuthenticator.class).in(Scopes.SINGLETON);
+ bind(InMemoryMailboxManager.class).in(Scopes.SINGLETON);
+ bind(UnionMailboxACLResolver.class).in(Scopes.SINGLETON);
+ bind(SimpleGroupMembershipResolver.class).in(Scopes.SINGLETON);
+ }
+
+ @Provides @Named(Names.MAILBOXMANAGER_NAME) @Singleton
+ public MailboxManager provideMailboxManager(InMemoryMailboxManager mailboxManager) throws MailboxException {
+ mailboxManager.init();
+ return mailboxManager;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java
new file mode 100644
index 0000000..2926711
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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;
+
+import org.apache.james.jmap.methods.GetMessageListMethod;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.modules.TestFilesystemModule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class MemoryJamesServerTest extends AbstractJamesServerTest<InMemoryId> {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Override
+ protected GuiceJamesServer<InMemoryId> createJamesServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<InMemoryId>(){})
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new TestFilesystemModule(temporaryFolder),
+ new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/dnsservice.xml b/server/container/guice/memory-guice/src/test/resources/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/dnsservice.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/imapserver.xml b/server/container/guice/memory-guice/src/test/resources/imapserver.xml
new file mode 100644
index 0000000..ff478a9
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/imapserver.xml
@@ -0,0 +1,54 @@
+<?xml version="1.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.
+-->
+
+
+<imapservers>
+ <imapserver enabled="true">
+ <jmxName>imapserver</jmxName>
+ <bind>0.0.0.0:1143</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+ <imapserver enabled="true">
+ <jmxName>imapserver-ssl</jmxName>
+ <bind>0.0.0.0:1993</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/keystore b/server/container/guice/memory-guice/src/test/resources/keystore
new file mode 100644
index 0000000..536a6c7
Binary files /dev/null and b/server/container/guice/memory-guice/src/test/resources/keystore differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/lmtpserver.xml b/server/container/guice/memory-guice/src/test/resources/lmtpserver.xml
new file mode 100644
index 0000000..5c4a9c7
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/lmtpserver.xml
@@ -0,0 +1,41 @@
+<?xml version="1.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.
+ -->
+
+<lmtpservers>
+
+ <lmtpserver enabled="true">
+ <jmxName>lmtpserver</jmxName>
+ <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
+ <bind>127.0.0.1:1024</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <connectiontimeout>1200</connectiontimeout>
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!-- This sets the maximum allowed message size (in kilobytes) for this -->
+ <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+ <maxmessagesize>0</maxmessagesize>
+ <handlerchain>
+ <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </lmtpserver>
+
+</lmtpservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml b/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml
new file mode 100644
index 0000000..57c5784
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/mailetcontainer.xml
@@ -0,0 +1,168 @@
+<?xml version="1.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.
+ -->
+
+<mailetcontainer enableJmx="false">
+
+ <context>
+ <postmaster>postmaster@james.minet.net</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="false">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+ <!-- Hook on sievemanager@james.linagora.com
+ Mail send to this address will get interpreted with SIEVE Manage -->
+ <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
+ <processor>sieve-manager-check</processor>
+ </mailet>
+ <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="All" class="SetMailAttribute">
+ <spamChecked>true</spamChecked>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <!-- Check for delivery from a known spam server -->
+ <!-- This set of matchers/mailets redirect all emails from known -->
+ <!-- black holes, open relays, and spam servers to the spam processor -->
+ <!-- For this set to function properly, the spam processor must be configured. -->
+ <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
+ <processor>spam</processor>
+ <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="false">
+ <mailet match="All" class="Bounce"/>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/error/</repositoryPath>
+ </mailet>
+ </processor>
+
+
+ <processor state="transport" enableJmx="false">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
+ <name>X-WasSigned</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
+ <mailet match="All" class="RecipientRewriteTable" />
+ <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+ <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
+ <outgoingQueue>outgoing</outgoingQueue>
+ <delayTime>5000, 100000, 500000</delayTime>
+ <maxRetries>25</maxRetries>
+ <maxDnsProblemRetries>0</maxDnsProblemRetries>
+ <deliveryThreads>10</deliveryThreads>
+ <sendpartial>true</sendpartial>
+ <bounceProcessor>bounces</bounceProcessor>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>relay-denied</processor>
+ </mailet>
+ </processor>
+
+ <processor state="spam" enableJmx="false">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/spam/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="local-address-error" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/address-error/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
+ <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="false">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+
+ <processor state="sieve-manager-check" enableJmx="false">
+ <!-- Only local users can manage their scripts -->
+ <mailet match="RecipientIsLocal" class="ToProcessor">
+ <processor>sieve-manager</processor>
+ </mailet>
+ <!-- Notify other people about their failure -->
+ <mailet match="All" class="Bounce">
+ <inline>heads</inline>
+ <attachment>none</attachment>
+ <passThrough>false</passThrough>
+ <prefix>[REJECTED]</prefix>
+ <notice>
+ You can't send messages to configure SIEVE on this serveur unless you are the official SIEVE manager.
+ </notice>
+ </mailet>
+ <mailet match="All" class="Null"/>
+ </processor>
+
+ <processor state="sieve-manager">
+ <mailet match="All" class="SetMailAttribute">
+ <org.apache.james.SMTPAuthUser>true</org.apache.james.SMTPAuthUser>
+ </mailet>
+ <mailet match="All" class="org.apache.james.transport.mailets.managesieve.ManageSieveMailet">
+ <helpURL>file:/root/james-server-app-3.0.0-beta5-SNAPSHOT/conf/managesieve.help.txt</helpURL>
+ </mailet>
+ <mailet match="All" class="Null"/>
+ </processor>
+ </processors>
+
+</mailetcontainer>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/mailrepositorystore.xml b/server/container/guice/memory-guice/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/mailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/managesieveserver.xml b/server/container/guice/memory-guice/src/test/resources/managesieveserver.xml
new file mode 100644
index 0000000..ec57e09
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/managesieveserver.xml
@@ -0,0 +1,65 @@
+<?xml version="1.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.
+ -->
+
+<!--
+ This template file can be used as example for James Server configuration
+ DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<managesieveservers>
+
+ <managesieveserver enabled="true">
+
+ <jmxName>managesieveserver</jmxName>
+
+ <bind>0.0.0.0:4190</bind>
+
+ <connectionBacklog>200</connectionBacklog>
+
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <!-- The algorithm is optional and only needs to be specified when using something other
+ than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
+ <algorithm>SunX509</algorithm>
+ </tls>
+
+ <!-- connection timeout in secconds -->
+ <connectiontimeout>360</connectiontimeout>
+
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+
+ </managesieveserver>
+
+</managesieveservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/pop3server.xml b/server/container/guice/memory-guice/src/test/resources/pop3server.xml
new file mode 100644
index 0000000..e4187da
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/pop3server.xml
@@ -0,0 +1,42 @@
+<?xml version="1.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.
+ -->
+
+
+<pop3servers>
+ <pop3server enabled="true">
+ <jmxName>pop3server</jmxName>
+ <bind>0.0.0.0:1110</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectiontimeout>1200</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <handlerchain>
+ <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </pop3server>
+</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/memory-guice/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/resources/smtpserver.xml b/server/container/guice/memory-guice/src/test/resources/smtpserver.xml
new file mode 100644
index 0000000..a3d4b8f
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/resources/smtpserver.xml
@@ -0,0 +1,105 @@
+<?xml version="1.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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <authRequired>false</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:10465</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/data/data-memory/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-memory/pom.xml b/server/data/data-memory/pom.xml
index aa35b9f..fa43105 100644
--- a/server/data/data-memory/pom.xml
+++ b/server/data/data-memory/pom.xml
@@ -44,6 +44,12 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>james-server-dnsservice-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>james-server-data-library</artifactId>
<type>test-jar</type>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index 358c385..910d58f 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -58,7 +58,9 @@
<module>karaf/features</module>
<module>karaf/integration</module>
- <module>container/cassandra-guice</module>
+ <module>container/guice/cassandra-guice</module>
+ <module>container/guice/memory-guice</module>
+ <module>container/guice/guice-common</module>
<module>container/cli</module>
<module>container/core</module>
<module>container/filesystem-api</module>
@@ -92,7 +94,9 @@
<module>protocols/fetchmail</module>
<module>protocols/protocols-imap4</module>
<module>protocols/jmap</module>
- <module>protocols/jmap-integration-testing</module>
+ <module>protocols/jmap-integration-testing/cassandra-jmap-integration-testing</module>
+ <module>protocols/jmap-integration-testing/memory-jmap-integration-testing</module>
+ <module>protocols/jmap-integration-testing/jmap-integration-testing-common</module>
<module>protocols/protocols-library</module>
<module>protocols/protocols-lmtp</module>
<module>protocols/protocols-managesieve</module>
@@ -220,6 +224,17 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>james-server-jetty</artifactId>
<version>${project.version}</version>
</dependency>
@@ -531,6 +546,11 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>james-server-data-memory</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>james-server-core</artifactId>
<version>${project.version}</version>
</dependency>
@@ -555,6 +575,11 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>james-server-memory-guice</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>james-server-jmap</artifactId>
<version>${project.version}</version>
</dependency>
@@ -564,6 +589,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-jmap-integration-testing</artifactId>
+ <type>test-jar</type>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.james.protocols</groupId>
<artifactId>protocols-smtp</artifactId>
<version>${protocols.version}</version>
@@ -574,7 +605,6 @@
<groupId>org.apache.james</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
<version>${mailbox.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
@@ -853,6 +883,11 @@
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ <version>2.0.0.0</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
new file mode 100644
index 0000000..c5b6f4e
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>james-server</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>3.0.0-beta5-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>cassandra-jmap-integration-testing</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: JMAP :: Cassandra Integration testing</name>
+
+ <profiles>
+ <profile>
+ <id>noTest</id>
+ <activation>
+ <os>
+ <family>windows</family>
+ </os>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>disable-build-for-older-jdk</id>
+ <activation>
+ <jdk>(,1.8)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>jar</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-install</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-resources</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>default-testResources</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-descriptor</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>build-for-jdk-8</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-cassandra-guice</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-cassandra-guice</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-jmap-integration-testing</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.restassured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-3.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.cassandraunit</groupId>
+ <artifactId>cassandra-unit</artifactId>
+ <version>${cassandra-unit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>fully.qualified.MainClass</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>disable-animal-sniffer</id>
+ <activation>
+ <jdk>[1.6,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check_java_6</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java
new file mode 100644
index 0000000..2c7bf47
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMailboxesMethodTest.java
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.jmap.cassandra;
+
+import org.apache.james.CassandraJamesServerMain;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.jmap.methods.integration.GetMailboxesMethodTest;
+import org.apache.james.jmap.servers.CassandraJmapServerModule;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class CassandraGetMailboxesMethodTest extends GetMailboxesMethodTest {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
+ private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
+
+ @Rule
+ public RuleChain chain = RuleChain
+ .outerRule(temporaryFolder)
+ .around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<CassandraId> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<CassandraId>(){})
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java
new file mode 100644
index 0000000..1d81cc8
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessageListMethodTest.java
@@ -0,0 +1,57 @@
+/****************************************************************
+ * 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.jmap.cassandra;
+
+import org.apache.james.CassandraJamesServerMain;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.jmap.methods.integration.GetMessageListMethodTest;
+import org.apache.james.jmap.servers.CassandraJmapServerModule;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class CassandraGetMessageListMethodTest extends GetMessageListMethodTest {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
+ private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
+
+ @Rule
+ public RuleChain chain = RuleChain
+ .outerRule(temporaryFolder)
+ .around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<CassandraId>(){})
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
+ }
+
+ @Override
+ protected void await() {
+ embeddedElasticSearch.awaitForElasticSearch();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessagesMethodTest.java
new file mode 100644
index 0000000..7cc7a55
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetMessagesMethodTest.java
@@ -0,0 +1,57 @@
+/****************************************************************
+ * 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.jmap.cassandra;
+
+import org.apache.james.CassandraJamesServerMain;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.jmap.methods.integration.GetMessagesMethodTest;
+import org.apache.james.jmap.servers.CassandraJmapServerModule;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class CassandraGetMessagesMethodTest extends GetMessagesMethodTest {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
+ private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
+
+ @Rule
+ public RuleChain chain = RuleChain
+ .outerRule(temporaryFolder)
+ .around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<CassandraId>(){})
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
+ }
+
+ @Override
+ protected void await() {
+ embeddedElasticSearch.awaitForElasticSearch();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java
new file mode 100644
index 0000000..4408a31
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapAuthenticationTest.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.jmap.cassandra;
+
+import org.apache.james.CassandraJamesServerMain;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.jmap.FixedDateZonedDateTimeProvider;
+import org.apache.james.jmap.JMAPAuthenticationTest;
+import org.apache.james.jmap.servers.CassandraJmapServerModule;
+import org.apache.james.jmap.utils.ZonedDateTimeProvider;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class CassandraJmapAuthenticationTest extends JMAPAuthenticationTest {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
+ private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
+
+ @Rule
+ public RuleChain chain = RuleChain
+ .outerRule(temporaryFolder)
+ .around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer(FixedDateZonedDateTimeProvider zonedDateTimeProvider) {
+ return new GuiceJamesServer<>(new TypeLiteral<CassandraId>(){})
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra),
+ (binder) -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java
new file mode 100644
index 0000000..04a5cb1
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodTest.java
@@ -0,0 +1,57 @@
+/****************************************************************
+ * 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.jmap.cassandra;
+
+import org.apache.james.CassandraJamesServerMain;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.jmap.methods.integration.SetMessagesMethodTest;
+import org.apache.james.jmap.servers.CassandraJmapServerModule;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.TypeLiteral;
+
+public class CassandraSetMessagesMethodTest extends SetMessagesMethodTest {
+
+ private TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
+ private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
+
+ @Rule
+ public RuleChain chain = RuleChain
+ .outerRule(temporaryFolder)
+ .around(embeddedElasticSearch);
+
+ @Override
+ protected GuiceJamesServer<?> createJmapServer() {
+ return new GuiceJamesServer<>(new TypeLiteral<CassandraId>(){})
+ .combineWith(CassandraJamesServerMain.cassandraServerModule)
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
+ }
+
+ @Override
+ protected void await() {
+ embeddedElasticSearch.awaitForElasticSearch();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/CassandraJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/CassandraJmapServerModule.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/CassandraJmapServerModule.java
new file mode 100644
index 0000000..e9c9c3c
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/CassandraJmapServerModule.java
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.jmap.servers;
+
+import javax.inject.Singleton;
+
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestFilesystemModule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.rules.TemporaryFolder;
+
+import com.datastax.driver.core.Session;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+public class CassandraJmapServerModule extends AbstractModule {
+
+ private static final int LIMIT_TO_3_MESSAGES = 3;
+ private final TemporaryFolder temporaryFolder;
+ private final EmbeddedElasticSearch embeddedElasticSearch;
+ private final EmbeddedCassandra cassandra;
+
+ public CassandraJmapServerModule(TemporaryFolder temporaryFolder,
+ EmbeddedElasticSearch embeddedElasticSearch,
+ EmbeddedCassandra cassandra) {
+ this.temporaryFolder = temporaryFolder;
+ this.embeddedElasticSearch = embeddedElasticSearch;
+ this.cassandra = cassandra;
+ }
+
+ @Override
+ protected void configure() {
+ install(new TestElasticSearchModule(embeddedElasticSearch));
+ install(new TestFilesystemModule(temporaryFolder));
+ install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES));
+ bind(EmbeddedCassandra.class).toInstance(cassandra);
+ }
+
+ @Provides
+ @Singleton
+ Session provideSession(CassandraCluster initializedCassandra) {
+ return initializedCassandra.getConf();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/dnsservice.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/dnsservice.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/imapserver.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/imapserver.xml
new file mode 100644
index 0000000..ff478a9
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/imapserver.xml
@@ -0,0 +1,54 @@
+<?xml version="1.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.
+-->
+
+
+<imapservers>
+ <imapserver enabled="true">
+ <jmxName>imapserver</jmxName>
+ <bind>0.0.0.0:1143</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+ <imapserver enabled="true">
+ <jmxName>imapserver-ssl</jmxName>
+ <bind>0.0.0.0:1993</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/keystore b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/keystore
new file mode 100644
index 0000000..536a6c7
Binary files /dev/null and b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/keystore differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/lmtpserver.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/lmtpserver.xml
new file mode 100644
index 0000000..5c4a9c7
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/lmtpserver.xml
@@ -0,0 +1,41 @@
+<?xml version="1.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.
+ -->
+
+<lmtpservers>
+
+ <lmtpserver enabled="true">
+ <jmxName>lmtpserver</jmxName>
+ <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
+ <bind>127.0.0.1:1024</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <connectiontimeout>1200</connectiontimeout>
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!-- This sets the maximum allowed message size (in kilobytes) for this -->
+ <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+ <maxmessagesize>0</maxmessagesize>
+ <handlerchain>
+ <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </lmtpserver>
+
+</lmtpservers>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[10/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
new file mode 100644
index 0000000..da9cf03
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -0,0 +1,511 @@
+/****************************************************************
+ * 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.jmap.methods.integration;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.RestAssured.with;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+
+import java.io.ByteArrayInputStream;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.List;
+
+import javax.mail.Flags;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.JmapAuthentication;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public abstract class GetMessageListMethodTest {
+ private static final String NAME = "[0][0]";
+ private static final String ARGUMENTS = "[0][1]";
+
+ protected abstract GuiceJamesServer<?> createJmapServer();
+
+ protected abstract void await();
+
+ private AccessToken accessToken;
+ private String username;
+ private String domain;
+ private GuiceJamesServer<?> jmapServer;
+
+ @Before
+ public void setup() throws Throwable {
+ jmapServer = createJmapServer();
+ jmapServer.start();
+ RestAssured.port = jmapServer.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+
+ this.domain = "domain.tld";
+ this.username = "username@" + domain;
+ String password = "password";
+ jmapServer.serverProbe().addDomain(domain);
+ jmapServer.serverProbe().addUser(username, password);
+ this.accessToken = JmapAuthentication.authenticateJamesUser(username, password);
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ @Test
+ public void getMessageListShouldErrorInvalidArgumentsWhenRequestIsInvalid() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"filter\": true}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("invalidArguments"))
+ .body(ARGUMENTS + ".description", equalTo("Can not instantiate value of type [simple type, class org.apache.james.jmap.model.FilterCondition$Builder] from Boolean value (true); no single-boolean/Boolean-arg constructor/factory method\n" +
+ " at [Source: {\"filter\":true}; line: 1, column: 2] (through reference chain: org.apache.james.jmap.model.Builder[\"filter\"])"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnAllMessagesWhenSingleMailboxNoParameters() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnAllMessagesWhenMultipleMailboxesAndNoParameters() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox2|1"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnAllMessagesOfCurrentUserOnlyWhenMultipleMailboxesAndNoParameters() throws Exception {
+ String otherUser = "other@" + domain;
+ String password = "password";
+ jmapServer.serverProbe().addUser(otherUser, password);
+
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, otherUser, "mailbox");
+ jmapServer.serverProbe().appendMessage(otherUser, new MailboxPath(MailboxConstants.USER_NAMESPACE, otherUser, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox2|1"));
+ }
+
+ @Test
+ public void getMessageListShouldFilterMessagesWhenInMailboxesFilterMatches() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ String mailboxId =
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .post("/jmap")
+ .path("[0][1].list[0].id");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
+ }
+
+ @Test
+ public void getMessageListShouldFilterMessagesWhenMultipleInMailboxesFilterMatches() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
+ await();
+
+ List<String> mailboxIds =
+ with()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMailboxes\", {}, \"#0\"]]")
+ .post("/jmap")
+ .path("[0][1].list.id");
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body(String.format("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]", mailboxIds.get(0), mailboxIds.get(1)))
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
+ }
+
+ @Test
+ public void getMessageListShouldFilterMessagesWhenInMailboxesFilterDoesntMatches() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"mailbox2\"]}}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(ARGUMENTS + ".messageIds", empty());
+ }
+
+ @Test
+ public void getMessageListShouldSortMessagesWhenSortedByDateDefault() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"sort\":[\"date\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
+ }
+
+ @Test
+ public void getMessageListShouldSortMessagesWhenSortedByDateAsc() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"sort\":[\"date asc\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|2", "username@domain.tld|mailbox|1"));
+ }
+
+ @Test
+ public void getMessageListShouldSortMessagesWhenSortedByDateDesc() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"sort\":[\"date desc\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
+ }
+
+ @Test
+ public void getMessageListShouldWorkWhenCollapseThreadIsFalse() {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"collapseThreads\":false}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"));
+ }
+
+ @Test
+ public void getMessageListShouldWorkWhenCollapseThreadIsTrue() {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"collapseThreads\":true}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnAllMessagesWhenPositionIsNotGiven() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnSkipMessagesWhenPositionIsGiven() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"position\":1}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|2"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnAllMessagesWhenLimitIsNotGiven() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnLimitMessagesWhenLimitGiven() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"limit\":1}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
+ }
+
+ @Test
+ public void getMessageListShouldReturnLimitMessagesWithDefaultValueWhenLimitIsNotGiven() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test4\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2", "username@domain.tld|mailbox|3"));
+ }
+
+ @Test
+ public void getMessageListShouldChainFetchingMessagesWhenAskedFor() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.now();
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"fetchMessages\":true}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body("[0][0]", equalTo("messageList"))
+ .body("[1][0]", equalTo("messages"))
+ .body("[0][1].messageIds", hasSize(1))
+ .body("[0][1].messageIds[0]", equalTo("username@domain.tld|mailbox|1"))
+ .body("[1][1].list", hasSize(1))
+ .body("[1][1].list[0].id", equalTo("username@domain.tld|mailbox|1"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessagesMethodTest.java
new file mode 100644
index 0000000..23a06a0
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessagesMethodTest.java
@@ -0,0 +1,334 @@
+/****************************************************************
+ * 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.jmap.methods.integration;
+
+import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.nullValue;
+
+import java.io.ByteArrayInputStream;
+import java.time.ZonedDateTime;
+import java.util.Date;
+
+import javax.mail.Flags;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.JmapAuthentication;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.google.common.collect.ImmutableMap;
+import com.jayway.restassured.RestAssured;
+import com.jayway.restassured.http.ContentType;
+
+public abstract class GetMessagesMethodTest {
+ private static final String NAME = "[0][0]";
+ private static final String ARGUMENTS = "[0][1]";
+
+ protected abstract GuiceJamesServer<?> createJmapServer();
+
+ protected abstract void await();
+
+ private AccessToken accessToken;
+ private String username;
+ private GuiceJamesServer<?> jmapServer;
+
+ @Before
+ public void setup() throws Throwable {
+ jmapServer = createJmapServer();
+ jmapServer.start();
+ RestAssured.port = jmapServer.getJmapPort();
+ RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
+
+ String domain = "domain.tld";
+ username = "username@" + domain;
+ String password = "password";
+ jmapServer.serverProbe().addDomain(domain);
+ jmapServer.serverProbe().addUser(username, password);
+ jmapServer.serverProbe().createMailbox("#private", "username", "inbox");
+ accessToken = JmapAuthentication.authenticateJamesUser(username, password);
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ @Test
+ public void getMessagesShouldErrorNotSupportedWhenRequestContainsNonNullAccountId() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"accountId\": \"1\"}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
+ }
+
+ @Test
+ public void getMessagesShouldIgnoreUnknownArguments() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"WAT\": true}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(ARGUMENTS + ".notFound", empty())
+ .body(ARGUMENTS + ".list", empty());
+ }
+
+ @Test
+ public void getMessagesShouldErrorInvalidArgumentsWhenRequestContainsInvalidArgument() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": null}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("error"))
+ .body(ARGUMENTS + ".type", equalTo("invalidArguments"))
+ .body(ARGUMENTS + ".description", equalTo("N/A (through reference chain: org.apache.james.jmap.model.Builder[\"ids\"])"));
+ }
+
+ @Test
+ public void getMessagesShouldReturnEmptyListWhenNoMessage() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": []}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", empty());
+ }
+
+ @Test
+ public void getMessagesShouldReturnNoFoundIndicesWhenMessageNotFound() throws Exception {
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"username|inbox|12\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".notFound", contains("username|inbox|12"));
+ }
+
+ @Test
+ public void getMessagesShouldReturnMessagesWhenAvailable() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
+
+ ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
+ new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
+
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
+ .body(ARGUMENTS + ".list[0].threadId", equalTo(username + "|inbox|1"))
+ .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
+ .body(ARGUMENTS + ".list[0].textBody", equalTo("testmail"))
+ .body(ARGUMENTS + ".list[0].isUnread", equalTo(true))
+ .body(ARGUMENTS + ".list[0].preview", equalTo("testmail"))
+ .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("subject", "my test subject")))
+ .body(ARGUMENTS + ".list[0].date", equalTo("2014-10-30T14:12:00Z"));
+ }
+
+ @Test
+ public void getMessagesShouldReturnMessageWhenHtmlMessage() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
+
+ ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
+ new ByteArrayInputStream("Content-Type: text/html\r\nSubject: my test subject\r\n\r\nThis is a <b>HTML</b> mail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
+
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
+ .body(ARGUMENTS + ".list[0].threadId", equalTo(username + "|inbox|1"))
+ .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
+ .body(ARGUMENTS + ".list[0].htmlBody", equalTo("This is a <b>HTML</b> mail"))
+ .body(ARGUMENTS + ".list[0].isUnread", equalTo(true))
+ .body(ARGUMENTS + ".list[0].preview", equalTo("This is a <b>HTML</b> mail"))
+ .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("content-type", "text/html", "subject", "my test subject")))
+ .body(ARGUMENTS + ".list[0].date", equalTo("2014-10-30T14:12:00Z"));
+ }
+
+ @Test
+ public void getMessagesShouldReturnFilteredPropertiesMessagesWhenAsked() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
+
+ ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
+ new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
+
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"], \"properties\": [\"id\", \"subject\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
+ .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
+ .body(ARGUMENTS + ".list[0].textBody", nullValue())
+ .body(ARGUMENTS + ".list[0].isUnread", nullValue())
+ .body(ARGUMENTS + ".list[0].preview", nullValue())
+ .body(ARGUMENTS + ".list[0].headers", nullValue())
+ .body(ARGUMENTS + ".list[0].date", nullValue());
+ }
+
+ @Test
+ public void getMessagesShouldReturnFilteredHeaderPropertyWhenAsked() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
+
+ ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
+ new ByteArrayInputStream(("From: user@domain.tld\r\n"
+ + "header1: Header1Content\r\n"
+ + "HEADer2: Header2Content\r\n"
+ + "Subject: my test subject\r\n"
+ + "\r\n"
+ + "testmail").getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
+
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + username + "|inbox|1\"], \"properties\": [\"headers.from\", \"headers.heADER2\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
+ .body(ARGUMENTS + ".list[0].subject", nullValue())
+ .body(ARGUMENTS + ".list[0].textBody", nullValue())
+ .body(ARGUMENTS + ".list[0].isUnread", nullValue())
+ .body(ARGUMENTS + ".list[0].preview", nullValue())
+ .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("from", "user@domain.tld", "header2", "Header2Content")))
+ .body(ARGUMENTS + ".list[0].date", nullValue());
+ }
+
+ @Test
+ public void getMessagesShouldReturnNotFoundWhenIdDoesntMatch() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
+
+ ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
+ new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
+
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", empty())
+ .body(ARGUMENTS + ".notFound", hasSize(1));
+ }
+
+ @Test
+ public void getMessagesShouldReturnMandatoryPropertiesMessagesWhenNotAsked() throws Exception {
+ jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
+ jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
+ await();
+
+ given()
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + username + "|mailbox|1\"], \"properties\": [\"subject\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(ARGUMENTS + ".list[0].id", equalTo("username@domain.tld|mailbox|1"))
+ .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[20/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
JAMES-1693 implement a data memory module for Guice
That means have a tree of guice modules to pick from
when composing an application.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/517a4cfe
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/517a4cfe
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/517a4cfe
Branch: refs/heads/master
Commit: 517a4cfe725be483541c2fc7ce59f74edef62d45
Parents: 3413ec5
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Mon Mar 21 11:32:15 2016 +0100
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Wed Mar 23 17:07:13 2016 +0100
----------------------------------------------------------------------
.../inmemory/InMemoryMailboxManager.java | 8 +-
.../inmemory/InMemoryMailboxManagerTest.java | 3 +-
.../manager/InMemoryIntegrationResources.java | 3 +
.../mailbox/store/StoreSubscriptionManager.java | 5 +-
.../inmemory/host/InMemoryHostSystem.java | 4 +-
mpt/impl/smtp/cassandra/pom.xml | 6 +
.../apache/james/mpt/smtp/SmtpTestModule.java | 15 +-
.../src/test/resources/mailetcontainer.xml | 3 +
mpt/pom.xml | 6 +
server/container/cassandra-guice/README.adoc | 45 -
server/container/cassandra-guice/pom.xml | 471 ------
.../sample-configuration/cassandra.properties | 6 -
.../sample-configuration/dnsservice.xml | 29 -
.../sample-configuration/domainlist.xml | 28 -
.../elasticsearch.properties | 26 -
.../sample-configuration/imapserver.xml | 54 -
.../sample-configuration/jcr-repository.xml | 72 -
.../sample-configuration/jmap.properties | 11 -
.../sample-configuration/jmx.properties | 28 -
.../sample-configuration/lmtpserver.xml | 41 -
.../sample-configuration/mailetcontainer.xml | 137 --
.../mailrepositorystore.xml | 34 -
.../sample-configuration/pop3server.xml | 42 -
.../recipientrewritetable.xml | 27 -
.../sample-configuration/smtpserver.xml | 105 --
.../sample-configuration/usersrepository.xml | 27 -
.../org/apache/james/CassandraJamesServer.java | 65 -
.../apache/james/CassandraJamesServerMain.java | 82 --
.../org/apache/james/jmap/JMAPCommonModule.java | 70 -
.../java/org/apache/james/jmap/JMAPModule.java | 120 --
.../org/apache/james/jmap/MethodsModule.java | 65 -
.../james/modules/CommonServicesModule.java | 63 -
.../modules/data/CassandraDomainListModule.java | 65 -
.../CassandraRecipientRewriteTableModule.java | 68 -
.../data/CassandraUsersRepositoryModule.java | 38 -
.../modules/mailbox/CassandraMailboxModule.java | 83 --
.../modules/mailbox/CassandraSessionModule.java | 99 --
.../mailbox/ElasticSearchMailboxModule.java | 81 --
.../ScheduledExecutorServiceProvider.java | 49 -
.../modules/protocols/IMAPServerModule.java | 103 --
.../modules/protocols/JMAPServerModule.java | 67 -
.../modules/protocols/LMTPServerModule.java | 62 -
.../protocols/ManageSieveServerModule.java | 62 -
.../modules/protocols/POP3ServerModule.java | 62 -
.../protocols/ProtocolHandlerModule.java | 34 -
.../modules/protocols/SMTPServerModule.java | 68 -
.../modules/server/ActiveMQQueueModule.java | 60 -
.../server/CamelMailetContainerModule.java | 111 --
.../server/ConfigurationProviderModule.java | 33 -
.../james/modules/server/DNSServiceModule.java | 62 -
.../james/modules/server/EmbeddedActiveMQ.java | 107 --
.../apache/james/modules/server/JMXServer.java | 125 --
.../james/modules/server/JMXServerModule.java | 114 --
.../server/MailStoreRepositoryModule.java | 91 --
.../james/modules/server/QuotaModule.java | 38 -
.../james/modules/server/SieveModule.java | 37 -
.../james/utils/ConfigurationPerformer.java | 27 -
.../james/utils/ConfigurationProvider.java | 30 -
.../james/utils/ConfigurationsPerformer.java | 41 -
.../apache/james/utils/ExtendedServerProbe.java | 40 -
.../james/utils/FileConfigurationProvider.java | 90 --
.../apache/james/utils/GuiceGenericLoader.java | 47 -
.../utils/GuiceMailboxManagerResolver.java | 59 -
.../apache/james/utils/GuiceMailetLoader.java | 52 -
.../apache/james/utils/GuiceMatcherLoader.java | 52 -
.../james/utils/GuiceProtocolHandlerLoader.java | 60 -
.../apache/james/utils/GuiceServerProbe.java | 344 -----
.../utils/InMemoryMailRepositoryStore.java | 164 ---
.../james/utils/MailRepositoryProvider.java | 29 -
.../james/utils/MailboxManagerDefinition.java | 57 -
.../apache/james/utils/PropertiesReader.java | 43 -
.../apache/james/CassandraJamesServerTest.java | 157 --
.../james/modules/TestElasticSearchModule.java | 52 -
.../james/modules/TestFilesystemModule.java | 61 -
.../james/modules/TestJMAPServerModule.java | 68 -
.../utils/FileConfigurationProviderTest.java | 119 --
.../utils/InMemoryMailRepositoryStoreTest.java | 109 --
.../apache/james/utils/PropertiesReadTest.java | 44 -
.../src/test/resources/dnsservice.xml | 29 -
.../test/resources/fakemailrepositorystore.xml | 31 -
.../src/test/resources/imapserver.xml | 54 -
.../cassandra-guice/src/test/resources/keystore | Bin 2245 -> 0 bytes
.../src/test/resources/lmtpserver.xml | 41 -
.../src/test/resources/mailetcontainer.xml | 168 ---
.../src/test/resources/mailrepositorystore.xml | 31 -
.../src/test/resources/managesieveserver.xml | 65 -
.../src/test/resources/pop3server.xml | 42 -
.../src/test/resources/smtpserver.xml | 105 --
.../src/test/resources/test.properties | 6 -
.../cassandra-guice/src/test/resources/test.xml | 28 -
.../container/guice/cassandra-guice/README.adoc | 45 +
server/container/guice/cassandra-guice/pom.xml | 291 ++++
.../apache/james/CassandraJamesServerMain.java | 58 +
.../modules/data/CassandraDomainListModule.java | 65 +
.../CassandraRecipientRewriteTableModule.java | 68 +
.../data/CassandraUsersRepositoryModule.java | 38 +
.../modules/mailbox/CassandraMailboxModule.java | 97 ++
.../modules/mailbox/CassandraSessionModule.java | 99 ++
.../mailbox/ElasticSearchMailboxModule.java | 81 ++
.../ScheduledExecutorServiceProvider.java | 49 +
.../apache/james/CassandraJamesServerTest.java | 71 +
.../james/modules/TestElasticSearchModule.java | 52 +
.../src/test/resources/dnsservice.xml | 29 +
.../test/resources/fakemailrepositorystore.xml | 31 +
.../src/test/resources/imapserver.xml | 54 +
.../cassandra-guice/src/test/resources/keystore | Bin 0 -> 2245 bytes
.../src/test/resources/lmtpserver.xml | 41 +
.../src/test/resources/mailetcontainer.xml | 168 +++
.../src/test/resources/mailrepositorystore.xml | 31 +
.../src/test/resources/managesieveserver.xml | 65 +
.../src/test/resources/pop3server.xml | 42 +
.../src/test/resources/smtpserver.xml | 105 ++
server/container/guice/guice-common/pom.xml | 291 ++++
.../sample-configuration/cassandra.properties | 6 +
.../sample-configuration/dnsservice.xml | 29 +
.../sample-configuration/domainlist.xml | 28 +
.../elasticsearch.properties | 26 +
.../sample-configuration/imapserver.xml | 54 +
.../sample-configuration/jcr-repository.xml | 72 +
.../sample-configuration/jmap.properties | 11 +
.../sample-configuration/jmx.properties | 28 +
.../sample-configuration/lmtpserver.xml | 41 +
.../sample-configuration/mailetcontainer.xml | 137 ++
.../mailrepositorystore.xml | 34 +
.../sample-configuration/pop3server.xml | 42 +
.../recipientrewritetable.xml | 27 +
.../sample-configuration/smtpserver.xml | 105 ++
.../sample-configuration/usersrepository.xml | 27 +
.../java/org/apache/james/GuiceJamesServer.java | 94 ++
.../org/apache/james/jmap/JMAPCommonModule.java | 70 +
.../java/org/apache/james/jmap/JMAPModule.java | 127 ++
.../org/apache/james/jmap/MethodsModule.java | 74 +
.../james/modules/CommonServicesModule.java | 79 +
.../james/modules/MailetProcessingModule.java | 36 +
.../java/org/apache/james/modules/Names.java | 24 +
.../apache/james/modules/ProtocolsModule.java | 52 +
.../modules/protocols/IMAPServerModule.java | 103 ++
.../modules/protocols/JMAPServerModule.java | 75 +
.../modules/protocols/LMTPServerModule.java | 62 +
.../protocols/ManageSieveServerModule.java | 63 +
.../modules/protocols/POP3ServerModule.java | 62 +
.../protocols/ProtocolHandlerModule.java | 34 +
.../modules/protocols/SMTPServerModule.java | 68 +
.../modules/server/ActiveMQQueueModule.java | 68 +
.../server/CamelMailetContainerModule.java | 111 ++
.../server/ConfigurationProviderModule.java | 33 +
.../james/modules/server/DNSServiceModule.java | 62 +
.../james/modules/server/EmbeddedActiveMQ.java | 107 ++
.../apache/james/modules/server/JMXServer.java | 125 ++
.../james/modules/server/JMXServerModule.java | 103 ++
.../server/MailStoreRepositoryModule.java | 91 ++
.../james/modules/server/QuotaModule.java | 38 +
.../james/modules/server/SieveModule.java | 37 +
.../james/utils/ConfigurationPerformer.java | 27 +
.../james/utils/ConfigurationProvider.java | 30 +
.../james/utils/ConfigurationsPerformer.java | 41 +
.../apache/james/utils/ExtendedServerProbe.java | 40 +
.../james/utils/FileConfigurationProvider.java | 90 ++
.../apache/james/utils/GuiceGenericLoader.java | 47 +
.../apache/james/utils/GuiceGenericType.java | 40 +
.../utils/GuiceMailboxManagerResolver.java | 59 +
.../apache/james/utils/GuiceMailetLoader.java | 53 +
.../apache/james/utils/GuiceMatcherLoader.java | 53 +
.../james/utils/GuiceProtocolHandlerLoader.java | 61 +
.../apache/james/utils/GuiceServerProbe.java | 344 +++++
.../utils/InMemoryMailRepositoryStore.java | 164 +++
.../james/utils/MailRepositoryProvider.java | 29 +
.../james/utils/MailboxManagerDefinition.java | 57 +
.../apache/james/utils/PropertiesReader.java | 43 +
.../apache/james/AbstractJamesServerTest.java | 117 ++
.../james/modules/TestFilesystemModule.java | 61 +
.../james/modules/TestJMAPServerModule.java | 68 +
.../utils/FileConfigurationProviderTest.java | 119 ++
.../utils/InMemoryMailRepositoryStoreTest.java | 109 ++
.../apache/james/utils/PropertiesReadTest.java | 44 +
.../test/resources/fakemailrepositorystore.xml | 31 +
.../src/test/resources/mailrepositorystore.xml | 31 +
.../src/test/resources/test.properties | 6 +
.../guice-common/src/test/resources/test.xml | 28 +
server/container/guice/memory-guice/README.adoc | 38 +
server/container/guice/memory-guice/pom.xml | 261 ++++
.../org/apache/james/MemoryJamesServerMain.java | 49 +
.../james/modules/data/MemoryDataModule.java | 76 +
.../modules/mailbox/MemoryMailboxModule.java | 101 ++
.../org/apache/james/MemoryJamesServerTest.java | 44 +
.../src/test/resources/dnsservice.xml | 29 +
.../src/test/resources/imapserver.xml | 54 +
.../memory-guice/src/test/resources/keystore | Bin 0 -> 2245 bytes
.../src/test/resources/lmtpserver.xml | 41 +
.../src/test/resources/mailetcontainer.xml | 168 +++
.../src/test/resources/mailrepositorystore.xml | 31 +
.../src/test/resources/managesieveserver.xml | 65 +
.../src/test/resources/pop3server.xml | 42 +
.../src/test/resources/smtpserver.xml | 105 ++
server/data/data-memory/pom.xml | 6 +
server/pom.xml | 41 +-
.../cassandra-jmap-integration-testing/pom.xml | 255 ++++
.../CassandraGetMailboxesMethodTest.java | 53 +
.../CassandraGetMessageListMethodTest.java | 57 +
.../CassandraGetMessagesMethodTest.java | 57 +
.../CassandraJmapAuthenticationTest.java | 55 +
.../CassandraSetMessagesMethodTest.java | 57 +
.../jmap/servers/CassandraJmapServerModule.java | 64 +
.../src/test/resources/dnsservice.xml | 29 +
.../src/test/resources/imapserver.xml | 54 +
.../src/test/resources/keystore | Bin 0 -> 2245 bytes
.../src/test/resources/lmtpserver.xml | 41 +
.../src/test/resources/mailetcontainer.xml | 103 ++
.../src/test/resources/mailrepositorystore.xml | 31 +
.../src/test/resources/pop3server.xml | 42 +
.../src/test/resources/smtpserver.xml | 105 ++
.../jmap-integration-testing-common/pom.xml | 241 +++
.../org/apache/james/jmap/ContainerTest.java | 45 +
.../jmap/FixedDateZonedDateTimeProvider.java | 39 +
.../james/jmap/JMAPAuthenticationTest.java | 474 ++++++
.../apache/james/jmap/JmapAuthentication.java | 55 +
.../org/apache/james/jmap/UserCredentials.java | 66 +
.../integration/GetMailboxesMethodTest.java | 421 ++++++
.../integration/GetMessageListMethodTest.java | 511 +++++++
.../integration/GetMessagesMethodTest.java | 334 +++++
.../integration/SetMessagesMethodTest.java | 1367 +++++++++++++++++
.../memory-jmap-integration-testing/pom.xml | 221 +++
.../memory/MemoryGetMailboxesMethodTest.java | 44 +
.../memory/MemoryGetMessageListMethodTest.java | 48 +
.../memory/MemoryGetMessagesMethodTest.java | 48 +
.../memory/MemoryJmapAuthenticationTest.java | 46 +
.../memory/MemorySetMessagesMethodTest.java | 47 +
.../jmap/servers/MemoryJmapServerModule.java | 43 +
.../src/test/resources/dnsservice.xml | 29 +
.../src/test/resources/imapserver.xml | 54 +
.../src/test/resources/keystore | Bin 0 -> 2245 bytes
.../src/test/resources/lmtpserver.xml | 41 +
.../src/test/resources/mailetcontainer.xml | 103 ++
.../src/test/resources/mailrepositorystore.xml | 31 +
.../src/test/resources/managesieveserver.xml | 65 +
.../src/test/resources/pop3server.xml | 42 +
.../src/test/resources/smtpserver.xml | 105 ++
.../protocols/jmap-integration-testing/pom.xml | 269 ----
.../jmap/CassandraJmapAuthenticationTest.java | 39 -
.../org/apache/james/jmap/ContainerTest.java | 46 -
.../jmap/FixedDateZonedDateTimeProvider.java | 39 -
.../james/jmap/JMAPAuthenticationTest.java | 478 ------
.../apache/james/jmap/JmapAuthentication.java | 55 -
.../java/org/apache/james/jmap/JmapServer.java | 31 -
.../org/apache/james/jmap/UserCredentials.java | 66 -
.../jmap/cassandra/CassandraJmapServer.java | 109 --
.../jmap/methods/GetMailboxesMethodTest.java | 429 ------
.../jmap/methods/GetMessageListMethodTest.java | 516 -------
.../jmap/methods/GetMessagesMethodTest.java | 339 -----
.../jmap/methods/SetMessagesMethodTest.java | 1372 ------------------
.../CassandraGetMailboxesMethodTest.java | 35 -
.../CassandraGetMessageListMethodTest.java | 35 -
.../CassandraGetMessagesMethodTest.java | 35 -
.../CassandraSetMessagesMethodTest.java | 35 -
.../src/test/resources/dnsservice.xml | 29 -
.../test/resources/fakemailrepositorystore.xml | 31 -
.../src/test/resources/imapserver.xml | 54 -
.../src/test/resources/keystore | Bin 2245 -> 0 bytes
.../src/test/resources/lmtpserver.xml | 41 -
.../src/test/resources/mailetcontainer.xml | 103 --
.../src/test/resources/mailrepositorystore.xml | 31 -
.../src/test/resources/pop3server.xml | 42 -
.../src/test/resources/smtpserver.xml | 105 --
.../src/test/resources/test.properties | 6 -
.../src/test/resources/test.xml | 28 -
265 files changed, 12842 insertions(+), 10123 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
index 1814766..a1683c9 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
@@ -20,24 +20,26 @@
package org.apache.james.mailbox.inmemory;
import java.util.List;
+import javax.inject.Inject;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.store.Authenticator;
+import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.StoreMailboxManager;
import com.google.common.collect.Lists;
public class InMemoryMailboxManager extends StoreMailboxManager<InMemoryId> {
- public InMemoryMailboxManager(Authenticator authenticator, MailboxPathLocker locker, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) {
- super(new InMemoryMailboxSessionMapperFactory(), authenticator, locker, aclResolver, groupMembershipResolver);
+ @Inject
+ public InMemoryMailboxManager(MailboxSessionMapperFactory<InMemoryId> mailboxSessionMapperFactory, Authenticator authenticator, MailboxPathLocker locker, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) {
+ super(mailboxSessionMapperFactory, authenticator, locker, aclResolver, groupMembershipResolver);
}
@Override
public List<Capabilities> getSupportedCapabilities() {
return Lists.newArrayList(Capabilities.Basic, Capabilities.Move);
-
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManagerTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManagerTest.java
index f960885..d3c6cf0 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManagerTest.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManagerTest.java
@@ -83,7 +83,8 @@ public class InMemoryMailboxManagerTest extends AbstractMailboxManagerTest {
MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- StoreMailboxManager<InMemoryId> mailboxManager = new InMemoryMailboxManager(new MockAuthenticator(), new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
+ InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
+ StoreMailboxManager<InMemoryId> mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, new MockAuthenticator(), new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
mailboxManager.init();
setMailboxManager(mailboxManager);
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index a1d5104..52fe81d 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
@@ -26,6 +26,7 @@ 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.InMemoryMailboxManager;
+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.manager.IntegrationResources;
@@ -50,7 +51,9 @@ public class InMemoryIntegrationResources implements IntegrationResources {
public MailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver) throws MailboxException {
MockAuthenticator mockAuthenticator = new MockAuthenticator();
mockAuthenticator.addUser(ManagerTestResources.USER, ManagerTestResources.USER_PASS);
+ InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
final StoreMailboxManager<InMemoryId> manager = new InMemoryMailboxManager(
+ mailboxSessionMapperFactory,
mockAuthenticator,
new NoMailboxPathLocker(),
new UnionMailboxACLResolver(),
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreSubscriptionManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreSubscriptionManager.java
index 9fac23a..e611536 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreSubscriptionManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreSubscriptionManager.java
@@ -22,6 +22,8 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import javax.inject.Inject;
+
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.RequestAware;
import org.apache.james.mailbox.SubscriptionManager;
@@ -41,7 +43,8 @@ public class StoreSubscriptionManager implements SubscriptionManager {
private static final int INITIAL_SIZE = 32;
protected SubscriptionMapperFactory mapperFactory;
-
+
+ @Inject
public StoreSubscriptionManager(SubscriptionMapperFactory mapperFactory) {
this.mapperFactory = mapperFactory;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
index 9c3e427..63f20d1 100644
--- a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
+++ b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
@@ -30,6 +30,7 @@ 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.InMemoryMailboxManager;
+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;
@@ -79,7 +80,8 @@ public class InMemoryHostSystem extends JamesImapHostSystem {
MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- mailboxManager = new InMemoryMailboxManager(userManager, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
+ InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
+ mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, userManager, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mailboxManager.getMapperFactory());
InMemoryPerUserMaxQuotaManager perUserMaxQuotaManager = new InMemoryPerUserMaxQuotaManager();
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mpt/impl/smtp/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/pom.xml b/mpt/impl/smtp/cassandra/pom.xml
index e553987..ab2e539 100644
--- a/mpt/impl/smtp/cassandra/pom.xml
+++ b/mpt/impl/smtp/cassandra/pom.xml
@@ -159,6 +159,12 @@
<type>test-jar</type>
</dependency>
<dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
index 6a0203d..317fc71 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/SmtpTestModule.java
@@ -31,6 +31,9 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
import org.apache.james.mailbox.elasticsearch.ClientProvider;
import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.modules.CommonServicesModule;
+import org.apache.james.modules.MailetProcessingModule;
+import org.apache.james.modules.ProtocolsModule;
import org.apache.james.modules.TestFilesystemModule;
import org.apache.james.mpt.api.SmtpHostSystem;
import org.apache.james.mpt.smtp.dns.InMemoryDNSService;
@@ -85,13 +88,17 @@ public class SmtpTestModule extends AbstractModule {
.build());
};
- install(Modules.override(CassandraJamesServerMain.defaultModule)
- .with(Modules.combine(
- new TestFilesystemModule(folder),
+ install(Modules
+ .override(
+ CassandraJamesServerMain.cassandraServerModule,
+ new CommonServicesModule<>(CassandraJamesServerMain.cassandraId),
+ new ProtocolsModule<>(CassandraJamesServerMain.cassandraId),
+ new MailetProcessingModule())
+ .with(new TestFilesystemModule(folder),
cassandra,
dns,
elasticSearch,
- jmap)));
+ jmap));
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml b/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
index 12770b4..c51a7fb 100644
--- a/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
+++ b/mpt/impl/smtp/cassandra/src/test/resources/mailetcontainer.xml
@@ -57,6 +57,9 @@
<name>X-UserIsAuth</name>
<value>true</value>
</mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
<mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
<name>X-WasSigned</name>
<value>true</value>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/mpt/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/pom.xml b/mpt/pom.xml
index 7b63477..afc2fd6 100644
--- a/mpt/pom.xml
+++ b/mpt/pom.xml
@@ -255,6 +255,12 @@
<version>${james.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <version>${james.version}</version>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
<groupId>org.apache.james.protocols</groupId>
<artifactId>protocols-imap</artifactId>
<version>${james-protocols.version}</version>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/README.adoc
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/README.adoc b/server/container/cassandra-guice/README.adoc
deleted file mode 100644
index e3648ff..0000000
--- a/server/container/cassandra-guice/README.adoc
+++ /dev/null
@@ -1,45 +0,0 @@
-= Guice-Cassandra Module How-to
-
-== Building
-
-=== Requirements
-
- * Java 8 SDK
- * Docker
- * Maven
-
-=== Building the artifacts
-
-An usual compilation using maven will produce two artifacts into target directory :
-
- * james-server-cassandra-guice-${version}.jar
- * james-server-cassandra-guice-${version}.lib
-
-== Running
-
-=== Requirements
-
- * Cassandra
- * ElasticSearch 1.5.2
-
-=== James Launch
-
-To run james, you have to create a directory containing required configuration files.
-
-A sample directory (appropriately named sample-directory) is provided with some
-default value you may need to replace.
-
-You also need to generate a keystore with the following command :
-[source]
-----
-$ keytool -genkey -alias james -keyalg RSA -keystore conf/keystore
-----
-
-You need to have a Cassandra and an ElasticSearch instance running.
-
-Once everything is set up, you just have to run the jar with :
-
-[source]
-----
-$ java -Dworking.directory=sample-configuration -jar target/james-server-cassandra-guice-${version}.jar
-----
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/pom.xml b/server/container/cassandra-guice/pom.xml
deleted file mode 100644
index f35d980..0000000
--- a/server/container/cassandra-guice/pom.xml
+++ /dev/null
@@ -1,471 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server</artifactId>
- <version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <artifactId>james-server-cassandra-guice</artifactId>
- <packaging>jar</packaging>
-
- <name>Apache James :: Server :: Cassandra - guice injection</name>
- <description>An advanced email server - Cassandra backend with guice injection</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>disable-build-for-older-jdk</id>
- <activation>
- <jdk>(,1.8)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>default-jar</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>jar</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>test-jar</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-compile</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testCompile</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>default-test</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <executions>
- <execution>
- <id>default-install</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>default-resources</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testResources</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-descriptor</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>build-for-jdk-8</id>
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/${project.build.finalName}.lib</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>default-jar</id>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>${project.build.finalName}.lib/</classpathPrefix>
- <mainClass>org.apache.james.CassandraJamesServerMain</mainClass>
- <useUniqueVersions>false</useUniqueVersions>
- </manifest>
- </archive>
- </configuration>
- </execution>
- <execution>
- <id>test-jar</id>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>apache-james-backends-cassandra</artifactId>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-cassandra</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-cassandra</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-elasticsearch</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-elasticsearch</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-tika</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-tool</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-mailet-standard</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-cli</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-core</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-data-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-data-file</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-data-cassandra</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-data-library</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-dnsservice-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-dnsservice-dnsjava</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-dnsservice-library</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-fetchmail</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-filesystem-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-jmap</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-lifecycle-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-mailbox-adapter</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-mailets</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-mailetcontainer-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-mailetcontainer-camel</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-protocols-imap4</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-protocols-library</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-protocols-library</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-protocols-lmtp</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-protocols-managesieve</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-protocols-pop3</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-protocols-smtp</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-queue-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-queue-activemq</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-queue-file</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-queue-jms</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>james-server-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james.protocols</groupId>
- <artifactId>protocols-imap</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james.protocols</groupId>
- <artifactId>protocols-managesieve</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.inject.extensions</groupId>
- <artifactId>guice-multibindings</artifactId>
- </dependency>
- <dependency>
- <groupId>com.jayway.awaitility</groupId>
- <artifactId>awaitility</artifactId>
- </dependency>
- <dependency>
- <groupId>com.jayway.restassured</groupId>
- <artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.nurkiewicz.asyncretry</groupId>
- <artifactId>asyncretry</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-daemon</groupId>
- <artifactId>commons-daemon</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr-runtime</artifactId>
- <version>3.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <exclusions>
- <exclusion>
- <artifactId>tools</artifactId>
- <groupId>com.sun</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.onami.lifecycle</groupId>
- <artifactId>org.apache.onami.lifecycle.jsr250</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>${assertj-3.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.cassandraunit</groupId>
- <artifactId>cassandra-unit</artifactId>
- <version>${cassandra-unit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.elasticsearch</groupId>
- <artifactId>elasticsearch</artifactId>
- <version>1.5.2</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>disable-animal-sniffer</id>
- <activation>
- <jdk>[1.6,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>check_java_6</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/cassandra.properties
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/cassandra.properties b/server/container/cassandra-guice/sample-configuration/cassandra.properties
deleted file mode 100644
index 1358332..0000000
--- a/server/container/cassandra-guice/sample-configuration/cassandra.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# Configuration file for cassandra mailbox
-
-cassandra.ip=172.17.0.2
-cassandra.port=9042
-cassandra.keyspace=apache_james
-cassandra.replication.factor=1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/dnsservice.xml b/server/container/cassandra-guice/sample-configuration/dnsservice.xml
deleted file mode 100644
index 0978a00..0000000
--- a/server/container/cassandra-guice/sample-configuration/dnsservice.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.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.
- -->
-
-<dnsservice>
- <servers>
- <server>8.8.8.8</server>
- <server>62.210.16.6</server>
- </servers>
- <autodiscover>false</autodiscover>
- <authoritative>false</authoritative>
- <maxcachesize>50000</maxcachesize>
-</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/domainlist.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/domainlist.xml b/server/container/cassandra-guice/sample-configuration/domainlist.xml
deleted file mode 100644
index 8d00118..0000000
--- a/server/container/cassandra-guice/sample-configuration/domainlist.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.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.
- -->
-
-<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
- <domainnames>
- <domainname>james.apache.org</domainname>
- </domainnames>
- <autodetect>true</autodetect>
- <autodetectIP>true</autodetectIP>
- <defaultDomain>localhost</defaultDomain>
-</domainlist>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/elasticsearch.properties
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/elasticsearch.properties b/server/container/cassandra-guice/sample-configuration/elasticsearch.properties
deleted file mode 100644
index 924404c..0000000
--- a/server/container/cassandra-guice/sample-configuration/elasticsearch.properties
+++ /dev/null
@@ -1,26 +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.
-
-# This template file can be used as example for James Server configuration
-# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-# Configuration file for ElasticSearch
-
-elasticsearch.masterHost=172.17.0.1
-elasticsearch.port=9300
-elasticsearch.nb.shards=1
-elasticsearch.nb.replica=0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/imapserver.xml b/server/container/cassandra-guice/sample-configuration/imapserver.xml
deleted file mode 100644
index c03b978..0000000
--- a/server/container/cassandra-guice/sample-configuration/imapserver.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.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.
--->
-
-
-<imapservers>
- <imapserver enabled="true">
- <jmxName>imapserver</jmxName>
- <bind>0.0.0.0:1143</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="true">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
- <imapserver enabled="true">
- <jmxName>imapserver-ssl</jmxName>
- <bind>0.0.0.0:1993</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="true" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- </imapserver>
-</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/jcr-repository.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/jcr-repository.xml b/server/container/cassandra-guice/sample-configuration/jcr-repository.xml
deleted file mode 100644
index c1b998a..0000000
--- a/server/container/cassandra-guice/sample-configuration/jcr-repository.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.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.
--->
-
-<!--
- This template file can be used as example for James Server configuration
- DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
--->
-
-<!-- See http://james.apache.org/server/3/config.html for usage -->
-
-<!DOCTYPE Repository
- PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 2.0//EN"
- "http://jackrabbit.apache.org/dtd/repository-2.0.dtd">
-
-<Repository>
- <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
- <param name="path" value="${rep.home}/repository"/>
- </FileSystem>
- <DataStore class="org.apache.jackrabbit.core.data.FileDataStore"/>
- <Security appName="Jackrabbit">
- <SecurityManager class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager" workspaceName="security">
- </SecurityManager>
- <AccessManager class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
- </AccessManager>
- <LoginModule class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
- <param name="anonymousId" value="anonymous"/>
- <param name="adminId" value="admin"/>
- </LoginModule>
- </Security>
- <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="james"/>
- <Workspace name="${wsp.name}">
- <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
- <param name="path" value="${wsp.home}"/>
- </FileSystem>
- <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
- <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
- <param name="schemaObjectPrefix" value="${wsp.name}_"/>
- </PersistenceManager>
- <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
- <param name="path" value="${wsp.home}/index"/>
- <param name="supportHighlighting" value="true"/>
- </SearchIndex>
- </Workspace>
- <Versioning rootPath="${rep.home}/version">
- <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
- <param name="path" value="${rep.home}/version" />
- </FileSystem>
- <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
- <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
- <param name="schemaObjectPrefix" value="version_"/>
- </PersistenceManager>
- </Versioning>
- <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
- <param name="path" value="${rep.home}/repository/index"/>
- <param name="supportHighlighting" value="true"/>
- </SearchIndex>
-</Repository>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/jmap.properties
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/jmap.properties b/server/container/cassandra-guice/sample-configuration/jmap.properties
deleted file mode 100644
index d785ccd..0000000
--- a/server/container/cassandra-guice/sample-configuration/jmap.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# Configuration file for JMAP
-
-tls.keystoreURL=file://conf/keystore
-tls.secret=james72laBalle
-
-#
-# If you wish to use OAuth authentication, you should provide a valid JWT public key.
-# The following entry specify the link to the URL of the public key file,
-# which should be a PEM format file.
-#
-jwt.publickeypem.url=
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/jmx.properties
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/jmx.properties b/server/container/cassandra-guice/sample-configuration/jmx.properties
deleted file mode 100644
index a1dbdf8..0000000
--- a/server/container/cassandra-guice/sample-configuration/jmx.properties
+++ /dev/null
@@ -1,28 +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.
-#
-
-# This template file can be used as example for James Server configuration
-# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-# This template file can be used as example for James Server configuration
-# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-
-# See http://james.apache.org/server/3/config.html for usage
-
-jmx.address=127.0.0.1
-jmx.port=9999
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/lmtpserver.xml b/server/container/cassandra-guice/sample-configuration/lmtpserver.xml
deleted file mode 100644
index 87a0caa..0000000
--- a/server/container/cassandra-guice/sample-configuration/lmtpserver.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.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.
- -->
-
-<lmtpservers>
-
- <lmtpserver enabled="false">
- <jmxName>lmtpserver</jmxName>
- <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
- <bind>127.0.0.1:1024</bind>
- <connectionBacklog>200</connectionBacklog>
- <connectiontimeout>1200</connectiontimeout>
- <!-- Set the maximum simultaneous incoming connections for this service -->
- <connectionLimit>0</connectionLimit>
- <!-- Set the maximum simultaneous incoming connections per IP for this service -->
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!-- This sets the maximum allowed message size (in kilobytes) for this -->
- <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
- <maxmessagesize>0</maxmessagesize>
- <handlerchain>
- <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </lmtpserver>
-
-</lmtpservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/mailetcontainer.xml b/server/container/cassandra-guice/sample-configuration/mailetcontainer.xml
deleted file mode 100644
index 968b59c..0000000
--- a/server/container/cassandra-guice/sample-configuration/mailetcontainer.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailetcontainer enableJmx="true">
-
- <context>
- <postmaster>postmaster@james.minet.net</postmaster>
- </context>
-
- <spooler>
- <threads>20</threads>
- </spooler>
-
- <processors>
- <processor state="root" enableJmx="true">
- <mailet match="All" class="PostmasterAlias"/>
- <mailet match="RelayLimit=30" class="Null"/>
- <!-- Hook on sievemanager@james.linagora.com
- Mail send to this address will get interpreted with SIEVE Manage -->
- <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
- <processor>sieve-manager-check</processor>
- </mailet>
- <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="All" class="SetMailAttribute">
- <spamChecked>true</spamChecked>
- </mailet>
- <mailet match="SMTPAuthSuccessful" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- <!-- Check for delivery from a known spam server -->
- <!-- This set of matchers/mailets redirect all emails from known -->
- <!-- black holes, open relays, and spam servers to the spam processor -->
- <!-- For this set to function properly, the spam processor must be configured. -->
- <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
- <processor>spam</processor>
- <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
- </mailet>
- <mailet match="All" class="ToProcessor">
- <processor>transport</processor>
- </mailet>
- </processor>
-
- <processor state="error" enableJmx="true">
- <mailet match="All" class="Bounce"/>
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/error/</repositoryPath>
- </mailet>
- </processor>
-
-
- <processor state="transport" enableJmx="true">
- <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
- <name>X-UserIsAuth</name>
- <value>true</value>
- </mailet>
- <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
- <name>X-WasSigned</name>
- <value>true</value>
- </mailet>
- <mailet match="All" class="RecipientRewriteTable" />
- <mailet match="RecipientIsLocal" class="LocalDelivery"/>
- <mailet match="HostIsLocal" class="ToProcessor">
- <processor>local-address-error</processor>
- <notice>550 - Requested action not taken: no such user here</notice>
- </mailet>
- <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
- <outgoingQueue>outgoing</outgoingQueue>
- <delayTime>5000, 100000, 500000</delayTime>
- <maxRetries>25</maxRetries>
- <maxDnsProblemRetries>0</maxDnsProblemRetries>
- <deliveryThreads>10</deliveryThreads>
- <sendpartial>true</sendpartial>
- <bounceProcessor>bounces</bounceProcessor>
- </mailet>
- <mailet match="All" class="ToProcessor">
- <processor>relay-denied</processor>
- </mailet>
- </processor>
-
- <processor state="spam" enableJmx="true">
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/spam/</repositoryPath>
- </mailet>
- </processor>
-
- <processor state="local-address-error" enableJmx="true">
- <mailet match="All" class="Bounce">
- <attachment>none</attachment>
- </mailet>
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/address-error/</repositoryPath>
- </mailet>
- </processor>
-
- <processor state="relay-denied" enableJmx="true">
- <mailet match="All" class="Bounce">
- <attachment>none</attachment>
- </mailet>
- <mailet match="All" class="ToRepository">
- <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
- <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
- </mailet>
- </processor>
-
- <processor state="bounces" enableJmx="true">
- <mailet match="All" class="DSNBounce">
- <passThrough>false</passThrough>
- </mailet>
- </processor>
- </processors>
-
-</mailetcontainer>
-
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/mailrepositorystore.xml b/server/container/cassandra-guice/sample-configuration/mailrepositorystore.xml
deleted file mode 100644
index acca810..0000000
--- a/server/container/cassandra-guice/sample-configuration/mailrepositorystore.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.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.
- -->
-
-<mailrepositorystore>
- <mailrepositories>
- <!-- File based repositories. These repositories store all message data -->
- <!-- in the file system. -->
- <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
- <protocols>
- <protocol>file</protocol>
- </protocols>
- <!-- Set if the messages should be listed sorted. False by default -->
- <config FIFO="false" CACHEKEYS="true"/>
- </mailrepository>
- </mailrepositories>
-</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/pop3server.xml b/server/container/cassandra-guice/sample-configuration/pop3server.xml
deleted file mode 100644
index c57c832..0000000
--- a/server/container/cassandra-guice/sample-configuration/pop3server.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.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.
- -->
-
-
-<pop3servers>
- <pop3server enabled="false">
- <jmxName>pop3server</jmxName>
- <bind>0.0.0.0:1110</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <!-- To create a new keystore execute:
- keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
- -->
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- </tls>
- <connectiontimeout>1200</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <handlerchain>
- <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
- </handlerchain>
- </pop3server>
-</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/recipientrewritetable.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/recipientrewritetable.xml b/server/container/cassandra-guice/sample-configuration/recipientrewritetable.xml
deleted file mode 100644
index 7e7f586..0000000
--- a/server/container/cassandra-guice/sample-configuration/recipientrewritetable.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.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.
- -->
-
-<!-- The default table for storing James' RecipientRewriteTable mappings. -->
-<recipientrewritetable class="org.apache.james.rrt.jpa.JPARecipientRewriteTable">
- <recursiveMapping>true</recursiveMapping>
- <mappingLimit>10</mappingLimit>
- <mapping>some@domain=some</mapping>
-</recipientrewritetable>
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/smtpserver.xml b/server/container/cassandra-guice/sample-configuration/smtpserver.xml
deleted file mode 100644
index c34fcd1..0000000
--- a/server/container/cassandra-guice/sample-configuration/smtpserver.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.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.
- -->
-
-<smtpservers>
- <smtpserver enabled="true">
- <jmxName>smtpserver-global</jmxName>
- <bind>0.0.0.0:1025</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <authRequired>false</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <verifyIdentity>true</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
- <smtpserver enabled="true">
- <jmxName>smtpserver-TLS</jmxName>
- <bind>0.0.0.0:1465</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="true" startTLS="false">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!--
- Authorize only local users
- -->
- <authRequired>true</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <!-- Trust authenticated users -->
- <verifyIdentity>false</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
- <smtpserver enabled="true">
- <jmxName>smtpserver-authenticated</jmxName>
- <bind>0.0.0.0:1587</bind>
- <connectionBacklog>200</connectionBacklog>
- <tls socketTLS="false" startTLS="true">
- <keystore>file://conf/keystore</keystore>
- <secret>james72laBalle</secret>
- <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
- <algorithm>SunX509</algorithm>
- </tls>
- <connectiontimeout>360</connectiontimeout>
- <connectionLimit>0</connectionLimit>
- <connectionLimitPerIP>0</connectionLimitPerIP>
- <!--
- Authorize only local users
- -->
- <authRequired>true</authRequired>
- <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
- <!-- Trust authenticated users -->
- <verifyIdentity>false</verifyIdentity>
- <maxmessagesize>0</maxmessagesize>
- <addressBracketsEnforcement>true</addressBracketsEnforcement>
- <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
- <handlerchain>
- <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
- <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
- </handlerchain>
- </smtpserver>
-</smtpservers>
-
-
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[19/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
Posted by ma...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/sample-configuration/usersrepository.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/sample-configuration/usersrepository.xml b/server/container/cassandra-guice/sample-configuration/usersrepository.xml
deleted file mode 100644
index fc76107..0000000
--- a/server/container/cassandra-guice/sample-configuration/usersrepository.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.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.
- -->
-
-<usersrepository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
- <destination URL="file://users/"/>
- <algorithm>MD5</algorithm>
- <enableVirtualHosting>true</enableVirtualHosting>
- <enableForwarding>true</enableForwarding>
-</usersrepository>
-
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServer.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServer.java b/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServer.java
deleted file mode 100644
index 45f054b..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServer.java
+++ /dev/null
@@ -1,65 +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;
-
-import javax.annotation.PreDestroy;
-
-import org.apache.james.jmap.JMAPServer;
-import org.apache.james.utils.ConfigurationsPerformer;
-import org.apache.james.utils.ExtendedServerProbe;
-import org.apache.james.utils.GuiceServerProbe;
-import org.apache.onami.lifecycle.core.Stager;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Module;
-import com.google.inject.TypeLiteral;
-
-public class CassandraJamesServer {
-
- private final Module serverModule;
- private Stager<PreDestroy> preDestroy;
- private GuiceServerProbe serverProbe;
- private int jmapPort;
-
- public CassandraJamesServer(Module serverModule) {
- this.serverModule = serverModule;
- }
-
- public void start() throws Exception {
- Injector injector = Guice.createInjector(serverModule);
- injector.getInstance(ConfigurationsPerformer.class).initModules();
- preDestroy = injector.getInstance(Key.get(new TypeLiteral<Stager<PreDestroy>>() {}));
- serverProbe = injector.getInstance(GuiceServerProbe.class);
- jmapPort = injector.getInstance(JMAPServer.class).getPort();
- }
-
- public void stop() {
- preDestroy.stage();
- }
-
- public ExtendedServerProbe serverProbe() {
- return serverProbe;
- }
-
- public int getJmapPort() {
- return jmapPort;
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
deleted file mode 100644
index fb1b2e6..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ /dev/null
@@ -1,82 +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;
-
-import org.apache.james.modules.CommonServicesModule;
-import org.apache.james.modules.data.CassandraDomainListModule;
-import org.apache.james.modules.data.CassandraRecipientRewriteTableModule;
-import org.apache.james.modules.data.CassandraUsersRepositoryModule;
-import org.apache.james.modules.mailbox.CassandraMailboxModule;
-import org.apache.james.modules.mailbox.CassandraSessionModule;
-import org.apache.james.modules.mailbox.ElasticSearchMailboxModule;
-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.ActiveMQQueueModule;
-import org.apache.james.modules.server.CamelMailetContainerModule;
-import org.apache.james.modules.server.ConfigurationProviderModule;
-import org.apache.james.modules.server.DNSServiceModule;
-import org.apache.james.modules.server.JMXServerModule;
-import org.apache.james.modules.server.MailStoreRepositoryModule;
-import org.apache.james.modules.server.QuotaModule;
-import org.apache.james.modules.server.SieveModule;
-import org.apache.onami.lifecycle.jsr250.PreDestroyModule;
-
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-public class CassandraJamesServerMain {
-
- public static final Module defaultModule = Modules.combine(
- new CommonServicesModule(),
- new CassandraMailboxModule(),
- new CassandraSessionModule(),
- new ElasticSearchMailboxModule(),
- new CassandraUsersRepositoryModule(),
- new CassandraDomainListModule(),
- new CassandraRecipientRewriteTableModule(),
- new DNSServiceModule(),
- new IMAPServerModule(),
- new ProtocolHandlerModule(),
- new POP3ServerModule(),
- new SMTPServerModule(),
- new LMTPServerModule(),
- new ManageSieveServerModule(),
- new ActiveMQQueueModule(),
- new SieveModule(),
- new MailStoreRepositoryModule(),
- new CamelMailetContainerModule(),
- new QuotaModule(),
- new ConfigurationProviderModule(),
- new JMAPServerModule(),
- new PreDestroyModule());
-
- public static void main(String[] args) throws Exception {
- CassandraJamesServer server = new CassandraJamesServer(Modules.combine(
- defaultModule,
- new JMXServerModule()));
- server.start();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java
deleted file mode 100644
index d2ad4b0..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java
+++ /dev/null
@@ -1,70 +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.jmap;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.james.jmap.api.AccessTokenManager;
-import org.apache.james.jmap.api.ContinuationTokenManager;
-import org.apache.james.jmap.api.access.AccessTokenRepository;
-import org.apache.james.jmap.crypto.AccessTokenManagerImpl;
-import org.apache.james.jmap.crypto.JamesSignatureHandler;
-import org.apache.james.jmap.crypto.SignatureHandler;
-import org.apache.james.jmap.crypto.SignedContinuationTokenManager;
-import org.apache.james.jmap.memory.access.MemoryAccessTokenRepository;
-import org.apache.james.jmap.send.MailFactory;
-import org.apache.james.jmap.send.MailSpool;
-import org.apache.james.jmap.utils.DefaultZonedDateTimeProvider;
-import org.apache.james.jmap.utils.ZonedDateTimeProvider;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.name.Names;
-
-public class JMAPCommonModule extends AbstractModule {
-
- private static final long DEFAULT_TOKEN_EXPIRATION_IN_MS = TimeUnit.MILLISECONDS.convert(15, TimeUnit.MINUTES);
-
- @Override
- protected void configure() {
- bind(SignatureHandler.class).to(JamesSignatureHandler.class);
- bind(ZonedDateTimeProvider.class).to(DefaultZonedDateTimeProvider.class);
- bind(ContinuationTokenManager.class).to(SignedContinuationTokenManager.class);
-
- bindConstant().annotatedWith(Names.named(AccessTokenRepository.TOKEN_EXPIRATION_IN_MS)).to(DEFAULT_TOKEN_EXPIRATION_IN_MS);
- bind(AccessTokenRepository.class).to(MemoryAccessTokenRepository.class);
- bind(AccessTokenManager.class).to(AccessTokenManagerImpl.class);
-
- bind(MailSpool.class).in(Singleton.class);
- bind(MailFactory.class).in(Singleton.class);
- }
-
- @Provides
- public List<AuthenticationStrategy> authStrategies(
- AccessTokenAuthenticationStrategy accessTokenAuthenticationStrategy,
- JWTAuthenticationStrategy jwtAuthenticationStrategy) {
-
- return ImmutableList.of(
- jwtAuthenticationStrategy,
- accessTokenAuthenticationStrategy);
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPModule.java
deleted file mode 100644
index 4a61f45..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPModule.java
+++ /dev/null
@@ -1,120 +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.jmap;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Optional;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.io.FileUtils;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.jmap.methods.RequestHandler;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-
-import com.github.fge.lambdas.Throwing;
-import com.google.common.base.Preconditions;
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class JMAPModule extends AbstractModule {
- private static final int DEFAULT_JMAP_PORT = 80;
-
- @Override
- protected void configure() {
- install(new JMAPCommonModule());
- install(new MethodsModule());
- bind(RequestHandler.class).in(Singleton.class);
- Multibinder<ConfigurationPerformer> preconditions = Multibinder.newSetBinder(binder(), ConfigurationPerformer.class);
- preconditions.addBinding().to(MailetConfigurationPrecondition.class);
- preconditions.addBinding().to(MoveCapabilityPrecondition.class);
- }
-
- @Provides
- @Singleton
- JMAPConfiguration provideConfiguration(FileSystem fileSystem) throws ConfigurationException, IOException{
- PropertiesConfiguration configuration = getConfiguration(fileSystem);
- return JMAPConfiguration.builder()
- .keystore(configuration.getString("tls.keystoreURL"))
- .secret(configuration.getString("tls.secret"))
- .jwtPublicKeyPem(loadPublicKey(fileSystem, Optional.ofNullable(configuration.getString("jwt.publickeypem.url"))))
- .port(configuration.getInt("jmap.port", DEFAULT_JMAP_PORT))
- .build();
- }
-
- private PropertiesConfiguration getConfiguration(FileSystem fileSystem) throws FileNotFoundException, ConfigurationException {
- return new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "jmap.properties"));
- }
-
- private Optional<String> loadPublicKey(FileSystem fileSystem, Optional<String> jwtPublickeyPemUrl) {
- return jwtPublickeyPemUrl.map(Throwing.function(url -> FileUtils.readFileToString(fileSystem.getFile(url))));
- }
-
- @Singleton
- public static class MailetConfigurationPrecondition implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
-
- @Inject
- public MailetConfigurationPrecondition(ConfigurationProvider configurationProvider) {
- this.configurationProvider = configurationProvider;
- }
-
- @Override
- public void initModule() throws Exception {
- Optional<HierarchicalConfiguration> removeMimeHeaderMailet = configurationProvider.getConfiguration("mailetcontainer")
- .configurationAt("processors")
- .configurationsAt("processor")
- .stream()
- .filter(processor -> processor.getString("[@state]").equals("transport"))
- .flatMap(transport -> transport.configurationsAt("mailet").stream())
- .filter(mailet -> mailet.getString("[@class]").equals("RemoveMimeHeader"))
- .filter(mailet -> mailet.getString("[@match]").equals("All"))
- .filter(mailet -> mailet.getProperty("name").equals("bcc"))
- .findAny();
- if (!removeMimeHeaderMailet.isPresent()) {
- throw new ConfigurationException("Missing RemoveMimeHeader in mailets configuration (mailetcontainer -> processors -> transport). Should be configured to remove Bcc header");
- }
- }
- }
-
- @Singleton
- public static class MoveCapabilityPrecondition implements ConfigurationPerformer {
-
- private final MailboxManager mailboxManager;
-
- @Inject
- public MoveCapabilityPrecondition(MailboxManager mailboxManager) {
- this.mailboxManager = mailboxManager;
- }
-
- @Override
- public void initModule() throws Exception {
- Preconditions.checkArgument(mailboxManager.getSupportedCapabilities().contains(MailboxManager.Capabilities.Move),
- "MOVE support in MailboxManager is required by JMAP Module");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/MethodsModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/MethodsModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/MethodsModule.java
deleted file mode 100644
index b5d254a..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/MethodsModule.java
+++ /dev/null
@@ -1,65 +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.jmap;
-
-import org.apache.james.jmap.json.ObjectMapperFactory;
-import org.apache.james.jmap.methods.GetMailboxesMethod;
-import org.apache.james.jmap.methods.GetMessageListMethod;
-import org.apache.james.jmap.methods.GetMessagesMethod;
-import org.apache.james.jmap.methods.JmapRequestParser;
-import org.apache.james.jmap.methods.JmapRequestParserImpl;
-import org.apache.james.jmap.methods.JmapResponseWriter;
-import org.apache.james.jmap.methods.JmapResponseWriterImpl;
-import org.apache.james.jmap.methods.Method;
-import org.apache.james.jmap.methods.SetMessagesCreationProcessor;
-import org.apache.james.jmap.methods.SetMessagesDestructionProcessor;
-import org.apache.james.jmap.methods.SetMessagesMethod;
-import org.apache.james.jmap.methods.SetMessagesProcessor;
-import org.apache.james.jmap.methods.SetMessagesUpdateProcessor;
-import org.apache.james.mailbox.cassandra.CassandraId;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Singleton;
-import com.google.inject.TypeLiteral;
-import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Names;
-
-public class MethodsModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(JmapRequestParser.class).to(JmapRequestParserImpl.class).in(Singleton.class);
- bind(JmapResponseWriter.class).to(JmapResponseWriterImpl.class).in(Singleton.class);
- bind(ObjectMapperFactory.class).in(Singleton.class);
-
- bindConstant().annotatedWith(Names.named(GetMessageListMethod.MAXIMUM_LIMIT)).to(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT);
-
- Multibinder<Method> methods = Multibinder.newSetBinder(binder(), Method.class);
- methods.addBinding().to(new TypeLiteral<GetMailboxesMethod<CassandraId>>(){});
- methods.addBinding().to(new TypeLiteral<GetMessageListMethod<CassandraId>>(){});
- methods.addBinding().to(new TypeLiteral<GetMessagesMethod<CassandraId>>(){});
- methods.addBinding().to(new TypeLiteral<SetMessagesMethod<CassandraId>>(){});
-
- Multibinder<SetMessagesProcessor<CassandraId>> setMessagesProcessors = Multibinder.newSetBinder(binder(), new TypeLiteral<SetMessagesProcessor<CassandraId>>(){});
- setMessagesProcessors.addBinding().to(new TypeLiteral<SetMessagesUpdateProcessor<CassandraId>>(){});
- setMessagesProcessors.addBinding().to(new TypeLiteral<SetMessagesCreationProcessor<CassandraId>>(){});
- setMessagesProcessors.addBinding().to(new TypeLiteral<SetMessagesDestructionProcessor<CassandraId>>(){});
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/CommonServicesModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/CommonServicesModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/CommonServicesModule.java
deleted file mode 100644
index 3802c56..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/CommonServicesModule.java
+++ /dev/null
@@ -1,63 +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.modules;
-
-import java.util.Optional;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.apache.commons.cli.MissingArgumentException;
-import org.apache.james.core.JamesServerResourceLoader;
-import org.apache.james.core.filesystem.FileSystemImpl;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.filesystem.api.JamesDirectoriesProvider;
-import org.apache.james.utils.ConfigurationProvider;
-import org.apache.james.utils.FileConfigurationProvider;
-import org.apache.james.utils.GuiceServerProbe;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-
-public class CommonServicesModule extends AbstractModule {
-
- public static final String CONFIGURATION_PATH = "configurationPath";
-
- @Override
- protected void configure() {
- bind(FileSystem.class).to(FileSystemImpl.class);
- bind(ConfigurationProvider.class).to(FileConfigurationProvider.class);
- bind(GuiceServerProbe.class).in(Singleton.class);
- }
-
- @Provides @Singleton @Named(CONFIGURATION_PATH)
- public String configurationPath() {
- return FileSystem.FILE_PROTOCOL_AND_CONF;
- }
-
- @Provides @Singleton
- public JamesDirectoriesProvider directories() throws MissingArgumentException {
- String rootDirectory = Optional
- .ofNullable(System.getProperty("working.directory"))
- .orElseThrow(() -> new MissingArgumentException("Server needs a working.directory env entry"));
- return new JamesServerResourceLoader(rootDirectory);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
deleted file mode 100644
index 4f815f2..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
+++ /dev/null
@@ -1,65 +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.modules.data;
-
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.domainlist.cassandra.CassandraDomainList;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Scopes;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class CassandraDomainListModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DomainList.class);
-
- @Override
- public void configure() {
- bind(CassandraDomainList.class).in(Scopes.SINGLETON);
- bind(DomainList.class).to(CassandraDomainList.class);
- Multibinder.newSetBinder(binder(), CassandraModule.class).addBinding().to(org.apache.james.domainlist.cassandra.CassandraDomainListModule.class);
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(CassandraDomainListConfigurationPerformer.class);
- }
-
- @Singleton
- public static class CassandraDomainListConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final CassandraDomainList cassandraDomainList;
-
- @Inject
- public CassandraDomainListConfigurationPerformer(ConfigurationProvider configurationProvider, CassandraDomainList cassandraDomainList) {
- this.configurationProvider = configurationProvider;
- this.cassandraDomainList = cassandraDomainList;
- }
-
- @Override
- public void initModule() throws Exception {
- cassandraDomainList.setLog(LOGGER);
- cassandraDomainList.configure(configurationProvider.getConfiguration("domainlist"));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
deleted file mode 100644
index d261a7d..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
+++ /dev/null
@@ -1,68 +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.modules.data;
-
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.rrt.api.RecipientRewriteTable;
-import org.apache.james.rrt.cassandra.CassandraRRTModule;
-import org.apache.james.rrt.cassandra.CassandraRecipientRewriteTable;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Scopes;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class CassandraRecipientRewriteTableModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(RecipientRewriteTable.class);
-
- @Override
- public void configure() {
- bind(CassandraRecipientRewriteTable.class).in(Scopes.SINGLETON);
- bind(RecipientRewriteTable.class).to(CassandraRecipientRewriteTable.class);
- Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
- cassandraDataDefinitions.addBinding().to(CassandraRRTModule.class);
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(CassandraRecipientRewriteTablePerformer.class);
- }
-
- @Singleton
- public static class CassandraRecipientRewriteTablePerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final CassandraRecipientRewriteTable recipientRewriteTable;
-
- @Inject
- public CassandraRecipientRewriteTablePerformer(ConfigurationProvider configurationProvider, CassandraRecipientRewriteTable recipientRewriteTable) {
- this.configurationProvider = configurationProvider;
- this.recipientRewriteTable = recipientRewriteTable;
- }
-
- @Override
- public void initModule() throws Exception {
- recipientRewriteTable.setLog(LOGGER);
- recipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
deleted file mode 100644
index a776626..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
+++ /dev/null
@@ -1,38 +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.modules.data;
-
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.user.api.UsersRepository;
-import org.apache.james.user.cassandra.CassandraUsersRepository;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.multibindings.Multibinder;
-
-public class CassandraUsersRepositoryModule extends AbstractModule {
-
- @Override
- public void configure() {
- bind(UsersRepository.class).to(CassandraUsersRepository.class);
- Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.user.cassandra.CassandraUsersRepositoryModule.class);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
deleted file mode 100644
index 756ac62..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ /dev/null
@@ -1,83 +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.modules.mailbox;
-
-import javax.inject.Singleton;
-
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxPathLocker;
-import org.apache.james.mailbox.SubscriptionManager;
-import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
-import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
-import org.apache.james.mailbox.cassandra.CassandraSubscriptionManager;
-import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
-import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.store.Authenticator;
-import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
-import org.apache.james.mailbox.store.NoMailboxPathLocker;
-import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
-import org.apache.james.mailbox.store.mail.MessageMapperFactory;
-import org.apache.james.mailbox.store.mail.ModSeqProvider;
-import org.apache.james.mailbox.store.mail.UidProvider;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Named;
-
-public class CassandraMailboxModule extends AbstractModule {
-
- public static final String MAILBOXMANAGER_NAME = "mailboxmanager";
-
- @Override
- protected void configure() {
- bind(new TypeLiteral<MessageMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
- bind(new TypeLiteral<MailboxMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
- bind(new TypeLiteral<MailboxSessionMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
- bind(new TypeLiteral<MailboxSessionMapperFactory<? extends MailboxId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
- bind(new TypeLiteral<ModSeqProvider<CassandraId>>(){}).to(new TypeLiteral<CassandraModSeqProvider>(){});
- bind(new TypeLiteral<UidProvider<CassandraId>>(){}).to(new TypeLiteral<CassandraUidProvider>(){});
-
- bind(SubscriptionManager.class).to(CassandraSubscriptionManager.class);
- bind(MailboxSessionMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class);
- bind(MailboxPathLocker.class).to(NoMailboxPathLocker.class);
- bind(Authenticator.class).to(UserRepositoryAuthenticator.class);
- bind(MailboxManager.class).to(CassandraMailboxManager.class);
-
- Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAclModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMessageModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule.class);
- cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule.class);
- }
-
- @Provides @Named(MAILBOXMANAGER_NAME) @Singleton
- public MailboxManager provideMailboxManager(CassandraMailboxManager cassandraMailboxManager) throws MailboxException {
- cassandraMailboxManager.init();
- return cassandraMailboxManager;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
deleted file mode 100644
index f40cf41..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
+++ /dev/null
@@ -1,99 +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.modules.mailbox;
-
-import java.io.FileNotFoundException;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
-import org.apache.james.backends.cassandra.init.ClusterFactory;
-import org.apache.james.backends.cassandra.init.ClusterWithKeyspaceCreatedFactory;
-import org.apache.james.backends.cassandra.init.SessionWithInitializedTablesFactory;
-import org.apache.james.filesystem.api.FileSystem;
-
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.core.exceptions.NoHostAvailableException;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
-
-public class CassandraSessionModule extends AbstractModule {
-
- private static final int DEFAULT_CONNECTION_MAX_RETRIES = 10;
- private static final int DEFAULT_CONNECTION_MIN_DELAY = 5000;
-
- @Override
- protected void configure() {
- bind(ScheduledExecutorService.class).toProvider(ScheduledExecutorServiceProvider.class);
- }
-
- @Provides
- @Singleton
- CassandraModule composeDataDefinitions(Set<CassandraModule> modules) {
- return new CassandraModuleComposite(modules.toArray(new CassandraModule[0]));
- }
-
- @Provides
- @Singleton
- Session provideSession(FileSystem fileSystem, Cluster cluster, CassandraModule cassandraModule)
- throws FileNotFoundException, ConfigurationException{
- PropertiesConfiguration configuration = getConfiguration(fileSystem);
- String keyspace = configuration.getString("cassandra.keyspace");
- return new SessionWithInitializedTablesFactory(cassandraModule).createSession(cluster, keyspace);
- }
-
- @Provides
- @Singleton
- Cluster provideCluster(FileSystem fileSystem, AsyncRetryExecutor executor) throws FileNotFoundException, ConfigurationException, ExecutionException, InterruptedException {
- PropertiesConfiguration configuration = getConfiguration(fileSystem);
-
- return getRetryer(executor, configuration)
- .getWithRetry(ctx -> ClusterWithKeyspaceCreatedFactory.clusterWithInitializedKeyspace(
- ClusterFactory.createClusterForSingleServerWithoutPassWord(
- configuration.getString("cassandra.ip"),
- configuration.getInt("cassandra.port")),
- configuration.getString("cassandra.keyspace"),
- configuration.getInt("cassandra.replication.factor")))
- .get();
- }
-
- private static AsyncRetryExecutor getRetryer(AsyncRetryExecutor executor, PropertiesConfiguration configuration) {
- return executor.retryOn(NoHostAvailableException.class)
- .withProportionalJitter()
- .withMaxRetries(configuration.getInt("cassandra.retryConnection.maxRetries", DEFAULT_CONNECTION_MAX_RETRIES))
- .withMinDelay(configuration.getInt("cassandra.retryConnection.minDelay", DEFAULT_CONNECTION_MIN_DELAY));
- }
-
- @Provides
- private AsyncRetryExecutor provideAsyncRetryExecutor(ScheduledExecutorService scheduler) {
- return new AsyncRetryExecutor(scheduler);
- }
-
- private PropertiesConfiguration getConfiguration(FileSystem fileSystem) throws FileNotFoundException, ConfigurationException {
- return new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "cassandra.properties"));
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
deleted file mode 100644
index 7fc7638..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
+++ /dev/null
@@ -1,81 +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.modules.mailbox;
-
-import java.io.FileNotFoundException;
-import java.util.concurrent.ExecutionException;
-
-import javax.inject.Singleton;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.mailbox.elasticsearch.ClientProvider;
-import org.apache.james.mailbox.elasticsearch.ClientProviderImpl;
-import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
-import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
-import org.apache.james.mailbox.store.extractor.TextExtractor;
-import org.apache.james.mailbox.store.search.MessageSearchIndex;
-import org.apache.james.mailbox.tika.extractor.TikaTextExtractor;
-import org.elasticsearch.client.transport.NoNodeAvailableException;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
-
-public class ElasticSearchMailboxModule extends AbstractModule {
-
- private static final int DEFAULT_CONNECTION_MAX_RETRIES = 7;
- private static final int DEFAULT_CONNECTION_MIN_DELAY = 3000;
-
- @Override
- protected void configure() {
- bind(new TypeLiteral<MessageSearchIndex<CassandraId>>(){}).to(new TypeLiteral<ElasticSearchListeningMessageSearchIndex<CassandraId>>() {});
- bind(TextExtractor.class).to(TikaTextExtractor.class);
- }
-
- @Provides
- @Singleton
- protected ClientProvider provideClientProvider(FileSystem fileSystem, AsyncRetryExecutor executor) throws ConfigurationException, FileNotFoundException, ExecutionException, InterruptedException {
- PropertiesConfiguration propertiesReader = new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "elasticsearch.properties"));
-
- ClientProvider clientProvider = new ClientProviderImpl(propertiesReader.getString("elasticsearch.masterHost"),
- propertiesReader.getInt("elasticsearch.port"));
- getRetryer(executor, propertiesReader)
- .getWithRetry(ctx -> IndexCreationFactory.createIndex(clientProvider,
- propertiesReader.getInt("elasticsearch.nb.shards"),
- propertiesReader.getInt("elasticsearch.nb.replica")))
- .get();
- NodeMappingFactory.applyMapping(clientProvider);
- return clientProvider;
- }
-
- private static AsyncRetryExecutor getRetryer(AsyncRetryExecutor executor, PropertiesConfiguration configuration) {
- return executor
- .withProportionalJitter()
- .retryOn(NoNodeAvailableException.class)
- .withMaxRetries(configuration.getInt("elasticsearch.retryConnection.maxRetries", DEFAULT_CONNECTION_MAX_RETRIES))
- .withMinDelay(configuration.getInt("elasticsearch.retryConnection.minDelay", DEFAULT_CONNECTION_MIN_DELAY));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.java
deleted file mode 100644
index 48fe3f1..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ScheduledExecutorServiceProvider.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.modules.mailbox;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
-import javax.annotation.PreDestroy;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Provider;
-
-@VisibleForTesting
-class ScheduledExecutorServiceProvider implements Provider<ScheduledExecutorService> {
-
- private final ScheduledExecutorService scheduler;
-
- @VisibleForTesting
- ScheduledExecutorServiceProvider() {
- scheduler = Executors.newSingleThreadScheduledExecutor();
- }
-
- @Override
- public ScheduledExecutorService get() {
- return scheduler;
- }
-
- @PreDestroy
- private void stop() {
- scheduler.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
deleted file mode 100644
index 1b9b8ac..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
+++ /dev/null
@@ -1,103 +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.modules.protocols;
-
-import org.apache.james.imap.api.process.ImapProcessor;
-import org.apache.james.imap.decode.ImapDecoder;
-import org.apache.james.imap.encode.ImapEncoder;
-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.imapserver.netty.IMAPServerFactory;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.SubscriptionManager;
-import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.modules.mailbox.CassandraMailboxModule;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Named;
-
-public class IMAPServerModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(IMAPServerModule.class);
-
- @Override
- protected void configure() {
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(IMAPModuleConfigurationPerformer.class);
- }
-
- @Provides
- @Singleton
- ImapProcessor provideImapProcessor(
- @Named(CassandraMailboxModule.MAILBOXMANAGER_NAME)MailboxManager mailboxManager,
- SubscriptionManager subscriptionManager,
- QuotaManager quotaManager,
- QuotaRootResolver quotaRootResolver) {
- return DefaultImapProcessorFactory.createXListSupportingProcessor(
- mailboxManager,
- subscriptionManager,
- null,
- quotaManager,
- quotaRootResolver,
- 120,
- ImmutableSet.of("ACL", "MOVE"));
- }
-
- @Provides
- @Singleton
- ImapDecoder provideImapDecoder() {
- return DefaultImapDecoderFactory.createDecoder();
- }
-
- @Provides
- @Singleton
- ImapEncoder provideImapEncoder() {
- return new DefaultImapEncoderFactory().buildImapEncoder();
- }
-
- @Singleton
- public static class IMAPModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final IMAPServerFactory imapServerFactory;
-
- @Inject
- public IMAPModuleConfigurationPerformer(ConfigurationProvider configurationProvider, IMAPServerFactory imapServerFactory) {
- this.configurationProvider = configurationProvider;
- this.imapServerFactory = imapServerFactory;
- }
-
- @Override
- public void initModule() throws Exception {
- imapServerFactory.setLog(LOGGER);
- imapServerFactory.configure(configurationProvider.getConfiguration("imapserver"));
- imapServerFactory.init();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
deleted file mode 100644
index 69740b1..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
+++ /dev/null
@@ -1,67 +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.modules.protocols;
-
-import org.apache.james.jmap.JMAPModule;
-import org.apache.james.jmap.JMAPServer;
-import org.apache.james.jmap.crypto.JamesSignatureHandler;
-import org.apache.james.utils.ConfigurationPerformer;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-
-import java.security.Security;
-
-public class JMAPServerModule extends AbstractModule {
-
- @Override
- protected void configure() {
- install(new JMAPModule());
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(JMAPModuleConfigurationPerformer.class);
- }
-
- @Singleton
- public static class JMAPModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final JMAPServer server;
- private final JamesSignatureHandler signatureHandler;
-
- @Inject
- public JMAPModuleConfigurationPerformer(JMAPServer server, JamesSignatureHandler signatureHandler) {
- this.server = server;
- this.signatureHandler = signatureHandler;
- }
-
- @Override
- public void initModule() throws Exception {
- signatureHandler.init();
- server.configure(null);
- registerPEMWithSecurityProvider();
- }
-
- private void registerPEMWithSecurityProvider() {
- Security.addProvider(new BouncyCastleProvider());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
deleted file mode 100644
index a7b7c83..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
+++ /dev/null
@@ -1,62 +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.modules.protocols;
-
-import org.apache.james.lmtpserver.netty.LMTPServerFactory;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class LMTPServerModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(LMTPServerModule.class);
-
- @Override
- protected void configure() {
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(LMTPModuleConfigurationPerformer.class);
- }
-
- @Singleton
- public static class LMTPModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final LMTPServerFactory lmtpServerFactory;
-
- @Inject
- public LMTPModuleConfigurationPerformer(ConfigurationProvider configurationProvider, LMTPServerFactory lmtpServerFactory) {
- this.configurationProvider = configurationProvider;
- this.lmtpServerFactory = lmtpServerFactory;
- }
-
- @Override
- public void initModule() throws Exception {
- lmtpServerFactory.setLog(LOGGER);
- lmtpServerFactory.configure(configurationProvider.getConfiguration("lmtpserver"));
- lmtpServerFactory.init();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
deleted file mode 100644
index cb2429e..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
+++ /dev/null
@@ -1,62 +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.modules.protocols;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-import org.apache.james.managesieve.api.commands.CoreCommands;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ManageSieveServerModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveServerModule.class);
-
- @Override
- protected void configure() {
- bind(CoreCommands.class).to(CoreProcessor.class);
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(ManageSieveModuleConfigurationPerformer.class);
- }
-
- @Singleton
- public static class ManageSieveModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final ManageSieveServerFactory manageSieveServerFactory;
-
- @Inject
- public ManageSieveModuleConfigurationPerformer(ConfigurationProvider configurationProvider, ManageSieveServerFactory manageSieveServerFactory) {
- this.configurationProvider = configurationProvider;
- this.manageSieveServerFactory = manageSieveServerFactory;
- }
-
- @Override
- public void initModule() throws Exception {
- manageSieveServerFactory.setLog(LOGGER);
- manageSieveServerFactory.configure(configurationProvider.getConfiguration("managesieveserver"));
- manageSieveServerFactory.init();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
deleted file mode 100644
index 2bbe6a8..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
+++ /dev/null
@@ -1,62 +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.modules.protocols;
-
-import org.apache.james.pop3server.netty.POP3ServerFactory;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class POP3ServerModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(POP3ServerModule.class);
-
- @Override
- protected void configure() {
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(POP3ModuleConfigurationPerformer.class);
- }
-
- @Singleton
- public static class POP3ModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final POP3ServerFactory pop3ServerFactory;
-
- @Inject
- public POP3ModuleConfigurationPerformer(ConfigurationProvider configurationProvider, POP3ServerFactory pop3ServerFactory) {
- this.configurationProvider = configurationProvider;
- this.pop3ServerFactory = pop3ServerFactory;
- }
-
- @Override
- public void initModule() throws Exception {
- pop3ServerFactory.setLog(LOGGER);
- pop3ServerFactory.configure(configurationProvider.getConfiguration("pop3server"));
- pop3ServerFactory.init();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
deleted file mode 100644
index 10d20d2..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
+++ /dev/null
@@ -1,34 +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.modules.protocols;
-
-import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
-import org.apache.james.utils.GuiceProtocolHandlerLoader;
-
-import com.google.inject.AbstractModule;
-
-public class ProtocolHandlerModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(ProtocolHandlerLoader.class).to(GuiceProtocolHandlerLoader.class);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
deleted file mode 100644
index 6275822..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
+++ /dev/null
@@ -1,68 +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.modules.protocols;
-
-import org.apache.james.smtpserver.SendMailHandler;
-import org.apache.james.smtpserver.netty.SMTPServerFactory;
-import org.apache.james.utils.ConfigurationPerformer;
-import org.apache.james.utils.ConfigurationProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.multibindings.Multibinder;
-
-public class SMTPServerModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SMTPServerModule.class);
-
- @Override
- protected void configure() {
- Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(SMTPModuleConfigurationPerformer.class);
- }
-
- @Singleton
- public static class SMTPModuleConfigurationPerformer implements ConfigurationPerformer {
-
- private final ConfigurationProvider configurationProvider;
- private final SMTPServerFactory smtpServerFactory;
- private final SendMailHandler sendMailHandler;
-
- @Inject
- public SMTPModuleConfigurationPerformer(ConfigurationProvider configurationProvider,
- SMTPServerFactory smtpServerFactory,
- SendMailHandler sendMailHandler) {
- this.configurationProvider = configurationProvider;
- this.smtpServerFactory = smtpServerFactory;
- this.sendMailHandler = sendMailHandler;
- }
-
- @Override
- public void initModule() throws Exception {
- smtpServerFactory.setLog(LOGGER);
- smtpServerFactory.configure(configurationProvider.getConfiguration("smtpserver"));
- smtpServerFactory.init();
- sendMailHandler.init(null);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
deleted file mode 100644
index e7602bb..0000000
--- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
+++ /dev/null
@@ -1,60 +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.modules.server;
-
-import javax.jms.ConnectionFactory;
-
-import org.apache.james.jmap.send.PostDequeueDecoratorFactory;
-import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.queue.activemq.ActiveMQMailQueueFactory;
-import org.apache.james.queue.api.MailQueueFactory;
-import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.TypeLiteral;
-
-public class ActiveMQQueueModule extends AbstractModule {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQQueueModule.class);
-
- @Override
- protected void configure() {
- bind(MailQueueItemDecoratorFactory.class).to(new TypeLiteral<PostDequeueDecoratorFactory<CassandraId>>(){}).in(Singleton.class);
- }
-
- @Provides
- @Singleton
- ConnectionFactory provideEmbededActiveMQ(EmbeddedActiveMQ embeddedActiveMQ) {
- return embeddedActiveMQ.getConnectionFactory();
- }
-
- @Provides
- @Singleton
- public MailQueueFactory createActiveMailQueueFactory(ActiveMQMailQueueFactory activeMQMailQueueFactory) {
- activeMQMailQueueFactory.setUseJMX(true);
- activeMQMailQueueFactory.setLog(LOGGER);
- activeMQMailQueueFactory.init();
- return activeMQMailQueueFactory;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org