This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 71d06b5c2d JAMES-3899 - Fix test case unstable (#1695)
71d06b5c2d is described below
commit 71d06b5c2d4e5cb26a021012657e251adcd801e0
Author: vttran <[email protected]>
AuthorDate: Thu Aug 24 04:39:28 2023 +0700
JAMES-3899 - Fix test case unstable (#1695)
- ImapTestClient got an error "failed. Command not valid in this state."
---
.../WithStorageDirectiveIntegrationTest.java | 42 +++++++++++++++-------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
index e7b28c82bd..39c7060fc6 100644
---
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
+++
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
@@ -26,8 +26,12 @@ import static
org.apache.james.mailets.configuration.Constants.PASSWORD;
import static org.apache.james.mailets.configuration.Constants.RECIPIENT;
import static
org.apache.james.mailets.configuration.Constants.awaitAtMostOneMinute;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.awaitility.Durations.FIVE_HUNDRED_MILLISECONDS;
+import static org.awaitility.Durations.TEN_SECONDS;
import java.io.File;
+import java.io.IOException;
import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetConfiguration;
@@ -38,10 +42,11 @@ import org.apache.james.probe.DataProbe;
import org.apache.james.transport.mailets.WithStorageDirective;
import org.apache.james.transport.matchers.SenderIsLocal;
import org.apache.james.utils.DataProbeImpl;
-import org.apache.james.utils.MailRepositoryProbeImpl;
import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.utils.SpoolerProbe;
import org.apache.james.utils.TestIMAPClient;
+import org.awaitility.Awaitility;
+import org.awaitility.core.ConditionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -56,8 +61,10 @@ class WithStorageDirectiveIntegrationTest {
private TemporaryJamesServer jamesServer;
@AfterEach
- void tearDown() {
+ void tearDown() throws IOException {
jamesServer.shutdown();
+ testIMAPClient.close();
+ messageSender.close();
}
@Test
@@ -116,16 +123,27 @@ class WithStorageDirectiveIntegrationTest {
.sendMessage(FROM, RECIPIENT);
awaitAtMostOneMinute.until(() ->
jamesServer.getProbe(SpoolerProbe.class).processingFinished());
- testIMAPClient.connect(LOCALHOST_IP,
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
- .login(RECIPIENT, PASSWORD)
- .select("target1")
- .awaitMessage(awaitAtMostOneMinute)
- .close();
- testIMAPClient.connect(LOCALHOST_IP,
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
- .login(RECIPIENT, PASSWORD)
- .select("target2")
- .awaitMessage(awaitAtMostOneMinute)
- .close();
+
+ ConditionFactory imapAwait = Awaitility.with()
+ .pollInterval(FIVE_HUNDRED_MILLISECONDS)
+ .await()
+ .atMost(TEN_SECONDS);
+
+ awaitAtMostOneMinute.untilAsserted(() ->
+ assertThatCode(() -> testIMAPClient.connect(LOCALHOST_IP,
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+ .login(RECIPIENT, PASSWORD)
+ .select("target1")
+ .awaitMessage(imapAwait)
+ .close())
+ .doesNotThrowAnyException());
+
+ awaitAtMostOneMinute.untilAsserted(() ->
+ assertThatCode(() -> testIMAPClient.connect(LOCALHOST_IP,
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+ .login(RECIPIENT, PASSWORD)
+ .select("target2")
+ .awaitMessage(imapAwait)
+ .close())
+ .doesNotThrowAnyException());
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]