diff --git a/core/src/main/java/org/testcontainers/containers/output/OutputFrame.java b/core/src/main/java/org/testcontainers/containers/output/OutputFrame.java index 9948bb451d1..d5ddcada8c8 100644 --- a/core/src/main/java/org/testcontainers/containers/output/OutputFrame.java +++ b/core/src/main/java/org/testcontainers/containers/output/OutputFrame.java @@ -30,7 +30,7 @@ public byte[] getBytes() { public String getUtf8String() { if (bytes == null) { - return null; + return ""; } return new String(bytes, Charsets.UTF_8); diff --git a/modules/jdbc-test/pom.xml b/modules/jdbc-test/pom.xml index d025dc7780f..2ce69f20476 100644 --- a/modules/jdbc-test/pom.xml +++ b/modules/jdbc-test/pom.xml @@ -34,7 +34,7 @@ org.postgresql postgresql - 9.3-1101-jdbc41 + 42.0.0 test diff --git a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java index 725f73d639c..f8229f4131c 100644 --- a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java +++ b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java @@ -1,11 +1,17 @@ package org.testcontainers.containers; +import org.testcontainers.containers.wait.LogMessageWaitStrategy; + +import java.time.Duration; + +import static java.time.temporal.ChronoUnit.SECONDS; + /** * @author richardnorth */ public class PostgreSQLContainer> extends JdbcDatabaseContainer { - public static final String NAME = "postgresql"; - public static final String IMAGE = "postgres"; + static final String NAME = "postgresql"; + static final String IMAGE = "postgres"; public static final Integer POSTGRESQL_PORT = 5432; private String databaseName = "test"; private String username = "test"; @@ -17,6 +23,10 @@ public PostgreSQLContainer() { public PostgreSQLContainer(final String dockerImageName) { super(dockerImageName); + this.waitStrategy = new LogMessageWaitStrategy() + .withRegEx(".*database system is ready to accept connections.*\\s") + .withTimes(2) + .withStartupTimeout(Duration.of(60, SECONDS)); } @Override @@ -73,4 +83,9 @@ public SELF withPassword(final String password) { this.password = password; return self(); } + + @Override + protected void waitUntilContainerStarted() { + getWaitStrategy().waitUntilReady(this); + } }