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/03/22 02:03:48 UTC

[james-project] 19/25: JAMES-3722 Add a test: enable QRESYNC with a mailbox selected

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 a5356f892f6dadb6e1e6ea3d15293a44a2ac5747
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Mar 8 15:17:36 2022 +0700

    JAMES-3722 Add a test: enable QRESYNC with a mailbox selected
---
 .../james/imapserver/netty/IMAPServerTest.java     | 42 ++++++++++++++++++++--
 1 file changed, 39 insertions(+), 3 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 5c0c424..058884e 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
@@ -39,9 +39,6 @@ import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.function.Predicate;
-import java.util.List;
-import java.util.Properties;
-import java.util.function.Predicate;
 import java.util.stream.IntStream;
 
 import javax.mail.FetchProfile;
@@ -92,6 +89,7 @@ import org.apache.james.server.core.configuration.Configuration;
 import org.apache.james.server.core.filesystem.FileSystemImpl;
 import org.apache.james.util.ClassLoaderUtils;
 import org.apache.james.utils.TestIMAPClient;
+import org.assertj.core.api.SoftAssertions;
 import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
@@ -1739,6 +1737,44 @@ class IMAPServerTest {
                 .hasSize(1);
         }
 
+        @Test
+        void enableQRESYNCShouldReturnHighestModseq() throws Exception {
+            inbox.delete(ImmutableList.of(MessageUid.MIN_VALUE), mailboxSession);
+
+            ModSeq highestModSeq = memoryIntegrationResources.getMailboxManager().getMailbox(MailboxPath.inbox(USER), mailboxSession)
+                .getMetaData(false, mailboxSession, MessageManager.MailboxMetaData.FetchGroup.NO_COUNT)
+                .getHighestModSeq();
+
+            UidValidity uidValidity = memoryIntegrationResources.getMailboxManager()
+                .getMailbox(MailboxPath.inbox(USER), mailboxSession)
+                .getMailboxEntity().getUidValidity();
+
+            inbox.delete(ImmutableList.of(MessageUid.of(10), MessageUid.of(11), MessageUid.of(12),
+                    MessageUid.of(25), MessageUid.of(26),
+                    MessageUid.of(32)), mailboxSession);
+
+            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("I00104 SELECT INBOX\r\n".getBytes(StandardCharsets.UTF_8)));
+            readStringUntil(server, s -> s.contains("I00104 OK [READ-WRITE] SELECT completed."));
+
+            server.write(ByteBuffer.wrap(("a2 ENABLE QRESYNC\r\n").getBytes(StandardCharsets.UTF_8)));
+
+            List<String> replies = readStringUntil(server, s -> s.contains("a2 OK ENABLE completed."));
+            SoftAssertions.assertSoftly(softly -> {
+                softly.assertThat(replies)
+                    .filteredOn(s -> s.contains("* OK [HIGHESTMODSEQ 41] Highest"))
+                    .hasSize(1);
+                softly.assertThat(replies)
+                    .filteredOn(s -> s.contains("* ENABLED QRESYNC"))
+                    .hasSize(1);
+            });
+        }
+
         private void setUpTestingData() {
             IntStream.range(0, 37)
                 .forEach(Throwing.intConsumer(i -> inbox.appendMessage(MessageManager.AppendCommand.builder()

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