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 65547008e042c143ca7073708a4d03d4e0a6949b
Author: Quan Tran <[email protected]>
AuthorDate: Mon Jul 13 22:58:39 2026 +0700

    [BUILD] ImapSetMessagesMailboxesUpdatesCompatibilityContract: isolate using 
different users
---
 ...istributedIMAPSetMessagesCompatibilityTest.java |  2 +-
 ...agesMailboxesUpdatesCompatibilityContract.scala | 71 ++++++++++++++--------
 .../MemoryIMAPSetMessagesCompatibilityTest.java    |  2 +-
 3 files changed, 46 insertions(+), 29 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedIMAPSetMessagesCompatibilityTest.java
 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedIMAPSetMessagesCompatibilityTest.java
index 19ee97e634..138605e35e 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedIMAPSetMessagesCompatibilityTest.java
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedIMAPSetMessagesCompatibilityTest.java
@@ -23,7 +23,7 @@ import 
org.apache.james.jmap.rfc8621.contract.ImapSetMessagesMailboxesUpdatesCom
 import org.apache.james.utils.TestIMAPClient;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class DistributedIMAPSetMessagesCompatibilityTest extends 
DistributedBase implements ImapSetMessagesMailboxesUpdatesCompatibilityContract 
{
+public class DistributedIMAPSetMessagesCompatibilityTest extends 
PerClassDistributedBase implements 
ImapSetMessagesMailboxesUpdatesCompatibilityContract {
     @RegisterExtension
     TestIMAPClient testIMAPClient = new TestIMAPClient();
 
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/ImapSetMessagesMailboxesUpdatesCompatibilityContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/ImapSetMessagesMailboxesUpdatesCompatibilityContract.scala
index 110ab5e654..c6bd479c36 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/ImapSetMessagesMailboxesUpdatesCompatibilityContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/ImapSetMessagesMailboxesUpdatesCompatibilityContract.scala
@@ -21,17 +21,19 @@ package org.apache.james.jmap.rfc8621.contract
 
 import java.nio.charset.StandardCharsets
 import java.util
+import java.util.UUID
 import java.util.concurrent.TimeUnit
 
+import com.google.common.hash.Hashing
 import io.netty.handler.codec.http.HttpHeaderNames.ACCEPT
 import io.restassured.RestAssured
 import io.restassured.RestAssured.`given`
 import org.apache.http.HttpStatus.SC_OK
 import org.apache.james.GuiceJamesServer
+import org.apache.james.core.Username
 import org.apache.james.jmap.JMAPTestingConstants.{DOMAIN, LOCALHOST_IP}
 import org.apache.james.jmap.http.UserCredential
-import 
org.apache.james.jmap.rfc8621.contract.Fixture.{ACCEPT_RFC8621_VERSION_HEADER, 
ACCOUNT_ID, ANDRE, BOB, BOB_PASSWORD, authScheme, baseRequestSpecBuilder}
-import 
org.apache.james.jmap.rfc8621.contract.ImapSetMessagesMailboxesUpdatesCompatibilityContract.bobInboxPath
+import 
org.apache.james.jmap.rfc8621.contract.Fixture.{ACCEPT_RFC8621_VERSION_HEADER, 
BOB_PASSWORD, authScheme, baseRequestSpecBuilder}
 import org.apache.james.mailbox.DefaultMailboxes
 import org.apache.james.mailbox.MessageManager.AppendCommand
 import org.apache.james.mailbox.model.{MailboxConstants, MailboxId, 
MailboxPath, MessageId}
@@ -44,11 +46,21 @@ import org.awaitility.Awaitility
 import org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS
 import org.junit.jupiter.api.{BeforeEach, Test}
 
-object ImapSetMessagesMailboxesUpdatesCompatibilityContract {
-  private val bobInboxPath = MailboxPath.forUser(BOB, DefaultMailboxes.INBOX)
+object ImapSetMessagesCompatibilityContext {
+  case class TestContext(bobUsername: Username, bobAccountId: String, 
andreUsername: Username)
+  val currentContext: java.util.concurrent.atomic.AtomicReference[TestContext] 
= new java.util.concurrent.atomic.AtomicReference[TestContext]()
 }
 
+object ImapSetMessagesMailboxesUpdatesCompatibilityContract {}
+
 trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
+  import ImapSetMessagesCompatibilityContext.currentContext
+
+  def bobUsername: Username = currentContext.get().bobUsername
+  def bobAccountId: String = currentContext.get().bobAccountId
+  def andreUsername: Username = currentContext.get().andreUsername
+  def bobInboxPath: MailboxPath = MailboxPath.forUser(bobUsername, 
DefaultMailboxes.INBOX)
+
   private lazy val slowPacedPollInterval = ONE_HUNDRED_MILLISECONDS
   private lazy val calmlyAwait = Awaitility.`with`
     .pollInterval(slowPacedPollInterval)
@@ -60,18 +72,23 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
   @BeforeEach
   def setUp(server: GuiceJamesServer): Unit = {
+    val uniqueSuffix = UUID.randomUUID().toString.replace("-", "").take(8)
+    val bob = Username.fromLocalPartWithDomain(s"bob$uniqueSuffix", DOMAIN)
+    val andre = Username.fromLocalPartWithDomain(s"andre$uniqueSuffix", DOMAIN)
+    currentContext.set(ImapSetMessagesCompatibilityContext.TestContext(
+      bob, Hashing.sha256().hashString(bob.asString(), 
StandardCharsets.UTF_8).toString, andre))
     server.getProbe(classOf[DataProbeImpl])
       .fluent
       .addDomain(DOMAIN)
-      .addUser(BOB.asString, BOB_PASSWORD)
+      .addUser(bobUsername.asString, BOB_PASSWORD)
 
     val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
-    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, BOB.asString, 
DefaultMailboxes.INBOX)
-    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, BOB.asString, 
DefaultMailboxes.ARCHIVE)
-    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, BOB.asString, 
DefaultMailboxes.TRASH)
+    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, 
bobUsername.asString, DefaultMailboxes.INBOX)
+    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, 
bobUsername.asString, DefaultMailboxes.ARCHIVE)
+    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, 
bobUsername.asString, DefaultMailboxes.TRASH)
 
     RestAssured.requestSpecification = baseRequestSpecBuilder(server)
-      .setAuth(authScheme(UserCredential(BOB, BOB_PASSWORD)))
+      .setAuth(authScheme(UserCredential(bobUsername, BOB_PASSWORD)))
       .build
   }
 
@@ -85,7 +102,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
     // Then the user has a IMAP message in mailbox "archive"
     imapClient.connect(LOCALHOST_IP, 
server.getProbe(classOf[ImapGuiceProbe]).getImapPort)
-      .login(BOB, BOB_PASSWORD)
+      .login(bobUsername, BOB_PASSWORD)
       .select(DefaultMailboxes.ARCHIVE)
       .awaitMessageCount(awaitAtMostOneMinute, 1)
 
@@ -104,7 +121,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
     // Then the user has a IMAP message in mailbox "archive"
     imapClient.connect(LOCALHOST_IP, 
server.getProbe(classOf[ImapGuiceProbe]).getImapPort)
-      .login(BOB, BOB_PASSWORD)
+      .login(bobUsername, BOB_PASSWORD)
       .select(DefaultMailboxes.ARCHIVE)
       .awaitMessageCount(awaitAtMostOneMinute, 1)
 
@@ -123,7 +140,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
     // Then the user has a IMAP notification about 1 new message when 
selecting mailbox "archive"
     imapClient.connect(LOCALHOST_IP, 
server.getProbe(classOf[ImapGuiceProbe]).getImapPort)
-      .login(BOB, BOB_PASSWORD)
+      .login(bobUsername, BOB_PASSWORD)
       .select(DefaultMailboxes.ARCHIVE)
 
     assertThat(imapClient.userGetNotifiedForNewMessagesWhenSelectingMailbox(1))
@@ -137,7 +154,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
     // Given the user has an open IMAP connection with mailbox "archive" 
selected
     imapClient.connect(LOCALHOST_IP, 
server.getProbe(classOf[ImapGuiceProbe]).getImapPort)
-      .login(BOB, BOB_PASSWORD)
+      .login(bobUsername, BOB_PASSWORD)
       .select(DefaultMailboxes.ARCHIVE)
 
     // When the user moves "m1" to user mailbox "archive"
@@ -158,13 +175,13 @@ trait 
ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
     // Given the user has an open IMAP connection with mailbox "archive" 
selected
     imapClient.connect(LOCALHOST_IP, 
server.getProbe(classOf[ImapGuiceProbe]).getImapPort)
-      .login(BOB, BOB_PASSWORD)
+      .login(bobUsername, BOB_PASSWORD)
       .select(DefaultMailboxes.ARCHIVE)
 
     // When the user copy by IMAP first message of "inbox" to mailbox "archive"
     val imapClientCopy: TestIMAPClient = new TestIMAPClient
     imapClientCopy.connect(LOCALHOST_IP, 
server.getProbe(classOf[ImapGuiceProbe]).getImapPort)
-      .login(BOB.asString, BOB_PASSWORD)
+      .login(bobUsername.asString, BOB_PASSWORD)
       .select(DefaultMailboxes.INBOX)
       .copyFirstMessage(DefaultMailboxes.ARCHIVE)
     imapClientCopy.close()
@@ -184,7 +201,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
     // Given the user has an open IMAP connection with mailbox "inbox" selected
     imapClient.connect(LOCALHOST_IP, 
server.getProbe(classOf[ImapGuiceProbe]).getImapPort)
-      .login(BOB, BOB_PASSWORD)
+      .login(bobUsername, BOB_PASSWORD)
       .select(DefaultMailboxes.INBOX)
 
     // When the user moves "m1" to user mailbox "archive"
@@ -199,21 +216,21 @@ trait 
ImapSetMessagesMailboxesUpdatesCompatibilityContract {
     val message: Message = Message.Builder
       .of
       .setSubject("test")
-      .setSender(ANDRE.asString)
-      .setFrom("ANDRE <" + ANDRE.asString + ">")
-      .setTo(BOB.asString)
+      .setSender(andreUsername.asString)
+      .setFrom("andreUsername <" + andreUsername.asString + ">")
+      .setTo(bobUsername.asString)
       .setSubject("My awesome subject")
       .setBody("This is the content", StandardCharsets.UTF_8)
       .build
 
     server.getProbe(classOf[MailboxProbeImpl])
-      .appendMessage(BOB.asString(), bobInboxPath, 
AppendCommand.builder().build(message))
+      .appendMessage(bobUsername.asString(), bobInboxPath, 
AppendCommand.builder().build(message))
       .getMessageId
   }
 
   def moveMessageFromInboxToArchive(server: GuiceJamesServer, messageId: 
MessageId): Unit = {
     val archiveMailboxId: MailboxId = 
server.getProbe(classOf[MailboxProbeImpl])
-      .getMailboxId(MailboxConstants.USER_NAMESPACE, BOB.asString, 
DefaultMailboxes.ARCHIVE)
+      .getMailboxId(MailboxConstants.USER_NAMESPACE, bobUsername.asString, 
DefaultMailboxes.ARCHIVE)
 
     val request =
       s"""{
@@ -222,7 +239,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
          |    "urn:ietf:params:jmap:mail"],
          |  "methodCalls": [
          |    ["Email/set", {
-         |      "accountId": "$ACCOUNT_ID",
+         |      "accountId": "$bobAccountId",
          |      "update": {
          |        "${messageId.serialize}": {
          |          "mailboxIds": {
@@ -244,9 +261,9 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
   def copyMessageFromInboxToArchive(server: GuiceJamesServer, messageId: 
MessageId): Unit = {
     val inboxId: MailboxId = server.getProbe(classOf[MailboxProbeImpl])
-      .getMailboxId(MailboxConstants.USER_NAMESPACE, BOB.asString, 
DefaultMailboxes.INBOX)
+      .getMailboxId(MailboxConstants.USER_NAMESPACE, bobUsername.asString, 
DefaultMailboxes.INBOX)
     val archiveMailboxId: MailboxId = 
server.getProbe(classOf[MailboxProbeImpl])
-      .getMailboxId(MailboxConstants.USER_NAMESPACE, BOB.asString, 
DefaultMailboxes.ARCHIVE)
+      .getMailboxId(MailboxConstants.USER_NAMESPACE, bobUsername.asString, 
DefaultMailboxes.ARCHIVE)
 
     val request =
       s"""{
@@ -255,7 +272,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
          |    "urn:ietf:params:jmap:mail"],
          |  "methodCalls": [
          |    ["Email/set", {
-         |      "accountId": "$ACCOUNT_ID",
+         |      "accountId": "$bobAccountId",
          |      "update": {
          |        "${messageId.serialize}": {
          |          "mailboxIds": {
@@ -278,7 +295,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
 
   def listMessageIdsArchive(server: GuiceJamesServer): util.ArrayList[String] 
= {
     val archiveMailboxId: MailboxId = 
server.getProbe(classOf[MailboxProbeImpl])
-      .getMailboxId(MailboxConstants.USER_NAMESPACE, BOB.asString, 
DefaultMailboxes.ARCHIVE)
+      .getMailboxId(MailboxConstants.USER_NAMESPACE, bobUsername.asString, 
DefaultMailboxes.ARCHIVE)
 
     val request =
       s"""{
@@ -286,7 +303,7 @@ trait ImapSetMessagesMailboxesUpdatesCompatibilityContract {
          |  "methodCalls": [[
          |    "Email/query",
          |    {
-         |      "accountId": "$ACCOUNT_ID",
+         |      "accountId": "$bobAccountId",
          |      "filter": {"inMailbox": "${archiveMailboxId.serialize}"}
          |    },
          |    "c1"]]
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryIMAPSetMessagesCompatibilityTest.java
 
b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryIMAPSetMessagesCompatibilityTest.java
index 73932e9301..51551fcde2 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryIMAPSetMessagesCompatibilityTest.java
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryIMAPSetMessagesCompatibilityTest.java
@@ -23,7 +23,7 @@ import 
org.apache.james.jmap.rfc8621.contract.ImapSetMessagesMailboxesUpdatesCom
 import org.apache.james.utils.TestIMAPClient;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class MemoryIMAPSetMessagesCompatibilityTest extends MemoryBase 
implements ImapSetMessagesMailboxesUpdatesCompatibilityContract {
+public class MemoryIMAPSetMessagesCompatibilityTest extends PerClassMemoryBase 
implements ImapSetMessagesMailboxesUpdatesCompatibilityContract {
     @RegisterExtension
     TestIMAPClient testIMAPClient = new TestIMAPClient();
 


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

Reply via email to