Skip to content

Commit

Permalink
Update the tests to use WireMock 3.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev committed Aug 30, 2023
1 parent d8d31f4 commit 4c9b8a7
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-webhooks-extension</artifactId>
<version>2.35.0</version>
<version>3.0.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 @@ -47,9 +47,14 @@
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";
private static final String WIREMOCK_2_LATEST_TAG = "2.35.0-1";
private static final String WIREMOCK_3_LATEST_TAG = "3.0.0-1";
/*package*/ static final String WIREMOCK_2_MINIMUM_SUPPORTED_VERSION = "2.0.0";

/**
* @deprecated Not really guaranteed to be latest. Will be reworked
*/
@Deprecated
public static final DockerImageName WIREMOCK_2_LATEST =
DockerImageName.parse(OFFICIAL_IMAGE_NAME).withTag(WIREMOCK_2_LATEST_TAG);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.wiremock.integrations.testcontainers;

import org.testcontainers.utility.DockerImageName;

public class TestConfig {

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

public static final DockerImageName WIREMOCK_DEFAULT_IMAGE =
DockerImageName.parse(WireMockContainer.OFFICIAL_IMAGE_NAME).withTag(DEFAULT_TEST_TAG);

public static final DockerImageName WIREMOCK_2_IMAGE =
DockerImageName.parse(WireMockContainer.OFFICIAL_IMAGE_NAME).withTag(WIREMOCK_2_TEST_TAG);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class WireMockContainerBannerTest {

WireMockContainer wireMockContainer = new WireMockContainer(WireMockContainer.WIREMOCK_2_LATEST);
WireMockContainer wireMockContainer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE);

@Test
void bannerIsByDefaultDisabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class WireMockContainerExtensionTest {
private static final Logger LOGGER = LoggerFactory.getLogger(WireMockContainerExtensionTest.class);

@Container
WireMockContainer wiremockServer = new WireMockContainer(WireMockContainer.WIREMOCK_2_LATEST)
WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withStartupTimeout(Duration.ofSeconds(60))
.withMapping("json-body-transformer", WireMockContainerExtensionTest.class, "json-body-transformer.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class WireMockContainerExtensionsCombinationTest {
private static final Logger LOGGER = LoggerFactory.getLogger(WireMockContainerExtensionsCombinationTest.class);

@Container
WireMockContainer wiremockServer = new WireMockContainer(WireMockContainer.WIREMOCK_2_LATEST)
WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.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.0.jar").toFile()))
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-3.0.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
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ class WireMockContainerExtensionsWebhookTest {

TestHttpServer applicationServer = TestHttpServer.newInstance();
@Container
WireMockContainer wiremockServer = new WireMockContainer(WireMockContainer.WIREMOCK_2_LATEST)
WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withCliArg("--global-response-templating")
.withMapping("webhook-callback-template", WireMockContainerExtensionsWebhookTest.class, "webhook-callback-template.json")
.withExtensions("Webhook",
Collections.singleton("org.wiremock.webhooks.Webhooks"),
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-2.35.0.jar").toFile()))
Collections.singleton(Paths.get("target", "test-wiremock-extension", "wiremock-webhooks-extension-3.0.0.jar").toFile()))
.withAccessToHost(true); // Force the host access mechanism


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class WireMockContainerJunit4Test {

@Rule
public WireMockContainer wiremockServer = new WireMockContainer(WireMockContainer.WIREMOCK_2_LATEST)
public WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE)
.withMapping("hello", WireMockContainerTest.class, "hello-world.json")
.withMapping("hello-resource", WireMockContainerTest.class, "hello-world-resource.json")
.withFileFromResource("hello-world-resource-response.xml", WireMockContainerTest.class, "hello-world-resource-response.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class WireMockContainerTest {

@Container
WireMockContainer wiremockServer = new WireMockContainer(WireMockContainer.WIREMOCK_2_LATEST)
WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE)
.withMapping("hello", WireMockContainerTest.class, "hello-world.json")
.withMapping("hello-resource", WireMockContainerTest.class, "hello-world-resource.json")
.withFileFromResource("hello-world-resource-response.xml", WireMockContainerTest.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class WireMockContainerUnitTest {

@Test
public void shouldInitWithDefault() {
WireMockContainer container = new WireMockContainer(WireMockContainer.WIREMOCK_2_LATEST);
WireMockContainer container = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE);
}

@Test
Expand Down

0 comments on commit 4c9b8a7

Please sign in to comment.