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 ad...@apache.org on 2016/10/04 17:27:20 UTC
[1/4] james-project git commit: MAILET-135 MailetContext should
provide its logger
Repository: james-project
Updated Branches:
refs/heads/master 2fda86985 -> cd6fe9cbd
MAILET-135 MailetContext should provide its logger
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9a3f49ca
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9a3f49ca
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9a3f49ca
Branch: refs/heads/master
Commit: 9a3f49cab775d0b316a74537dc4725ca33f2040a
Parents: 4044435
Author: Antoine Duprat <ad...@linagora.com>
Authored: Wed Sep 21 14:53:58 2016 +0200
Committer: Antoine Duprat <ad...@apache.org>
Committed: Tue Oct 4 12:45:06 2016 +0200
----------------------------------------------------------------------
mailet/api/pom.xml | 4 ++++
.../api/src/main/java/org/apache/mailet/MailetContext.java | 9 +++++++--
.../java/org/apache/mailet/base/test/FakeMailContext.java | 5 +++++
.../james/mailetcontainer/api/mock/MockMailetContext.java | 6 ++++++
.../james/mailetcontainer/impl/JamesMailetContext.java | 5 +++++
.../james/transport/mailets/RecordingMailContext.java | 5 +++++
.../james/smtpserver/mock/mailet/MockMailContext.java | 6 ++++++
7 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/9a3f49ca/mailet/api/pom.xml
----------------------------------------------------------------------
diff --git a/mailet/api/pom.xml b/mailet/api/pom.xml
index ba1cbea..cb99c9a 100644
--- a/mailet/api/pom.xml
+++ b/mailet/api/pom.xml
@@ -45,6 +45,10 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9a3f49ca/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/main/java/org/apache/mailet/MailetContext.java b/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
index 24cf8cc..d9447a2 100644
--- a/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
+++ b/mailet/api/src/main/java/org/apache/mailet/MailetContext.java
@@ -20,12 +20,15 @@
package org.apache.mailet;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import org.slf4j.Logger;
+
/**
* Defines a set of methods that can be used to interact with the mailet
* container. For example, it can be used to send a new message, to deliver
@@ -367,4 +370,6 @@ public interface MailetContext {
* @since Mailet API v2.5
*/
List<String> dnsLookup(String name, RecordType type) throws TemporaryLookupException, LookupException;
+
+ Logger getLogger();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9a3f49ca/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
index 516dc62..4dc1e62 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMailContext.java
@@ -286,4 +286,9 @@ public class FakeMailContext implements MailetContext {
public List<SentMail> getSentMails() {
return sentMails;
}
+
+ @Override
+ public Logger getLogger() {
+ return logger.orNull();
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9a3f49ca/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
index e01c174..f3edeb9 100644
--- a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
+++ b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
@@ -34,6 +34,7 @@ import org.apache.mailet.LookupException;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
+import org.slf4j.Logger;
@SuppressWarnings("deprecation")
public class MockMailetContext implements MailetContext {
@@ -183,4 +184,9 @@ public class MockMailetContext implements MailetContext {
public void setAttribute(String arg0, Object arg1) {
attributes.put(arg0, arg1);
}
+
+ @Override
+ public Logger getLogger() {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9a3f49ca/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
index 7afe0b5..26f7d9f 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailetContext.java
@@ -484,4 +484,9 @@ public class JamesMailetContext implements MailetContext, LogEnabled, Configurab
throw new ConfigurationException("Unable to access DomainList", e);
}
}
+
+ @Override
+ public Logger getLogger() {
+ return log;
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9a3f49ca/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
index 95e6bec..36d264d 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
@@ -33,6 +33,7 @@ import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
import org.apache.mailet.TemporaryLookupException;
import org.apache.mailet.base.test.FakeMailContext;
+import org.slf4j.Logger;
/**
* @since 15.12.12 12:02
@@ -225,4 +226,8 @@ public class RecordingMailContext implements MailetContext {
return context.dnsLookup(name, type);
}
+ @Override
+ public Logger getLogger() {
+ return context.getLogger();
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9a3f49ca/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
index 618c305..bfeb03c 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/mock/mailet/MockMailContext.java
@@ -31,6 +31,7 @@ import org.apache.mailet.LookupException;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
+import org.slf4j.Logger;
@SuppressWarnings("deprecation")
public class MockMailContext implements MailetContext {
@@ -158,4 +159,9 @@ public class MockMailContext implements MailetContext {
public Iterator<HostAddress> getSMTPHostAddresses(String domainName) {
return null; // trivial implementation
}
+
+ @Override
+ public Logger getLogger() {
+ return null;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[4/4] james-project git commit: MAILET-135 Add a simple test on
sending an email
Posted by ad...@apache.org.
MAILET-135 Add a simple test on sending an email
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/cd6fe9cb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/cd6fe9cb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/cd6fe9cb
Branch: refs/heads/master
Commit: cd6fe9cbd4ce369378e8b450e8e8adf005872997
Parents: 4dd77f9
Author: Antoine Duprat <ad...@linagora.com>
Authored: Wed Sep 21 15:49:15 2016 +0200
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Tue Oct 4 18:41:44 2016 +0200
----------------------------------------------------------------------
.../modules/server/MemoryMailQueueFactory.java | 11 ++-
.../mailets/CommonMailetConfigurationTest.java | 80 +++++++++++++++++++-
.../james/mailets/TemporaryJamesServer.java | 5 ++
.../src/test/resources/logback.xml | 21 +++++
.../src/test/resources/usersrepository.xml | 25 ++++++
5 files changed, 140 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/cd6fe9cb/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
index c1f92b1..eebc896 100644
--- 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
@@ -25,6 +25,7 @@ import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
import org.apache.james.core.MailImpl;
import org.apache.james.queue.api.MailQueue;
@@ -32,6 +33,7 @@ import org.apache.james.queue.api.MailQueueFactory;
import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
import org.apache.mailet.Mail;
+import com.github.fge.lambdas.Throwing;
import com.google.common.base.Objects;
import com.google.inject.Inject;
@@ -78,12 +80,19 @@ public class MemoryMailQueueFactory implements MailQueueFactory {
@Override
public void enQueue(Mail mail) throws MailQueueException {
try {
- mailItems.addFirst(new MemoryMailQueueItem(new MailImpl(mail)));
+ mailItems.addFirst(new MemoryMailQueueItem(cloneMail(mail)));
} catch (MessagingException e) {
throw new MailQueueException("Error while copying mail " + mail.getName(), e);
}
}
+ private Mail cloneMail(Mail mail) throws MessagingException {
+ MailImpl mailImpl = new MailImpl(mail);
+ Optional.ofNullable(mail.getMessage())
+ .ifPresent(Throwing.consumer(message -> mailImpl.setMessage(new MimeMessage(message))));
+ return mailImpl;
+ }
+
@Override
public MailQueueItem deQueue() throws MailQueueException, InterruptedException {
while (true) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/cd6fe9cb/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
index 3d785aa..d8a8cad 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
@@ -19,6 +19,12 @@
package org.apache.james.mailets;
+import java.io.IOException;
+import java.nio.channels.SocketChannel;
+
+import org.apache.commons.net.imap.IMAPClient;
+import org.apache.commons.net.smtp.SMTPClient;
+import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetContainer;
import org.junit.After;
@@ -27,14 +33,24 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import com.google.common.base.Throwables;
+import com.jayway.awaitility.Awaitility;
+import com.jayway.awaitility.Duration;
+import com.jayway.awaitility.core.ConditionFactory;
+
public class CommonMailetConfigurationTest {
private static final String DEFAULT_DOMAIN = "james.org";
+ private static final String LOCALHOST_IP = "127.0.0.1";
+ private static final int IMAP_PORT = 1143;
+ private static final int SMTP_PORT = 1025;
+ private static final String PASSWORD = "secret";
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
private TemporaryJamesServer jamesServer;
+ private ConditionFactory calmlyAwait;
@Before
public void setup() throws Exception {
@@ -52,6 +68,8 @@ public class CommonMailetConfigurationTest {
.build();
jamesServer = new TemporaryJamesServer(temporaryFolder, mailetContainer);
+ Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
+ calmlyAwait = Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
}
@After
@@ -60,6 +78,66 @@ public class CommonMailetConfigurationTest {
}
@Test
- public void startingJamesWithCommonMailetConfigurationShouldWork() {
+ public void startingJamesWithCommonMailetConfigurationShouldWork() throws Exception {
+ }
+
+ @Test
+ public void simpleMailShouldBeSent() throws Exception {
+ jamesServer.getServerProbe().addDomain(DEFAULT_DOMAIN);
+ String from = "user@" + DEFAULT_DOMAIN;
+ jamesServer.getServerProbe().addUser(from, PASSWORD);
+ String recipient = "user2@" + DEFAULT_DOMAIN;
+ jamesServer.getServerProbe().addUser(recipient, PASSWORD);
+ jamesServer.getServerProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipient, "INBOX");
+
+ SMTPClient smtpClient = new SMTPClient();
+ try (SocketChannel socketChannel = SocketChannel.open()) {
+ smtpClient.connect(LOCALHOST_IP, SMTP_PORT);
+ sendMessage(smtpClient, from, recipient);
+
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(() -> messageHasBeenSent(smtpClient));
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(() -> userReceivedMessage(recipient));
+ } finally {
+ smtpClient.disconnect();
+ }
+ }
+
+ private void sendMessage(SMTPClient smtpClient, String from, String recipient) {
+ try {
+ smtpClient.helo(DEFAULT_DOMAIN);
+ smtpClient.setSender(from);
+ smtpClient.rcpt("<" + recipient + ">");
+ smtpClient.sendShortMessageData("subject: test\r\n" +
+ "\r\n" +
+ "content\r\n" +
+ ".\r\n");
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ private boolean messageHasBeenSent(SMTPClient smtpClient) throws IOException {
+ return smtpClient.getReplyString()
+ .contains("250 2.6.0 Message received");
+ }
+
+ private boolean userReceivedMessage(String user) {
+ IMAPClient imapClient = new IMAPClient();
+ try {
+ imapClient.connect(LOCALHOST_IP, IMAP_PORT);
+ imapClient.login(user, PASSWORD);
+ imapClient.select("INBOX");
+ imapClient.fetch("1:1", "ALL");
+ String replyString = imapClient.getReplyString();
+ return replyString.contains("OK FETCH completed");
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ } finally {
+ try {
+ imapClient.close();
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/cd6fe9cb/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
index 265df8b..71cedb1 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
@@ -31,6 +31,7 @@ import org.apache.james.GuiceJamesServer;
import org.apache.james.MemoryJamesServerMain;
import org.apache.james.mailets.configuration.MailetContainer;
import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.utils.ExtendedServerProbe;
import org.junit.rules.TemporaryFolder;
public class TemporaryJamesServer {
@@ -67,4 +68,8 @@ public class TemporaryJamesServer {
public void shutdown() {
jamesServer.stop();
}
+
+ public ExtendedServerProbe getServerProbe() {
+ return jamesServer.serverProbe();
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/cd6fe9cb/server/mailet/integration-testing/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/logback.xml b/server/mailet/integration-testing/src/test/resources/logback.xml
new file mode 100644
index 0000000..52c0153
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/resources/logback.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+ <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
+ <resetJUL>true</resetJUL>
+ </contextListener>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
+ <immediateFlush>false</immediateFlush>
+ </encoder>
+ </appender>
+
+ <root level="WARN">
+ <appender-ref ref="CONSOLE" />
+ </root>
+
+ <logger name="org.apache.james.mailetcontainer.impl.JamesMailetContext" level="DEBUG"/>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/james-project/blob/cd6fe9cb/server/mailet/integration-testing/src/test/resources/usersrepository.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/usersrepository.xml b/server/mailet/integration-testing/src/test/resources/usersrepository.xml
new file mode 100644
index 0000000..85046b3
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/resources/usersrepository.xml
@@ -0,0 +1,25 @@
+<?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">
+ <algorithm>MD5</algorithm>
+ <enableVirtualHosting>true</enableVirtualHosting>
+</usersrepository>
+
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/4] james-project git commit: MAILET-135 Introduce mailet pipeline
testing
Posted by ad...@apache.org.
MAILET-135 Introduce mailet pipeline 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/4044435e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4044435e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4044435e
Branch: refs/heads/master
Commit: 4044435e69a2174058c33c280a6ffe1e838ff88e
Parents: 2fda869
Author: Antoine Duprat <ad...@linagora.com>
Authored: Thu Sep 15 16:49:51 2016 +0200
Committer: Antoine Duprat <ad...@apache.org>
Committed: Tue Oct 4 12:45:06 2016 +0200
----------------------------------------------------------------------
server/mailet/integration-testing/pom.xml | 258 +++++++++++++++++++
.../mailets/CommonMailetConfigurationTest.java | 65 +++++
.../mailets/TemporaryFilesystemModule.java | 95 +++++++
.../james/mailets/TemporaryJamesServer.java | 70 +++++
.../mailets/configuration/CommonProcessors.java | 248 ++++++++++++++++++
.../configuration/MailetConfiguration.java | 99 +++++++
.../mailets/configuration/MailetContainer.java | 104 ++++++++
.../configuration/ProcessorConfiguration.java | 96 +++++++
.../configuration/SerializableAsXml.java | 26 ++
.../src/test/resources/dnsservice.xml | 29 +++
.../src/test/resources/domainlist.xml | 27 ++
.../src/test/resources/imapserver.xml | 54 ++++
.../src/test/resources/keystore | Bin 0 -> 2245 bytes
.../src/test/resources/lmtpserver.xml | 41 +++
.../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/pom.xml | 1 +
19 files changed, 1456 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/pom.xml b/server/mailet/integration-testing/pom.xml
new file mode 100644
index 0000000..8bd8838
--- /dev/null
+++ b/server/mailet/integration-testing/pom.xml
@@ -0,0 +1,258 @@
+<?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-mailets-integration-testing</artifactId>
+ <packaging>bundle</packaging>
+
+ <name>Apache James :: Server :: Mailets 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>org.apache.james</groupId>
+ <artifactId>james-server-data-memory</artifactId>
+ </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-mailetcontainer-camel</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-mailets</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-memory-guice</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.1.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <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>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </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>animal-sniffer-java-8</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <configuration>
+ <signature>
+ <groupId>org.codehaus.mojo.signature</groupId>
+ <artifactId>java18</artifactId>
+ <version>1.0</version>
+ </signature>
+ </configuration>
+ <executions>
+ <execution>
+ <id>check_java_8</id>
+ <phase>test</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
new file mode 100644
index 0000000..3d785aa
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.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.mailets;
+
+import org.apache.james.mailets.configuration.CommonProcessors;
+import org.apache.james.mailets.configuration.MailetContainer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+public class CommonMailetConfigurationTest {
+
+ private static final String DEFAULT_DOMAIN = "james.org";
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private TemporaryJamesServer jamesServer;
+
+ @Before
+ public void setup() throws Exception {
+ MailetContainer mailetContainer = MailetContainer.builder()
+ .postmaster("postmaster@" + DEFAULT_DOMAIN)
+ .threads(5)
+ .addProcessor(CommonProcessors.root())
+ .addProcessor(CommonProcessors.error())
+ .addProcessor(CommonProcessors.transport())
+ .addProcessor(CommonProcessors.spam())
+ .addProcessor(CommonProcessors.localAddressError())
+ .addProcessor(CommonProcessors.relayDenied())
+ .addProcessor(CommonProcessors.bounces())
+ .addProcessor(CommonProcessors.sieveManagerCheck())
+ .build();
+
+ jamesServer = new TemporaryJamesServer(temporaryFolder, mailetContainer);
+ }
+
+ @After
+ public void tearDown() {
+ jamesServer.shutdown();
+ }
+
+ @Test
+ public void startingJamesWithCommonMailetConfigurationShouldWork() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java
new file mode 100644
index 0000000..aeebc0a
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryFilesystemModule.java
@@ -0,0 +1,95 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT 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.mailets;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.function.Supplier;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.james.core.JamesServerResourceLoader;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.filesystem.api.JamesDirectoriesProvider;
+import org.apache.james.modules.CommonServicesModule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.name.Names;
+
+public class TemporaryFilesystemModule extends AbstractModule {
+
+ private static final List<String> CONFIGURATION_FILE_NAMES = ImmutableList.of("dnsservice.xml",
+ "domainlist.xml",
+ "imapserver.xml",
+ "keystore",
+ "lmtpserver.xml",
+ "mailrepositorystore.xml",
+ "managesieveserver.xml",
+ "pop3server.xml",
+ "recipientrewritetable.xml",
+ "smtpserver.xml",
+ "usersrepository.xml");
+
+ private final Supplier<File> workingDirectory;
+
+ private static File rootDir(TemporaryFolder temporaryFolder) {
+ return temporaryFolder.getRoot();
+ }
+
+ public TemporaryFilesystemModule(TemporaryFolder temporaryFolder) {
+ this(() -> TemporaryFilesystemModule.rootDir(temporaryFolder));
+ }
+
+ public TemporaryFilesystemModule(Supplier<File> workingDirectory) {
+ this.workingDirectory = workingDirectory;
+ }
+
+ @Override
+ protected void configure() {
+ try {
+ bind(JamesDirectoriesProvider.class).toInstance(new JamesServerResourceLoader(workingDirectory.get().getAbsolutePath()));
+ copyResources(Paths.get(workingDirectory.get().getAbsolutePath(), "conf"));
+ bindConstant().annotatedWith(Names.named(CommonServicesModule.CONFIGURATION_PATH)).to(FileSystem.FILE_PROTOCOL_AND_CONF);
+ } catch (IOException e) {
+ Throwables.propagate(e);
+ }
+ }
+
+ private void copyResources(Path resourcesFolder) throws FileNotFoundException, IOException {
+ CONFIGURATION_FILE_NAMES.stream()
+ .forEach(resourceName -> copyResource(resourcesFolder, resourceName));
+ }
+
+ private void copyResource(Path resourcesFolder, String resourceName) {
+ try (OutputStream outputStream = new FileOutputStream(resourcesFolder.resolve(resourceName).toFile())){
+ IOUtils.copy(ClassLoader.getSystemClassLoader().getResource(resourceName).openStream(), outputStream);
+ } catch (IOException e) {
+ Throwables.propagate(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
new file mode 100644
index 0000000..265df8b
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.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.mailets;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Paths;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.io.IOUtils;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.mailets.configuration.MailetContainer;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.rules.TemporaryFolder;
+
+public class TemporaryJamesServer {
+
+ private static final String MAILETCONTAINER_CONFIGURATION_FILENAME = "mailetcontainer.xml";
+
+ private static final int LIMIT_TO_3_MESSAGES = 3;
+
+ private final GuiceJamesServer jamesServer;
+
+
+ public TemporaryJamesServer(TemporaryFolder temporaryFolder, MailetContainer mailetContainer) throws Exception {
+ appendMailetConfigurations(temporaryFolder, mailetContainer);
+
+ jamesServer = new GuiceJamesServer()
+ .combineWith(MemoryJamesServerMain.inMemoryServerModule)
+ .overrideWith(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES),
+ new TemporaryFilesystemModule(temporaryFolder));
+
+ jamesServer.start();
+ }
+
+ private void appendMailetConfigurations(TemporaryFolder temporaryFolder, MailetContainer mailetContainer) throws ConfigurationException, IOException {
+ try (OutputStream outputStream = createMailetConfigurationFile(temporaryFolder)) {
+ IOUtils.write(mailetContainer.serializeAsXml(), outputStream);
+ }
+ }
+
+ private FileOutputStream createMailetConfigurationFile(TemporaryFolder temporaryFolder) throws IOException {
+ File configurationFolder = temporaryFolder.newFolder("conf");
+ return new FileOutputStream(Paths.get(configurationFolder.getAbsolutePath(), MAILETCONTAINER_CONFIGURATION_FILENAME).toFile());
+ }
+
+ public void shutdown() {
+ jamesServer.stop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/CommonProcessors.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/CommonProcessors.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/CommonProcessors.java
new file mode 100644
index 0000000..294f01c
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/CommonProcessors.java
@@ -0,0 +1,248 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT 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.mailets.configuration;
+
+public class CommonProcessors {
+
+ public static ProcessorConfiguration root() {
+ return ProcessorConfiguration.builder()
+ .state("root")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("PostmasterAlias")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("RelayLimit=30")
+ .clazz("Null")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("RecipientIs=sievemanager@james.linagora.com")
+ .clazz("ToProcessor")
+ .addProperty("processor", "sieve-manager-check")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("HasMailAttribute=spamChecked")
+ .clazz("ToProcessor")
+ .addProperty("processor", "transport")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("SetMailAttribute")
+ .addProperty("spamChecked", "true")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("SMTPAuthSuccessful")
+ .clazz("ToProcessor")
+ .addProperty("processor", "transport")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("InSpammerBlacklist=query.bondedsender.org.")
+ .clazz("ToProcessor")
+ .addProperty("processor", "transport")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("InSpammerBlacklist=dnsbl.njabl.org.")
+ .clazz("ToProcessor")
+ .addProperty("processor", "spam")
+ .addProperty("notice", "550 Requested action not taken: rejected - see http://njabl.org/")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("ToProcessor")
+ .addProperty("processor", "transport")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration error() {
+ return ProcessorConfiguration.builder()
+ .state("error")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("Bounce")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("ToRepository")
+ .addProperty("repositoryPath", "file://var/mail/error/")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration transport() {
+ return ProcessorConfiguration.builder()
+ .state("transport")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("SMTPAuthSuccessful")
+ .clazz("SetMimeHeader")
+ .addProperty("name", "X-UserIsAuth")
+ .addProperty("value", "true")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("HasMailAttribute=org.apache.james.SMIMECheckSignature")
+ .clazz("SetMimeHeader")
+ .addProperty("name", "X-WasSigned")
+ .addProperty("value", "true")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("RemoveMimeHeader")
+ .addProperty("name", "bcc")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("RecipientRewriteTable")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("RecipientIsLocal")
+ .clazz("org.apache.james.jmap.mailet.VacationMailet")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("RecipientIsLocal")
+ .clazz("LocalDelivery")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("SMTPAuthSuccessful")
+ .clazz("RemoteDelivery")
+ .addProperty("outgoingQueue", "outgoing")
+ .addProperty("delayTime", "5000, 100000, 500000")
+ .addProperty("maxRetries", "25")
+ .addProperty("maxDnsProblemRetries", "0")
+ .addProperty("deliveryThreads", "10")
+ .addProperty("sendpartial", "true")
+ .addProperty("bounceProcessor", "bounces")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("ToProcessor")
+ .addProperty("processor", "relay-denied")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration spam() {
+ return ProcessorConfiguration.builder()
+ .state("spam")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("ToRepository")
+ .addProperty("repositoryPath", "file://var/mail/spam/")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration localAddressError() {
+ return ProcessorConfiguration.builder()
+ .state("local-address-error")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("Bounce")
+ .addProperty("attachment", "none")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("ToRepository")
+ .addProperty("repositoryPath", "file://var/mail/address-error/")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration relayDenied() {
+ return ProcessorConfiguration.builder()
+ .state("replay-denied")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("Bounce")
+ .addProperty("attachment", "none")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("ToRepository")
+ .addProperty("repositoryPath", "file://var/mail/relay-denied/")
+ .addProperty("notice", "Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration bounces() {
+ return ProcessorConfiguration.builder()
+ .state("bounces")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("DSNBounce")
+ .addProperty("passThrough", "false")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration sieveManagerCheck() {
+ return ProcessorConfiguration.builder()
+ .state("sieve-manager-check")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("RecipientIsLocal")
+ .clazz("ToProcessor")
+ .addProperty("processor", "sieve-manager")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("Bounce")
+ .addProperty("inline", "heads")
+ .addProperty("attachment", "none")
+ .addProperty("passThrough", "false")
+ .addProperty("prefix", "[REJECTED]")
+ .addProperty("notice", "You can't send messages to configure SIEVE on this serveur unless you are the official SIEVE manager.")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("Null")
+ .build())
+ .build();
+ }
+
+ public static ProcessorConfiguration sieveManager() {
+ return ProcessorConfiguration.builder()
+ .state("sieve-manager")
+ .enableJmx(true)
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("SetMailAttribute")
+ .addProperty("org.apache.james.SMTPAuthUser", "true")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("org.apache.james.transport.mailets.managesieve.ManageSieveMailet")
+ .addProperty("helpURL", "file:/root/james-server-app-3.0.0-beta5-SNAPSHOT/conf/managesieve.help.txt")
+ .build())
+ .addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("Null")
+ .build())
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetConfiguration.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetConfiguration.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetConfiguration.java
new file mode 100644
index 0000000..f841bfb
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetConfiguration.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.mailets.configuration;
+
+import java.util.Map;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+
+public class MailetConfiguration implements SerializableAsXml {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private String match;
+ private String clazz;
+ private ImmutableMap.Builder<String, String> properties;
+
+ private Builder() {
+ properties = ImmutableMap.builder();
+ }
+
+ public Builder match(String match) {
+ this.match = match;
+ return this;
+ }
+
+ public Builder clazz(String clazz) {
+ this.clazz = clazz;
+ return this;
+ }
+
+ public Builder addProperty(String key, String value) {
+ this.properties.put(key, value);
+ return this;
+ }
+
+ public MailetConfiguration build() {
+ Preconditions.checkState(!Strings.isNullOrEmpty(match), "'match' is mandatory");
+ Preconditions.checkState(!Strings.isNullOrEmpty(clazz), "'class' is mandatory");
+ return new MailetConfiguration(match, clazz, properties.build());
+ }
+ }
+
+ private final String match;
+ private final String clazz;
+ private final Map<String, String> properties;
+
+ private MailetConfiguration(String match, String clazz, ImmutableMap<String, String> properties) {
+ this.match = match;
+ this.clazz = clazz;
+ this.properties = properties;
+ }
+
+ public String getMatch() {
+ return match;
+ }
+
+ public String getClazz() {
+ return clazz;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public String serializeAsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<mailet match=\"").append(getMatch()).append("\" class=\"").append(getClazz()).append("\">\n");
+ for (Map.Entry<String, String> entry : getProperties().entrySet()) {
+ builder.append("<").append(entry.getKey()).append(">").append(entry.getValue()).append("</").append(entry.getKey()).append(">\n");
+ }
+ builder.append("</mailet>\n");
+ return builder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetContainer.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetContainer.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetContainer.java
new file mode 100644
index 0000000..ae71091
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/MailetContainer.java
@@ -0,0 +1,104 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT 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.mailets.configuration;
+
+import java.util.List;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+
+public class MailetContainer implements SerializableAsXml {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private String postmaster;
+ private int threads;
+ private ImmutableList.Builder<ProcessorConfiguration> processors;
+
+ private Builder() {
+ processors = ImmutableList.builder();
+ }
+
+ public Builder postmaster(String postmaster) {
+ this.postmaster = postmaster;
+ return this;
+ }
+
+ public Builder threads(int threads) {
+ this.threads = threads;
+ return this;
+ }
+
+ public Builder addProcessor(ProcessorConfiguration processorConfiguration) {
+ this.processors.add(processorConfiguration);
+ return this;
+ }
+
+ public MailetContainer build() {
+ Preconditions.checkState(!Strings.isNullOrEmpty(postmaster), "'postmaster' is mandatory");
+ Preconditions.checkState(threads > 0, "'threads' should be greater than 0");
+ return new MailetContainer(postmaster, threads, processors.build());
+ }
+ }
+
+ private final String postmaster;
+ private final int threads;
+ private final List<ProcessorConfiguration> processors;
+
+ private MailetContainer(String postmaster, int threads, List<ProcessorConfiguration> processors) {
+ this.postmaster = postmaster;
+ this.threads = threads;
+ this.processors = processors;
+ }
+
+ public String getPostmaster() {
+ return postmaster;
+ }
+
+ public int getThreads() {
+ return threads;
+ }
+
+ public List<ProcessorConfiguration> getProcessors() {
+ return processors;
+ }
+
+ @Override
+ public String serializeAsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<?xml version=\"1.0\"?>\n")
+ .append("<mailetcontainer enableJmx=\"true\">\n")
+ .append("<context><postmaster>").append(getPostmaster()).append("</postmaster>").append("</context>\n")
+ .append("<spooler><threads>").append(getThreads()).append("</threads>").append("</spooler>\n")
+ .append("<processors>\n");
+ for (ProcessorConfiguration processorConfiguration : getProcessors()) {
+ builder.append(processorConfiguration.serializeAsXml());
+ }
+ builder.append("</processors>\n")
+ .append("</mailetcontainer>");
+ return builder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/ProcessorConfiguration.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/ProcessorConfiguration.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/ProcessorConfiguration.java
new file mode 100644
index 0000000..00128f1
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/ProcessorConfiguration.java
@@ -0,0 +1,96 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT 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.mailets.configuration;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+
+public class ProcessorConfiguration implements SerializableAsXml {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private String state;
+ private boolean enableJmx;
+ private ImmutableList.Builder<MailetConfiguration> mailets;
+
+ private Builder() {
+ mailets = ImmutableList.builder();
+ }
+
+ public Builder state(String state) {
+ this.state = state;
+ return this;
+ }
+
+ public Builder enableJmx(boolean enableJmx) {
+ this.enableJmx = enableJmx;
+ return this;
+ }
+
+ public Builder addMailet(MailetConfiguration mailetConfiguration) {
+ this.mailets.add(mailetConfiguration);
+ return this;
+ }
+
+ public ProcessorConfiguration build() {
+ Preconditions.checkState(!Strings.isNullOrEmpty(state), "'state' is mandatory");
+ return new ProcessorConfiguration(state, enableJmx, mailets.build());
+ }
+ }
+
+ private final String state;
+ private final boolean enableJmx;
+ private final ImmutableList<MailetConfiguration> mailets;
+
+ private ProcessorConfiguration(String state, boolean enableJmx, ImmutableList<MailetConfiguration> mailets) {
+ this.state = state;
+ this.enableJmx = enableJmx;
+ this.mailets = mailets;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public boolean isEnableJmx() {
+ return enableJmx;
+ }
+
+ public ImmutableList<MailetConfiguration> getMailets() {
+ return mailets;
+ }
+
+ @Override
+ public String serializeAsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<processor state=\"").append(getState()).append("\" enableJmx=\"").append(isEnableJmx() ? "true" : "false").append("\">\n");
+ for (MailetConfiguration mailet : getMailets()) {
+ builder.append(mailet.serializeAsXml());
+ }
+ builder.append("</processor>\n");
+ return builder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/SerializableAsXml.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/SerializableAsXml.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/SerializableAsXml.java
new file mode 100644
index 0000000..fcc9248
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/configuration/SerializableAsXml.java
@@ -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. *
+ ****************************************************************/
+
+
+package org.apache.james.mailets.configuration;
+
+public interface SerializableAsXml {
+
+ String serializeAsXml();
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/dnsservice.xml b/server/mailet/integration-testing/src/test/resources/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/mailet/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/4044435e/server/mailet/integration-testing/src/test/resources/domainlist.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/domainlist.xml b/server/mailet/integration-testing/src/test/resources/domainlist.xml
new file mode 100644
index 0000000..e2797bb
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/resources/domainlist.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.
+ -->
+
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
+ <autodetect>true</autodetect>
+ <autodetectIP>true</autodetectIP>
+ <defaultDomain>localhost</defaultDomain>
+</domainlist>
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/imapserver.xml b/server/mailet/integration-testing/src/test/resources/imapserver.xml
new file mode 100644
index 0000000..ff478a9
--- /dev/null
+++ b/server/mailet/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/4044435e/server/mailet/integration-testing/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/keystore b/server/mailet/integration-testing/src/test/resources/keystore
new file mode 100644
index 0000000..536a6c7
Binary files /dev/null and b/server/mailet/integration-testing/src/test/resources/keystore differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/4044435e/server/mailet/integration-testing/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/lmtpserver.xml b/server/mailet/integration-testing/src/test/resources/lmtpserver.xml
new file mode 100644
index 0000000..5c4a9c7
--- /dev/null
+++ b/server/mailet/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/4044435e/server/mailet/integration-testing/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/mailrepositorystore.xml b/server/mailet/integration-testing/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/mailet/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/4044435e/server/mailet/integration-testing/src/test/resources/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/managesieveserver.xml b/server/mailet/integration-testing/src/test/resources/managesieveserver.xml
new file mode 100644
index 0000000..ec57e09
--- /dev/null
+++ b/server/mailet/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/4044435e/server/mailet/integration-testing/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/pop3server.xml b/server/mailet/integration-testing/src/test/resources/pop3server.xml
new file mode 100644
index 0000000..e4187da
--- /dev/null
+++ b/server/mailet/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/4044435e/server/mailet/integration-testing/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/smtpserver.xml b/server/mailet/integration-testing/src/test/resources/smtpserver.xml
new file mode 100644
index 0000000..a3d4b8f
--- /dev/null
+++ b/server/mailet/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/4044435e/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index d8d6773..73c42cc 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -72,6 +72,7 @@
<module>mailet/mailetcontainer-api</module>
<module>mailet/mailetcontainer-camel</module>
<module>mailet/mailets</module>
+ <module>mailet/integration-testing</module>
<module>dns-service/dnsservice-api</module>
<module>dns-service/dnsservice-dnsjava</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[3/4] james-project git commit: MAILET-135 Log mailet processing in
debug
Posted by ad...@apache.org.
MAILET-135 Log mailet processing in debug
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4dd77f9e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4dd77f9e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4dd77f9e
Branch: refs/heads/master
Commit: 4dd77f9e2c85da1c08b78ce9eff2d7a7234a2853
Parents: 9a3f49c
Author: Antoine Duprat <ad...@linagora.com>
Authored: Wed Sep 21 14:55:17 2016 +0200
Committer: Antoine Duprat <ad...@apache.org>
Committed: Tue Oct 4 16:05:12 2016 +0200
----------------------------------------------------------------------
mailet/base/pom.xml | 1 -
.../mailet/base/MailetPipelineLogging.java | 68 ++++++++++++++++++++
.../api/mock/MockMailetContext.java | 5 +-
.../impl/camel/CamelProcessor.java | 3 +
4 files changed, 75 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/4dd77f9e/mailet/base/pom.xml
----------------------------------------------------------------------
diff --git a/mailet/base/pom.xml b/mailet/base/pom.xml
index d67639f..867b8c2 100644
--- a/mailet/base/pom.xml
+++ b/mailet/base/pom.xml
@@ -78,7 +78,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <scope>test</scope>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/james-project/blob/4dd77f9e/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java b/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.java
new file mode 100644
index 0000000..e0a9069
--- /dev/null
+++ b/mailet/base/src/main/java/org/apache/mailet/base/MailetPipelineLogging.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.mailet.base;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+import org.apache.mailet.MailetContext;
+import org.slf4j.Logger;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+public class MailetPipelineLogging {
+
+ public static void logBeginOfMailetProcess(final Mailet mailet, final Mail mail) {
+ getLogger(mailet)
+ .transform(new Function<Logger, Boolean>() {
+
+ @Override
+ public Boolean apply(Logger logger) {
+ logger.debug("Entering mailet: {}\n\tmail state {}", mailet.getMailetInfo(), mail.getState());
+ return true;
+ }
+ });
+ }
+
+ public static void logEndOfMailetProcess(final Mailet mailet, final Mail mail) {
+ getLogger(mailet)
+ .transform(new Function<Logger, Boolean>() {
+
+ @Override
+ public Boolean apply(Logger logger) {
+ logger.debug("End of mailet: {}\n\tmail state {}", mailet.getMailetInfo(), mail.getState());
+ return true;
+ }
+ });
+ }
+
+ private static Optional<Logger> getLogger(Mailet mailet) {
+ MailetConfig mailetConfig = mailet.getMailetConfig();
+ if (mailetConfig == null) {
+ return Optional.absent();
+ }
+ MailetContext mailetContext = mailetConfig.getMailetContext();
+ if (mailetContext == null) {
+ return Optional.absent();
+ }
+ return Optional.fromNullable(mailetContext.getLogger());
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4dd77f9e/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
index f3edeb9..e4f8750 100644
--- a/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
+++ b/server/mailet/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
@@ -35,10 +35,13 @@ import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@SuppressWarnings("deprecation")
public class MockMailetContext implements MailetContext {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MockMailetContext.class);
+
private final Map<String, Object> attributes = new HashMap<String, Object>();
private final List<Mail> mails = new ArrayList<Mail>();
@@ -187,6 +190,6 @@ public class MockMailetContext implements MailetContext {
@Override
public Logger getLogger() {
- return null;
+ return LOGGER;
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4dd77f9e/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelProcessor.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelProcessor.java
index 8e47625..fa71705 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelProcessor.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelProcessor.java
@@ -31,6 +31,7 @@ import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.MailetP
import org.apache.mailet.Mail;
import org.apache.mailet.Mailet;
import org.apache.mailet.MailetConfig;
+import org.apache.mailet.base.MailetPipelineLogging;
import org.slf4j.Logger;
/**
@@ -61,6 +62,7 @@ public class CamelProcessor implements Processor {
long start = System.currentTimeMillis();
MessagingException ex = null;
try {
+ MailetPipelineLogging.logBeginOfMailetProcess(mailet, mail);
mailet.service(mail);
} catch (MessagingException me) {
ex = me;
@@ -85,6 +87,7 @@ public class CamelProcessor implements Processor {
}
} finally {
+ MailetPipelineLogging.logEndOfMailetProcess(mailet, mail);
List<MailetProcessorListener> listeners = processor.getListeners();
long complete = System.currentTimeMillis() - start;
for (MailetProcessorListener listener : listeners) {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org