package io.quarkus.it.mailer;

import java.util.HashMap;
import java.util.Map;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;

public class FakeMailerTestResource implements QuarkusTestResourceLifecycleManager {

    public GenericContainer<?> server = new GenericContainer<>("reachfive/fake-smtp-server:latest")
            .withExposedPorts(1080, 1025)
            .waitingFor(Wait.forHttp("/api/emails"));

    @Override
    public Map<String, String> start() {
        server.start();
        HashMap<String, String> properties = new HashMap<>();
        properties.put("quarkus.mailer.port", Integer.toString(server.getMappedPort(1025)));
        properties.put("quarkus.mailer.host", server.getContainerIpAddress());
        properties.put("fake.mailer", server.getContainerIpAddress() + ":" + server.getMappedPort(1080));
        //        properties.put("quarkus.mailer.port", Integer.toString(32787));
        //        properties.put("quarkus.mailer.host", "localhost");
        //        properties.put("fake.mailer", "localhost" + ":" + 32786);
        return properties;
    }

    @Override
    public void stop() {
        server.close();
    }
}

@@ -73,16 +73,84 @@
 l.Map;%0A%0A
+import org.testcontainers.containers.FixedHostPortGenericContainer;%0A
 import o
@@ -452,16 +452,29 @@
 r = new 
+FixedHostPort
 GenericC
@@ -538,16 +538,21 @@
    .with
+Fixed
 ExposedP
@@ -558,14 +558,59 @@
 Port
-s(1080
+(9155, 1080)%0A            .withFixedExposedPort(9156
 , 10

Use fixed port for mailer test