Annotation Type UseDropwizardApp
-
@Retention(RUNTIME) @Target(TYPE) public @interface UseDropwizardAppDropwizard spock extension. Starts dropwizard application before all tests in class and shutdown after them.Gucie injections will work on test class (just annotate required fields with
Inject.Sharedmay be used to define common injection points for all tests in class.Note:
setupSpec()fixture is called after application start andcleanupSpec()before application tear down.Extension would also recognize the following test fields (including super classes):
- static
GuiceyConfigurationHookannotated withEnableHook- hook from field will be registered ClientSupportannotated withInjectClientfield will be injected with client instance.
Internally based on
DropwizardTestSupport.- Since:
- 03.01.2015
- See Also:
InjectClient
- static
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Class<? extends io.dropwizard.Application>value
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringconfigConfigOverride[]configOverridejava.lang.Class<? extends ru.vyarus.dropwizard.guice.hook.GuiceyConfigurationHook>[]hooksHooks provide access to guice builder allowing complete customization of application context in tests.booleanrandomPortsEnables random ports usage.java.lang.StringrestMappingSpecifies rest mapping path.
-
-
-
-
configOverride
ConfigOverride[] configOverride
- Returns:
- list of overridden configuration values (may be used even without real configuration)
- Default:
- {}
-
-
-
hooks
java.lang.Class<? extends ru.vyarus.dropwizard.guice.hook.GuiceyConfigurationHook>[] hooks
Hooks provide access to guice builder allowing complete customization of application context in tests.Additional hooks could be declared in static test fields:
@EnableHook static GuiceyConfigurationHook HOOK = { it.disableExtensions(Something.class)}.- Returns:
- list of hooks to use
- See Also:
for more info,EnableHook
- Default:
- {}
-
-
-
randomPorts
boolean randomPorts
Enables random ports usage. Supports both simple and default dropwizard servers. Random ports would be set even if you specify exact configuration file with configured ports (option overrides configuration).To get port numbers in test use
ClientSupportstatic field:
Or use client target methods directly.@InjectClient ClientSupport client static setupSpec() { String baseUrl = "http://localhost:" + client.getPort(); String baseAdminUrl = "http://localhost:" + client.getAdminPort(); }- Returns:
- true to use random ports
- Default:
- false
-
-
-
restMapping
java.lang.String restMapping
Specifies rest mapping path. This is the same as specifyingconfigOverride()"server.rootMapping=/something/*". Specified value would be prefixed with "/" and, if required "/*" applied at the end. So it would be correct to specifyrestMapping = "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.
- Returns:
- rest mapping (empty string - do nothing)
- Default:
- ""
-
-