Class TestSupportHolder
java.lang.Object
ru.vyarus.dropwizard.guice.test.builder.TestSupportHolder
Holds
DropwizardTestSupport object during test application execution.
Works for junit 5 extensions run and for manual runs with
TestSupport.run(io.dropwizard.testing.DropwizardTestSupport, ru.vyarus.dropwizard.guice.test.TestSupport.RunCallback) method (or builder run methods).- Since:
- 15.11.2023
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClientSupportstatic <C extends io.dropwizard.core.Configuration>
io.dropwizard.testing.DropwizardTestSupport<C>Obtain the test support object, used for test application execution (by junit 5 extension or withTestSupport.run(io.dropwizard.testing.DropwizardTestSupport, ru.vyarus.dropwizard.guice.test.TestSupport.RunCallback)(or any derived method, like builder run methods).static booleanstatic voidreset()Reset thread-bound state.static voidsetContext(io.dropwizard.testing.DropwizardTestSupport<?> support, TestClientFactory clientFactory) Used to register a context support object.static voidsetContext(io.dropwizard.testing.DropwizardTestSupport<?> support, ClientSupport client) Used to register a context support object.
-
Method Details
-
setContext
public static void setContext(io.dropwizard.testing.DropwizardTestSupport<?> support, @Nullable TestClientFactory clientFactory) Used to register a context support object. Intended to be used ONLY by guicey.- Parameters:
support- context support objectclientFactory- custom factory object forClientSupport(may be null for default factory usage)- Throws:
IllegalStateException- if any support object already bound in thread
-
setContext
public static void setContext(io.dropwizard.testing.DropwizardTestSupport<?> support, @Nullable ClientSupport client) Used to register a context support object. Intended to be used ONLY by guicey.- Parameters:
support- context support objectclient- client support instance (from junit 5 extension context; null to create new client)- Throws:
IllegalStateException- if any support object already bound in thread
-
getContext
public static <C extends io.dropwizard.core.Configuration> io.dropwizard.testing.DropwizardTestSupport<C> getContext()Obtain the test support object, used for test application execution (by junit 5 extension or withTestSupport.run(io.dropwizard.testing.DropwizardTestSupport, ru.vyarus.dropwizard.guice.test.TestSupport.RunCallback)(or any derived method, like builder run methods).Use
isContextSet()to check context initialization- Type Parameters:
C- configuration type- Returns:
- context support object
- Throws:
NullPointerException- if test support context is not bound in thread
-
isContextSet
public static boolean isContextSet()- Returns:
- true if the support object is bound in thread, false otherwise
-
getClient
- Returns:
- context test web client (in case of junit extensions would be the same client as in extenion)
-
reset
public static void reset()Reset thread-bound state.
-