java.lang.Object | |||||
↳ | org.springframework.core.env.PropertySource<T> | ||||
↳ | org.springframework.core.env.EnumerablePropertySource<T> | ||||
↳ | org.springframework.core.env.MapPropertySource | ||||
↳ | org.springframework.core.env.PropertiesPropertySource | ||||
↳ | org.springframework.mock.env.MockPropertySource |
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(String, String)
and withProperty(String, String)
methods are exposed for
convenience, for example:
PropertySource<?> source = new MockPropertySource().withProperty("foo", "bar");
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | MOCK_PROPERTIES_PROPERTY_SOURCE_NAME | {@value } is the default name for MockPropertySource instances not
otherwise given an explicit name. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.core.env.EnumerablePropertySource
| |||||||||||
From class
org.springframework.core.env.PropertySource
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new
MockPropertySource named {@value #MOCK_PROPERTIES_PROPERTY_SOURCE_NAME}
that will maintain its own internal Properties instance. | |||||||||||
Create a new
MockPropertySource with the given name that will
maintain its own internal Properties instance. | |||||||||||
Create a new
MockPropertySource named {@value #MOCK_PROPERTIES_PROPERTY_SOURCE_NAME}
and backed by the given Properties object. | |||||||||||
Create a new
MockPropertySource with with the given name and backed by the given
Properties object |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Set the given property on the underlying
Properties object. | |||||||||||
Convenient synonym for
setProperty(String, String) that returns the current instance. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.core.env.MapPropertySource
| |||||||||||
From class
org.springframework.core.env.EnumerablePropertySource
| |||||||||||
From class
org.springframework.core.env.PropertySource
| |||||||||||
From class
java.lang.Object
|
{@value } is the default name for MockPropertySource
instances not
otherwise given an explicit name.
Create a new MockPropertySource
named {@value #MOCK_PROPERTIES_PROPERTY_SOURCE_NAME}
that will maintain its own internal Properties
instance.
Create a new MockPropertySource
with the given name that will
maintain its own internal Properties
instance.
name | the name of the property source
|
---|
Create a new MockPropertySource
named {@value #MOCK_PROPERTIES_PROPERTY_SOURCE_NAME}
and backed by the given Properties
object.
properties | the properties to use |
---|
Create a new MockPropertySource
with with the given name and backed by the given
Properties
object
name | the name of the property source |
---|---|
properties | the properties to use |
Set the given property on the underlying Properties
object.
Convenient synonym for setProperty(String, String)
that returns the current instance.
Useful for method chaining and fluent-style use.
MockPropertySource
instance