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 2026/06/04 12:35:18 UTC
(james-project) 03/31: [REFACTORING] Split IMAPServerPartialFetchTest
This is an automated email from the ASF dual-hosted git repository.
chibenwa pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 0216785580a70ac2f414ca2228df74a627a75144
Author: Quan Tran <hq...@linagora.com>
AuthorDate: Thu Jun 4 14:13:59 2026 +0700
[REFACTORING] Split IMAPServerPartialFetchTest
---
.../netty/IMAPServerPartialFetchTest.java | 110 +++++++++++++++++++++
.../james/imapserver/netty/IMAPServerTest.java | 81 ---------------
2 files changed, 110 insertions(+), 81 deletions(-)
diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerPartialFetchTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerPartialFetchTest.java
new file mode 100644
index 0000000000..54ba98a84f
--- /dev/null
+++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerPartialFetchTest.java
@@ -0,0 +1,110 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.imapserver.netty;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.imap.processor.fetch.FetchProcessor;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+
+@SuppressWarnings("checkstyle:membername")
+class IMAPServerPartialFetchTest extends AbstractIMAPServerTest {
+ IMAPServer imapServer;
+ private int port;
+
+ @BeforeEach
+ void beforeEach() throws Exception {
+ imapServer = createImapServer("imapServer.xml", FetchProcessor.LocalCacheConfiguration.DEFAULT);
+ port = imapServer.getListenAddresses().get(0).getPort();
+ }
+
+ @AfterEach
+ void tearDown() {
+ imapServer.destroy();
+ }
+
+ @Test
+ void fetchShouldRetrieveMessage() throws Exception {
+ testIMAPClient.connect("127.0.0.1", port)
+ .login(USER.asString(), USER_PASS)
+ .append("INBOX", SMALL_MESSAGE);
+
+ assertThat(testIMAPClient
+ .select("INBOX")
+ .readFirstMessage())
+ .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[] {21}\r\nheader: value\r\n\r\nBODY)\r\n");
+ }
+
+ @Test
+ void fetchShouldRetrieveMessageWhenOffsetAndLimitExceedingMessageSize() throws Exception {
+ testIMAPClient.connect("127.0.0.1", port)
+ .login(USER.asString(), USER_PASS)
+ .append("INBOX", SMALL_MESSAGE);
+
+ assertThat(testIMAPClient
+ .select("INBOX")
+ .readFirstMessageInMailbox("BODY[]<8.20>"))
+ .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {13}\r\nvalue\r\n\r\nBODY)\r\n");
+ }
+
+ @Test
+ void fetchShouldRetrieveMessageWhenOffsetAndLimitEqualMessageSize() throws Exception {
+ testIMAPClient.connect("127.0.0.1", port)
+ .login(USER.asString(), USER_PASS)
+ .append("INBOX", SMALL_MESSAGE);
+
+ assertThat(testIMAPClient
+ .select("INBOX")
+ .readFirstMessageInMailbox("BODY[]<8.13>"))
+ .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {13}\r\nvalue\r\n\r\nBODY)\r\n");
+ }
+
+ @Test
+ void fetchShouldRetrieveMessageWhenOffsetAndLimitBelowMessageSize() throws Exception {
+ testIMAPClient.connect("127.0.0.1", port)
+ .login(USER.asString(), USER_PASS)
+ .append("INBOX", SMALL_MESSAGE);
+
+ assertThat(testIMAPClient
+ .select("INBOX")
+ .readFirstMessageInMailbox("BODY[]<8.12>"))
+ .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {12}\r\nvalue\r\n\r\nBOD)\r\n");
+
+ assertThat(testIMAPClient
+ .select("INBOX")
+ .readFirstMessageInMailbox("BODY[]<8.12>"))
+ .contains("* 1 FETCH (BODY[]<8> {12}\r\nvalue\r\n\r\nBOD)\r\n");
+ }
+
+ @Test
+ void fetchShouldRetrieveMessageWhenOffsetAndNoLimitSpecified() throws Exception {
+ testIMAPClient.connect("127.0.0.1", port)
+ .login(USER.asString(), USER_PASS)
+ .append("INBOX", SMALL_MESSAGE);
+
+ assertThat(testIMAPClient
+ .select("INBOX")
+ .readFirstMessageInMailbox("BODY[]<8>"))
+ .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {13}\r\nvalue\r\n\r\nBODY)\r\n");
+ }
+}
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 5f47296a70..1debd8cba7 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
@@ -233,87 +233,6 @@ class IMAPServerTest {
return ImmutableSet.of(new IpConnectionCheck());
}
- @Nested
- class PartialFetch {
- IMAPServer imapServer;
- private int port;
-
- @BeforeEach
- void beforeEach() throws Exception {
- imapServer = createImapServer("imapServer.xml", FetchProcessor.LocalCacheConfiguration.DEFAULT);
- port = imapServer.getListenAddresses().get(0).getPort();
- }
-
- @AfterEach
- void tearDown() {
- imapServer.destroy();
- }
-
- @Test
- void fetchShouldRetrieveMessage() throws Exception {
- testIMAPClient.connect("127.0.0.1", port)
- .login(USER.asString(), USER_PASS)
- .append("INBOX", SMALL_MESSAGE);
-
- assertThat(testIMAPClient
- .select("INBOX")
- .readFirstMessage())
- .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[] {21}\r\nheader: value\r\n\r\nBODY)\r\n");
- }
-
- @Test
- void fetchShouldRetrieveMessageWhenOffsetAndLimitExceedingMessageSize() throws Exception {
- testIMAPClient.connect("127.0.0.1", port)
- .login(USER.asString(), USER_PASS)
- .append("INBOX", SMALL_MESSAGE);
-
- assertThat(testIMAPClient
- .select("INBOX")
- .readFirstMessageInMailbox("BODY[]<8.20>"))
- .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {13}\r\nvalue\r\n\r\nBODY)\r\n");
- }
-
- @Test
- void fetchShouldRetrieveMessageWhenOffsetAndLimitEqualMessageSize() throws Exception {
- testIMAPClient.connect("127.0.0.1", port)
- .login(USER.asString(), USER_PASS)
- .append("INBOX", SMALL_MESSAGE);
-
- assertThat(testIMAPClient
- .select("INBOX")
- .readFirstMessageInMailbox("BODY[]<8.13>"))
- .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {13}\r\nvalue\r\n\r\nBODY)\r\n");
- }
-
- @Test
- void fetchShouldRetrieveMessageWhenOffsetAndLimitBelowMessageSize() throws Exception {
- testIMAPClient.connect("127.0.0.1", port)
- .login(USER.asString(), USER_PASS)
- .append("INBOX", SMALL_MESSAGE);
-
- assertThat(testIMAPClient
- .select("INBOX")
- .readFirstMessageInMailbox("BODY[]<8.12>"))
- .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {12}\r\nvalue\r\n\r\nBOD)\r\n");
-
- assertThat(testIMAPClient
- .select("INBOX")
- .readFirstMessageInMailbox("BODY[]<8.12>"))
- .contains("* 1 FETCH (BODY[]<8> {12}\r\nvalue\r\n\r\nBOD)\r\n");
- }
-
- @Test
- void fetchShouldRetrieveMessageWhenOffsetAndNoLimitSpecified() throws Exception {
- testIMAPClient.connect("127.0.0.1", port)
- .login(USER.asString(), USER_PASS)
- .append("INBOX", SMALL_MESSAGE);
-
- assertThat(testIMAPClient
- .select("INBOX")
- .readFirstMessageInMailbox("BODY[]<8>"))
- .contains("* 1 FETCH (FLAGS (\\Recent \\Seen) BODY[]<8> {13}\r\nvalue\r\n\r\nBODY)\r\n");
- }
- }
@Nested
class NoLimit {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org