public class MockEnvironment extends AbstractEnvironment
ConfigurableEnvironment
implementation exposing
setProperty(String, String)
and withProperty(String, String)
methods for testing purposes.MockPropertySource
ACTIVE_PROFILES_PROPERTY_NAME, DEFAULT_PROFILES_PROPERTY_NAME, IGNORE_GETENV_PROPERTY_NAME, logger, RESERVED_DEFAULT_PROFILE_NAME
Constructor and Description |
---|
MockEnvironment()
Create a new
MockEnvironment with a single MockPropertySource . |
Modifier and Type | Method and Description |
---|---|
void |
setProperty(java.lang.String key,
java.lang.String value)
Set a property on the underlying
MockPropertySource for this environment. |
MockEnvironment |
withProperty(java.lang.String key,
java.lang.String value)
Convenient synonym for
setProperty(java.lang.String, java.lang.String) that returns the current instance. |
acceptsProfiles, addActiveProfile, containsProperty, customizePropertySources, doGetActiveProfiles, doGetDefaultProfiles, getActiveProfiles, getConversionService, getDefaultProfiles, getProperty, getProperty, getProperty, getProperty, getPropertyAsClass, getPropertySources, getRequiredProperty, getRequiredProperty, getReservedDefaultProfiles, getSystemEnvironment, getSystemProperties, isProfileActive, merge, resolvePlaceholders, resolveRequiredPlaceholders, setActiveProfiles, setConversionService, setDefaultProfiles, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, suppressGetenvAccess, toString, validateProfile, validateRequiredProperties
public MockEnvironment()
MockEnvironment
with a single MockPropertySource
.public void setProperty(java.lang.String key, java.lang.String value)
MockPropertySource
for this environment.public MockEnvironment withProperty(java.lang.String key, java.lang.String value)
setProperty(java.lang.String, java.lang.String)
that returns the current instance.
Useful for method chaining and fluent-style use.MockEnvironment
instanceMockPropertySource.withProperty(java.lang.String, java.lang.Object)