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/01 02:08:03 UTC
[james-project] branch master updated: JAMES-3715 Add tests for IMAP COMPRESS transport layer
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 ff8e6d8 JAMES-3715 Add tests for IMAP COMPRESS transport layer
ff8e6d8 is described below
commit ff8e6d87759fd7ab86c2c08f5b865d4c5527cab2
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 26 11:58:58 2022 +0700
JAMES-3715 Add tests for IMAP COMPRESS transport layer
Commons-net do not look like it supports compression thus I resorted
to use javax.mail
Compression is one of the untested features that broke during the
Netty 4 upgrade thus I take this opportunity to add more tests.
---
server/protocols/protocols-imap4/pom.xml | 6 +++
.../james/imapserver/netty/IMAPServerTest.java | 48 ++++++++++++++++++++++
.../src/test/resources/imapServerCompress.xml | 14 +++++++
3 files changed, 68 insertions(+)
diff --git a/server/protocols/protocols-imap4/pom.xml b/server/protocols/protocols-imap4/pom.xml
index 0308f96..0b4cba5 100644
--- a/server/protocols/protocols-imap4/pom.xml
+++ b/server/protocols/protocols-imap4/pom.xml
@@ -143,6 +143,12 @@
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jzlib</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
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 07f3bfa..590ef08 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
@@ -19,6 +19,7 @@
package org.apache.james.imapserver.netty;
+import static javax.mail.Folder.READ_WRITE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -29,6 +30,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Properties;
+import javax.mail.FetchProfile;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
@@ -79,6 +81,8 @@ import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
+import com.sun.mail.imap.IMAPFolder;
+
import nl.altindag.ssl.exception.GenericKeyStoreException;
import nl.altindag.ssl.exception.PrivateKeyParseException;
@@ -293,6 +297,50 @@ class IMAPServerTest {
}
@Nested
+ class Compress {
+ IMAPServer imapServer;
+ private int port;
+
+ @BeforeEach
+ void beforeEach() throws Exception {
+ imapServer = createImapServer("imapServerCompress.xml");
+ port = imapServer.getListenAddresses().get(0).getPort();
+ }
+
+ @AfterEach
+ void tearDown() {
+ imapServer.destroy();
+ }
+
+ @Test
+ void shouldNotThrowWhenCompressionEnabled() throws Exception {
+ InMemoryMailboxManager mailboxManager = memoryIntegrationResources.getMailboxManager();
+ MailboxSession mailboxSession = mailboxManager.createSystemSession(USER);
+ mailboxManager.createMailbox(
+ MailboxPath.inbox(USER),
+ mailboxSession);
+ mailboxManager.getMailbox(MailboxPath.inbox(USER), mailboxSession)
+ .appendMessage(MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"), mailboxSession);
+
+ Properties props = new Properties();
+ props.put("mail.imap.user", USER.asString());
+ props.put("mail.imap.host", "127.0.0.1");
+ props.put("mail.imap.auth.mechanisms", "LOGIN");
+ props.put("mail.imap.compress.enable", true);
+ final Session session = Session.getInstance(props);
+ final Store store = session.getStore("imap");
+ store.connect("127.0.0.1", port, USER.asString(), USER_PASS);
+ final FetchProfile fetchProfile = new FetchProfile();
+ fetchProfile.add(FetchProfile.Item.ENVELOPE);
+ final IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX");
+ inbox.open(READ_WRITE);
+
+ inbox.getMessageByUID(1);
+ }
+
+ }
+
+ @Nested
class StartTLS {
IMAPServer imapServer;
private int port;
diff --git a/server/protocols/protocols-imap4/src/test/resources/imapServerCompress.xml b/server/protocols/protocols-imap4/src/test/resources/imapServerCompress.xml
new file mode 100644
index 0000000..ff5459d
--- /dev/null
+++ b/server/protocols/protocols-imap4/src/test/resources/imapServerCompress.xml
@@ -0,0 +1,14 @@
+
+<imapserver enabled="true">
+ <jmxName>imapserver</jmxName>
+ <bind>0.0.0.0:0</bind>
+ <compress>true</compress>
+ <connectionBacklog>200</connectionBacklog>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <idleTimeInterval>120</idleTimeInterval>
+ <idleTimeIntervalUnit>SECONDS</idleTimeIntervalUnit>
+ <enableIdle>true</enableIdle>
+ <inMemorySizeLimit>65536</inMemorySizeLimit> <!-- 64 KB -->
+ <plainAuthDisallowed>false</plainAuthDisallowed>
+</imapserver>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org