james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [36/44] james-project git commit: JAMES-2262 Correct Tests for Groups
Date Fri, 05 Jan 2018 03:01:20 GMT
JAMES-2262 Correct Tests for Groups

Webadmin start was not awaited, leading to failing API calls, and failing tests on my local
computer.


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

Branch: refs/heads/master
Commit: 51c64ca62edc03ea014f0120ea7ce7630a297a83
Parents: 85e48ef
Author: benwa <btellier@linagora.com>
Authored: Fri Dec 22 14:44:11 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Jan 5 09:34:38 2018 +0700

----------------------------------------------------------------------
 .../apache/james/utils/WebAdminGuiceProbe.java  |  4 ++++
 .../RecipientRewriteTableIntegrationTest.java   |  8 ++++----
 .../james/smtp/SmtpAuthorizedAddressesTest.java |  5 ++---
 .../james/smtp/SmtpBracketEnforcementTest.java  |  4 ++--
 .../smtp/SmtpIdentityVerificationTest.java      |  4 ++--
 .../james/smtp/SmtpSizeLimitationTest.java      |  4 ++--
 .../transport/mailets/GroupMappingTest.java     | 20 +++++++++++---------
 .../integration/SetMessagesMethodTest.java      |  1 +
 .../apache/james/utils/IMAPMessageReader.java   |  4 ++++
 .../apache/james/utils/SMTPMessageSender.java   |  4 ++++
 10 files changed, 36 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/utils/WebAdminGuiceProbe.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/utils/WebAdminGuiceProbe.java
b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/utils/WebAdminGuiceProbe.java
index 40cde64..9caa85f 100644
--- a/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/utils/WebAdminGuiceProbe.java
+++ b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/utils/WebAdminGuiceProbe.java
@@ -34,4 +34,8 @@ public class WebAdminGuiceProbe implements GuiceProbe {
     public int getWebAdminPort() {
         return webAdminServer.getPort().get().getValue();
     }
+
+    public void await() {
+        webAdminServer.await();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
index 041e001..d6d1162 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
@@ -103,8 +103,8 @@ public class RecipientRewriteTableIntegrationTest {
 
         imapMessageReader.connect(LOCALHOST_IP, IMAP_PORT)
             .login(RECIPIENT, PASSWORD)
-            .select(IMAPMessageReader.INBOX);
-        awaitOneMinute.until(imapMessageReader::userDoesNotReceiveMessage);
+            .select(IMAPMessageReader.INBOX)
+            .awaitNoMessage(awaitOneMinute);
     }
 
     @Test
@@ -156,8 +156,8 @@ public class RecipientRewriteTableIntegrationTest {
 
         imapMessageReader.connect(LOCALHOST_IP, IMAP_PORT)
             .login(ANY_AT_JAMES, PASSWORD)
-            .select(IMAPMessageReader.INBOX);
-        awaitOneMinute.until(imapMessageReader::userDoesNotReceiveMessage);
+            .select(IMAPMessageReader.INBOX)
+            .awaitNoMessage(awaitOneMinute);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/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 4fa53a4..f4940dd 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
@@ -138,9 +138,8 @@ public class SmtpAuthorizedAddressesTest {
             .withAutorizedAddresses("172.0.0.0/8"));
 
         messageSender.connect(LOCALHOST_IP, SMTP_PORT)
-            .sendMessage(FROM, TO);
-
-        awaitOneMinute.until(messageSender::messageSendingFailed);
+            .sendMessage(FROM, TO)
+            .awaitSentFail(awaitOneMinute);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpBracketEnforcementTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpBracketEnforcementTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpBracketEnforcementTest.java
index ca52508..aeed2bb 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpBracketEnforcementTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpBracketEnforcementTest.java
@@ -102,7 +102,7 @@ public class SmtpBracketEnforcementTest {
 
         messageSender.connect(LOCALHOST_IP, SMTP_PORT)
             .authenticate(USER, PASSWORD)
-            .sendMessageNoBracket(USER, USER);
-        awaitOneMinute.until(messageSender::messageSendingFailed);
+            .sendMessageNoBracket(USER, USER)
+            .awaitSentFail(awaitOneMinute);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
index fdf7f7c..1c652d6 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
@@ -97,8 +97,8 @@ public class SmtpIdentityVerificationTest {
 
         messageSender.connect(LOCALHOST_IP, SMTP_PORT)
             .authenticate(ATTACKER, ATTACKER_PASSWORD)
-            .sendMessage(USER, USER);
-        awaitOneMinute.until(messageSender::messageSendingFailed);
+            .sendMessage(USER, USER)
+            .awaitSentFail(awaitOneMinute);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpSizeLimitationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpSizeLimitationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpSizeLimitationTest.java
index 1509c26..ff8bed4 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpSizeLimitationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpSizeLimitationTest.java
@@ -72,8 +72,8 @@ public class SmtpSizeLimitationTest {
 
         messageSender.connect(LOCALHOST_IP, SMTP_PORT)
             .authenticate(USER, PASSWORD)
-            .sendMessageWithHeaders(USER, USER, Strings.repeat("Long message", 1024));
-            awaitOneMinute.until(messageSender::messageSendingFailed);
+            .sendMessageWithHeaders(USER, USER, Strings.repeat("Long message", 1024))
+            .awaitSentFail(awaitOneMinute);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/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 6ae78d3..fb82b8d 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
@@ -131,8 +131,10 @@ public class GroupMappingTest {
         jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE,
USER_DOMAIN1, "INBOX");
         jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE,
USER_DOMAIN2, "INBOX");
 
+        WebAdminGuiceProbe webAdminGuiceProbe = jamesServer.getProbe(WebAdminGuiceProbe.class);
+        webAdminGuiceProbe.await();
         restApiRequest = RestAssured.given()
-            .port(jamesServer.getProbe(WebAdminGuiceProbe.class).getWebAdminPort());
+            .port(webAdminGuiceProbe.getWebAdminPort());
 
         message = MimeMessageBuilder.mimeMessageBuilder()
             .setSubject("test")
@@ -274,11 +276,11 @@ public class GroupMappingTest {
             .sendMessage( FakeMail.builder()
                 .mimeMessage(message)
                 .sender(SENDER)
-                .recipient(GROUP_ON_DOMAIN2))
+                .recipient(GROUP_ON_DOMAIN1))
             .awaitSent(awaitOneMinute);
 
         imapMessageReader.connect(LOCALHOST_IP, IMAP_PORT)
-            .login(USER_DOMAIN1, PASSWORD)
+            .login(USER_DOMAIN2, PASSWORD)
             .select(IMAPMessageReader.INBOX)
             .awaitMessage(awaitOneMinute);
 
@@ -303,17 +305,17 @@ public class GroupMappingTest {
                 .mimeMessage(message)
                 .sender(SENDER)
                 .recipient(GROUP_ON_DOMAIN1))
-            .awaitSent(awaitOneMinute);
+            .awaitSentFail(awaitOneMinute);
 
         imapMessageReader.connect(LOCALHOST_IP, IMAP_PORT)
             .login(USER_DOMAIN1, PASSWORD)
             .select(IMAPMessageReader.INBOX)
-            .awaitMessage(awaitOneMinute);
+            .awaitNoMessage(awaitOneMinute);
 
         imapMessageReader.connect(LOCALHOST_IP, IMAP_PORT)
             .login(USER_DOMAIN1, PASSWORD)
             .select(IMAPMessageReader.INBOX)
-            .awaitMessage(awaitOneMinute);
+            .awaitNoMessage(awaitOneMinute);
     }
 
     @Test
@@ -350,8 +352,8 @@ public class GroupMappingTest {
 
         imapMessageReader.connect(LOCALHOST_IP, IMAP_PORT)
             .login(USER_DOMAIN1, PASSWORD)
-            .select(IMAPMessageReader.INBOX);
-        awaitOneMinute.until(imapMessageReader::userDoesNotReceiveMessage);
+            .select(IMAPMessageReader.INBOX)
+            .awaitNoMessage(awaitOneMinute);
     }
 
     @Test
@@ -426,7 +428,7 @@ public class GroupMappingTest {
             .awaitSent(awaitOneMinute);
 
         imapMessageReader.connect(LOCALHOST_IP, IMAP_PORT)
-            .login(USER_DOMAIN2, PASSWORD)
+            .login(USER_DOMAIN1, PASSWORD)
             .select(IMAPMessageReader.INBOX)
             .awaitMessage(awaitOneMinute);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index adc161f..af217d6 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -4529,6 +4529,7 @@ public abstract class SetMessagesMethodTest {
 
         try (IMAPMessageReader imapMessageReader = new IMAPMessageReader()
                 .connect(LOCALHOST_IP, IMAP_PORT)
+                .login(USERNAME, PASSWORD)
                 .select(MailboxConstants.INBOX)) {
             assertThat(imapMessageReader.readFirstMessage())
                 .contains("X-MY-MULTIVALUATED-HEADER: first value")

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/testing/src/main/java/org/apache/james/utils/IMAPMessageReader.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/utils/IMAPMessageReader.java b/server/testing/src/main/java/org/apache/james/utils/IMAPMessageReader.java
index 2d27da0..2f16384 100644
--- a/server/testing/src/main/java/org/apache/james/utils/IMAPMessageReader.java
+++ b/server/testing/src/main/java/org/apache/james/utils/IMAPMessageReader.java
@@ -76,6 +76,10 @@ public class IMAPMessageReader extends ExternalResource implements Closeable
{
         conditionFactory.until(this::hasAMessage);
     }
 
+    public void awaitNoMessage(ConditionFactory conditionFactory) throws IOException {
+        conditionFactory.until(this::userDoesNotReceiveMessage);
+    }
+
     public boolean hasAMessageWithFlags(String flags) throws IOException {
         imapClient.fetch("1:1", "ALL");
         String replyString = imapClient.getReplyString();

http://git-wip-us.apache.org/repos/asf/james-project/blob/51c64ca6/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java b/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
index 9370ccd..bb8d982 100644
--- a/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
+++ b/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
@@ -168,6 +168,10 @@ public class SMTPMessageSender extends ExternalResource implements Closeable
{
         conditionFactory.until(this::messageHasBeenSent);
     }
 
+    public void awaitSentFail(ConditionFactory conditionFactory) {
+        conditionFactory.until(this::messageSendingFailed);
+    }
+
     public boolean messageSendingFailed() throws IOException {
         String replyString = smtpClient.getReplyString().trim();
         return replyString.startsWith("4") || replyString.startsWith("5");


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