question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dbunit schema from application.properties.yml

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rmpestanocommented, Feb 20, 2022

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

0reactions
rmpestanocommented, Aug 14, 2022

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found