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 beb804951cc2861b46a8212d6e9a6291e34639da Author: Quan Tran <[email protected]> AuthorDate: Thu Jun 4 15:35:44 2026 +0700 [REFACTORING] Split IMAPServerPlainAuthenticateThenAnotherCommandTest --- ...verPlainAuthenticateThenAnotherCommandTest.java | 66 ++++++++++++++++++++++ .../james/imapserver/netty/IMAPServerTest.java | 33 ----------- 2 files changed, 66 insertions(+), 33 deletions(-) diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerPlainAuthenticateThenAnotherCommandTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerPlainAuthenticateThenAnotherCommandTest.java new file mode 100644 index 0000000000..e687482d91 --- /dev/null +++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerPlainAuthenticateThenAnotherCommandTest.java @@ -0,0 +1,66 @@ +/**************************************************************** + * 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.commons.net.imap.AuthenticatingIMAPClient; +import org.apache.james.util.concurrency.ConcurrentTestRunner; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + + +@SuppressWarnings("checkstyle:membername") +class IMAPServerPlainAuthenticateThenAnotherCommandTest extends AbstractIMAPServerTest { + IMAPServer imapServer; + int port; + + @BeforeEach + void setup() throws Exception { + imapServer = createImapServer("imapServer.xml"); + port = imapServer.getListenAddresses().get(0).getPort(); + } + + @AfterEach + void tearDown() { + if (imapServer != null) { + imapServer.destroy(); + } + } + + @Test + void authenticateShouldOnlyConsumeAuthDataCommandNotTheNextCommand() throws Exception { + ConcurrentTestRunner.builder() + .operation((threadNumber, step) -> { + AuthenticatingIMAPClient imapClient = new AuthenticatingIMAPClient(); + imapClient.connect("127.0.0.1", port); + assertThat(imapClient.authenticate(AuthenticatingIMAPClient.AUTH_METHOD.PLAIN, USER.asString(), + USER_PASS)).isTrue(); + assertThat(imapClient.logout()).isTrue(); + imapClient.disconnect(); + }) + .threadCount(10) + .operationCount(200) + .runSuccessfullyWithin(Duration.ofMinutes(10)); + } +} 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 95067aef25..3228d511f8 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 @@ -241,40 +241,7 @@ class IMAPServerTest { - @Nested - class PlainAuthenticateThenAnotherCommand { - IMAPServer imapServer; - int port; - @BeforeEach - void setup() throws Exception { - imapServer = createImapServer("imapServer.xml"); - port = imapServer.getListenAddresses().get(0).getPort(); - } - - @AfterEach - void tearDown() { - if (imapServer != null) { - imapServer.destroy(); - } - } - - @Test - void authenticateShouldOnlyConsumeAuthDataCommandNotTheNextCommand() throws Exception { - ConcurrentTestRunner.builder() - .operation((threadNumber, step) -> { - AuthenticatingIMAPClient imapClient = new AuthenticatingIMAPClient(); - imapClient.connect("127.0.0.1", port); - assertThat(imapClient.authenticate(AuthenticatingIMAPClient.AUTH_METHOD.PLAIN, USER.asString(), - USER_PASS)).isTrue(); - assertThat(imapClient.logout()).isTrue(); - imapClient.disconnect(); - }) - .threadCount(10) - .operationCount(200) - .runSuccessfullyWithin(Duration.ofMinutes(10)); - } - } @Nested class IDCommandTest { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
