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 9dd0ceaf8c08f7b952d1ce1d4da189bea8ae5498
Author: Quan Tran <[email protected]>
AuthorDate: Thu Jun 4 14:21:10 2026 +0700

    [REFACTORING] Split IMAPServerSSLConfigurationTest
---
 .../netty/IMAPServerSSLConfigurationTest.java      | 129 +++++++++++++++++++++
 .../james/imapserver/netty/IMAPServerTest.java     |  99 ----------------
 2 files changed, 129 insertions(+), 99 deletions(-)

diff --git 
a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerSSLConfigurationTest.java
 
b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerSSLConfigurationTest.java
new file mode 100644
index 0000000000..3a71bcde50
--- /dev/null
+++ 
b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerSSLConfigurationTest.java
@@ -0,0 +1,129 @@
+/****************************************************************
+ * 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.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.FileNotFoundException;
+
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import nl.altindag.ssl.exception.GenericKeyStoreException;
+import nl.altindag.ssl.pem.exception.PrivateKeyParseException;
+
+
+@SuppressWarnings("checkstyle:membername")
+class IMAPServerSSLConfigurationTest extends AbstractIMAPServerTest {
+    IMAPServer imapServer;
+
+    @AfterEach
+    void tearDown() {
+        if (imapServer != null) {
+            imapServer.destroy();
+        }
+    }
+
+    @Test
+    void initShouldAcceptJKSFormat() {
+        assertThatCode(() -> imapServer = 
createImapServer("imapServerSslJKS.xml"))
+            .doesNotThrowAnyException();
+    }
+
+    @Test
+    void initShouldAcceptPKCS12Format() {
+        assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPKCS12.xml"))
+            .doesNotThrowAnyException();
+    }
+
+    @Test
+    void initShouldAcceptPEMKeysWithPassword() {
+        assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPEM.xml"))
+            .doesNotThrowAnyException();
+    }
+
+    @Test
+    void initShouldAcceptPEMKeysWithoutPassword() {
+        assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPEMNoPass.xml"))
+            .doesNotThrowAnyException();
+    }
+
+    @Test
+    void initShouldAcceptJKSByDefault() {
+        assertThatCode(() -> imapServer = 
createImapServer("imapServerSslDefaultJKS.xml"))
+            .doesNotThrowAnyException();
+    }
+
+    @Test
+    void initShouldThrowWhenSslEnabledWithoutKeys() {
+        assertThatThrownBy(() -> createImapServer("imapServerSslNoKeys.xml"))
+            .isInstanceOf(ConfigurationException.class)
+            .hasMessageContaining("keystore or (privateKey and certificates) 
needs to get configured");
+    }
+
+    @Test
+    void initShouldThrowWhenJKSWithBadPassword() {
+        assertThatThrownBy(() -> 
createImapServer("imapServerSslJKSBadPassword.xml"))
+            .isInstanceOf(GenericKeyStoreException.class)
+            .hasMessageContaining("keystore password was incorrect");
+    }
+
+    @Test
+    void initShouldThrowWhenPEMWithBadPassword() {
+        assertThatThrownBy(() -> 
createImapServer("imapServerSslPEMBadPass.xml"))
+            .isInstanceOf(PrivateKeyParseException.class);
+    }
+
+    @Test
+    void initShouldThrowWhenPEMWithMissingPassword() {
+        assertThatThrownBy(() -> 
createImapServer("imapServerSslPEMMissingPass.xml"))
+            .isInstanceOf(IllegalArgumentException.class)
+            .hasMessage("A password is mandatory with an encrypted key");
+    }
+
+    @Test
+    void initShouldNotThrowWhenPEMWithExtraPassword() {
+        assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPEMExtraPass.xml"))
+            .doesNotThrowAnyException();
+    }
+
+    @Test
+    void initShouldThrowWhenJKSWenNotFound() {
+        assertThatThrownBy(() -> 
createImapServer("imapServerSslJKSNotFound.xml"))
+            .isInstanceOf(FileNotFoundException.class)
+            .hasMessage("class path resource [keystore.notfound.jks] cannot be 
resolved to URL because it does not exist");
+    }
+
+    @Test
+    void initShouldThrowWhenPKCS12WithBadPassword() {
+        assertThatThrownBy(() -> 
createImapServer("imapServerSslPKCS12WrongPassword.xml"))
+            .isInstanceOf(GenericKeyStoreException.class)
+            .hasMessageContaining("keystore password was incorrect");
+    }
+
+    @Test
+    void initShouldThrowWhenPKCS12WithMissingPassword() {
+        assertThatThrownBy(() -> 
createImapServer("imapServerSslPKCS12MissingPassword.xml"))
+            .isInstanceOf(GenericKeyStoreException.class)
+            .hasMessageContaining("keystore password was incorrect");
+    }
+}
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 c0e8a46bcb..267c9476ab 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
@@ -34,7 +34,6 @@ import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.Socket;
@@ -69,7 +68,6 @@ import jakarta.mail.search.SearchTerm;
 import jakarta.mail.search.SubjectTerm;
 
 import org.apache.commons.configuration2.HierarchicalConfiguration;
-import org.apache.commons.configuration2.ex.ConfigurationException;
 import org.apache.commons.configuration2.tree.ImmutableNode;
 import org.apache.commons.net.imap.AuthenticatingIMAPClient;
 import org.apache.commons.net.imap.IMAPSClient;
@@ -131,8 +129,6 @@ import io.netty.handler.codec.compression.JdkZlibDecoder;
 import io.netty.handler.codec.compression.JdkZlibEncoder;
 import io.netty.handler.codec.compression.ZlibWrapper;
 import io.netty.handler.ssl.SslContextBuilder;
-import nl.altindag.ssl.exception.GenericKeyStoreException;
-import nl.altindag.ssl.pem.exception.PrivateKeyParseException;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 import reactor.core.scheduler.Schedulers;
@@ -259,101 +255,6 @@ class IMAPServerTest {
 
 
 
-    @Nested
-    class Ssl {
-        IMAPServer imapServer;
-
-        @AfterEach
-        void tearDown() {
-            if (imapServer != null) {
-                imapServer.destroy();
-            }
-        }
-
-        @Test
-        void initShouldAcceptJKSFormat() {
-            assertThatCode(() -> imapServer = 
createImapServer("imapServerSslJKS.xml"))
-                .doesNotThrowAnyException();
-        }
-
-        @Test
-        void initShouldAcceptPKCS12Format() {
-            assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPKCS12.xml"))
-                .doesNotThrowAnyException();
-        }
-
-        @Test
-        void initShouldAcceptPEMKeysWithPassword() {
-            assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPEM.xml"))
-                .doesNotThrowAnyException();
-        }
-
-        @Test
-        void initShouldAcceptPEMKeysWithoutPassword() {
-            assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPEMNoPass.xml"))
-                .doesNotThrowAnyException();
-        }
-
-        @Test
-        void initShouldAcceptJKSByDefault() {
-            assertThatCode(() -> imapServer = 
createImapServer("imapServerSslDefaultJKS.xml"))
-                .doesNotThrowAnyException();
-        }
-
-        @Test
-        void initShouldThrowWhenSslEnabledWithoutKeys() {
-            assertThatThrownBy(() -> 
createImapServer("imapServerSslNoKeys.xml"))
-                .isInstanceOf(ConfigurationException.class)
-                .hasMessageContaining("keystore or (privateKey and 
certificates) needs to get configured");
-        }
-
-        @Test
-        void initShouldThrowWhenJKSWithBadPassword() {
-            assertThatThrownBy(() -> 
createImapServer("imapServerSslJKSBadPassword.xml"))
-                .isInstanceOf(GenericKeyStoreException.class)
-                .hasMessageContaining("keystore password was incorrect");
-        }
-
-        @Test
-        void initShouldThrowWhenPEMWithBadPassword() {
-            assertThatThrownBy(() -> 
createImapServer("imapServerSslPEMBadPass.xml"))
-                .isInstanceOf(PrivateKeyParseException.class);
-        }
-
-        @Test
-        void initShouldThrowWhenPEMWithMissingPassword() {
-            assertThatThrownBy(() -> 
createImapServer("imapServerSslPEMMissingPass.xml"))
-                .isInstanceOf(IllegalArgumentException.class)
-                .hasMessage("A password is mandatory with an encrypted key");
-        }
-
-        @Test
-        void initShouldNotThrowWhenPEMWithExtraPassword() {
-            assertThatCode(() -> imapServer = 
createImapServer("imapServerSslPEMExtraPass.xml"))
-                .doesNotThrowAnyException();
-        }
-
-        @Test
-        void initShouldThrowWhenJKSWenNotFound() {
-            assertThatThrownBy(() -> 
createImapServer("imapServerSslJKSNotFound.xml"))
-                .isInstanceOf(FileNotFoundException.class)
-                .hasMessage("class path resource [keystore.notfound.jks] 
cannot be resolved to URL because it does not exist");
-        }
-
-        @Test
-        void initShouldThrowWhenPKCS12WithBadPassword() {
-            assertThatThrownBy(() -> 
createImapServer("imapServerSslPKCS12WrongPassword.xml"))
-                .isInstanceOf(GenericKeyStoreException.class)
-                .hasMessageContaining("keystore password was incorrect");
-        }
-
-        @Test
-        void initShouldThrowWhenPKCS12WithMissingPassword() {
-            assertThatThrownBy(() -> 
createImapServer("imapServerSslPKCS12MissingPassword.xml"))
-                .isInstanceOf(GenericKeyStoreException.class)
-                .hasMessageContaining("keystore password was incorrect");
-        }
-    }
 
     @Nested
     class Limit {


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

Reply via email to