Class PostgresContainerUtils

java.lang.Object
org.evomaster.client.java.postgres.test.utils.PostgresContainerUtils

public class PostgresContainerUtils extends Object
Shared utility for creating and configuring PostgreSQL Testcontainers instances. Used across modules (client-java/sql, core, e2e tests) to avoid code duplication.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default version of PostgreSQL used when none is explicitly specified.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getJdbcUrl(org.testcontainers.containers.GenericContainer<?> container)
    Constructs a JDBC URL for a PostgreSQL database hosted in the given container.
    static org.testcontainers.containers.GenericContainer<?>
    Creates a new PostgreSQL container using the default version ("14").
    static org.testcontainers.containers.GenericContainer<?>
    Creates a new PostgreSQL container using the specified version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_POSTGRES_VERSION

      public static final String DEFAULT_POSTGRES_VERSION
      Default version of PostgreSQL used when none is explicitly specified.
      See Also:
  • Constructor Details

    • PostgresContainerUtils

      public PostgresContainerUtils()
  • Method Details

    • newContainer

      public static org.testcontainers.containers.GenericContainer<?> newContainer()
      Creates a new PostgreSQL container using the default version ("14").
      Returns:
      A configured GenericContainer instance ready to be started.
    • newContainer

      public static org.testcontainers.containers.GenericContainer<?> newContainer(String version)
      Creates a new PostgreSQL container using the specified version. The container is pre-configured with:
      • Port 5432 exposed
      • Temporary filesystem for the data directory (avoids disk I/O in tests)
      • POSTGRES_HOST_AUTH_METHOD=trust (no password required)
      • Readiness wait on the "database system is ready to accept connections" log message
      Parameters:
      version - The PostgreSQL Docker image version tag (e.g. "14", "17").
      Returns:
      A configured GenericContainer instance ready to be started.
    • getJdbcUrl

      public static String getJdbcUrl(org.testcontainers.containers.GenericContainer<?> container)
      Constructs a JDBC URL for a PostgreSQL database hosted in the given container.
      Parameters:
      container - A running PostgreSQL GenericContainer with port 5432 mapped.
      Returns:
      JDBC URL of the form jdbc:postgresql://<host>:<port>/postgres.