Class MockEnvironment
java.lang.Object
org.springframework.core.env.AbstractEnvironment
org.springframework.mock.env.MockEnvironment
- All Implemented Interfaces:
- ConfigurableEnvironment, ConfigurablePropertyResolver, Environment, PropertyResolver
Simple 
ConfigurableEnvironment implementation exposing
setProperty(String, Object) and withProperty(String, Object) methods for testing purposes.- Since:
- 3.2
- Author:
- Chris Beams, Sam Brannen
- See Also:
- 
Field SummaryFields inherited from class AbstractEnvironmentACTIVE_PROFILES_PROPERTY_NAME, DEFAULT_PROFILES_PROPERTY_NAME, IGNORE_GETENV_PROPERTY_NAME, logger, RESERVED_DEFAULT_PROFILE_NAME
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidsetProperty(String name, Object value) Set a property on the underlyingMockPropertySourcefor this environment.withProperty(String name, Object value) Convenient synonym forsetProperty(String, Object)that returns the current instance.Methods inherited from class AbstractEnvironmentacceptsProfiles, acceptsProfiles, addActiveProfile, containsProperty, createPropertyResolver, customizePropertySources, doGetActiveProfiles, doGetActiveProfilesProperty, doGetDefaultProfiles, doGetDefaultProfilesProperty, getActiveProfiles, getConversionService, getDefaultProfiles, getProperty, getProperty, getProperty, getProperty, getPropertyResolver, getPropertySources, getRequiredProperty, getRequiredProperty, getReservedDefaultProfiles, getSystemEnvironment, getSystemProperties, isProfileActive, merge, resolvePlaceholders, resolveRequiredPlaceholders, setActiveProfiles, setConversionService, setDefaultProfiles, setEscapeCharacter, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, suppressGetenvAccess, toString, validateProfile, validateRequiredPropertiesMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface EnvironmentmatchesProfiles
- 
Constructor Details- 
MockEnvironmentpublic MockEnvironment()Create a newMockEnvironmentwith a singleMockPropertySource.
 
- 
- 
Method Details- 
setPropertySet a property on the underlyingMockPropertySourcefor this environment.- Since:
- 6.2.8
- See Also:
 
- 
withPropertyConvenient synonym forsetProperty(String, Object)that returns the current instance.Useful for method chaining and fluent-style use. - Returns:
- this MockEnvironmentinstance
- Since:
- 6.2.8
- See Also:
 
 
-