GoldenFileAssertions
that asserts the content as text.Configuration
programmatically.DropwizardAppRule
and a config file with the following
minimal content:
# use random ports so that tests can run in parallel
# and do not affect each other when one is not shutting down
server:
applicationConnectors:
- type: http
port: 0
adminConnectors:
- type: http
port: 0
Instead of specifying connectors in a config file you can create random ports
programmatically:
new DropwizardAppRule<>(
App.class,
randomPorts(),
...);
When using Junit5 use DropwizardAppExtension
.DropwizardRuleHelper
using programmatic
custom configuration without the need for a configuration yaml file.SystemPropertyRule
insteadPath
objects to check if a file matches the expected contents and
updates them if needed.Path
is exactly equal to the given
one.Path
equals the semantic of the given YAML
content.ConfigOverride.config(String, Supplier)
instead.
The above example can be written as:
class MyTest { private static final WireMockClassRule WIRE = new WireMockClassRule(wireMockConfig().dynamicPort()); private static final DropwizardAppRule<AppConfiguration> DW = new DropwizardAppRule<>( TestApplication.class, ResourceHelpers.resourceFilePath("test-config.yml"), ConfigOverride.config("url", WIRE::baseUrl)); // or ConfigOverride.config("url", () -> WIRE.baseUrl())); @ClassRule public static final RuleChain CHAIN = RuleChain.outerRule(WIRE).around(DW); }
TestRule
allows to set system properties for JUnit tests.jersey
root path
, referenced in the config.yaml
asjersey
root path
, referenced in the config.yaml
as