Arsnael commented on a change in pull request #910:
URL: https://github.com/apache/james-project/pull/910#discussion_r825566745



##########
File path: 
server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
##########
@@ -995,134 +996,115 @@ void beforeEach() throws Exception {
             memoryIntegrationResources.getMailboxManager()
                 .createMailbox(MailboxPath.inbox(USER), mailboxSession);
             inbox = 
memoryIntegrationResources.getMailboxManager().getMailbox(MailboxPath.inbox(USER),
 mailboxSession);
+
+            clientConnection = SocketChannel.open();
+            clientConnection.connect(new InetSocketAddress(LOCALHOST_IP, 
port));
+            readBytes(clientConnection);
         }
 
         @AfterEach
-        void tearDown() {
+        void tearDown() throws Exception {
             imapServer.destroy();
+            clientConnection.close();

Review comment:
       Shouldn't we close the client connection before destroying the server?

##########
File path: 
server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
##########
@@ -1034,11 +1038,73 @@ void idleShouldBeInterruptible() throws Exception {
             readStringUntil(server, s -> s.contains("+ Idling"));
 
             
server.write(ByteBuffer.wrap(("DONE\r\n").getBytes(StandardCharsets.UTF_8)));
-            assertThat(readStringUntil(server, s -> s.contains("a3 OK IDLE 
completed.")))
-                .isNotNull();
+
+            Awaitility.await().atMost(Duration.ofSeconds(2)).untilAsserted(() 
->
+                assertThat(readStringUntil(server, s -> s.contains("a3 OK IDLE 
completed.")))
+                    .isNotNull());
+        }
+
+        @Test
+        void idleShouldBeInterruptibleWhenBatched() throws Exception {
+            SocketChannel server = SocketChannel.open();
+            server.connect(new InetSocketAddress(LOCALHOST_IP, port));
+            readBytes(server);
+
+            server.write(ByteBuffer.wrap(String.format("a0 LOGIN %s %s\r\n", 
USER.asString(), USER_PASS).getBytes(StandardCharsets.UTF_8)));
+            readBytes(server);
+
+            server.write(ByteBuffer.wrap(("a2 SELECT 
INBOX\r\n").getBytes(StandardCharsets.UTF_8)));
+            readStringUntil(server, s -> s.contains("a2 OK [READ-WRITE] SELECT 
completed."));
+
+            server.write(ByteBuffer.wrap(("a3 
IDLE\r\nDONE\r\n").getBytes(StandardCharsets.UTF_8)));
+
+            Awaitility.await().atMost(Duration.ofSeconds(2)).untilAsserted(() 
->
+                assertThat(readStringUntil(server, s -> s.contains("a3 OK IDLE 
completed.")))
+                    .isNotNull());
         }
 
         @Test
+        void idleShouldResponsesShouldBeOrdered() throws Exception {

Review comment:
       ```suggestion
           void idleResponsesShouldBeOrdered() throws Exception {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to