Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.time.Duration;

import org.apache.james.util.concurrency.ConcurrentTestRunner;
import org.apache.james.utils.TestIMAPClient;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -61,15 +62,21 @@ void idCommandShouldReturnConfiguredResponse() throws Exception {
}

@Test
void concurrentIdCommandsInTheSameSessionShouldSucceed() throws Exception {
void concurrentIdCommandsShouldSucceed() throws Exception {
imapServer = createImapServer("imapServer.xml");
int port = imapServer.getListenAddresses().getFirst().getPort();

testIMAPClient.connect("127.0.0.1", imapServer.getListenAddresses().getFirst().getPort());
// One client per thread: a single TestIMAPClient wraps one socket and one
// reader, so sharing it across threads interleaves the replies and a thread
// can read an empty string that belongs to nobody.
ConcurrentTestRunner.builder()
.operation((threadNumber, step) -> {
assertThat(testIMAPClient.sendCommand("ID (\"name\" \"Apache James\")"))
.contains("* ID NIL")
.contains("OK ID completed.");
try (TestIMAPClient client = new TestIMAPClient()) {
client.connect("127.0.0.1", port);
assertThat(client.sendCommand("ID (\"name\" \"Apache James\")"))
.contains("* ID NIL")
.contains("OK ID completed.");
}
})
.threadCount(20)
.operationCount(1)
Expand Down