Package org.springframework.mock.env
Class MockEnvironment
- java.lang.Object
- org.springframework.core.env.AbstractEnvironment
- org.springframework.mock.env.MockEnvironment
- All Implemented Interfaces:
ConfigurableEnvironment
,ConfigurablePropertyResolver
,Environment
,PropertyResolver
public class MockEnvironment extends AbstractEnvironment
SimpleConfigurableEnvironment
implementation exposingsetProperty(String, String)
andwithProperty(String, String)
methods for testing purposes.- Since:
- 3.2
- Author:
- Chris Beams, Sam Brannen
- See Also:
MockPropertySource
Field Summary
Fields inherited from class org.springframework.core.env.AbstractEnvironment
ACTIVE_PROFILES_PROPERTY_NAME, DEFAULT_PROFILES_PROPERTY_NAME, IGNORE_GETENV_PROPERTY_NAME, logger, RESERVED_DEFAULT_PROFILE_NAME
Constructor Summary
Constructors Constructor Description MockEnvironment()
Create a newMockEnvironment
with a singleMockPropertySource
.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setProperty(String key, String value)
Set a property on the underlyingMockPropertySource
for this environment.MockEnvironment
withProperty(String key, String value)
Convenient synonym forsetProperty(java.lang.String, java.lang.String)
that returns the current instance.Methods inherited from class org.springframework.core.env.AbstractEnvironment
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
Constructor Detail
MockEnvironment
public MockEnvironment()
Create a newMockEnvironment
with a singleMockPropertySource
.
Method Detail
setProperty
public void setProperty(String key, String value)
Set a property on the underlyingMockPropertySource
for this environment.
withProperty
public MockEnvironment withProperty(String key, String value)
Convenient synonym forsetProperty(java.lang.String, java.lang.String)
that returns the current instance. Useful for method chaining and fluent-style use.- Returns:
- this
MockEnvironment
instance - See Also:
MockPropertySource.withProperty(java.lang.String, java.lang.Object)