diff --git a/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/java/com/linagora/tmail/james/MemoryCalendarEventReplyWithAMQPWorkflowTest.java b/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/java/com/linagora/tmail/james/MemoryCalendarEventReplyWithAMQPWorkflowTest.java index c13b0f87c5..cf3c2555d3 100644 --- a/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/java/com/linagora/tmail/james/MemoryCalendarEventReplyWithAMQPWorkflowTest.java +++ b/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/java/com/linagora/tmail/james/MemoryCalendarEventReplyWithAMQPWorkflowTest.java @@ -3,11 +3,14 @@ import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.DEFAULT; import java.io.File; -import java.nio.charset.StandardCharsets; +import java.io.FileInputStream; +import java.net.URI; import java.nio.file.Path; import java.util.Optional; import java.util.UUID; +import jakarta.inject.Singleton; + import org.apache.commons.io.FileUtils; import org.apache.james.JamesServerBuilder; import org.apache.james.JamesServerExtension; @@ -16,6 +19,12 @@ import org.junit.jupiter.api.extension.RegisterExtension; import com.github.fge.lambdas.Throwing; +import com.google.inject.AbstractModule; +import com.google.inject.Module; +import com.google.inject.Provides; +import com.linagora.tmail.AmqpUri; +import com.linagora.tmail.OpenPaasModule; +import com.linagora.tmail.configuration.OpenPaasConfiguration; import com.linagora.tmail.james.app.MemoryConfiguration; import com.linagora.tmail.james.app.MemoryServer; import com.linagora.tmail.james.common.LinagoraCalendarEventReplyWithAMQPWorkflowContract; @@ -38,12 +47,12 @@ public class MemoryCalendarEventReplyWithAMQPWorkflowTest implements LinagoraCal Throwing.runnable(() -> FileUtils.copyDirectory(new File(ClassLoader.getSystemClassLoader().getResource(".").getFile()), confPath.toFile())).run(); - // Replace amqp uri in the mailetcontainer_with_amqpforward_openpass.xml and write it to mailetcontainer.xml - Throwing.runnable(() -> { - String sourceContent = FileUtils.readFileToString(confPath.resolve("mailetcontainer_with_amqpforward_openpass.xml").toFile(), StandardCharsets.UTF_8); - String newContent = sourceContent.replace("{{AmqpForwardAttribute_uri}}", amqpExtension.getAmqpUri()); - FileUtils.writeStringToFile(confPath.resolve("mailetcontainer.xml").toFile(), newContent, StandardCharsets.UTF_8); - }).run(); + // Write content of mailetcontainer_with_amqpforward_openpass.xml to mailetcontainer.xml. + Throwing.runnable(() -> + FileUtils.copyToFile( + new FileInputStream(confPath.resolve("mailetcontainer_with_amqpforward_openpass.xml").toFile()), + confPath.resolve("mailetcontainer.xml").toFile() + )).run(); System.out.println("confPath: " + confPath); return MemoryConfiguration.builder() @@ -53,7 +62,12 @@ public class MemoryCalendarEventReplyWithAMQPWorkflowTest implements LinagoraCal .build(); }) .server(configuration -> MemoryServer.createServer(configuration) - .overrideWith(new LinagoraTestJMAPServerModule(), new DelegationProbeModule())) + .combineWith(new OpenPaasModule()) + .overrideWith( + new LinagoraTestJMAPServerModule(), + new DelegationProbeModule(), + provideOpenPaasConfigurationModule(amqpExtension.getAmqpUri())) + ) .build(); @Override @@ -65,4 +79,20 @@ public String randomBlobId() { public Optional readAMQPContent() { return Throwing.supplier(() -> amqpExtension.readContent()).get(); } + + private static Module provideOpenPaasConfigurationModule(String amqpUri) { + return new AbstractModule() { + @Provides + @Singleton + public OpenPaasConfiguration provideOpenPaasConfiguration() { + return new OpenPaasConfiguration( + AmqpUri.from(amqpUri), + URI.create("http://localhost:8081"), + "user", + "password" + ); + } + }; + + } } diff --git a/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/resources/mailetcontainer_with_amqpforward_openpass.xml b/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/resources/mailetcontainer_with_amqpforward_openpass.xml index 3c2219a179..99f7c30291 100644 --- a/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/resources/mailetcontainer_with_amqpforward_openpass.xml +++ b/tmail-backend/integration-tests/jmap/memory-jmap-integration-tests/src/test/resources/mailetcontainer_with_amqpforward_openpass.xml @@ -56,13 +56,11 @@ rawIcalendar2 ignore - - {{AmqpForwardAttribute_uri}} + + icalendarAsJson2 james:events fanout - icalendarAsJson2 icalendar_routing_key2 - ignore