From f4856a039fba674ca0600aa9c914c2e80d75e609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez=20Gonzales?= Date: Fri, 18 Aug 2023 12:50:05 -0600 Subject: [PATCH] Rename forListeningPort(int... port) to forListeningPorts(int... ports) (#7425) --- .../containers/wait/strategy/HostPortWaitStrategy.java | 10 +++++----- .../testcontainers/containers/wait/strategy/Wait.java | 8 ++++---- .../junit/wait/strategy/HostPortWaitStrategyTest.java | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/testcontainers/containers/wait/strategy/HostPortWaitStrategy.java b/core/src/main/java/org/testcontainers/containers/wait/strategy/HostPortWaitStrategy.java index 878eb10f132..5f7eb92818c 100644 --- a/core/src/main/java/org/testcontainers/containers/wait/strategy/HostPortWaitStrategy.java +++ b/core/src/main/java/org/testcontainers/containers/wait/strategy/HostPortWaitStrategy.java @@ -26,13 +26,13 @@ @Slf4j public class HostPortWaitStrategy extends AbstractWaitStrategy { - private int[] port; + private int[] ports; @Override @SneakyThrows(InterruptedException.class) protected void waitUntilReady() { final Set externalLivenessCheckPorts; - if (this.port == null) { + if (this.ports == null || this.ports.length == 0) { externalLivenessCheckPorts = getLivenessCheckPorts(); if (externalLivenessCheckPorts.isEmpty()) { if (log.isDebugEnabled()) { @@ -46,7 +46,7 @@ protected void waitUntilReady() { } else { externalLivenessCheckPorts = Arrays - .stream(this.port) + .stream(this.ports) .mapToObj(port -> waitStrategyTarget.getMappedPort(port)) .collect(Collectors.toSet()); } @@ -124,8 +124,8 @@ private Set getInternalPorts(Set externalLivenessCheckPorts, L .collect(Collectors.toSet()); } - public HostPortWaitStrategy forPort(int... port) { - this.port = port; + public HostPortWaitStrategy forPorts(int... ports) { + this.ports = ports; return this; } } diff --git a/core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java b/core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java index 1ec858e3fbb..5a70c7f2fbc 100644 --- a/core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java +++ b/core/src/main/java/org/testcontainers/containers/wait/strategy/Wait.java @@ -26,13 +26,13 @@ public static HostPortWaitStrategy forListeningPort() { } /** - * Convenience method to return a WaitStrategy for an exposed or mapped port. + * Convenience method to return a WaitStrategy for exposed or mapped ports. * - * @param port the port to check + * @param ports the port to check * @return the WaitStrategy */ - public static HostPortWaitStrategy forListeningPort(int... port) { - return new HostPortWaitStrategy().forPort(port); + public static HostPortWaitStrategy forListeningPorts(int... ports) { + return new HostPortWaitStrategy().forPorts(ports); } /** diff --git a/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java b/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java index 79b40ee03b4..bed23566899 100644 --- a/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java +++ b/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java @@ -37,7 +37,7 @@ public static class ExplicitHostPortWaitStrategyTest { .withExposedPorts() .withCommand("sh", "-c", "while true; do nc -lp 8080; done") .withExposedPorts(8080) - .waitingFor(Wait.forListeningPort(8080).withStartupTimeout(Duration.ofSeconds(10))); + .waitingFor(Wait.forListeningPorts(8080).withStartupTimeout(Duration.ofSeconds(10))); @Test public void testWaiting() {}