类 MockPropertySource
public class MockPropertySource
extends cn.taketoday.core.env.PropertiesPropertySource
Simple
PropertySource implementation for use in testing. Accepts
a user-provided Properties object, or if omitted during construction,
the implementation will initialize its own.
The setProperty(java.lang.String, java.lang.Object) and withProperty(java.lang.String, java.lang.Object) methods are exposed for
convenience, for example:
PropertySource<?> source = new MockPropertySource().withProperty("foo", "bar");
- 从以下版本开始:
- 4.0
- 作者:
- Chris Beams
- 另请参阅:
-
嵌套类概要
从类继承的嵌套类/接口 cn.taketoday.core.env.PropertySource
cn.taketoday.core.env.PropertySource.StubPropertySource -
字段概要
字段修饰符和类型字段说明static final String"mockProperties" is the default name forMockPropertySourceinstances not otherwise given an explicit name.从类继承的字段 cn.taketoday.core.env.PropertySource
name, source -
构造器概要
构造器构造器说明Create a newMockPropertySourcenamed "mockProperties" that will maintain its own internalPropertiesinstance.MockPropertySource(String name) Create a newMockPropertySourcewith the given name that will maintain its own internalPropertiesinstance.MockPropertySource(String name, Properties properties) Create a newMockPropertySourcewith the given name and backed by the givenPropertiesobject.MockPropertySource(Properties properties) -
方法概要
修饰符和类型方法说明voidsetProperty(String name, Object value) Set the given property on the underlyingPropertiesobject.withProperty(String name, Object value) Convenient synonym forsetProperty(java.lang.String, java.lang.Object)that returns the current instance.从类继承的方法 cn.taketoday.core.env.PropertiesPropertySource
getPropertyNames从类继承的方法 cn.taketoday.core.env.MapPropertySource
containsProperty, getProperty从类继承的方法 cn.taketoday.core.env.PropertySource
equals, getName, getSource, hashCode, named, toString
-
字段详细资料
-
MOCK_PROPERTIES_PROPERTY_SOURCE_NAME
"mockProperties" is the default name forMockPropertySourceinstances not otherwise given an explicit name.
-
-
构造器详细资料
-
MockPropertySource
public MockPropertySource()Create a newMockPropertySourcenamed "mockProperties" that will maintain its own internalPropertiesinstance. -
MockPropertySource
Create a newMockPropertySourcewith the given name that will maintain its own internalPropertiesinstance.- 参数:
name- the name of the property source
-
MockPropertySource
- 参数:
properties- the properties to use
-
MockPropertySource
Create a newMockPropertySourcewith the given name and backed by the givenPropertiesobject.- 参数:
name- the name of the property sourceproperties- the properties to use
-
-
方法详细资料
-
setProperty
Set the given property on the underlyingPropertiesobject. -
withProperty
Convenient synonym forsetProperty(java.lang.String, java.lang.Object)that returns the current instance. Useful for method chaining and fluent-style use.- 返回:
- this
MockPropertySourceinstance
-