Skip to content
Exposed docs1.11

Exposed JDBC Test Support

Latest stable Based on Exposed release 1.11.0

Reusable JDBC database, transaction, schema, table, assertion, and Testcontainers fixtures.

Database tests need deterministic connection reuse, per-database serialization, transaction setup, schema/table cleanup, and real dialects. Reimplementing that harness in every module makes failures harder to compare.

Use it in tests for Exposed JDBC code and shared table/mapping contracts. Keep it out of production runtime dependencies.

testImplementation("io.github.bluetape4k.exposed:bluetape4k-exposed-jdbc-tests"), managed by the central BOM.

withDb serializes access per TestDB, caches the connection, opens a maxAttempts = 1 transaction, and restores temporary configuration. withTables creates fixtures and attempts deterministic cleanup, including a top-level fallback. withSchemas commits before cascade cleanup.

withTables(TestDB.POSTGRESQL, Actors) {
Actors.insert { it[name] = "Ada" }
Actors.selectAll().count() shouldBeEqualTo 1L
}
TaskAPI
Transaction fixturewithDb
Table lifecyclewithTables
Schema lifecyclewithSchemas
Auto-commit probewithAutoCommit
Database matrixTestDB, TestDBConfig, container helpers
Assertions/shared schemasassertion and shared packages

Use H2 for fast DSL checks only when dialect behavior is irrelevant. Run the deployed database through Testcontainers for SQL, type, isolation, and migration behavior. Let the fixture own cleanup rather than sharing mutable tables between tests.

The module exposes JUnit 5, bluetape4k Testcontainers, and MariaDB/MySQL/PostgreSQL container support as test APIs. Drivers remain compile-time test dependencies.

Select a TestDB and optional DatabaseConfig override per call. Temporary configuration is restored after the fixture.

Parallel tests against the same database without the fixture can race on DDL. Assuming cleanup always succeeds hides dialect/connection failures. A container test without a bounded startup policy can make the suite flaky.

These are test-only operations. Capture container logs and database identity on failure; do not expose fixture credentials outside the test process.

The support module tests its own serialization, transaction, configuration restoration, schema/table cleanup, assertions, and DDL behavior.

Use it with JDBC operations and testing after learning transaction ownership.

The harness does not reproduce production pool load or replace migration/chaos tests. The per-database semaphore intentionally serializes conflicting fixture work.

These diagrams are loaded directly from README assets published with the 1.11.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.

JDBC test dialect coverage

Release README: exposed/jdbc-tests/README.md

JDBC test lifecycle

Release README: exposed/jdbc-tests/README.md