Hi guys,
thanks for your productive answers. I managed to mock the Camunda HttpConnector calls, here's how I did it:
1. Use WireMock by simply using the
get started page via the JUnit rule.
2. Since WireMock runs a server for backing the mocks on http://
localhost:8089, a call to http://
my-service:8089/myresource won't work
Therefore I used a ConnectorConfigurator like @Daniel
suggested to intercept all HttpConnector calls and overwrite all hostnames to localhost.
HttpEntityEnclosingRequestBase httpTarget = ((HttpEntityEnclosingRequestBase) invocation.getTarget());
URI oldUri = httpTarget.getURI();
httpTarget.setURI(resetUriToLocalhost(oldUri));
System.out.println("Http-Connector target url changed from: " + oldUri.toString() + " to: " + httpTarget.getURI().toString());
return invocation.proceed();
public URI resetUriToLocalhost(URI uri) {
try {
URI newUri = new URI(uri.getScheme(), uri.getUserInfo(), "localhost", uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
return newUri;
} catch (URISyntaxException e) {
System.out.println("Updating URI port failed");
e.printStackTrace();
return uri;
}
}
}
PS: This works only for one mocked service, multiple ones could be managed by using the WireMock API directly instead of the JUnit Rule.