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 31eaf24564c646158279ce221edc8aa794db7dac Author: Quan Tran <[email protected]> AuthorDate: Thu Jun 4 15:36:52 2026 +0700 [REFACTORING] Split IMAPServerIDCommandTest --- .../imapserver/netty/IMAPServerIDCommandTest.java | 78 ++++++++++++++++++++++ .../james/imapserver/netty/IMAPServerTest.java | 50 -------------- 2 files changed, 78 insertions(+), 50 deletions(-) diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerIDCommandTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerIDCommandTest.java new file mode 100644 index 0000000000..a26b53c7ef --- /dev/null +++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerIDCommandTest.java @@ -0,0 +1,78 @@ +/**************************************************************** + * 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 java.time.Duration; + +import org.apache.james.util.concurrency.ConcurrentTestRunner; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + + +@SuppressWarnings("checkstyle:membername") +class IMAPServerIDCommandTest extends AbstractIMAPServerTest { + IMAPServer imapServer; + + @AfterEach + void tearDown() { + if (imapServer != null) { + imapServer.destroy(); + } + } + + @Test + void idCommandShouldReturnNILWhenNoConfigured() throws Exception { + imapServer = createImapServer("imapServer.xml"); + + assertThat( + testIMAPClient.connect("127.0.0.1", imapServer.getListenAddresses().getFirst().getPort()) + .sendCommand("ID (\"name\" \"Apache James\")")) + .contains("* ID NIL") + .contains("OK ID completed."); + } + + @Test + void idCommandShouldReturnConfiguredResponse() throws Exception { + imapServer = createImapServer("imapServerIdCommandResponseFields.xml"); + assertThat( + testIMAPClient.connect("127.0.0.1", imapServer.getListenAddresses().getFirst().getPort()) + .sendCommand("ID (\"name\" \"Apache James\")")) + .contains("* ID (\"name\" \"Apache James\" \"version\" \"3.9.0\")") + .contains("OK ID completed."); + } + + @Test + void concurrentIdCommandsInTheSameSessionShouldSucceed() throws Exception { + imapServer = createImapServer("imapServer.xml"); + + testIMAPClient.connect("127.0.0.1", imapServer.getListenAddresses().getFirst().getPort()); + ConcurrentTestRunner.builder() + .operation((threadNumber, step) -> { + assertThat(testIMAPClient.sendCommand("ID (\"name\" \"Apache James\")")) + .contains("* ID NIL") + .contains("OK ID completed."); + }) + .threadCount(20) + .operationCount(1) + .runSuccessfullyWithin(Duration.ofMinutes(5)); + } +} 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 3228d511f8..6a5ebed47d 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 @@ -27,7 +27,6 @@ import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import java.nio.charset.StandardCharsets; import java.security.cert.X509Certificate; -import java.time.Duration; import java.util.List; import java.util.Set; import java.util.function.Predicate; @@ -59,7 +58,6 @@ import org.apache.james.protocols.lib.LegacyJavaEncryptionFactory; import org.apache.james.protocols.lib.mock.ConfigLoader; import org.apache.james.server.core.filesystem.FileSystemImpl; import org.apache.james.util.ClassLoaderUtils; -import org.apache.james.util.concurrency.ConcurrentTestRunner; import org.apache.james.utils.TestIMAPClient; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -243,54 +241,6 @@ class IMAPServerTest { - @Nested - class IDCommandTest { - IMAPServer imapServer; - - @AfterEach - void tearDown() { - if (imapServer != null) { - imapServer.destroy(); - } - } - - @Test - void idCommandShouldReturnNILWhenNoConfigured() throws Exception { - imapServer = createImapServer("imapServer.xml"); - - assertThat( - testIMAPClient.connect("127.0.0.1", imapServer.getListenAddresses().getFirst().getPort()) - .sendCommand("ID (\"name\" \"Apache James\")")) - .contains("* ID NIL") - .contains("OK ID completed."); - } - - @Test - void idCommandShouldReturnConfiguredResponse() throws Exception { - imapServer = createImapServer("imapServerIdCommandResponseFields.xml"); - assertThat( - testIMAPClient.connect("127.0.0.1", imapServer.getListenAddresses().getFirst().getPort()) - .sendCommand("ID (\"name\" \"Apache James\")")) - .contains("* ID (\"name\" \"Apache James\" \"version\" \"3.9.0\")") - .contains("OK ID completed."); - } - - @Test - void concurrentIdCommandsInTheSameSessionShouldSucceed() throws Exception { - imapServer = createImapServer("imapServer.xml"); - - testIMAPClient.connect("127.0.0.1", imapServer.getListenAddresses().getFirst().getPort()); - ConcurrentTestRunner.builder() - .operation((threadNumber, step) -> { - assertThat(testIMAPClient.sendCommand("ID (\"name\" \"Apache James\")")) - .contains("* ID NIL") - .contains("OK ID completed."); - }) - .threadCount(20) - .operationCount(1) - .runSuccessfullyWithin(Duration.ofMinutes(5)); - } - } @Nested class RenameMailboxTest { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
