C - the configuration typepublic class DropwizardAppRule<C extends Configuration>
extends org.junit.rules.ExternalResource
By default, the Application will be constructed using reflection to invoke the nullary
constructor. If your application does not provide a public nullary constructor, you will need to
override the newApplication() method to provide your application instance(s).
Using DropwizardAppRule at the suite level can speed up test runs, as the application is only started and stopped once for the entire suite:
@RunWith(Suite.class)
@SuiteClasses({FooTest.class, BarTest.class})
public class MySuite {
@ClassRule
public static final DropwizardAppRule<MyConfig> DROPWIZARD = new DropwizardAppRule<>(...);
}
If the same instance of DropwizardAppRule is reused at the suite- and class-level, then the application will be started and stopped once, regardless of whether the entire suite or a single test is executed.
public class FooTest {
@ClassRule public static final DropwizardAppRule<MyConfig> DROPWIZARD = MySuite.DROPWIZARD;
public void testFoo() { ... }
}
public class BarTest {
@ClassRule public static final DropwizardAppRule<MyConfig> DROPWIZARD = MySuite.DROPWIZARD;
public void testBar() { ... }
}
| Modifier and Type | Class and Description |
|---|---|
static class |
DropwizardAppRule.ServiceListener<T extends Configuration> |
| Constructor and Description |
|---|
DropwizardAppRule(Class<? extends Application<C>> applicationClass) |
DropwizardAppRule(Class<? extends Application<C>> applicationClass,
C configuration)
Alternate constructor that allows specifying exact Configuration object to
use, instead of reading a resource and binding it as Configuration object.
|
DropwizardAppRule(Class<? extends Application<C>> applicationClass,
String configPath,
ConfigOverride... configOverrides) |
DropwizardAppRule(Class<? extends Application<C>> applicationClass,
String configPath,
Optional<String> customPropertyPrefix,
ConfigOverride... configOverrides) |
DropwizardAppRule(DropwizardTestSupport<C> testSupport) |
| Modifier and Type | Method and Description |
|---|---|
DropwizardAppRule<C> |
addListener(DropwizardAppRule.ServiceListener<C> listener) |
protected void |
after() |
protected void |
before() |
int |
getAdminPort() |
<A extends Application<C>> |
getApplication() |
C |
getConfiguration() |
Environment |
getEnvironment() |
int |
getLocalPort() |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
int |
getPort(int connectorIndex) |
DropwizardTestSupport<C> |
getTestSupport() |
DropwizardAppRule<C> |
manage(io.dropwizard.lifecycle.Managed managed) |
Application<C> |
newApplication() |
public DropwizardAppRule(Class<? extends Application<C>> applicationClass)
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigOverride... configOverrides)
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, String configPath, Optional<String> customPropertyPrefix, ConfigOverride... configOverrides)
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, C configuration)
public DropwizardAppRule(DropwizardTestSupport<C> testSupport)
public DropwizardAppRule<C> addListener(DropwizardAppRule.ServiceListener<C> listener)
public DropwizardAppRule<C> manage(io.dropwizard.lifecycle.Managed managed)
protected void before()
before in class org.junit.rules.ExternalResourceprotected void after()
after in class org.junit.rules.ExternalResourcepublic C getConfiguration()
public int getLocalPort()
public int getPort(int connectorIndex)
public int getAdminPort()
public Application<C> newApplication()
public <A extends Application<C>> A getApplication()
public Environment getEnvironment()
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public DropwizardTestSupport<C> getTestSupport()
Copyright © 2016. All rights reserved.