Annotation 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):
- 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:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends ru.vyarus.dropwizard.guice.hook.GuiceyConfigurationHook>[]Hooks provide access to guice builder allowing complete customization of application context in tests.booleanEnables random ports usage.Specifies rest mapping path.
-
Element Details
-
value
Class<? extends io.dropwizard.core.Application> value- Returns:
- application class
-
-
-
config
String config- Returns:
- path to configuration file (optional)
- Default:
- ""
-
configOverride
ConfigOverride[] configOverride- Returns:
- list of overridden configuration values (may be used even without real configuration)
- Default:
- {}
-
hooks
Class<? extends ru.vyarus.dropwizard.guice.hook.GuiceyConfigurationHook>[] hooksHooks 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 infoEnableHook
- Default:
- {}
-
randomPorts
boolean randomPortsEnables 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
String restMappingSpecifies 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:
- ""
-