Class PostgresContainerUtils
java.lang.Object
org.evomaster.client.java.postgres.test.utils.PostgresContainerUtils
Shared utility for creating and configuring PostgreSQL Testcontainers instances.
Used across modules (client-java/sql, core, e2e tests) to avoid code duplication.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault version of PostgreSQL used when none is explicitly specified. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetJdbcUrl(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<?>newContainer(String version) Creates a new PostgreSQL container using the specified version.
-
Field Details
-
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
GenericContainerinstance ready to be started.
-
newContainer
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
GenericContainerinstance ready to be started.
-
getJdbcUrl
Constructs a JDBC URL for a PostgreSQL database hosted in the given container.- Parameters:
container- A running PostgreSQLGenericContainerwith port 5432 mapped.- Returns:
- JDBC URL of the form
jdbc:postgresql://<host>:<port>/postgres.
-