Skip to content

Commit

Permalink
Ensure camel-quarkus-integration-wiremock-support is test scope
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed May 25, 2021
1 parent 179bf3a commit 1a95c39
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions integration-tests/digitalocean/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-wiremock-support</artifactId>
<scope>test</scope>
</dependency>

<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,32 @@
*/
package org.apache.camel.quarkus.component.digitalocean.it;

import com.github.tomakehurst.wiremock.http.HttpClientFactory;
import com.myjeeva.digitalocean.impl.DigitalOceanClient;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.DefaultRoutePlanner;
import org.apache.http.impl.conn.DefaultSchemePortResolver;
import org.apache.http.protocol.HttpContext;

public class DigitalOceanClientMock extends DigitalOceanClient {

public DigitalOceanClientMock(String authToken, String apiHost) {
super(authToken);
this.apiHost = apiHost;
this.httpClient = HttpClientFactory.createClient();
this.httpClient = HttpClients.custom()
.setRoutePlanner(new DefaultRoutePlanner(DefaultSchemePortResolver.INSTANCE) {
@Override
public HttpRoute determineRoute(HttpHost host, HttpRequest request, HttpContext context)
throws HttpException {
// Override DigitalOceanClient forcing HTTPS
HttpHost httpSchemeHost = new HttpHost(host.getHostName(), host.getPort(), "http");
return super.determineRoute(httpSchemeHost, request, context);
}
})
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class DigitaloceanRoute extends RouteBuilder {
@Unremovable
@Named("digitalOceanClient")
DigitalOceanClient initDigitalOceanClient(MockApiService mockApiService) {
Optional<String> wireMockUrl = ConfigProvider.getConfig().getOptionalValue("wiremock.url.ssl", String.class);
Optional<String> wireMockUrl = ConfigProvider.getConfig().getOptionalValue("wiremock.url", String.class);
if (wireMockUrl.isPresent()) {
return mockApiService.createDigitalOceanClient(wireMockUrl.get(), oAuthToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
public class MockApiService {

public DigitalOceanClient createDigitalOceanClient(String wireMockUrl, String oAuthToken) {
DigitalOceanClientMock digitalOceanClient = new DigitalOceanClientMock(oAuthToken, getFormattedURI(wireMockUrl));
return digitalOceanClient;
return new DigitalOceanClientMock(oAuthToken, getFormattedURI(wireMockUrl));
}

String getFormattedURI(String wireMockUrl) {
return wireMockUrl.replaceAll("https://", "");
return wireMockUrl.replaceAll("http://", "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.camel.quarkus.component.digitalocean.it;

import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import org.apache.camel.quarkus.test.wiremock.WireMockTestResourceLifecycleManager;

public class DigitaloceanTestResource extends WireMockTestResourceLifecycleManager {
Expand All @@ -33,10 +32,4 @@ protected String getRecordTargetBaseUrl() {
protected boolean isMockingEnabled() {
return !envVarsPresent(DIGITALOCEAN_AUTH_TOKEN, DIGITALOCEAN_PUBLIC_KEY);
}

@Override
protected void customizeWiremockConfiguration(WireMockConfiguration config) {
// add an SSL port
config.dynamicHttpsPort();
}
}
5 changes: 1 addition & 4 deletions integration-tests/geocoder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@
</dependency>

<!-- dependencies needed to mock Google maps API -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-wiremock-support</artifactId>
<scope>test</scope>
</dependency>


Expand Down
1 change: 1 addition & 0 deletions integration-tests/slack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-wiremock-support</artifactId>
<scope>test</scope>
</dependency>

<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
Expand Down

0 comments on commit 1a95c39

Please sign in to comment.