diff --git a/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ContainerMountebankProxy.java b/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ContainerMountebankProxy.java index 4d899ba..3c8e476 100644 --- a/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ContainerMountebankProxy.java +++ b/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ContainerMountebankProxy.java @@ -20,6 +20,8 @@ * #L% */ +import java.util.Collection; + public class ContainerMountebankProxy extends MountebankProxy { private final MountebankContainer container; @@ -71,4 +73,10 @@ public String getApiUrl() { public String getImposterAuthority(int imposterPort) throws IllegalArgumentException { return container.getContainerIpAddress() + ":" + getContainer().getMappedPort(imposterPort); } + + @Override + public Collection getImposterPorts() { + return container.getImposterPorts(); + } + } diff --git a/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ExternalMountebankProxy.java b/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ExternalMountebankProxy.java index 610cba8..6feca19 100644 --- a/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ExternalMountebankProxy.java +++ b/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/ExternalMountebankProxy.java @@ -20,6 +20,7 @@ * #L% */ +import java.util.Collection; import java.util.Map; /** Facade for an externally managed instance of mountebank. */ @@ -45,4 +46,10 @@ public String getImposterAuthority(int imposterPort) throws IllegalArgumentExcep } throw new IllegalArgumentException("No mapped authority for imposter port " + imposterPort); } + + @Override + public Collection getImposterPorts() { + return imposterAuthorities.keySet(); + } + } diff --git a/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/MountebankProxy.java b/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/MountebankProxy.java index 75a9184..357d792 100644 --- a/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/MountebankProxy.java +++ b/testcontainers-proxy-mountebank/src/main/java/com/traum/mountebank/MountebankProxy.java @@ -31,6 +31,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.util.Collection; public abstract class MountebankProxy { @@ -99,4 +100,6 @@ public void saveImposters(Path impostersOutput, boolean forReplay) { public abstract String getApiUrl(); public abstract String getImposterAuthority(int imposterPort) throws IllegalArgumentException; + + public abstract Collection getImposterPorts(); } diff --git a/testcontainers-proxy-quarkus/src/main/java/com/traum/mountebank/quarkus/MountebankProxyTestResourceLifecycleManager.java b/testcontainers-proxy-quarkus/src/main/java/com/traum/mountebank/quarkus/MountebankProxyTestResourceLifecycleManager.java index e7517c8..4490a45 100644 --- a/testcontainers-proxy-quarkus/src/main/java/com/traum/mountebank/quarkus/MountebankProxyTestResourceLifecycleManager.java +++ b/testcontainers-proxy-quarkus/src/main/java/com/traum/mountebank/quarkus/MountebankProxyTestResourceLifecycleManager.java @@ -29,22 +29,25 @@ public class MountebankProxyTestResourceLifecycleManager implements QuarkusTestResourceLifecycleManager { - private final ContainerMountebankProxy proxy; + private final MountebankProxy proxy; public MountebankProxyTestResourceLifecycleManager() { this(new Integer[0]); } public MountebankProxyTestResourceLifecycleManager(Integer... imposterPorts) { - proxy = new ContainerMountebankProxy(imposterPorts); + this(new ContainerMountebankProxy(imposterPorts)); + } + + public MountebankProxyTestResourceLifecycleManager(MountebankProxy proxy) { + this.proxy = proxy; } @Override public Map start() { - proxy.start(); + getProxy().start(); System.setProperty(MountebankExtension.EXTERNAL_PROXY_API_URL_PROPERTY, proxy.getApiUrl()); - proxy - .getContainer() + getProxy() .getImposterPorts() .forEach( port -> {