dependabot[bot] on gradle
xvik on master
Bump system-stubs-jupiter from … Merge pull request #273 from xv… (compare)
dependabot[bot] on gradle
Bump system-stubs-jupiter from … (compare)
xvik on freedom
no hk2 check add contracts debug (compare)
dependabot[bot] on gradle
xvik on master
Bump com.gradle.enterprise from… Merge pull request #272 from xv… (compare)
dependabot[bot] on gradle
Bump com.gradle.enterprise from… (compare)
xvik on gh-pages
Publish 5.7.0 documentation (compare)
xvik on master
[Gradle Release Plugin] - new v… (compare)
xvik on 5.7.0
public class AccountResourceIT {
public void addToSystemProperties() {
System.setProperty(propertyPrefix + key, value.get());
}
dropwizardApp =
new DropwizardAppExtension<>(
HttpServer.class,
"src/test/resources/dropwizard-test-config.yml",
ConfigOverride.config(
"database.url",
singleInstancePostgresExtension.getEmbeddedPostgres().getJdbcUrl(
"postgres", "postgres")
),
ConfigOverride.config(
"server.applicationConnectors[0].port", String.valueOf(0)
),
ConfigOverride.config(
"server.adminConnectors[0].port", String.valueOf(0)
),
ConfigOverride.config(
"engine.indexDataPrefix",
tempDir.toAbsolutePath().toString()
)
);
ConfigOverride
works through system propertirs it is not suitable for parallel tests. You need custom support inside your application: store embedded db credentials in some ThreadLocal variable and application should lookup it on startup and use if custom data available.
does that mean I can't use DropwizardAppExtension<HttpServerConfiguration> any more since it loads from a yml file
It's not a problem, in dropwizard you always have control how configuration is applied to code and always can modify it
sorry I should've asked this better.
So my question really is for writing an extension using DropwizardAppExtension and dynamically set database (with embededPostgres). In the extension I'll construct a dropwizard app, and then for each test class I'll have a different port for postgres so they don’t conflict with each other.
Then let's say there are two test classes A, B uses this extension. So in A, the system property of database.url will be set to pg://A. When A starts, A will set the system property "dw.database.url" to "pg://A"
and when B starts, B will sets it to "pg://B". However A didn’t knonw and will keep using "pg://B" which causes problems when run in parallel.
So I guess this is where the confusion comes from. I think there might be one possibility and would like to hear what you think:
I would like to not use the same system property for A and B. Maybe "A.dw.database.url" and "B.dw.database.url". But I need to let DW know that it’s no longer "dw.database.url" that it should read DB settings from
new DropwizardAppExtension<>(
HttpServer.class,
"src/test/resources/dropwizard-test-config.yml",
"randomPrefixString",
ConfigOverride.config("randomPrefixString",
"database.url",
singleInstancePostgresExtension.getEmbeddedPostgres().getJdbcUrl(
"postgres", "postgres")
),
ConfigOverride.config("randomPrefixString",
"server.applicationConnectors[0].port", String.valueOf(0)
),
ConfigOverride.config("randomPrefixString",
"server.adminConnectors[0].port", String.valueOf(0)
),
ConfigOverride.config("randomPrefixString",
"engine.indexDataPrefix",
tempDir.toAbsolutePath().toString()
)
);