File tree 4 files changed +43
-11
lines changed
main/java/org/wiremock/integrations/testcontainers
test/java/org/wiremock/integrations/testcontainers
4 files changed +43
-11
lines changed Original file line number Diff line number Diff line change 33
33
<maven .compiler.target>${java.version} </maven .compiler.target>
34
34
<maven .compiler.source>${java.version} </maven .compiler.source>
35
35
<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>
38
38
<assertj .version>3.26.3</assertj .version>
39
39
<awaitility .version>4.2.2</awaitility .version>
40
40
<project .scm.id>github</project .scm.id>
67
67
<!-- Fix dependency convergence [logback-classic vs junit] -->
68
68
<groupId >org.slf4j</groupId >
69
69
<artifactId >slf4j-api</artifactId >
70
- <version >2.0.15 </version >
70
+ <version >2.0.17 </version >
71
71
</dependency >
72
72
</dependencies >
73
73
</dependencyManagement >
147
147
<plugin >
148
148
<groupId >org.apache.maven.plugins</groupId >
149
149
<artifactId >maven-javadoc-plugin</artifactId >
150
- <version >3.8.0 </version >
150
+ <version >3.11.2 </version >
151
151
<executions >
152
152
<execution >
153
153
<id >attach-javadocs</id >
237
237
<id >release</id >
238
238
<properties >
239
239
<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>
241
241
</properties >
242
242
<build >
243
243
<pluginManagement >
Original file line number Diff line number Diff line change @@ -63,16 +63,18 @@ public class WireMockContainer extends GenericContainer<WireMockContainer> {
63
63
private static final String FILES_DIR = "/home/wiremock/__files/" ;
64
64
65
65
private static final String EXTENSIONS_DIR = "/var/wiremock/extensions/" ;
66
+ private static final int PORT = 8080 ;
66
67
private static final WaitStrategy DEFAULT_WAITER = Wait
67
68
.forHttp ("/__admin/mappings" )
68
69
.withMethod ("GET" )
69
- .forStatusCode (200 );
70
+ .forStatusCode (200 )
71
+ .forPort (PORT );
70
72
71
73
private static final WaitStrategy HEALTH_CHECK_ENDPOINT_WAITER = Wait
72
74
.forHttp ("/__admin/health" )
73
75
.withMethod ("GET" )
74
- .forStatusCode (200 );
75
- private static final int PORT = 8080 ;
76
+ .forStatusCode (200 )
77
+ . forPort ( PORT ) ;
76
78
private final StringBuilder wireMockArgs ;
77
79
private final Map <String , Stub > mappingStubs = new HashMap <>();
78
80
private final Map <String , MountableFile > mappingFiles = new HashMap <>();
@@ -371,7 +373,7 @@ public Integer getPort() {
371
373
@ Override
372
374
protected void configure () {
373
375
super .configure ();
374
- withExposedPorts (PORT );
376
+ addExposedPorts (PORT );
375
377
for (Stub stub : mappingStubs .values ()) {
376
378
withCopyToContainer (Transferable .of (stub .json ), MAPPINGS_DIR + stub .name + ".json" );
377
379
}
Original file line number Diff line number Diff line change 24
24
25
25
public class WireMockContainerJunit4Test {
26
26
27
+ private static final int WIREMOCK_DEFAULT_PORT = 8080 ;
28
+ private static final int ADDITIONAL_MAPPED_PORT = 8443 ;
29
+
27
30
@ Rule
28
31
public WireMockContainer wiremockServer = new WireMockContainer (TestConfig .WIREMOCK_DEFAULT_IMAGE )
29
32
.withMapping ("hello" , WireMockContainerTest .class , "hello-world.json" )
30
33
.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 );
32
36
33
37
@ Test
34
38
public void helloWorld () throws Exception {
@@ -71,4 +75,15 @@ public void helloWorldFromFile() throws Exception {
71
75
.as ("Wrong response body" )
72
76
.contains ("Hello, world!" );
73
77
}
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
+ }
74
89
}
Original file line number Diff line number Diff line change 28
28
@ Testcontainers (parallel = true )
29
29
class WireMockContainerTest {
30
30
31
+ private static final int WIREMOCK_DEFAULT_PORT = 8080 ;
32
+ private static final int ADDITIONAL_MAPPED_PORT = 8443 ;
33
+
31
34
@ Container
32
35
WireMockContainer wiremockServer = new WireMockContainer (TestConfig .WIREMOCK_DEFAULT_IMAGE )
33
36
.withMapping ("hello" , WireMockContainerTest .class , "hello-world.json" )
34
37
.withMapping ("hello-resource" , WireMockContainerTest .class , "hello-world-resource.json" )
35
38
.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 );
37
41
38
42
39
43
@ ParameterizedTest
@@ -67,4 +71,15 @@ void helloWorldFromFile() throws Exception {
67
71
.as ("Wrong response body" )
68
72
.contains ("Hello, world!" );
69
73
}
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
+ }
70
85
}
You can’t perform that action at this time.
0 commit comments