Skip to content

Commit

Permalink
allow overriding proxy handle in test resource
Browse files Browse the repository at this point in the history
  • Loading branch information
schulzp committed Jun 24, 2020
1 parent bad55ea commit e80108a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* #L%
*/

import java.util.Collection;

public class ContainerMountebankProxy extends MountebankProxy {

private final MountebankContainer container;
Expand Down Expand Up @@ -71,4 +73,10 @@ public String getApiUrl() {
public String getImposterAuthority(int imposterPort) throws IllegalArgumentException {
return container.getContainerIpAddress() + ":" + getContainer().getMappedPort(imposterPort);
}

@Override
public Collection<Integer> getImposterPorts() {
return container.getImposterPorts();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* #L%
*/

import java.util.Collection;
import java.util.Map;

/** Facade for an externally managed instance of mountebank. */
Expand All @@ -45,4 +46,10 @@ public String getImposterAuthority(int imposterPort) throws IllegalArgumentExcep
}
throw new IllegalArgumentException("No mapped authority for imposter port " + imposterPort);
}

@Override
public Collection<Integer> getImposterPorts() {
return imposterAuthorities.keySet();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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<Integer> getImposterPorts();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> start() {
proxy.start();
getProxy().start();
System.setProperty(MountebankExtension.EXTERNAL_PROXY_API_URL_PROPERTY, proxy.getApiUrl());
proxy
.getContainer()
getProxy()
.getImposterPorts()
.forEach(
port -> {
Expand Down

0 comments on commit e80108a

Please sign in to comment.