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

    [BUILD] VacationRelayIntegrationTest: isolate using different users
---
 .../DistributedVacationRelayIntegrationTest.java   |  1 +
 .../contract/VacationRelayIntegrationTest.scala    | 26 +++++++++++++++-------
 .../memory/MemoryVacationRelayIntegrationTest.java |  1 +
 3 files changed, 20 insertions(+), 8 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/DistributedVacationRelayIntegrationTest.java
 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedVacationRelayIntegrationTest.java
index 5faa711369..f67d309308 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedVacationRelayIntegrationTest.java
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedVacationRelayIntegrationTest.java
@@ -64,6 +64,7 @@ public class DistributedVacationRelayIntegrationTest 
implements VacationRelayInt
         .server(configuration -> 
CassandraRabbitMQJamesServerMain.createServer(configuration)
             .overrideWith(new TestJMAPServerModule(), new 
DelegationProbeModule(), new IdentityProbeModule())
             .overrideWith((binder -> 
binder.bind(DNSService.class).toInstance(inMemoryDNSService))))
+        .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
         .build();
 
     @Override
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/VacationRelayIntegrationTest.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationRelayIntegrationTest.scala
index c27c782ad9..a607109521 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationRelayIntegrationTest.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/VacationRelayIntegrationTest.scala
@@ -19,17 +19,19 @@
 
 package org.apache.james.jmap.rfc8621.contract
 
+import java.util.UUID
 import java.util.concurrent.TimeUnit
 
 import com.github.fge.lambdas.Throwing
 import org.apache.commons.net.smtp.SMTPClient
 import org.apache.james.GuiceJamesServer
 import org.apache.james.core.MailAddress
+import org.apache.james.core.Username
 import org.apache.james.dnsservice.api.InMemoryDNSService
 import org.apache.james.jmap.JMAPTestingConstants.{DOMAIN, LOCALHOST_IP, 
calmlyAwait}
 import org.apache.james.jmap.JmapGuiceProbe
 import org.apache.james.jmap.api.model.AccountId
-import 
org.apache.james.jmap.rfc8621.contract.VacationRelayIntegrationTest.{PASSWORD, 
REASON, USER_WITH_DOMAIN}
+import 
org.apache.james.jmap.rfc8621.contract.VacationRelayIntegrationTest.{PASSWORD, 
REASON}
 import org.apache.james.junit.categories.BasicFeature
 import org.apache.james.mailbox.DefaultMailboxes
 import org.apache.james.mailbox.model.MailboxConstants
@@ -44,29 +46,37 @@ import org.assertj.core.api.SoftAssertions
 import org.junit.experimental.categories.Category
 import org.junit.jupiter.api.{AfterEach, BeforeEach, Test}
 
+object VacationRelayIntegrationTestContext {
+  val currentUsername: java.util.concurrent.atomic.AtomicReference[String] = 
new java.util.concurrent.atomic.AtomicReference[String]()
+}
+
 object VacationRelayIntegrationTest {
-  private val USER = "benwa"
-  private val USER_WITH_DOMAIN = USER + '@' + DOMAIN
   private val PASSWORD = "secret"
   private val REASON = "Message explaining my wonderful vacations"
 }
 
 trait VacationRelayIntegrationTest {
+  import VacationRelayIntegrationTestContext.currentUsername
+
+  def userWithDomain: String = currentUsername.get()
+
   def getFakeSmtp: MockSmtpServerExtension
   def getInMemoryDns: InMemoryDNSService
 
   @BeforeEach
   def setUp(server: GuiceJamesServer): Unit = {
+    val user = s"user${UUID.randomUUID().toString.replace("-", 
"").take(8)}@$DOMAIN"
+    currentUsername.set(user)
     getInMemoryDns.registerMxRecord("yopmail.com", 
getFakeSmtp.getMockSmtp.getIPAddress)
 
     server.getProbe(classOf[DataProbeImpl])
       .fluent
       .addDomain(DOMAIN)
-      .addUser(USER_WITH_DOMAIN, PASSWORD)
+      .addUser(user, PASSWORD)
 
     val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
-    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, 
USER_WITH_DOMAIN, DefaultMailboxes.SENT)
-    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, 
USER_WITH_DOMAIN, DefaultMailboxes.INBOX)
+    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, user, 
DefaultMailboxes.SENT)
+    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, user, 
DefaultMailboxes.INBOX)
   }
 
   @AfterEach
@@ -79,7 +89,7 @@ trait VacationRelayIntegrationTest {
   @Test
   def forwardingAnEmailShouldWork(server: GuiceJamesServer): Unit = {
     server.getProbe(classOf[JmapGuiceProbe])
-      .modifyVacation(AccountId.fromString(USER_WITH_DOMAIN), 
VacationPatch.builder.isEnabled(true).textBody(REASON).build)
+      .modifyVacation(AccountId.fromString(userWithDomain), 
VacationPatch.builder.isEnabled(true).textBody(REASON).build)
 
     val externalMail = "[email protected]"
 
@@ -88,7 +98,7 @@ trait VacationRelayIntegrationTest {
     smtpClient.connect(LOCALHOST_IP, 
server.getProbe(classOf[SmtpGuiceProbe]).getSmtpPort.getValue)
     smtpClient.helo(DOMAIN)
     smtpClient.setSender(externalMail)
-    smtpClient.rcpt("<" + USER_WITH_DOMAIN + ">")
+    smtpClient.rcpt("<" + userWithDomain + ">")
     smtpClient.sendShortMessageData("From: " + externalMail + 
"\r\n\r\nReply-To: <" + externalMail + ">\r\n\r\ncontent")
     calmlyAwait.atMost(1, TimeUnit.MINUTES).untilAsserted(() => {
       val mails = getFakeSmtp.getMockSmtp.getConfigurationClient.listMails
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/MemoryVacationRelayIntegrationTest.java
 
b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryVacationRelayIntegrationTest.java
index 4035d34528..52a8f20c80 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryVacationRelayIntegrationTest.java
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryVacationRelayIntegrationTest.java
@@ -51,6 +51,7 @@ public class MemoryVacationRelayIntegrationTest implements 
VacationRelayIntegrat
         .server(configuration -> 
MemoryJamesServerMain.createServer(configuration)
             .overrideWith(new TestJMAPServerModule(), new 
DelegationProbeModule(), new IdentityProbeModule())
             .overrideWith((binder -> 
binder.bind(DNSService.class).toInstance(inMemoryDNSService))))
+        .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
         .build();
 
     @Override


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

Reply via email to