I am trying to make an integration test of a Java application that uses a jdbc postgres connection.
In the integration test i spawn two testcontainers, an application one and a postgres one.
How can i inject in the application the postgresDB.getJdbcUrl()
?
Currently I have a datasource.properties
file that the application uses for the jdbc connection.
In integration test folder i have another datasource-test.properties
file that is loaded to the application testcontainer.
The datasource-test.properties
is created dynamically after the postgres testcontainer is started but the application container starts before the dynamic creation of the datasource-test.properties
.
Can i use this approach? How to load properties file in testcontainer after another testcontainer creates this file?
If not I need something similar to @DynamicPropertySource
that Spring Boot has but my application is not Spring.