Class DefaultTestClientFactory
java.lang.Object
ru.vyarus.dropwizard.guice.test.client.DefaultTestClientFactory
- All Implemented Interfaces:
TestClientFactory
- Direct Known Subclasses:
ApacheTestClientFactory
Default client factory for
ClientSupport. Enables INFO logging of
all requests and responses into ClientSupport logger.
Auto register multipart feature if it's available in classpath (through dropwizard-froms).
By default, log all requests and responses into system out (console). This could be disabled with
disableConsoleLog() method (system property).
NOTE: default HttpUrlConnectorProvider does not support PATCH method on
jdk > 16 (requires additional --add-opens). To workaround it, use apache or connection provider.
If client customization is required, extend this class and override
configure(org.glassfish.jersey.client.JerseyClientBuilder, io.dropwizard.testing.DropwizardTestSupport) method.
- Since:
- 15.11.2023
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class"Hacked" logger to print everything directly into system out. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property name used to disable direct console logs. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigure(org.glassfish.jersey.client.JerseyClientBuilder builder, io.dropwizard.testing.DropwizardTestSupport<?> support) Provides the ability to customize default client in extending class.org.glassfish.jersey.client.JerseyClientcreate(io.dropwizard.testing.DropwizardTestSupport<?> support) Creates client instance forClientSupport(once per support instance).protected jakarta.ws.rs.core.FeatureConfigure logging feature.static voidDisable client logs into system out.static voidEnable client logs into system out.
-
Field Details
-
USE_LOGGER
System property name used to disable direct console logs.- See Also:
-
-
Constructor Details
-
DefaultTestClientFactory
public DefaultTestClientFactory()
-
-
Method Details
-
disableConsoleLog
public static void disableConsoleLog()Disable client logs into system out. Instead, logs would go intoClientSupportlogger. -
enableConsoleLog
public static void enableConsoleLog()Enable client logs into system out. Could be used to revertdisableConsoleLog()action. -
create
public org.glassfish.jersey.client.JerseyClient create(io.dropwizard.testing.DropwizardTestSupport<?> support) Description copied from interface:TestClientFactoryCreates client instance forClientSupport(once per support instance). Called lazily (only before jersey client is actually required to perform call), so the support object should be already initialized.- Specified by:
createin interfaceTestClientFactory- Parameters:
support- support object- Returns:
- client instance
-
createLogger
protected jakarta.ws.rs.core.Feature createLogger()Configure logging feature.- Returns:
- logging feature
-
configure
protected void configure(org.glassfish.jersey.client.JerseyClientBuilder builder, io.dropwizard.testing.DropwizardTestSupport<?> support) Provides the ability to customize default client in extending class.- Parameters:
builder- client builder (pre-configured)support- dropwizard support instance (for accessing environment and configuration)
-