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 68a82b6eb687b7475d6df00ad7320d28bee4e755
Author: Quan Tran <[email protected]>
AuthorDate: Thu Jun 4 15:12:24 2026 +0700

    [REFACTORING] Split IMAPServerSSLTest
---
 .../james/imapserver/netty/IMAPServerSSLTest.java  | 88 ++++++++++++++++++++++
 .../james/imapserver/netty/IMAPServerTest.java     | 51 -------------
 2 files changed, 88 insertions(+), 51 deletions(-)

diff --git 
a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerSSLTest.java
 
b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerSSLTest.java
new file mode 100644
index 0000000000..10b3037139
--- /dev/null
+++ 
b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerSSLTest.java
@@ -0,0 +1,88 @@
+/****************************************************************
+ * 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.apache.james.jmap.JMAPTestingConstants.LOCALHOST_IP;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+
+@SuppressWarnings("checkstyle:membername")
+class IMAPServerSSLTest extends AbstractIMAPServerTest {
+    IMAPServer imapServer;
+    private MailboxSession mailboxSession;
+    private MessageManager inbox;
+    private Socket clientConnection;
+
+    @BeforeEach
+    void beforeEach() throws Exception {
+        imapServer = createImapServer("imapServerSSL.xml");
+        int port = imapServer.getListenAddresses().get(0).getPort();
+        mailboxSession = 
memoryIntegrationResources.getMailboxManager().createSystemSession(USER);
+        memoryIntegrationResources.getMailboxManager()
+            .createMailbox(MailboxPath.inbox(USER), mailboxSession);
+        inbox = 
memoryIntegrationResources.getMailboxManager().getMailbox(MailboxPath.inbox(USER),
 mailboxSession);
+
+        SSLContext ctx = SSLContext.getInstance("TLS");
+        ctx.init(null, new TrustManager[]{new BlindTrustManager()}, null);
+        clientConnection = ctx.getSocketFactory().createSocket();
+        clientConnection.connect(new InetSocketAddress(LOCALHOST_IP, port));
+        byte[] buffer = new byte[8193];
+        clientConnection.getInputStream().read(buffer);
+    }
+
+    @AfterEach
+    void tearDown() throws Exception {
+        clientConnection.close();
+        imapServer.destroy();
+    }
+
+    @Test
+    void startTlsCapabilityShouldFailWhenSSLSocket() throws Exception {
+        clientConnection.getOutputStream().write("a0 
STARTTLS\r\n".getBytes(StandardCharsets.UTF_8));
+        assertThat(readString(clientConnection)).startsWith("a0 BAD STARTTLS 
failed. Unknown command.");
+    }
+
+    @Test
+    void startTlsCapabilityShouldNotBeAdvertisedWhenSSLSocket() throws 
Exception {
+        clientConnection.getOutputStream().write("a0 
CAPABILITY\r\n".getBytes(StandardCharsets.UTF_8));
+        assertThat(readString(clientConnection)).doesNotContain("STARTTLS");
+    }
+
+    private String readString(Socket channel) throws IOException {
+        byte[] buffer = new byte[8193];
+        int read = channel.getInputStream().read(buffer);
+        return new String(buffer, 0, read, StandardCharsets.US_ASCII);
+    }
+}
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 c4cf29d18f..61bd446a70 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
@@ -33,7 +33,6 @@ import static org.mockito.Mockito.spy;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
-import java.net.Socket;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
 import java.nio.charset.StandardCharsets;
@@ -46,8 +45,6 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Predicate;
 import java.util.stream.IntStream;
 
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 
 import jakarta.mail.Flags;
@@ -253,54 +250,6 @@ class IMAPServerTest {
 
 
 
-    @Nested
-    class SSL {
-        IMAPServer imapServer;
-        private MailboxSession mailboxSession;
-        private MessageManager inbox;
-        private Socket clientConnection;
-
-        @BeforeEach
-        void beforeEach() throws Exception {
-            imapServer = createImapServer("imapServerSSL.xml");
-            int port = imapServer.getListenAddresses().get(0).getPort();
-            mailboxSession = 
memoryIntegrationResources.getMailboxManager().createSystemSession(USER);
-            memoryIntegrationResources.getMailboxManager()
-                .createMailbox(MailboxPath.inbox(USER), mailboxSession);
-            inbox = 
memoryIntegrationResources.getMailboxManager().getMailbox(MailboxPath.inbox(USER),
 mailboxSession);
-
-            SSLContext ctx = SSLContext.getInstance("TLS");
-            ctx.init(null, new TrustManager[]{new BlindTrustManager()}, null);
-            clientConnection = ctx.getSocketFactory().createSocket();
-            clientConnection.connect(new InetSocketAddress(LOCALHOST_IP, 
port));
-            byte[] buffer = new byte[8193];
-            clientConnection.getInputStream().read(buffer);
-        }
-
-        @AfterEach
-        void tearDown() throws Exception {
-            clientConnection.close();
-            imapServer.destroy();
-        }
-
-        @Test
-        void startTlsCapabilityShouldFailWhenSSLSocket() throws Exception {
-            clientConnection.getOutputStream().write("a0 
STARTTLS\r\n".getBytes(StandardCharsets.UTF_8));
-            assertThat(readString(clientConnection)).startsWith("a0 BAD 
STARTTLS failed. Unknown command.");
-        }
-
-        @Test
-        void startTlsCapabilityShouldNotBeAdvertisedWhenSSLSocket() throws 
Exception {
-            clientConnection.getOutputStream().write("a0 
CAPABILITY\r\n".getBytes(StandardCharsets.UTF_8));
-            
assertThat(readString(clientConnection)).doesNotContain("STARTTLS");
-        }
-
-        private String readString(Socket channel) throws IOException {
-            byte[] buffer = new byte[8193];
-            int read = channel.getInputStream().read(buffer);
-            return new String(buffer, 0, read, StandardCharsets.US_ASCII);
-        }
-    }
 
     @Nested
     class IdleSSLCompress {


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

Reply via email to