Skip to content

Commit

Permalink
Fix testing guide's example for Testcontainers
Browse files Browse the repository at this point in the history
Fixes quarkusio#26573
If container.start() is missing, it will fail with "java.lang.IllegalStateException: Mapped port can only be obtained
after the container is started", or can get a NPE at a later phase of execution, if no call to retrieving port info is
made

(cherry picked from commit 46eb5b7)
  • Loading branch information
peterhuba authored and gsmet committed Jul 18, 2022
1 parent d4c724b commit 3ba71e9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/src/main/asciidoc/getting-started-testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,9 @@ public class CustomResource implements QuarkusTestResourceLifecycleManager, DevS
// apply the network to the container
containerNetworkId.ifPresent(container::withNetworkMode);
// start container before retrieving its URL or other properties
container.start();
String jdbcUrl = container.getJdbcUrl();
if (containerNetworkId.isPresent()) {
// Replace hostname + port in the provided JDBC URL with the hostname of the Docker container
Expand Down

0 comments on commit 3ba71e9

Please sign in to comment.