@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface UseDropwizardApp
Gucie injections will work on test class (just annotate required fields with Inject.
Shared may be used to define common injection points for all tests in class.
Note: setupSpec() fixture is called after application start and cleanupSpec() before
application tear down.
Extension would also recognize the following test fields (including super classes):
GuiceyConfigurationHook annotated with EnableHook - hook
from field will be registeredClientSupport annotated with InjectClient field will be injected
with client instance.
Internally based on DropwizardTestSupport.
InjectClient| Modifier and Type | Required Element and Description |
|---|---|
java.lang.Class<? extends io.dropwizard.Application> |
value |
| Modifier and Type | Optional Element and Description |
|---|---|
java.lang.String |
config |
ConfigOverride[] |
configOverride |
java.lang.Class<? extends GuiceyConfigurationHook>[] |
hooks
Hooks provide access to guice builder allowing complete customization of application context
in tests.
|
boolean |
randomPorts
Enables random ports usage.
|
java.lang.String |
restMapping
Specifies rest mapping path.
|
public abstract java.lang.Class<? extends io.dropwizard.Application> value
public abstract java.lang.String config
public abstract ConfigOverride[] configOverride
public abstract java.lang.Class<? extends GuiceyConfigurationHook>[] hooks
Additional hooks could be declared in static test fields:
@EnableHook static GuiceyConfigurationHook HOOK = { it.disableExtensions(Something.class)}.
for more info,
EnableHookpublic abstract boolean randomPorts
To get port numbers in test use ClientSupport static field:
@InjectClient ClientSupport client
static setupSpec() {
String baseUrl = "http://localhost:" + client.getPort();
String baseAdminUrl = "http://localhost:" + client.getAdminPort();
}
Or use client target methods directly.public abstract java.lang.String restMapping
configOverride()
"server.rootMapping=/something/*". Specified value would be prefixed with "/" and, if required
"/*" applied at the end. So it would be correct to specify restMapping = "api" (actually set value
would be "/api/*").
This option is only intended to simplify cases when custom configuration file is not yet used in tests (usually early PoC phase). It allows you to map servlet into application root in test (because rest is no more resides in root). When used with existing configuration file, this parameter will override file definition.