Skip to content

Commit

Permalink
Adapt to Wiremock 3.5.4 and fix tests for version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
graric committed May 22, 2024
1 parent eb7734e commit 65d737e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ A common example is using Wiremock 3.x with Java 1.8.
The module is compatible with the following WireMock versions:

- WireMock (aka WireMock Java) `2.0.0` and above
- WireMock (aka WireMock Java) `3.0.0` beta versions.
- WireMock (aka WireMock Java) `3.x` versions.
Note that the official image for WireMock 3 is yet to be released and verified ([issue #59](https://github.com/wiremock/wiremock-testcontainers-java/issues/59))

Other WireMock implementations may work but have not been tested yet.
Expand Down
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<java.version>1.8</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<wiremock.version>2.35.0</wiremock.version>
<wiremock.version>3.5.4</wiremock.version>
<testcontainers.version>1.19.0</testcontainers.version>
<junit.version>5.10.0</junit.version>
<assertj.version>3.24.2</assertj.version>
Expand Down Expand Up @@ -165,10 +165,15 @@
<version>0.4.1</version>
<classifier>jar-with-dependencies</classifier>
</artifactItem>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>${wiremock.version}</version>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-webhooks-extension</artifactId>
<version>2.35.1</version>
<version>2.35.0</version>
</dependency>
</artifactItems>
<outputDirectory>${project.build.directory}/test-wiremock-extension</outputDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class WireMockContainer extends GenericContainer<WireMockContainer> {

public static final String OFFICIAL_IMAGE_NAME = "wiremock/wiremock";
private static final String WIREMOCK_2_LATEST_TAG = "2.35.0-1";
private static final String WIREMOCK_3_LATEST_TAG = "3.0.1-1";
private static final String WIREMOCK_3_LATEST_TAG = "3.5.4";
/*package*/ static final String WIREMOCK_2_MINIMUM_SUPPORTED_VERSION = "2.0.0";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class TestConfig {

private static final String DEFAULT_TEST_TAG =
System.getProperty("wiremock.testcontainer.defaultTag", "3.1.0-1");
System.getProperty("wiremock.testcontainer.defaultTag", "3.5.4");
private static final String WIREMOCK_2_TEST_TAG =
System.getProperty("wiremock.testcontainer.wiremock2Tag", "2.35.1-1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class WireMockContainerExtensionsCombinationTest {
.withMapping("json-body-transformer", WireMockContainerExtensionsCombinationTest.class, "json-body-transformer.json")
.withExtensions("Webhook",
Collections.singleton("org.wiremock.webhooks.Webhooks"),
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-3.0.1.jar").toFile()))
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-3.5.4.jar").toFile()))
.withExtensions("JSON Body Transformer",
Collections.singleton("com.ninecookies.wiremock.extensions.JsonBodyTransformer"),
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-extensions-0.4.1-jar-with-dependencies.jar").toFile()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class WireMockContainerWebhooksTest {
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withCliArg("--global-response-templating")
.withMapping("webhook-callback-template", WireMockContainerWebhooksTest.class, "webhook-callback-template.json")
.withExtension("org.wiremock.webhooks.Webhooks")
.withAccessToHost(true); // Force the host access mechanism

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
*/
package org.wiremock.integrations.testcontainers.wiremock2;

import static org.assertj.core.api.Assertions.assertThat;
import static org.testcontainers.Testcontainers.exposeHostPorts;
import static org.testcontainers.shaded.org.awaitility.Awaitility.await;

import java.nio.file.Paths;
import java.time.Duration;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -28,14 +35,6 @@
import org.wiremock.integrations.testcontainers.testsupport.http.TestHttpClient;
import org.wiremock.integrations.testcontainers.testsupport.http.TestHttpServer;

import java.nio.file.Paths;
import java.time.Duration;
import java.util.Collections;

import static org.assertj.core.api.Assertions.assertThat;
import static org.testcontainers.Testcontainers.exposeHostPorts;
import static org.testcontainers.shaded.org.awaitility.Awaitility.await;

/**
* Tests the WireMock Webhook extension and TestContainers Networking
* For this type of tests we should use following steps:
Expand All @@ -59,14 +58,13 @@ class WebhooksExtensionTest {
TestHttpServer applicationServer = TestHttpServer.newInstance();
@Container
WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_2_IMAGE)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withCliArg("--global-response-templating")
.withMapping("webhook-callback-template", WebhooksExtensionTest.class, "webhook-callback-template.json")
.withExtensions("Webhooks",
Collections.singleton("org.wiremock.webhooks.Webhooks"),
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-2.35.1.jar").toFile()))
.withAccessToHost(true); // Force the host access mechanism

.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withCliArg("--global-response-templating")
.withMapping("webhook-callback-template", WebhooksExtensionTest.class, "webhook-callback-template.json")
.withExtensions("Webhooks",
Collections.singleton("org.wiremock.webhooks.Webhooks"),
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-2.35.0.jar").toFile()))
.withAccessToHost(true); // Force the host access mechanism

@Test
void callbackUsingJsonStub() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class WireMockContainerExtensionsCombinationTest {
.withMapping("json-body-transformer", WireMockContainerExtensionsCombinationTest.class, "json-body-transformer.json")
.withExtensions("Webhook",
Collections.singleton("org.wiremock.webhooks.Webhooks"),
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-2.35.1.jar").toFile()))
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-2.35.0.jar").toFile()))
.withExtensions("JSON Body Transformer",
Collections.singleton("com.ninecookies.wiremock.extensions.JsonBodyTransformer"),
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-extensions-0.4.1-jar-with-dependencies.jar").toFile()));
Expand Down

0 comments on commit 65d737e

Please sign in to comment.