Skip to content

feat(database): Add DatabaseConfig support to DataSourceDatabaseTester - #909

Merged
jeffjensen merged 1 commit into
mainfrom
707-datasourcedatabasetester-databaseconfig
Aug 6, 2026
Merged

feat(database): Add DatabaseConfig support to DataSourceDatabaseTester#909
jeffjensen merged 1 commit into
mainfrom
707-datasourcedatabasetester-databaseconfig

Conversation

@jeffjensen

@jeffjensen jeffjensen commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Add DataSourceDatabaseTester(DataSource, String schema, CachingConnectionProvider, DatabaseConfig) constructor that applies the given config's properties and features to every connection created via createConnection(), so callers no longer need an IOperationListener#connectionRetrieved() override just to reach into each connection's DatabaseConfig (e.g. to set PROPERTY_DATATYPE_FACTORY for a specific database), matching the workaround shown in the issue.
  • Add DatabaseConfig#copyPropertiesInto(DatabaseConfig) to copy every ALL_PROPERTIES entry from one config into another.
  • Fix DatabaseConfig's constructor, which left FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES's underlying property value unset despite ALL_PROPERTIES declaring it non-nullable - harmless until copyPropertiesInto()'s full iteration became the first caller to round-trip every declared property through setProperty(), which enforces that constraint strictly.

Fixes #707

Test plan

  • ./mvnw clean test - full unit suite passes
  • ./mvnw clean verify -Phsqldb-2-7 - full unit + IT suite passes
  • New DatabaseConfigTest coverage for copyPropertiesInto() (configured values copied; nullable property overwritten with null)
  • New DataSourceDatabaseTesterIT coverage: config applied with and without a CachingConnectionProvider; 4-arg constructor still rejects a null DataSource

🤖 Generated with Claude Code

https://claude.ai/code/session_0136dJj6sBAMovFVNgGkyaDd

Summary by Sourcery

Add constructor-injected DatabaseConfig support to DataSourceDatabaseTester and introduce a utility to copy database configuration properties between connections.

New Features:

  • Add a four-argument DataSourceDatabaseTester constructor that accepts an optional DatabaseConfig and applies it to each created connection.
  • Introduce DatabaseConfig.copyPropertiesInto(DatabaseConfig) to propagate all configuration properties and features from one config to another.

Bug Fixes:

  • Ensure DatabaseConfig initializes FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES to a non-null default to satisfy ALL_PROPERTIES constraints.

Documentation:

  • Document the new DatabaseConfig-based configuration support for DataSourceDatabaseTester in changes.xml for the 3.4.1-SNAPSHOT release.

Tests:

  • Add integration tests verifying DatabaseConfig is applied to connections created by DataSourceDatabaseTester with and without a CachingConnectionProvider and that null DataSource is still rejected by the new constructor.
  • Add unit tests covering DatabaseConfig.copyPropertiesInto() behavior for copying configured values and overwriting nullable properties with null.

Summary by CodeRabbit

  • New Features

    • Added support for applying customized database settings to each connection created by data source testers.
    • Added options for supplying database configuration when creating a data source tester.
    • Added functionality to copy database properties and feature settings between configurations.
  • Bug Fixes

    • Corrected the default Oracle recycle-bin table setting.
    • Improved consistency when transferring database configuration values.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai

sourcery-ai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds constructor-injected DatabaseConfig support to DataSourceDatabaseTester so a shared config is applied to every created connection, introduces a DatabaseConfig.copyPropertiesInto helper and fixes a previously unset feature flag property, along with corresponding tests and changelog entry.

Sequence diagram for DataSourceDatabaseTester connection creation with DatabaseConfig

sequenceDiagram
    actor Test
    participant Tester as DataSourceDatabaseTester
    participant Provider as CachingConnectionProvider
    participant DS as DataSource
    participant Conn as DatabaseConnection
    participant Config as DatabaseConfig

    Test->>Tester: getConnection()
    alt connectionProvider not null
        Tester->>Provider: getConnection()
        Provider-->>Tester: IDatabaseConnection
    else connectionProvider null
        Tester->>Tester: createConnection()
        Tester->>DS: getConnection()
        DS-->>Tester: java.sql.Connection
        Tester->>Conn: new DatabaseConnection(Connection, schema)
        Note over Tester: databaseConfig not null
        Tester->>Config: copyPropertiesInto(Conn.getConfig())
        Config-->>Tester: (properties applied)
        Tester-->>Test: IDatabaseConnection
    end
Loading

File-Level Changes

Change Details Files
Introduce constructor-injected DatabaseConfig for DataSourceDatabaseTester and apply its settings to every created connection, including when using a CachingConnectionProvider.
  • Add an optional DatabaseConfig field and 4-arg constructor to DataSourceDatabaseTester, delegating the existing 3-arg constructor to it with a null config.
  • Update createConnection() to copy the provided DatabaseConfig properties into each new DatabaseConnection's config before returning it.
  • Extend DataSourceDatabaseTester integration tests to cover config application with and without a CachingConnectionProvider and to verify the new constructor still enforces non-null DataSource.
src/main/java/org/dbunit/DataSourceDatabaseTester.java
src/test/java/org/dbunit/DataSourceDatabaseTesterIT.java
Add DatabaseConfig.copyPropertiesInto to clone all known properties/features into another config and ensure all non-nullable properties are initialized.
  • Implement copyPropertiesInto(DatabaseConfig) to iterate over ALL_PROPERTIES and set each property's value into a target DatabaseConfig via setProperty().
  • Initialize FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES in the DatabaseConfig constructor so its underlying property is non-null, matching ALL_PROPERTIES expectations.
  • Add unit tests verifying that copyPropertiesInto copies configured properties/features and overwrites target values, including nullable properties being reset to null.
src/main/java/org/dbunit/database/DatabaseConfig.java
src/test/java/org/dbunit/database/DatabaseConfigTest.java
Document the new DataSourceDatabaseTester constructor and DatabaseConfig behavior in the project changelog.
  • Update the 3.4.1-SNAPSHOT release description to mention constructor-injected per-connection DatabaseConfig support for DataSourceDatabaseTester and associated bug fix.
  • Add a new changelog action entry for issue Make connection properties configurable for DataSourceDatabaseTester  #707 describing the new constructor, copyPropertiesInto method, and the FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES initialization fix.
src/changes/changes.xml

Assessment against linked issues

Issue Objective Addressed Explanation
#707 Allow configuring connection-level properties (e.g., DatabaseConfig / PROPERTY_DATATYPE_FACTORY) directly via DataSourceDatabaseTester so they are applied to every created connection, avoiding the need for an IOperationListener#connectionRetrieved workaround.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 858d6c94-8ac1-4c14-ab8f-1e49781c52fb

📥 Commits

Reviewing files that changed from the base of the PR and between d4cd39c and 234a47d.

📒 Files selected for processing (5)
  • src/changes/changes.xml
  • src/main/java/org/dbunit/DataSourceDatabaseTester.java
  • src/main/java/org/dbunit/database/DatabaseConfig.java
  • src/test/java/org/dbunit/DataSourceDatabaseTesterIT.java
  • src/test/java/org/dbunit/database/DatabaseConfigTest.java
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/main/java/org/dbunit/database/DatabaseConfig.java
  • src/changes/changes.xml
  • src/test/java/org/dbunit/database/DatabaseConfigTest.java
  • src/test/java/org/dbunit/DataSourceDatabaseTesterIT.java
  • src/main/java/org/dbunit/DataSourceDatabaseTester.java

📝 Walkthrough

Walkthrough

The change adds DatabaseConfig.copyPropertiesInto, initializes the Oracle recycle-bin property, and adds DatabaseConfig injection to DataSourceDatabaseTester. Created connections receive the configured properties. Tests cover direct and cached providers.

Changes

Configurable database connections

Layer / File(s) Summary
DatabaseConfig copy contract
src/main/java/org/dbunit/database/DatabaseConfig.java, src/test/java/org/dbunit/database/DatabaseConfigTest.java
DatabaseConfig initializes the Oracle recycle-bin feature property and copies registered properties and features into another configuration. Tests cover configured and nullable values.
DataSourceDatabaseTester configuration propagation
src/main/java/org/dbunit/DataSourceDatabaseTester.java, src/test/java/org/dbunit/DataSourceDatabaseTesterIT.java
A four-argument constructor accepts DatabaseConfig. Created connections receive copied settings with direct and cached providers. Tests cover propagation and null DataSource validation.
Release documentation
src/changes/changes.xml
The 3.4.1-SNAPSHOT changelog records the new constructor, copy API, connection propagation, and Oracle property initialization.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DataSourceDatabaseTester
  participant CachingConnectionProvider
  participant DatabaseConnection
  participant DatabaseConfig
  DataSourceDatabaseTester->>CachingConnectionProvider: obtain connection
  CachingConnectionProvider-->>DataSourceDatabaseTester: return DatabaseConnection
  DataSourceDatabaseTester->>DatabaseConfig: copyPropertiesInto(connection configuration)
  DatabaseConfig->>DatabaseConnection: set copied properties and features
  DataSourceDatabaseTester-->>DataSourceDatabaseTester: return configured connection
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding DatabaseConfig support to DataSourceDatabaseTester.
Linked Issues check ✅ Passed The changes satisfy issue #707 by allowing callers to provide DatabaseConfig for every connection created by DataSourceDatabaseTester.
Out of Scope Changes check ✅ Passed The implementation, tests, changelog, and Oracle property initialization directly support the linked issue and stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 707-datasourcedatabasetester-databaseconfig

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/java/org/dbunit/database/DatabaseConfig.java (1)

284-290: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Complete the new JavaDoc parameter descriptions.

Line 287 uses a sentence fragment. Lines 104-110 use sentence fragments and omit final periods. Use complete sentences that begin with a capital letter and end with a period.

  • src/main/java/org/dbunit/database/DatabaseConfig.java#L284-L290: Rewrite @param target as a complete sentence.
  • src/main/java/org/dbunit/DataSourceDatabaseTester.java#L97-L114: Rewrite every new @param description as a complete sentence.

As per coding guidelines, “use complete sentences beginning with a capital letter and ending with a period for topic text, parameters, and return descriptions.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/dbunit/database/DatabaseConfig.java` around lines 284 -
290, Update the `@param` target description in DatabaseConfig.copyPropertiesInto
so it begins with a capital letter and ends with a period. In
DataSourceDatabaseTester.java lines 97-114, rewrite every new `@param` description
as a complete, capitalized sentence with a final period; apply the changes in
both affected files.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/main/java/org/dbunit/database/DatabaseConfig.java`:
- Around line 284-290: Update the `@param` target description in
DatabaseConfig.copyPropertiesInto so it begins with a capital letter and ends
with a period. In DataSourceDatabaseTester.java lines 97-114, rewrite every new
`@param` description as a complete, capitalized sentence with a final period;
apply the changes in both affected files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: df1a24c9-8e89-4dff-819a-b235a569e671

📥 Commits

Reviewing files that changed from the base of the PR and between d4cd39c and daa551e.

📒 Files selected for processing (5)
  • src/changes/changes.xml
  • src/main/java/org/dbunit/DataSourceDatabaseTester.java
  • src/main/java/org/dbunit/database/DatabaseConfig.java
  • src/test/java/org/dbunit/DataSourceDatabaseTesterIT.java
  • src/test/java/org/dbunit/database/DatabaseConfigTest.java

* Add DataSourceDatabaseTester(DataSource, String, CachingConnectionProvider,
  DatabaseConfig) constructor that applies the given config's properties and
  features to every connection created via createConnection(), so callers no
  longer need an IOperationListener#connectionRetrieved() override just to
  reach into each connection's DatabaseConfig (e.g. to set
  PROPERTY_DATATYPE_FACTORY for a specific database).
* Add DatabaseConfig#copyPropertiesInto(DatabaseConfig) to copy every
  ALL_PROPERTIES entry from one config into another.
* Fix DatabaseConfig's constructor, which left FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES's
  underlying property value unset despite ALL_PROPERTIES declaring it
  non-nullable - harmless until copyPropertiesInto()'s full iteration became
  the first caller to round-trip every declared property through
  setProperty(), which enforces that constraint strictly.

Refs: 707
@jeffjensen
jeffjensen force-pushed the 707-datasourcedatabasetester-databaseconfig branch from daa551e to 234a47d Compare August 6, 2026 00:18
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@jeffjensen
jeffjensen merged commit fca05d1 into main Aug 6, 2026
27 checks passed
@jeffjensen
jeffjensen deleted the 707-datasourcedatabasetester-databaseconfig branch August 6, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make connection properties configurable for DataSourceDatabaseTester

1 participant