Package ru.vyarus.dropwizard.guice.test
Class GuiceyAppRule<C extends io.dropwizard.core.Configuration>
java.lang.Object
org.junit.rules.ExternalResource
ru.vyarus.dropwizard.guice.test.GuiceyAppRule<C>
- Type Parameters:
C- configuration type
- All Implemented Interfaces:
org.junit.rules.TestRule
public class GuiceyAppRule<C extends io.dropwizard.core.Configuration>
extends org.junit.rules.ExternalResource
A JUnit rule for starting and stopping your guice application at the start and end of a test class.
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).
Based on DropwizardAppRule, but doesn't start jetty and as a consequence
jersey and guice web modules not initialized. Emulates managed objects lifecycle.
Suppose to be used for testing internal services business logic as lightweight alternative for dropwizard rule.
- Since:
- 23.10.2014
- See Also:
-
for junit 5 alterantive
-
Constructor Summary
ConstructorsConstructorDescriptionGuiceyAppRule(Class<? extends io.dropwizard.core.Application<C>> applicationClass, String configPath, io.dropwizard.testing.ConfigOverride... configOverrides) -
Method Summary
Methods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
GuiceyAppRule
-
-
Method Details
-
getConfiguration
-
getApplication
-
getEnvironment
public io.dropwizard.core.setup.Environment getEnvironment() -
getInjector
public com.google.inject.Injector getInjector() -
getBean
-
newApplication
-
before
- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
Throwable
-
after
protected void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-