james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [37/44] james-project git commit: JAMES-2267 Simplify and factorize RemoteDelivery configuration
Date Fri, 05 Jan 2018 03:01:21 GMT
JAMES-2267 Simplify and factorize RemoteDelivery configuration


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

Branch: refs/heads/master
Commit: 21e132665d496a085320624db2d6544a2e7a55cb
Parents: c6532c8
Author: benwa <btellier@linagora.com>
Authored: Thu Dec 21 11:27:30 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Jan 5 09:34:38 2018 +0700

----------------------------------------------------------------------
 .../james/mailets/BounceIntegrationTest.java    | 15 ++--
 .../GatewayRemoteDeliveryIntegrationTest.java   | 81 ++++----------------
 .../james/mailets/SmtpAuthIntegrationTest.java  |  5 +-
 .../configuration/MailetConfiguration.java      | 17 ++++
 .../james/smtp/SmtpAuthorizedAddressesTest.java | 11 +--
 .../transport/mailets/GroupMappingTest.java     | 10 +--
 6 files changed, 40 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/21e13266/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 1e686a7..e5a3cc2 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
@@ -247,17 +247,16 @@ public class BounceIntegrationTest {
             .awaitMessage(awaitOneMinute);
     }
 
-    private MailetContainer generateMailetContainerConfiguration(MailetConfiguration.Builder
redirectionMailetConfiguration) {
+    private MailetContainer.Builder generateMailetContainerConfiguration(MailetConfiguration.Builder
redirectionMailetConfiguration) {
         return MailetContainer.builder()
             .postmaster(POSTMASTER)
             .addProcessor(CommonProcessors.root())
             .addProcessor(CommonProcessors.error())
             .addProcessor(transport())
-            .addProcessor(bounces(redirectionMailetConfiguration))
-            .build();
+            .addProcessor(bounces(redirectionMailetConfiguration));
     }
 
-    private ProcessorConfiguration transport() {
+    private ProcessorConfiguration.Builder transport() {
         // This processor delivers emails to BOUNCE_RECEIVER and POSTMASTER
         // Other recipients will be bouncing
         return ProcessorConfiguration.transport()
@@ -270,13 +269,11 @@ public class BounceIntegrationTest {
                 .matcher(RecipientIs.class)
                 .matcherCondition(POSTMASTER)
                 .mailet(LocalDelivery.class))
-            .addMailet(MailetConfiguration.TO_BOUNCE)
-            .build();
+            .addMailet(MailetConfiguration.TO_BOUNCE);
     }
 
-    public static ProcessorConfiguration bounces(MailetConfiguration.Builder redirectionMailetConfiguration)
{
+    public static ProcessorConfiguration.Builder bounces(MailetConfiguration.Builder redirectionMailetConfiguration)
{
         return ProcessorConfiguration.bounces()
-            .addMailet(redirectionMailetConfiguration)
-            .build();
+            .addMailet(redirectionMailetConfiguration);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21e13266/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 55900f0..b4586d1 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
@@ -40,10 +40,7 @@ import org.apache.james.mailets.configuration.MailetConfiguration;
 import org.apache.james.mailets.configuration.MailetContainer;
 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.matchers.All;
-import org.apache.james.transport.matchers.RecipientIsLocal;
 import org.apache.james.util.docker.Images;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.apache.james.utils.DataProbeImpl;
@@ -211,12 +208,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
         jamesServer = TemporaryJamesServer.builder()
             .withBase(SMTP_AND_IMAP_MODULE)
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
-            .withMailetContainer(MailetContainer.builder()
-                .postmaster("postmaster@" + DEFAULT_DOMAIN)
-                .addProcessor(CommonProcessors.simpleRoot())
-                .addProcessor(CommonProcessors.error())
-                .addProcessor(relayAndLocalDeliveryTransport(gatewayProperty))
-                .addProcessor(CommonProcessors.bounces()))
+            .withMailetContainer(generateMailetContainerConfiguration(gatewayProperty))
             .build(temporaryFolder);
 
         dataProbe = jamesServer.getProbe(DataProbeImpl.class);
@@ -240,21 +232,13 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .withBase(SMTP_AND_IMAP_MODULE)
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
             .withMailetContainer(MailetContainer.builder()
-                .postmaster("postmaster@" + DEFAULT_DOMAIN)
                 .addProcessor(CommonProcessors.simpleRoot())
                 .addProcessor(CommonProcessors.error())
                 .addProcessor(ProcessorConfiguration.transport()
                     .addMailet(MailetConfiguration.BCC_STRIPPER)
                     .addMailet(MailetConfiguration.LOCAL_DELIVERY)
-                    .addMailet(MailetConfiguration.builder()
+                    .addMailet(MailetConfiguration.remoteDeliveryBuilderNoBounces()
                         .matcher(All.class)
-                        .mailet(RemoteDelivery.class)
-                        .addProperty("outgoingQueue", "outgoing")
-                        .addProperty("delayTime", "5000, 100000, 500000")
-                        .addProperty("maxRetries", "2")
-                        .addProperty("maxDnsProblemRetries", "0")
-                        .addProperty("deliveryThreads", "2")
-                        .addProperty("sendpartial", "true")
                         .addProperty("gateway", gatewayProperty)))
                 .addProcessor(CommonProcessors.bounces()))
             .build(temporaryFolder);
@@ -278,7 +262,6 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .withBase(SMTP_ONLY_MODULE)
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
             .withMailetContainer(MailetContainer.builder()
-                .postmaster("postmaster@" + DEFAULT_DOMAIN)
                 .addProcessor(CommonProcessors.simpleRoot())
                 .addProcessor(CommonProcessors.error())
                 .addProcessor(directResolutionTransport())
@@ -302,67 +285,29 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .body("[0].subject", equalTo("test")));
     }
 
-    private MailetContainer generateMailetContainerConfiguration(String gatewayProperty)
{
+    private MailetContainer.Builder generateMailetContainerConfiguration(String gatewayProperty)
{
         return MailetContainer.builder()
-            .postmaster("postmaster@" + DEFAULT_DOMAIN)
             .addProcessor(CommonProcessors.simpleRoot())
             .addProcessor(CommonProcessors.error())
-            .addProcessor(relayOnlyTransport(gatewayProperty))
-            .addProcessor(CommonProcessors.bounces())
-            .build();
+            .addProcessor(relayAndLocalDeliveryTransport(gatewayProperty))
+            .addProcessor(CommonProcessors.bounces());
     }
 
-    private ProcessorConfiguration relayOnlyTransport(String gatewayProperty) {
+    private ProcessorConfiguration.Builder relayAndLocalDeliveryTransport(String gatewayProperty)
{
         return ProcessorConfiguration.transport()
             .addMailet(MailetConfiguration.BCC_STRIPPER)
-            .addMailet(MailetConfiguration.builder()
-                .matcher(All.class)
-                .mailet(RemoteDelivery.class)
-                .addProperty("outgoingQueue", "outgoing")
-                .addProperty("delayTime", "5000, 100000, 500000")
-                .addProperty("maxRetries", "2")
-                .addProperty("maxDnsProblemRetries", "0")
-                .addProperty("deliveryThreads", "2")
-                .addProperty("sendpartial", "true")
-                .addProperty("bounceProcessor", "bounces")
-                .addProperty("gateway", gatewayProperty))
-            .build();
+            .addMailet(MailetConfiguration.LOCAL_DELIVERY)
+            .addMailet(MailetConfiguration.remoteDeliveryBuilder()
+                .addProperty("gateway", gatewayProperty)
+                .matcher(All.class));
     }
 
-    private ProcessorConfiguration relayAndLocalDeliveryTransport(String gatewayProperty)
{
+    private ProcessorConfiguration.Builder directResolutionTransport() {
         return ProcessorConfiguration.transport()
             .addMailet(MailetConfiguration.BCC_STRIPPER)
-            .addMailet(MailetConfiguration.builder()
-                .matcher(RecipientIsLocal.class)
-                .mailet(LocalDelivery.class))
-            .addMailet(MailetConfiguration.builder()
-                .matcher(All.class)
-                .mailet(RemoteDelivery.class)
-                .addProperty("outgoingQueue", "outgoing")
-                .addProperty("delayTime", "5000, 100000, 500000")
-                .addProperty("maxRetries", "2")
-                .addProperty("maxDnsProblemRetries", "0")
-                .addProperty("deliveryThreads", "2")
-                .addProperty("sendpartial", "true")
-                .addProperty("bounceProcessor", "bounces")
-                .addProperty("gateway", gatewayProperty))
-            .build();
+            .addMailet(MailetConfiguration.remoteDeliveryBuilder()
+                .matcher(All.class));
     }
 
-    private ProcessorConfiguration directResolutionTransport() {
-        return ProcessorConfiguration.transport()
-            .addMailet(MailetConfiguration.BCC_STRIPPER)
-            .addMailet(MailetConfiguration.builder()
-                .matcher(All.class)
-                .mailet(RemoteDelivery.class)
-                .addProperty("outgoingQueue", "outgoing")
-                .addProperty("delayTime", "5000, 100000, 500000")
-                .addProperty("maxRetries", "2")
-                .addProperty("maxDnsProblemRetries", "0")
-                .addProperty("deliveryThreads", "2")
-                .addProperty("sendpartial", "true")
-                .addProperty("bounceProcessor", "bounces"))
-            .build();
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/21e13266/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 61faf23..2a57982 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
@@ -89,13 +89,12 @@ public class SmtpAuthIntegrationTest {
         repositoryProbe = jamesServer.getProbe(MailRepositoryProbeImpl.class);
     }
 
-    private ProcessorConfiguration bounces() {
+    private ProcessorConfiguration.Builder bounces() {
         return ProcessorConfiguration.bounces()
             .addMailet(MailetConfiguration.builder()
                 .matcher(All.class)
                 .mailet(ToRepository.class)
-                .addProperty("repositoryPath", DROPPED_MAILS))
-            .build();
+                .addProperty("repositoryPath", DROPPED_MAILS));
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/21e13266/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 17c27d7..b7619c3 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
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.transport.mailets.LocalDelivery;
+import org.apache.james.transport.mailets.RemoteDelivery;
 import org.apache.james.transport.mailets.RemoveMimeHeader;
 import org.apache.james.transport.mailets.ToProcessor;
 import org.apache.james.transport.matchers.All;
@@ -103,6 +104,22 @@ public class MailetConfiguration implements SerializableAsXml {
         .addProperty("processor", ProcessorConfiguration.STATE_BOUNCES)
         .build();
 
+    public static MailetConfiguration.Builder remoteDeliveryBuilder() {
+        return remoteDeliveryBuilderNoBounces()
+            .addProperty("bounceProcessor", ProcessorConfiguration.STATE_BOUNCES);
+    }
+
+    public static MailetConfiguration.Builder remoteDeliveryBuilderNoBounces() {
+        return MailetConfiguration.builder()
+            .mailet(RemoteDelivery.class)
+            .addProperty("outgoingQueue", "outgoing")
+            .addProperty("delayTime", "5000, 100000, 500000")
+            .addProperty("maxRetries", "2")
+            .addProperty("maxDnsProblemRetries", "0")
+            .addProperty("deliveryThreads", "2")
+            .addProperty("sendpartial", "true");
+    }
+
     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/21e13266/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 14f5f4f..4fa53a4 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
@@ -36,7 +36,6 @@ import org.apache.james.mailets.configuration.MailetContainer;
 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.matchers.SMTPIsAuthNetwork;
 import org.apache.james.util.docker.Images;
 import org.apache.james.util.docker.SwarmGenericContainer;
@@ -90,16 +89,8 @@ public class SmtpAuthorizedAddressesTest {
             .addProcessor(ProcessorConfiguration.transport()
                 .addMailet(MailetConfiguration.BCC_STRIPPER)
                 .addMailet(MailetConfiguration.LOCAL_DELIVERY)
-                .addMailet(MailetConfiguration.builder()
+                .addMailet(MailetConfiguration.remoteDeliveryBuilder()
                     .matcher(SMTPIsAuthNetwork.class)
-                    .mailet(RemoteDelivery.class)
-                    .addProperty("outgoingQueue", "outgoing")
-                    .addProperty("delayTime", "5000, 100000, 500000")
-                    .addProperty("maxRetries", "25")
-                    .addProperty("maxDnsProblemRetries", "0")
-                    .addProperty("deliveryThreads", "10")
-                    .addProperty("sendpartial", "true")
-                    .addProperty("bounceProcessor", ProcessorConfiguration.STATE_BOUNCES)
                     .addProperty("gateway", fakeSmtp.getContainerIp()))
                 .addMailet(MailetConfiguration.TO_BOUNCE))
             .addProcessor(CommonProcessors.localAddressError())

http://git-wip-us.apache.org/repos/asf/james-project/blob/21e13266/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 5f51620..6ae78d3 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
@@ -108,16 +108,8 @@ public class GroupMappingTest {
                     .matcher(RecipientIsLocal.class)
                     .mailet(VacationMailet.class))
                 .addMailet(MailetConfiguration.LOCAL_DELIVERY)
-                .addMailet(MailetConfiguration.builder()
+                .addMailet(MailetConfiguration.remoteDeliveryBuilder()
                     .matcher(All.class)
-                    .mailet(RemoteDelivery.class)
-                    .addProperty("outgoingQueue", "outgoing")
-                    .addProperty("delayTime", "5000, 100000, 500000")
-                    .addProperty("maxRetries", "25")
-                    .addProperty("maxDnsProblemRetries", "0")
-                    .addProperty("deliveryThreads", "10")
-                    .addProperty("sendpartial", "true")
-                    .addProperty("bounceProcessor", "bounces")
                     .addProperty("gateway", fakeSmtp.getContainerIp())))
             .build();
 


---------------------------------------------------------------------
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