james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/4] james-project git commit: use untilAsserted instead of until + exception catching
Date Mon, 01 Oct 2018 02:05:28 GMT
Repository: james-project
Updated Branches:
  refs/heads/master e4f13e47f -> 436e8cde4


use untilAsserted instead of until + exception catching


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

Branch: refs/heads/master
Commit: 843a4c2157db69037e7979f6b18045d73d9c32c5
Parents: e4f13e4
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Fri Sep 28 15:54:24 2018 +0200
Committer: Matthieu Baechler <matthieu@apache.org>
Committed: Fri Sep 28 15:54:24 2018 +0200

----------------------------------------------------------------------
 .../org/apache/james/mpt/smtp/ForwardSmtpTest.java |  4 ++--
 ...ectResolutionRemoteDeliveryIntegrationTest.java |  8 ++++----
 .../GatewayRemoteDeliveryIntegrationTest.java      | 15 +++++++--------
 .../james/smtp/SmtpAuthorizedAddressesTest.java    |  4 ++--
 .../transport/mailets/GroupMappingRelayTest.java   |  2 +-
 .../james/jmap/VacationRelayIntegrationTest.java   |  4 ++--
 .../main/java/org/apache/james/utils/FakeSmtp.java | 17 ++++++-----------
 7 files changed, 24 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/843a4c21/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
index d6bffc8..430f3f8 100644
--- a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
+++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/ForwardSmtpTest.java
@@ -78,8 +78,8 @@ public abstract class ForwardSmtpTest {
     public void forwardingAnEmailShouldWork() throws Exception {
         scriptedTest.run("helo");
 
-        calmlyAwait.atMost(ONE_MINUTE).until(() ->
-            fakeSmtp.isReceived(response -> response
+        calmlyAwait.atMost(ONE_MINUTE).untilAsserted(() ->
+            fakeSmtp.assertEmailReceived(response -> response
                 .body("[0].from", equalTo("matthieu@yopmail.com"))
                 .body("[0].subject", equalTo("test"))
                 .body("[0].text", equalTo("content"))));

http://git-wip-us.apache.org/repos/asf/james-project/blob/843a4c21/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
index 88f5617..ef36921 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
@@ -120,7 +120,7 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
-            .until(this::messageIsReceivedByTheSmtpServer);
+            .untilAsserted(this::assertMessageReceivedByTheSmtpServer);
     }
 
     @Test
@@ -149,7 +149,7 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
-            .until(this::messageIsReceivedByTheSmtpServer);
+            .untilAsserted(this::assertMessageReceivedByTheSmtpServer);
     }
 
     @Test
@@ -208,8 +208,8 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
             .awaitMessage(awaitAtMostOneMinute);
     }
 
-    private boolean messageIsReceivedByTheSmtpServer() {
-        return fakeSmtp.isReceived(response -> response
+    private void assertMessageReceivedByTheSmtpServer() {
+        fakeSmtp.assertEmailReceived(response -> response
             .body("", hasSize(1))
             .body("[0].from", equalTo(FROM))
             .body("[0].subject", equalTo("test")));

http://git-wip-us.apache.org/repos/asf/james-project/blob/843a4c21/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 cb43c36..8aa6230 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
@@ -108,7 +108,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
-            .until(this::messageIsReceivedByTheSmtpServer);
+            .untilAsserted(this::assertMessageReceivedByTheSmtpServer);
     }
 
     @Test
@@ -127,7 +127,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
         messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
             .sendMessage(FROM, RECIPIENT);
 
-        awaitAtMostOneMinute.until(this::messageIsReceivedByTheSmtpServer);
+        awaitAtMostOneMinute.untilAsserted(this::assertMessageReceivedByTheSmtpServer);
     }
 
     @Test
@@ -148,7 +148,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
-            .until(this::messageIsReceivedByTheSmtpServer);
+            .untilAsserted(this::assertMessageReceivedByTheSmtpServer);
     }
 
     @Test
@@ -169,7 +169,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
-            .until(this::messageIsReceivedByTheSmtpServer);
+            .untilAsserted(this::assertMessageReceivedByTheSmtpServer);
     }
 
     @Test
@@ -194,8 +194,7 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .login(FROM, PASSWORD)
             .select(IMAPMessageReader.INBOX)
             .awaitMessage(awaitAtMostOneMinute);
-        assertThat(fakeSmtp.isReceived(response -> response.body("", hasSize(0))))
-            .isTrue();
+        fakeSmtp.assertEmailReceived(response -> response.body("", hasSize(0)));
     }
 
     @Test
@@ -250,8 +249,8 @@ public class GatewayRemoteDeliveryIntegrationTest {
             .awaitMessage(awaitAtMostOneMinute);
     }
 
-    private boolean messageIsReceivedByTheSmtpServer() {
-        return fakeSmtp.isReceived(response -> response
+    private void assertMessageReceivedByTheSmtpServer() {
+        fakeSmtp.assertEmailReceived(response -> response
             .body("", hasSize(1))
             .body("[0].from", equalTo(FROM))
             .body("[0].subject", equalTo("test")));

http://git-wip-us.apache.org/repos/asf/james-project/blob/843a4c21/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 dab089b..830e15c 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
@@ -111,7 +111,7 @@ public class SmtpAuthorizedAddressesTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.ONE_HUNDRED_MILLISECONDS)
-            .until(() -> fakeSmtp.isReceived(response -> response
+            .untilAsserted(() -> fakeSmtp.assertEmailReceived(response -> response
                 .body("", hasSize(1))
                 .body("[0].from", equalTo(FROM))
                 .body("[0].subject", equalTo("test"))));
@@ -141,7 +141,7 @@ public class SmtpAuthorizedAddressesTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
-            .until(() -> fakeSmtp.isReceived(response -> response
+            .untilAsserted(() -> fakeSmtp.assertEmailReceived(response -> response
                 .body("", hasSize(1))
                 .body("[0].from", equalTo(FROM))
                 .body("[0].subject", equalTo("test"))));

http://git-wip-us.apache.org/repos/asf/james-project/blob/843a4c21/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingRelayTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingRelayTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingRelayTest.java
index a4de0bb..afac261 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingRelayTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/GroupMappingRelayTest.java
@@ -161,7 +161,7 @@ public class GroupMappingRelayTest {
 
         awaitAtMostOneMinute
             .pollDelay(Duration.ONE_HUNDRED_MILLISECONDS)
-            .until(() -> fakeSmtp.isReceived(response -> response
+            .untilAsserted(() -> fakeSmtp.assertEmailReceived(response -> response
                 .body("[0].from", equalTo(SENDER))
                 .body("[0].to[0]", equalTo(externalMail))
                 .body("[0].text", equalTo(MESSAGE_CONTENT))));

http://git-wip-us.apache.org/repos/asf/james-project/blob/843a4c21/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
index 14e78b9..582a8f5 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationRelayIntegrationTest.java
@@ -115,8 +115,8 @@ public abstract class VacationRelayIntegrationTest {
         smtpClient.sendShortMessageData("content");
 
         calmlyAwait.atMost(1, TimeUnit.MINUTES)
-            .until(() ->
-                fakeSmtp.isReceived(response -> response
+            .untilAsserted(() ->
+                fakeSmtp.assertEmailReceived(response -> response
                     .body("[0].from", equalTo(USER_WITH_DOMAIN))
                     .body("[0].to[0]", equalTo(externalMail))
                     .body("[0].text", equalTo(REASON))));

http://git-wip-us.apache.org/repos/asf/james-project/blob/843a4c21/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java b/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
index 7a3246e..0ae1ccc 100644
--- a/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
+++ b/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
@@ -81,17 +81,12 @@ public class FakeSmtp implements TestRule {
         calmyAwait.until(() -> container.tryConnect(smtpPort));
     }
 
-    public boolean isReceived(Function<ValidatableResponse, ValidatableResponse> expectations)
{
-        try {
-            expectations.apply(
-                given(requestSpecification(), RESPONSE_SPECIFICATION)
-                    .get("/api/email")
-                .then()
-                    .statusCode(200));
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
+    public void assertEmailReceived(Function<ValidatableResponse, ValidatableResponse>
expectations) {
+        expectations.apply(
+            given(requestSpecification(), RESPONSE_SPECIFICATION)
+                .get("/api/email")
+            .then()
+                .statusCode(200));
     }
 
     private RequestSpecification requestSpecification() {


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