dbunit schema from application.properties.yml
See original GitHub issueI have a problem with defining which schema to load, so once dbunit try to get list of tables, he gets the first schema in my db and list of tables from it, which is wrong. for example if i wanna to use such db:
db:
WRONG_SCHEMA:
- table1name
- table2name
SCHEMA_THAT_I_ACTUALLY_NEED_TO_TEST:
- table10name
- table20name
so if i have in application.properties spring.datasource.url
defined as
jdbc:mariadb://${server-url}/${schema-name}?connectionCollation=utf8mb4_unicode_ci&serverTimezone=UTC
it is gonna connect to the right DB, but schema
would be null
and it will take the first public schema in db (WRONG_SCHEMA), which is wrong.
I cant define schema in code as @DBUnit(url = "SCHEMA_NAME")
because in dockers or anywhere else schema name might be changed.
So how can i load schema name in DBUnit configuration from application.yml file?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Frequently Asked Questions - DBUnit
The following sample demonstrates how you can export one or many tables from a database to a flat XML dataset file. Note that...
Read more >Use DBUnit in Spring without defined entities via "nativequery"
I overcame this by specifying a DataSourceInitializer Bean which runs a sql file for setting up tables:
Read more >“How-to” Guides - Spring
Spring Boot binds external properties from application.properties (or .yml files and other places) into an application at runtime. There is not ...
Read more >Configuring Separate Spring DataSource for Tests - Baeldung
The application.properties file in the src/test/resources folder should contain the standard key-value pairs necessary for configuring a data ...
Read more >Database Rider Documentation
DBUnit , the tool doing the dirty work the scenes, can be configured by @DBUnit annotation (class or method level) and dbunit.yml file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @vladbogun1, thank you for the follow up on this issue, maybe we could improve the documentation or even the code to prevent this issue in the future
Hi @netmikey,
Yea, that should be possible even for non spring based tests, I’ve created #483 for that, thanks for the feedback!
I’ve added some guidance in the ticket if someone wants to contribute (I’m away from keyboard for the next 10 days but I can help/review on mobile)
Cheers!