Class TestSupportHolder
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.builder.TestSupportHolder
-
public final class TestSupportHolder extends java.lang.ObjectHoldsDropwizardTestSupportobject during test application execution. Works for junit 5 extensions run and for manual runs withTestSupport.run(io.dropwizard.testing.DropwizardTestSupport, ru.vyarus.dropwizard.guice.test.TestSupport.RunCallback)method (or builder run methods).- Since:
- 15.11.2023
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClientSupportgetClient()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).static booleanisContextSet()static voidreset()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 Detail
-
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:
java.lang.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:
java.lang.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:
java.lang.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
public static ClientSupport getClient()
- Returns:
- context test web client (in case of junit extensions would be the same client as in extenion)
-
reset
public static void reset()
-
-