Package org.sdase.commons.server.testing
Class DropwizardConfigurationHelper<C extends io.dropwizard.Configuration>
- java.lang.Object
-
- org.sdase.commons.server.testing.DropwizardConfigurationHelper<C>
-
- Type Parameters:
C
- the type of theConfiguration
used by anApplication
- All Implemented Interfaces:
ConfigurationBuilders.CustomizationBuilder<C>
,ConfigurationBuilders.PortBuilder<C>
public class DropwizardConfigurationHelper<C extends io.dropwizard.Configuration> extends java.lang.Object implements ConfigurationBuilders.PortBuilder<C>, ConfigurationBuilders.CustomizationBuilder<C>
A helper that creates aConfiguration
programmatically.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description C
build()
static <C1 extends io.dropwizard.Configuration>
ConfigurationBuilders.PortBuilder<C1>configFrom(java.util.function.Supplier<C1> configurationSupplier)
ConfigurationBuilders.CustomizationBuilder<C>
withConfigurationModifier(java.util.function.Consumer<C> configurationCustomizer)
Allows to customize the configuration programmatically.ConfigurationBuilders.CustomizationBuilder<C>
withPorts(int applicationPort, int adminPort)
Sets the given ports as fixed ports.ConfigurationBuilders.CustomizationBuilder<C>
withRandomPorts()
Configures random application port and the admin port.ConfigurationBuilders.CustomizationBuilder<C>
withRootPath(java.lang.String rootPath)
Sets thejersey root path
, referenced in theconfig.yaml
as
-
-
-
Method Detail
-
configFrom
public static <C1 extends io.dropwizard.Configuration> ConfigurationBuilders.PortBuilder<C1> configFrom(java.util.function.Supplier<C1> configurationSupplier)
- Type Parameters:
C1
- the type of theConfiguration
used by anApplication
- Parameters:
configurationSupplier
- a supplier that creates the initialConfiguration
, e.g.MyAppConfig::new
- Returns:
- a builder for programmatic configuration
-
withConfigurationModifier
public ConfigurationBuilders.CustomizationBuilder<C> withConfigurationModifier(java.util.function.Consumer<C> configurationCustomizer)
Description copied from interface:ConfigurationBuilders.CustomizationBuilder
Allows to customize the configuration programmatically.- Specified by:
withConfigurationModifier
in interfaceConfigurationBuilders.CustomizationBuilder<C extends io.dropwizard.Configuration>
- Parameters:
configurationCustomizer
- a consumer that receives the currentConfiguration
of typeC
to modify it's internals- Returns:
- a builder for further configuration
-
withRootPath
public ConfigurationBuilders.CustomizationBuilder<C> withRootPath(java.lang.String rootPath)
Description copied from interface:ConfigurationBuilders.CustomizationBuilder
Sets thejersey root path
, referenced in theconfig.yaml
asserver: rootPath: /*
- Specified by:
withRootPath
in interfaceConfigurationBuilders.CustomizationBuilder<C extends io.dropwizard.Configuration>
- Parameters:
rootPath
- the path to set as root of the API- Returns:
- the builder instance
-
withRandomPorts
public ConfigurationBuilders.CustomizationBuilder<C> withRandomPorts()
Description copied from interface:ConfigurationBuilders.PortBuilder
Configures random application port and the admin port. This settings is equal to setting the connector ports in the configuration yaml to0
- Specified by:
withRandomPorts
in interfaceConfigurationBuilders.PortBuilder<C extends io.dropwizard.Configuration>
- Returns:
- the builder instance
-
withPorts
public ConfigurationBuilders.CustomizationBuilder<C> withPorts(int applicationPort, int adminPort)
Description copied from interface:ConfigurationBuilders.PortBuilder
Sets the given ports as fixed ports. This settings is equal to setting the connector ports in the configuration yaml to the given ports.- Specified by:
withPorts
in interfaceConfigurationBuilders.PortBuilder<C extends io.dropwizard.Configuration>
- Parameters:
applicationPort
- the port the application connector listens toadminPort
- the port the admin connector listens to- Returns:
- the builder instance
-
build
public C build()
- Specified by:
build
in interfaceConfigurationBuilders.CustomizationBuilder<C extends io.dropwizard.Configuration>
- Returns:
- the
Configuration
of typeC
created with this builder
-
-