diff --git a/drivers/jdbc/lib/build.gradle.kts b/drivers/jdbc/lib/build.gradle.kts index 0b63bc5a6..4965c2a59 100644 --- a/drivers/jdbc/lib/build.gradle.kts +++ b/drivers/jdbc/lib/build.gradle.kts @@ -38,13 +38,17 @@ dependencies { testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") testRuntimeOnly("org.junit.platform:junit-platform-launcher") - testImplementation("org.testcontainers:testcontainers:1.18.0") + testImplementation("org.testcontainers:testcontainers:1.21.4") testImplementation("org.postgresql:postgresql:42.6.0") testImplementation("org.slf4j:slf4j-api:2.0.7") testImplementation("org.slf4j:slf4j-simple:2.0.7") } +tasks.withType { + options.encoding = "UTF-8" +} + tasks.generateGrammarSource { maxHeapSize = "64m" source = project.objects diff --git a/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java b/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java index 393175c3d..f46c5b5d3 100644 --- a/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java +++ b/drivers/jdbc/lib/src/test/java/org/apache/age/jdbc/BaseDockerizedTest.java @@ -21,6 +21,7 @@ import java.sql.DriverManager; import java.sql.Statement; +import java.time.Duration; import org.apache.age.jdbc.base.Agtype; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -28,6 +29,7 @@ import org.junit.jupiter.api.TestInstance.Lifecycle; import org.postgresql.jdbc.PgConnection; import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.utility.DockerImageName; @TestInstance(Lifecycle.PER_CLASS) @@ -54,20 +56,19 @@ public void beforeAll() throws Exception { agensGraphContainer = new GenericContainer<>(DockerImageName .parse("apache/age:dev_snapshot_master")) .withEnv("POSTGRES_PASSWORD", CORRECT_DB_PASSWORDS) - .withExposedPorts(5432); + .withExposedPorts(5432) + .waitingFor(Wait.forLogMessage(".*database system is ready to accept connections.*\\n", 2) + .withStartupTimeout(Duration.ofSeconds(60))); agensGraphContainer.start(); + String host = agensGraphContainer.getHost(); int mappedPort = agensGraphContainer.getMappedPort(5432); String jdbcUrl = String - .format("jdbc:postgresql://%s:%d/%s", "localhost", mappedPort, "postgres"); + .format("jdbc:postgresql://%s:%d/%s?sslmode=disable", host, mappedPort, "postgres"); - try { - this.connection = DriverManager.getConnection(jdbcUrl, "postgres", CORRECT_DB_PASSWORDS) - .unwrap(PgConnection.class); - this.connection.addDataType("agtype", Agtype.class); - } catch (Exception e) { - System.out.println(e); - } + this.connection = DriverManager.getConnection(jdbcUrl, "postgres", CORRECT_DB_PASSWORDS) + .unwrap(PgConnection.class); + this.connection.addDataType("agtype", Agtype.class); try (Statement statement = connection.createStatement()) { statement.execute("CREATE EXTENSION IF NOT EXISTS age;"); statement.execute("LOAD 'age'");