Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the javadoc of AutoConfigureTestDatabase to make it clearer that it only replaces the main DataSource #23808

Closed
fransf-wtax opened this issue Oct 22, 2020 · 1 comment
Labels
type: documentation A documentation update
Milestone

Comments

@fransf-wtax
Copy link

TestDatabaseAutoConfiguration in the getDataSourceBeanDefinition method explicitly only finds for the primary data source to replace it with an embedded datasource.

When running a Spring Boot app with multiple datasources, you might expect all of them to be replaced with embedded datasources. It would be helpful if a message was logged for all non-primary data sources found explaining that they were not replaced because only replacing the primary data source is supported, possible with a reference to documentation explaining what the recommended approach is in the multiple-datasource scenario.

Also, the Javadoc for @AutoConfigureTestDatabase is somewhat misleading here:

 /**
 * Replace any DataSource bean (auto-configured or manually defined).
 */
ANY,

Actually, not "any" data source is replaced; only a single data source annotated as (or implicitly) @Primary.

Happy to submit pull requests for all of the above.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 22, 2020
@wilkinsona
Copy link
Member

Thanks for raising this. Auto-configuration of multiple DataSources is being tracked by #15732. I expect some corresponding improvements to be made to TestDatabaseAutoConfiguration as part of that. In the meantime, I think it would certainly be worthwhile clarifying exactly what "any" means. "(auto-configured or manually defined)" was an attempt to do that, but I agree that it's not clear that it means the context's only or primary DataSource bean, irrespective of whether it was manually defined or auto-configured.

@wilkinsona wilkinsona added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 28, 2020
@wilkinsona wilkinsona added this to the 2.2.x milestone Oct 28, 2020
@wilkinsona wilkinsona modified the milestones: 2.2.x, 2.2.12 Nov 3, 2020
@wilkinsona wilkinsona changed the title AutoConfigureTestDatabase only replaces primary data source without warning Clarify the javadoc of AutoConfigureTestDatabase to make it clearer that it only replaces the main DataSource Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

3 participants