Skip to content

Add getR2dbcUrl() helper to PostgreSQL, MySQL, and MariaDB R2DBC containers#11571

Open
PreAgile wants to merge 5 commits intotestcontainers:mainfrom
PreAgile:feat/r2dbc-get-url-helper
Open

Add getR2dbcUrl() helper to PostgreSQL, MySQL, and MariaDB R2DBC containers#11571
PreAgile wants to merge 5 commits intotestcontainers:mainfrom
PreAgile:feat/r2dbc-get-url-helper

Conversation

@PreAgile
Copy link
Contributor

Summary

  • Add static getR2dbcUrl(container) helpers for PostgreSQL, MySQL, and MariaDB R2DBC containers
  • Update both modern and compatibility package variants
  • Add tests covering generated URL shape and actual R2DBC connectivity

Problem

R2DBC support already exists via getOptions(container), but there is no simple URL helper similar to getJdbcUrl(). Users working with reactive stacks often need a plain R2DBC URL and currently have to construct it manually.

Design

  • Scope is limited to PostgreSQL, MySQL, and MariaDB
  • MSSQL is intentionally deferred due to the existing database-name limitation in its R2DBC support
  • The helper intentionally excludes credentials, mirroring getJdbcUrl()
  • The change follows the issue discussion by adding static helper methods on concrete implementations rather than changing a shared base API

Tests

  • Added testGetR2dbcUrl() to modern and compatibility test classes
  • Each test sets a custom database name, username, and password
  • Each test asserts the generated URL contains the custom database name
  • Each test creates a ConnectionFactory from the generated URL plus credentials and runs a query
  • CI passes

Closes #8797

PreAgile and others added 5 commits March 10, 2026 16:39
…C containers

Add a static getR2dbcUrl(container) method to each R2DBCDatabaseContainer
implementation for PostgreSQL, MySQL, and MariaDB. This mirrors the
existing getJdbcUrl() ergonomics, making R2DBC URL discovery straightforward
for reactive backend workflows.

Both modern and compatibility package classes are updated.
Integration tests verify URL correctness (database name assertion) and
actual connectivity with custom credentials.

Closes testcontainers#8797
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add getR2dbcUrl helper method to JdbcDatabaseContainer

1 participant