spring-framework / org.springframework.mock.env / MockEnvironment

MockEnvironment

open class MockEnvironment : AbstractEnvironment

Simple ConfigurableEnvironment implementation exposing #setProperty(String, String) and #withProperty(String, String) methods for testing purposes.

Author
Chris Beams

Author
Sam Brannen

Since
3.2

See Also
org.springframework.mock.env.MockPropertySource

Constructors

<init>

MockEnvironment()

Create a new MockEnvironment with a single MockPropertySource.

Functions

setProperty

open fun setProperty(key: String, value: String): Unit

Set a property on the underlying MockPropertySource for this environment.

withProperty

open fun withProperty(key: String, value: String): MockEnvironment

Convenient synonym for #setProperty that returns the current instance. Useful for method chaining and fluent-style use.