Package io.dropwizard.testing.junit
Class DropwizardAppRule<C extends Configuration>
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- io.dropwizard.testing.junit.DropwizardAppRule<C>
-
- Type Parameters:
C- the configuration type
- All Implemented Interfaces:
org.junit.rules.TestRule
@Deprecated public class DropwizardAppRule<C extends Configuration> extends org.junit.rules.ExternalResource
Deprecated.Deprecated since Dropwizard 2.0.0. Please migrate to JUnit 5 andDropwizardAppExtension.A JUnit rule for starting and stopping your application at the start and end of a test class.By default, the
Applicationwill be constructed using reflection to invoke the nullary constructor. If your application does not provide a public nullary constructor, you will need to override thenewApplication()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() { ... } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDropwizardAppRule.ServiceListener<T extends Configuration>Deprecated.
-
Constructor Summary
Constructors Constructor Description DropwizardAppRule(DropwizardTestSupport<C> testSupport)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, @Nullable String customPropertyPrefix, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, @Nullable String customPropertyPrefix, Function<Application<C>,Command> commandInstantiator, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigurationSourceProvider configSourceProvider, @Nullable String customPropertyPrefix, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigurationSourceProvider configSourceProvider, @Nullable String customPropertyPrefix, Function<Application<C>,Command> commandInstantiator, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigurationSourceProvider configSourceProvider, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, Optional<String> customPropertyPrefix, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, Optional<String> customPropertyPrefix, Function<Application<C>,Command> commandInstantiator, ConfigOverride... configOverrides)Deprecated.DropwizardAppRule(Class<? extends Application<C>> applicationClass, C configuration)Deprecated.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, C configuration, Function<Application<C>,Command> commandInstantiator)Deprecated.Alternate constructor that allows specifying the command the Dropwizard application is started with.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DropwizardAppRule<C>addListener(DropwizardAppRule.ServiceListener<C> listener)Deprecated.protected voidafter()Deprecated.protected voidbefore()Deprecated.javax.ws.rs.client.Clientclient()Deprecated.Returns a new HTTP JerseyClientfor performing HTTP requests against the tested Dropwizard server.protected org.glassfish.jersey.client.JerseyClientBuilderclientBuilder()Deprecated.intgetAdminPort()Deprecated.<A extends Application<C>>
AgetApplication()Deprecated.CgetConfiguration()Deprecated.EnvironmentgetEnvironment()Deprecated.intgetLocalPort()Deprecated.com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()Deprecated.intgetPort(int connectorIndex)Deprecated.DropwizardTestSupport<C>getTestSupport()Deprecated.DropwizardAppRule<C>manage(Managed managed)Deprecated.Application<C>newApplication()Deprecated.
-
-
-
Constructor Detail
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass)
Deprecated.
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigOverride... configOverrides)
Deprecated.
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigurationSourceProvider configSourceProvider, ConfigOverride... configOverrides)
Deprecated.- Since:
- 2.0
-
DropwizardAppRule
@Deprecated public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, Optional<String> customPropertyPrefix, ConfigOverride... configOverrides)
Deprecated.
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, @Nullable String customPropertyPrefix, ConfigOverride... configOverrides)
Deprecated.- Since:
- 2.0
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigurationSourceProvider configSourceProvider, @Nullable String customPropertyPrefix, ConfigOverride... configOverrides)
Deprecated.- Since:
- 2.0
-
DropwizardAppRule
@Deprecated public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, Optional<String> customPropertyPrefix, Function<Application<C>,Command> commandInstantiator, ConfigOverride... configOverrides)
Deprecated.
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, @Nullable String customPropertyPrefix, Function<Application<C>,Command> commandInstantiator, ConfigOverride... configOverrides)
Deprecated.- Since:
- 2.0
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, @Nullable String configPath, ConfigurationSourceProvider configSourceProvider, @Nullable String customPropertyPrefix, Function<Application<C>,Command> commandInstantiator, ConfigOverride... configOverrides)
Deprecated.- Since:
- 2.0
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, C configuration)
Deprecated.Alternate constructor that allows specifying exact Configuration object to use, instead of reading a resource and binding it as Configuration object.- Since:
- 0.9
-
DropwizardAppRule
public DropwizardAppRule(Class<? extends Application<C>> applicationClass, C configuration, Function<Application<C>,Command> commandInstantiator)
Deprecated.Alternate constructor that allows specifying the command the Dropwizard application is started with.- Since:
- 1.1.0
-
DropwizardAppRule
public DropwizardAppRule(DropwizardTestSupport<C> testSupport)
Deprecated.
-
-
Method Detail
-
addListener
public DropwizardAppRule<C> addListener(DropwizardAppRule.ServiceListener<C> listener)
Deprecated.
-
manage
public DropwizardAppRule<C> manage(Managed managed)
Deprecated.
-
before
protected void before() throws ExceptionDeprecated.- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
Exception
-
after
protected void after()
Deprecated.- Overrides:
afterin classorg.junit.rules.ExternalResource
-
getConfiguration
public C getConfiguration()
Deprecated.
-
getLocalPort
public int getLocalPort()
Deprecated.
-
getPort
public int getPort(int connectorIndex)
Deprecated.
-
getAdminPort
public int getAdminPort()
Deprecated.
-
newApplication
public Application<C> newApplication()
Deprecated.
-
getApplication
public <A extends Application<C>> A getApplication()
Deprecated.
-
getEnvironment
public Environment getEnvironment()
Deprecated.
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
Deprecated.
-
getTestSupport
public DropwizardTestSupport<C> getTestSupport()
Deprecated.
-
client
public javax.ws.rs.client.Client client()
Deprecated.Returns a new HTTP JerseyClientfor performing HTTP requests against the tested Dropwizard server. The client can be reused across different tests and automatically closed along with the server. The client can be augmented by overriding theclientBuilder()method.- Returns:
- a new
Clientmanaged by the rule.
-
clientBuilder
protected org.glassfish.jersey.client.JerseyClientBuilder clientBuilder()
Deprecated.
-
-