james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [34/44] james-project git commit: JAMES-2267 Factorize Mailet container configuration a bit further
Date Fri, 05 Jan 2018 02:56:53 GMT
JAMES-2267 Factorize Mailet container configuration a bit further


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5f658784
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5f658784
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5f658784

Branch: refs/heads/improve-mailet-testing-experience-v1
Commit: 5f6587841a6bf64e59974f98a26bdf32b2fef291
Parents: ea8b4de
Author: benwa <btellier@linagora.com>
Authored: Thu Dec 21 10:58:41 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Jan 5 09:33:52 2018 +0700

----------------------------------------------------------------------
 .../james/mailets/BounceIntegrationTest.java     |  6 +-----
 .../GatewayRemoteDeliveryIntegrationTest.java    | 19 ++++---------------
 .../mailets/NetworkMatcherIntegrationTest.java   |  9 +--------
 .../james/mailets/SmtpAuthIntegrationTest.java   | 15 ++-------------
 .../mailets/configuration/CommonProcessors.java  | 18 ++++++++++++++----
 .../configuration/MailetConfiguration.java       | 13 +++++++++++++
 .../james/smtp/SmtpAuthorizedAddressesTest.java  | 13 ++-----------
 .../transport/mailets/GroupMappingTest.java      | 11 +----------
 8 files changed, 38 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/BounceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/BounceIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/BounceIntegrationTest.java
index 6b67274..1e686a7 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/BounceIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/BounceIntegrationTest.java
@@ -41,7 +41,6 @@ import org.apache.james.transport.mailets.NotifyPostmaster;
 import org.apache.james.transport.mailets.NotifySender;
 import org.apache.james.transport.mailets.Redirect;
 import org.apache.james.transport.mailets.Resend;
-import org.apache.james.transport.mailets.ToProcessor;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIs;
 import org.apache.james.utils.DataProbeImpl;
@@ -271,10 +270,7 @@ public class BounceIntegrationTest {
                 .matcher(RecipientIs.class)
                 .matcherCondition(POSTMASTER)
                 .mailet(LocalDelivery.class))
-            .addMailet(MailetConfiguration.builder()
-                .matcher(All.class)
-                .mailet(ToProcessor.class)
-                .addProperty("processor", ProcessorConfiguration.STATE_BOUNCES))
+            .addMailet(MailetConfiguration.TO_BOUNCE)
             .build();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
index 7bfc074..f5d3818 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
@@ -43,7 +43,6 @@ import org.apache.james.mailets.configuration.ProcessorConfiguration;
 import org.apache.james.probe.DataProbe;
 import org.apache.james.transport.mailets.LocalDelivery;
 import org.apache.james.transport.mailets.RemoteDelivery;
-import org.apache.james.transport.mailets.ToProcessor;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIsLocal;
 import org.apache.james.util.docker.Images;
@@ -216,7 +215,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
             .withMailetContainer(MailetContainer.builder()
                 .postmaster("postmaster@" + DEFAULT_DOMAIN)
-                .addProcessor(root())
+                .addProcessor(CommonProcessors.simpleRoot())
                 .addProcessor(CommonProcessors.error())
                 .addProcessor(relayAndLocalDeliveryTransport(gatewayProperty))
                 .addProcessor(CommonProcessors.bounces()))
@@ -247,7 +246,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
             .withMailetContainer(MailetContainer.builder()
                 .postmaster("postmaster@" + DEFAULT_DOMAIN)
-                .addProcessor(root())
+                .addProcessor(CommonProcessors.simpleRoot())
                 .addProcessor(CommonProcessors.error())
                 .addProcessor(ProcessorConfiguration.transport()
                     .addMailet(MailetConfiguration.BCC_STRIPPER)
@@ -289,7 +288,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
             .withMailetContainer(MailetContainer.builder()
                 .postmaster("postmaster@" + DEFAULT_DOMAIN)
-                .addProcessor(root())
+                .addProcessor(CommonProcessors.simpleRoot())
                 .addProcessor(CommonProcessors.error())
                 .addProcessor(directResolutionTransport())
                 .addProcessor(CommonProcessors.bounces()))
@@ -315,23 +314,13 @@ public class GatewayRemoteDeliveryIntegrationTest {
     private MailetContainer generateMailetContainerConfiguration(String gatewayProperty)
{
         return MailetContainer.builder()
             .postmaster("postmaster@" + DEFAULT_DOMAIN)
-            .addProcessor(root())
+            .addProcessor(CommonProcessors.simpleRoot())
             .addProcessor(CommonProcessors.error())
             .addProcessor(relayOnlyTransport(gatewayProperty))
             .addProcessor(CommonProcessors.bounces())
             .build();
     }
 
-    public ProcessorConfiguration root() {
-        // Custom in memory DNS resolution is not possible combined with InSpamerBackList
-        return ProcessorConfiguration.root()
-            .addMailet(MailetConfiguration.builder()
-                .matcher(All.class)
-                .mailet(ToProcessor.class)
-                .addProperty("processor", "transport"))
-            .build();
-    }
-
     private ProcessorConfiguration relayOnlyTransport(String gatewayProperty) {
         return ProcessorConfiguration.transport()
             .addMailet(MailetConfiguration.BCC_STRIPPER)

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/NetworkMatcherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/NetworkMatcherIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/NetworkMatcherIntegrationTest.java
index da7c3d8..f8e41c6 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/NetworkMatcherIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/NetworkMatcherIntegrationTest.java
@@ -66,7 +66,7 @@ public class NetworkMatcherIntegrationTest {
             .withMailetContainer(MailetContainer.builder()
                 .addProcessor(rootProcessor)
                 .addProcessor(CommonProcessors.error())
-                .addProcessor(deliverOnlyTransport()))
+                .addProcessor(CommonProcessors.deliverOnlyTransport()))
             .build(temporaryFolder);
 
         DataProbe dataProbe = temporaryJamesServer.getProbe(DataProbeImpl.class);
@@ -75,13 +75,6 @@ public class NetworkMatcherIntegrationTest {
         return temporaryJamesServer;
     }
 
-    private ProcessorConfiguration deliverOnlyTransport() {
-        return ProcessorConfiguration.transport()
-            .addMailet(MailetConfiguration.BCC_STRIPPER)
-            .addMailet(MailetConfiguration.LOCAL_DELIVERY)
-            .build();
-    }
-
     private MailetConfiguration.Builder toRepository() {
         return MailetConfiguration.builder()
             .matcher(All.class)

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SmtpAuthIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SmtpAuthIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SmtpAuthIntegrationTest.java
index a3b7eae..61faf23 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SmtpAuthIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SmtpAuthIntegrationTest.java
@@ -68,18 +68,14 @@ public class SmtpAuthIntegrationTest {
                 .matcher(SMTPAuthSuccessful.class)
                 .mailet(ToProcessor.class)
                 .addProperty("processor", ProcessorConfiguration.STATE_TRANSPORT))
-            .addMailet(MailetConfiguration.builder()
-                .matcher(All.class)
-                .mailet(ToProcessor.class)
-                .addProperty("processor", ProcessorConfiguration.STATE_BOUNCES))
+            .addMailet(MailetConfiguration.TO_BOUNCE)
             .build();
 
         MailetContainer mailetContainer = MailetContainer.builder()
             .addProcessor(rootProcessor)
             .addProcessor(CommonProcessors.error())
-            .addProcessor(deliverOnlyTransport())
+            .addProcessor(CommonProcessors.deliverOnlyTransport())
             .addProcessor(bounces())
-            .addProcessor(CommonProcessors.sieveManagerCheck())
             .build();
 
         jamesServer = TemporaryJamesServer.builder()
@@ -93,13 +89,6 @@ public class SmtpAuthIntegrationTest {
         repositoryProbe = jamesServer.getProbe(MailRepositoryProbeImpl.class);
     }
 
-    private ProcessorConfiguration deliverOnlyTransport() {
-        return ProcessorConfiguration.transport()
-            .addMailet(MailetConfiguration.BCC_STRIPPER)
-            .addMailet(MailetConfiguration.LOCAL_DELIVERY)
-            .build();
-    }
-
     private ProcessorConfiguration bounces() {
         return ProcessorConfiguration.bounces()
             .addMailet(MailetConfiguration.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/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
index a3f9a4a..35620d3 100644
--- 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
@@ -87,13 +87,16 @@ public class CommonProcessors {
                         .mailet(ToProcessor.class)
                         .addProperty("processor", ProcessorConfiguration.STATE_SPAM)
                         .addProperty("notice", "550 Requested action not taken: rejected
- see http://njabl.org/"))
-                .addMailet(MailetConfiguration.builder()
-                        .matcher(All.class)
-                        .mailet(ToProcessor.class)
-                        .addProperty("processor", ProcessorConfiguration.STATE_TRANSPORT))
+                .addMailet(MailetConfiguration.TO_TRANSPORT)
                 .build();
     }
 
+    public static ProcessorConfiguration simpleRoot() {
+        return ProcessorConfiguration.root()
+            .addMailet(MailetConfiguration.TO_TRANSPORT)
+            .build();
+    }
+
     public static ProcessorConfiguration error() {
         return ProcessorConfiguration.error()
                 .enableJmx(true)
@@ -154,6 +157,13 @@ public class CommonProcessors {
                 .build();
     }
 
+    public static ProcessorConfiguration deliverOnlyTransport() {
+        return ProcessorConfiguration.transport()
+            .addMailet(MailetConfiguration.BCC_STRIPPER)
+            .addMailet(MailetConfiguration.LOCAL_DELIVERY)
+            .build();
+    }
+
     public static ProcessorConfiguration spam() {
         return ProcessorConfiguration.spam()
                 .enableJmx(true)

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/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
index 9241aa4..17c27d7 100644
--- 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
@@ -25,6 +25,7 @@ import java.util.Optional;
 
 import org.apache.james.transport.mailets.LocalDelivery;
 import org.apache.james.transport.mailets.RemoveMimeHeader;
+import org.apache.james.transport.mailets.ToProcessor;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIsLocal;
 import org.apache.mailet.Mailet;
@@ -90,6 +91,18 @@ public class MailetConfiguration implements SerializableAsXml {
         .mailet(LocalDelivery.class)
         .build();
 
+    public static final MailetConfiguration TO_TRANSPORT = MailetConfiguration.builder()
+        .matcher(All.class)
+        .mailet(ToProcessor.class)
+        .addProperty("processor", ProcessorConfiguration.STATE_TRANSPORT)
+        .build();
+
+    public static final MailetConfiguration TO_BOUNCE = MailetConfiguration.builder()
+        .matcher(All.class)
+        .mailet(ToProcessor.class)
+        .addProperty("processor", ProcessorConfiguration.STATE_BOUNCES)
+        .build();
+
     private final Class<? extends Matcher> matcher;
     private final Optional<String> matcherCondition;
     private final Class<? extends Mailet> mailet;

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpAuthorizedAddressesTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpAuthorizedAddressesTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpAuthorizedAddressesTest.java
index 0af382f..14f5f4f 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpAuthorizedAddressesTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpAuthorizedAddressesTest.java
@@ -37,8 +37,6 @@ import org.apache.james.mailets.configuration.ProcessorConfiguration;
 import org.apache.james.mailets.configuration.SmtpConfiguration;
 import org.apache.james.probe.DataProbe;
 import org.apache.james.transport.mailets.RemoteDelivery;
-import org.apache.james.transport.mailets.ToProcessor;
-import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.SMTPIsAuthNetwork;
 import org.apache.james.util.docker.Images;
 import org.apache.james.util.docker.SwarmGenericContainer;
@@ -87,11 +85,7 @@ public class SmtpAuthorizedAddressesTest {
 
     private void createJamesServer(SmtpConfiguration.Builder smtpConfiguration) throws Exception
{
         MailetContainer mailetContainer = MailetContainer.builder()
-            .addProcessor(ProcessorConfiguration.root()
-                .addMailet(MailetConfiguration.builder()
-                    .matcher(All.class)
-                    .mailet(ToProcessor.class)
-                    .addProperty("processor", ProcessorConfiguration.STATE_TRANSPORT)))
+            .addProcessor(CommonProcessors.simpleRoot())
             .addProcessor(CommonProcessors.error())
             .addProcessor(ProcessorConfiguration.transport()
                 .addMailet(MailetConfiguration.BCC_STRIPPER)
@@ -107,10 +101,7 @@ public class SmtpAuthorizedAddressesTest {
                     .addProperty("sendpartial", "true")
                     .addProperty("bounceProcessor", ProcessorConfiguration.STATE_BOUNCES)
                     .addProperty("gateway", fakeSmtp.getContainerIp()))
-                .addMailet(MailetConfiguration.builder()
-                    .matcher(All.class)
-                    .mailet(ToProcessor.class)
-                    .addProperty("processor", ProcessorConfiguration.STATE_BOUNCES)))
+                .addMailet(MailetConfiguration.TO_BOUNCE))
             .addProcessor(CommonProcessors.localAddressError())
             .addProcessor(CommonProcessors.relayDenied())
             .addProcessor(CommonProcessors.bounces())

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f658784/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingTest.java
index bb9880f..9a95c42 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingTest.java
@@ -48,7 +48,6 @@ import org.apache.james.modules.MailboxProbeImpl;
 import org.apache.james.probe.DataProbe;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIsLocal;
-import org.apache.james.transport.matchers.RelayLimit;
 import org.apache.james.util.docker.Images;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.apache.james.utils.DataProbeImpl;
@@ -107,15 +106,7 @@ public class GroupMappingTest {
         inMemoryDNSService.registerRecord("yopmail.com", containerIp, "yopmail.com");
 
         MailetContainer mailetContainer = MailetContainer.builder()
-            .addProcessor(ProcessorConfiguration.root()
-                .addMailet(MailetConfiguration.builder()
-                    .matcher(RelayLimit.class)
-                    .matcherCondition("30")
-                    .mailet(Null.class))
-                .addMailet(MailetConfiguration.builder()
-                    .matcher(All.class)
-                    .mailet(ToProcessor.class)
-                    .addProperty("processor", ProcessorConfiguration.STATE_TRANSPORT)))
+            .addProcessor(CommonProcessors.simpleRoot())
             .addProcessor(CommonProcessors.error())
             .addProcessor(ProcessorConfiguration.transport()
                 .addMailet(MailetConfiguration.BCC_STRIPPER)


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message