Skip to content

Conversation

@mathias82
Copy link

@mathias82 mathias82 commented Dec 1, 2025

Add inline configuration support to QuarkusUnitTest and remove obsolete test config files (#51206)

This commit introduces a new API method withConfiguration(String) that enables
inline configuration for QuarkusUnitTest using Java text blocks. The method
parses key=value properties and forwards them to overrideConfigKey(...),
eliminating the need for external .properties files or multiple configuration
calls in test code.

As part of this enhancement and in relation to issue #51206, obsolete test configuration
resources such as application-unittest-onlyreactive*.properties were removed,
since Dev Services now provide datasource URLs automatically and these files were
no longer required.

A new test QuarkusUnitTestWithConfigurationTest verifies that inline configuration
is correctly applied and propagated to the MicroProfile Config runtime.

@quarkus-bot

This comment was marked as resolved.

@mathias82 mathias82 force-pushed the hibernate-override-configkey-51206 branch from ef63778 to d57d397 Compare December 1, 2025 20:36
@mathias82
Copy link
Author

@gsmet whenever you have some time, I'd really appreciate a review on this PR.

@geoand geoand requested a review from lucamolteni December 2, 2025 07:03
@lucamolteni
Copy link
Contributor

thanks for the PR @mathias82 I'll review it soon

In the meanwhile, have you checked hibernate-reactive tests are correctly working?

@mathias82
Copy link
Author

mathias82 commented Dec 2, 2025

thanks for the PR @mathias82 I'll review it soon

In the meanwhile, have you checked hibernate-reactive tests are correctly working?

Yes the test its working as expected @lucamolteni

Copy link
Member

@radcortez radcortez left a comment

Choose a reason for hiding this comment

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

Thank you for the PR.

Can you please do the same for io.quarkus.test.QuarkusUnitTest#overrideRuntimeConfigKey?

Also io.quarkus.test.QuarkusProdModeTest#overrideConfigKey.

Thank you!

@lucamolteni
Copy link
Contributor

@mathias82 I see you've removed withConfigurationResource from 4 compatibility tests but there are 10, why not the others?

@mathias82
Copy link
Author

@mathias82 I see you've removed withConfigurationResource from 4 compatibility tests but there are 10, why not the others?

I removed @WithConfigurationResource only from the tests that rely exclusively on the reactive datasource and no longer require a test container connection string.

The remaining compatibility tests still need both:

quarkus.datasource.reactive.url=${postgres.reactive.url}
quarkus.datasource.jdbc.url=${postgres.blocking.url}

Those ${key} interpolations cannot be expressed through overrideConfigKey, so @WithConfigurationResource is still required there. Once we drop the JDBC configuration as well, we can remove it from those tests too.

Hope this clarifies the difference!

@lucamolteni

@mathias82
Copy link
Author

test(junit5-internal): replace application.properties with inline runtime config in QuarkusUnitTest

This change removes the need for external application.properties files in
QuarkusUnitTest-based tests and validates that runtime configuration can be
defined directly via withRuntimeConfiguration(...).

Key changes:

  • Added new test QuarkusUnitTestWithRuntimeConfigurationTest to assert that
    inline runtime configuration keys are correctly applied.
  • Used QuarkusUnitTest.withRuntimeConfiguration() instead of relying on
    application.properties.
  • Removed leftover properties file usage from previous Hibernate Extensions
    tests, as Dev Services makes container connection strings unnecessary.
  • Eliminated manual config indirection through ${...} placeholders.

@lucamolteni @radcortez

@mathias82 mathias82 requested a review from radcortez December 4, 2025 11:04
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-common</artifactId>
</dependency>
<dependency>
Copy link
Member

Choose a reason for hiding this comment

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

Hum... I'm not sure whether we should include arc here. What is the reason?

Copy link
Author

@mathias82 mathias82 Dec 6, 2025

Choose a reason for hiding this comment

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

Thanks for the question!

In this test QuarkusUnitTestWithRuntimeConfigurationTest I explicitly added the arc dependency because the class uses Quarkus Arc annotations:

import io.quarkus.arc.Unremovable;
import jakarta.inject.Singleton;

These annotations are part of the Arc CDI implementation, not part of the quarkus-test-common artifact. Without including arc, the test fails to compile because the Arc annotation types are not available on the classpath during the test scope.

In other words, Arc is required here to correctly load and process the CDI metadata used in this test. If we remove arc, the test breaks.

If you believe there is another recommended dependency that exposes these annotations without pulling the whole Arc module, I'm happy to revisit it, but currently this is the minimal dependency that makes the test compile and run.

@mathias82 mathias82 requested a review from radcortez December 6, 2025 07:31
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.

Use overrideConfigKey to test Hibernate tests instead of application.properties files

3 participants