You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/05/12 01:41:17 UTC

[james-project] 03/05: JAMES-3737 IMAPServerTest: test cumulation upon framing

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

commit ca8417e942fdd7c3f504fe6c729df91d8461e40d
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed May 11 14:12:12 2022 +0700

    JAMES-3737 IMAPServerTest: test cumulation upon framing
    
    Demonstrate that the buffer is not lost
---
 .../james/imapserver/netty/IMAPServerTest.java     | 31 ++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
index ae12a8117c..33a8f60cba 100644
--- a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
+++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
@@ -372,7 +372,7 @@ class IMAPServerTest {
                 "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
                 "MIME-Version: 1.0\r\n" +
                 "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
-                "C:\r\n" +
+                "\r\n" +
                 "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
             clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + msg.length() + "+}\r\n" +
                 msg + "\r\n").getBytes(StandardCharsets.UTF_8)));
@@ -393,13 +393,40 @@ class IMAPServerTest {
                 "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
                 "MIME-Version: 1.0\r\n" +
                 "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
-                "C:\r\n" +
+                "\r\n" +
                 "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
             clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + msg.length() + "+}\r\n" +
                 msg + "\r\nA005 NOOP").getBytes(StandardCharsets.UTF_8)));
 
             assertThat(new String(readBytes(clientConnection), StandardCharsets.US_ASCII)).contains("APPEND completed.");
         }
+
+        @Test
+        void extraDataAfterFirstLineShouldNotBeLost() throws Exception {
+            clientConnection.write(ByteBuffer.wrap(String.format("a0 LOGIN %s %s\r\n", USER.asString(), USER_PASS).getBytes(StandardCharsets.UTF_8)));
+            readBytes(clientConnection);
+
+            String msg = " Mon, 7 Feb 1994 21:52:25 -0800 (PST)\r\n" +
+                "From: Fred Foobar <fo...@Blurdybloop.COM>\r\n" +
+                "Subject: afternoon meeting 2\r\n" +
+                "To: mooch@owatagu.siam.edu\r\n" +
+                "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
+                "MIME-Version: 1.0\r\n" +
+                "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
+                "\r\n" +
+                "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
+            clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + (msg.length() + 4) + "+}\r\nDATE").getBytes(StandardCharsets.UTF_8)));
+
+            Thread.sleep(100); // Forces separate TCP messages
+
+            clientConnection.write(ByteBuffer.wrap((msg).getBytes(StandardCharsets.UTF_8)));
+
+            Thread.sleep(100); // Forces separate TCP messages
+
+            clientConnection.write(ByteBuffer.wrap(("\r\n").getBytes(StandardCharsets.UTF_8)));
+
+            assertThat(new String(readBytes(clientConnection), StandardCharsets.US_ASCII)).contains("APPEND completed.");
+        }
     }
 
     @Nested


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org