From a696af771b6eea60a18d6a92dfdc53a78ff8a9be Mon Sep 17 00:00:00 2001 From: Reinhard Prechtl Date: Tue, 26 Dec 2017 20:34:04 +0100 Subject: [PATCH] Change container wait strategy Instead of waiting for a log message, wait for the listening port becoming available. After a bugfix in Testcontainers 1.5.1, this is now possible. --- .../testcontainers/infinispan/InfinispanContainer.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java b/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java index 98593d5..c443dd5 100644 --- a/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java +++ b/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java @@ -6,17 +6,13 @@ import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.exceptions.HotRodClientException; import org.junit.runner.Description; -import org.rnorth.ducttape.Preconditions; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.wait.LogMessageWaitStrategy; +import org.testcontainers.containers.wait.Wait; -import java.time.Duration; import java.util.*; import java.util.stream.IntStream; -import static java.time.temporal.ChronoUnit.SECONDS; - /** * An implementation of the {@link org.testcontainers.containers.GenericContainer} class that can be * used to easily instantiate an Infinispan server for integration tests. @@ -77,9 +73,7 @@ public class InfinispanContainer extends GenericContainer { this.withCommand(STANDALONE_MODE_CMD); withExposedPorts(Arrays.stream(InfinispanEndpoints.values()).map(endpoint -> endpoint.protocolPort).toArray(Integer[]::new)); - this.waitStrategy = new LogMessageWaitStrategy() - .withRegEx(".*Infinispan Server.*started in.*\\s") - .withStartupTimeout(Duration.of(60, SECONDS)); + this.waitStrategy = Wait.forListeningPort(); } /**