Skip to content

Commit

Permalink
Override the default WaitStrategy (HostPortWaitStrategy), which doesn…
Browse files Browse the repository at this point in the history
…'t work on Windows, yet.

See the InternalCommandPortListeningCheck.
  • Loading branch information
gesellix committed Aug 28, 2024
1 parent 1995df5 commit 59f11a3
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Test;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
import org.zeroturnaround.exec.ProcessExecutor;
import org.zeroturnaround.exec.ProcessResult;

Expand Down Expand Up @@ -105,7 +106,22 @@ public static void main(String[] args) {

GenericContainer<?> container = new GenericContainer<>("testcontainers/helloworld:sha-141af7909907e04b124e691d3cd6fc7c32da2207")
.withNetwork(org.testcontainers.containers.Network.newNetwork())
.withExposedPorts(8080);
.withExposedPorts(8080)

// Override the default WaitStrategy (HostPortWaitStrategy),
// which doesn't work on Windows, yet.
// See the InternalCommandPortListeningCheck.
.waitingFor(new AbstractWaitStrategy(){

@Override
protected void waitUntilReady() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});

container.start();
}
Expand Down

0 comments on commit 59f11a3

Please sign in to comment.