Exposed JDBC Test Support
Latest stable Based on Exposed release 1.11.0
Reusable JDBC database, transaction, schema, table, assertion, and Testcontainers fixtures.
Problem
Section titled “Problem”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.
When to use it
Section titled “When to use it”Use it in tests for Exposed JDBC code and shared table/mapping contracts. Keep it out of production runtime dependencies.
Coordinates
Section titled “Coordinates”testImplementation("io.github.bluetape4k.exposed:bluetape4k-exposed-jdbc-tests"), managed by the central BOM.
Core concepts
Section titled “Core concepts”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.
Quick start
Section titled “Quick start”withTables(TestDB.POSTGRESQL, Actors) { Actors.insert { it[name] = "Ada" } Actors.selectAll().count() shouldBeEqualTo 1L}API by task
Section titled “API by task”| Task | API |
|---|---|
| Transaction fixture | withDb |
| Table lifecycle | withTables |
| Schema lifecycle | withSchemas |
| Auto-commit probe | withAutoCommit |
| Database matrix | TestDB, TestDBConfig, container helpers |
| Assertions/shared schemas | assertion and shared packages |
Recommended patterns
Section titled “Recommended patterns”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.
Integrations
Section titled “Integrations”The module exposes JUnit 5, bluetape4k Testcontainers, and MariaDB/MySQL/PostgreSQL container support as test APIs. Drivers remain compile-time test dependencies.
Configuration
Section titled “Configuration”Select a TestDB and optional DatabaseConfig override per call. Temporary configuration is restored after the fixture.
Failure modes
Section titled “Failure modes”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.
Operations
Section titled “Operations”These are test-only operations. Capture container logs and database identity on failure; do not expose fixture credentials outside the test process.
Testing
Section titled “Testing”The support module tests its own serialization, transaction, configuration restoration, schema/table cleanup, assertions, and DDL behavior.
Workshops and learning path
Section titled “Workshops and learning path”Use it with JDBC operations and testing after learning transaction ownership.
Limitations
Section titled “Limitations”The harness does not reproduce production pool load or replace migration/chaos tests. The per-database semaphore intentionally serializes conflicting fixture work.
Release diagrams
Section titled “Release diagrams”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
Section titled “JDBC test dialect coverage”Release README: exposed/jdbc-tests/README.md
JDBC test lifecycle
Section titled “JDBC test lifecycle”Release README: exposed/jdbc-tests/README.md

