Skip to content

Commit d34525c

Browse files
Merge branch 'main' into dependabot/maven/org.apache.maven.plugins-maven-release-plugin-3.1.1
2 parents d9f5658 + 7849fbd commit d34525c

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed

Diff for: pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
<maven.compiler.target>${java.version}</maven.compiler.target>
3434
<maven.compiler.source>${java.version}</maven.compiler.source>
3535
<wiremock.version>3.5.4</wiremock.version>
36-
<testcontainers.version>1.19.8</testcontainers.version>
37-
<junit.version>5.10.2</junit.version>
36+
<testcontainers.version>1.20.3</testcontainers.version>
37+
<junit.version>5.12.1</junit.version>
3838
<assertj.version>3.26.3</assertj.version>
3939
<awaitility.version>4.2.2</awaitility.version>
4040
<project.scm.id>github</project.scm.id>
@@ -67,7 +67,7 @@
6767
<!-- Fix dependency convergence [logback-classic vs junit] -->
6868
<groupId>org.slf4j</groupId>
6969
<artifactId>slf4j-api</artifactId>
70-
<version>2.0.15</version>
70+
<version>2.0.17</version>
7171
</dependency>
7272
</dependencies>
7373
</dependencyManagement>
@@ -147,7 +147,7 @@
147147
<plugin>
148148
<groupId>org.apache.maven.plugins</groupId>
149149
<artifactId>maven-javadoc-plugin</artifactId>
150-
<version>3.8.0</version>
150+
<version>3.11.2</version>
151151
<executions>
152152
<execution>
153153
<id>attach-javadocs</id>
@@ -237,7 +237,7 @@
237237
<id>release</id>
238238
<properties>
239239
<version.maven-release-plugin>3.1.1</version.maven-release-plugin>
240-
<version.maven-gpg-plugin>3.2.4</version.maven-gpg-plugin>
240+
<version.maven-gpg-plugin>3.2.7</version.maven-gpg-plugin>
241241
</properties>
242242
<build>
243243
<pluginManagement>

Diff for: src/main/java/org/wiremock/integrations/testcontainers/WireMockContainer.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,18 @@ public class WireMockContainer extends GenericContainer<WireMockContainer> {
6363
private static final String FILES_DIR = "/home/wiremock/__files/";
6464

6565
private static final String EXTENSIONS_DIR = "/var/wiremock/extensions/";
66+
private static final int PORT = 8080;
6667
private static final WaitStrategy DEFAULT_WAITER = Wait
6768
.forHttp("/__admin/mappings")
6869
.withMethod("GET")
69-
.forStatusCode(200);
70+
.forStatusCode(200)
71+
.forPort(PORT);
7072

7173
private static final WaitStrategy HEALTH_CHECK_ENDPOINT_WAITER = Wait
7274
.forHttp("/__admin/health")
7375
.withMethod("GET")
74-
.forStatusCode(200);
75-
private static final int PORT = 8080;
76+
.forStatusCode(200)
77+
.forPort(PORT);
7678
private final StringBuilder wireMockArgs;
7779
private final Map<String, Stub> mappingStubs = new HashMap<>();
7880
private final Map<String, MountableFile> mappingFiles = new HashMap<>();
@@ -371,7 +373,7 @@ public Integer getPort() {
371373
@Override
372374
protected void configure() {
373375
super.configure();
374-
withExposedPorts(PORT);
376+
addExposedPorts(PORT);
375377
for (Stub stub : mappingStubs.values()) {
376378
withCopyToContainer(Transferable.of(stub.json), MAPPINGS_DIR + stub.name + ".json");
377379
}

Diff for: src/test/java/org/wiremock/integrations/testcontainers/WireMockContainerJunit4Test.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424

2525
public class WireMockContainerJunit4Test {
2626

27+
private static final int WIREMOCK_DEFAULT_PORT = 8080;
28+
private static final int ADDITIONAL_MAPPED_PORT = 8443;
29+
2730
@Rule
2831
public WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE)
2932
.withMapping("hello", WireMockContainerTest.class, "hello-world.json")
3033
.withMapping("hello-resource", WireMockContainerTest.class, "hello-world-resource.json")
31-
.withFileFromResource("hello-world-resource-response.xml", WireMockContainerTest.class, "hello-world-resource-response.xml");
34+
.withFileFromResource("hello-world-resource-response.xml", WireMockContainerTest.class, "hello-world-resource-response.xml")
35+
.withExposedPorts(ADDITIONAL_MAPPED_PORT);
3236

3337
@Test
3438
public void helloWorld() throws Exception {
@@ -71,4 +75,15 @@ public void helloWorldFromFile() throws Exception {
7175
.as("Wrong response body")
7276
.contains("Hello, world!");
7377
}
78+
79+
@Test
80+
public void customPortsAreExposed() {
81+
//given
82+
83+
//when
84+
85+
//then
86+
assertThat(wiremockServer.getExposedPorts())
87+
.contains(WIREMOCK_DEFAULT_PORT, ADDITIONAL_MAPPED_PORT);
88+
}
7489
}

Diff for: src/test/java/org/wiremock/integrations/testcontainers/WireMockContainerTest.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@
2828
@Testcontainers(parallel = true)
2929
class WireMockContainerTest {
3030

31+
private static final int WIREMOCK_DEFAULT_PORT = 8080;
32+
private static final int ADDITIONAL_MAPPED_PORT = 8443;
33+
3134
@Container
3235
WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_DEFAULT_IMAGE)
3336
.withMapping("hello", WireMockContainerTest.class, "hello-world.json")
3437
.withMapping("hello-resource", WireMockContainerTest.class, "hello-world-resource.json")
3538
.withFileFromResource("hello-world-resource-response.xml", WireMockContainerTest.class,
36-
"hello-world-resource-response.xml");
39+
"hello-world-resource-response.xml")
40+
.withExposedPorts(ADDITIONAL_MAPPED_PORT);
3741

3842

3943
@ParameterizedTest
@@ -67,4 +71,15 @@ void helloWorldFromFile() throws Exception {
6771
.as("Wrong response body")
6872
.contains("Hello, world!");
6973
}
74+
75+
@Test
76+
void customPortsAreExposed() {
77+
//given
78+
79+
//when
80+
81+
//then
82+
assertThat(wiremockServer.getExposedPorts())
83+
.contains(WIREMOCK_DEFAULT_PORT, ADDITIONAL_MAPPED_PORT);
84+
}
7085
}

0 commit comments

Comments
 (0)