public class TestConfig extends Object implements Config
Config implementation using a Map for unit test usages. Use addConfigValue(String, String) to specify some configuration parameters.
The default converts are specified with registerDefaultConverters() and additional ones can be defined using registerConverter(Converter).
After the unit test has run, one should remove the configuration parameters with the method resetConfig().| Constructor and Description |
|---|
TestConfig() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addConfigValue(String key,
String value)
Add a configuration parameter value, which will be picked up a call to
Config.getValue(String, Class). |
<T> T |
convert(String value,
Class<T> asType) |
static void |
deregisterAllConverters()
De-register all converters, default one and additional registered ones.
|
Iterable<ConfigSource> |
getConfigSources() |
<T> T |
getOptionalValue(String propertyName,
Class<T> propertyType) |
Iterable<String> |
getPropertyNames() |
<T> T |
getValue(String propertyName,
Class<T> propertyType) |
static void |
registerConverter(Converter<?> converter)
Register a
Converter to convert the Configuration parameter value to a certain type. |
static void |
registerDefaultConverters()
Registers default
Converters for String, Boolean, Double, Float, Integer, Long and Date as defined
by the Geronimo Config implementation. |
static void |
resetConfig()
Reset all Configuration parameter values so that the tests keep on being independent.
|
public static void addConfigValue(String key, String value)
Config.getValue(String, Class).key - Parameter key valuevalue - Configuration parameter value.public static void resetConfig()
public static void registerConverter(Converter<?> converter)
Converter to convert the Configuration parameter value to a certain type.converter - The converter to be registered.public static void registerDefaultConverters()
Converters for String, Boolean, Double, Float, Integer, Long and Date as defined
by the Geronimo Config implementation.public static void deregisterAllConverters()
Converter is registered which could interfere with the normal execution of other tests.public <T> T getOptionalValue(String propertyName, Class<T> propertyType)
getOptionalValue in interface Configpublic Iterable<String> getPropertyNames()
getPropertyNames in interface Configpublic Iterable<ConfigSource> getConfigSources()
getConfigSources in interface ConfigCopyright © 2017–2018. All rights reserved.