public final class TestPropertyValues
extends java.lang.Object
Environment or to the system environment.| Modifier and Type | Class and Description |
|---|---|
static class |
TestPropertyValues.Pair
A single name value pair.
|
static class |
TestPropertyValues.Type
The type of property source.
|
| Modifier and Type | Method and Description |
|---|---|
TestPropertyValues |
and(java.lang.Iterable<java.lang.String> pairs)
Return a new
TestPropertyValues instance with additional entries. |
TestPropertyValues |
and(java.util.Map<java.lang.String,java.lang.String> map)
Return a new
TestPropertyValues instance with additional entries. |
TestPropertyValues |
and(java.util.stream.Stream<java.lang.String> pairs)
Return a new
TestPropertyValues instance with additional entries. |
<T> TestPropertyValues |
and(java.util.stream.Stream<T> stream,
java.util.function.Function<T,TestPropertyValues.Pair> mapper)
Return a new
TestPropertyValues instance with additional entries. |
TestPropertyValues |
and(java.lang.String... pairs)
Return a new
TestPropertyValues instance with additional entries. |
void |
applyTo(org.springframework.context.ConfigurableApplicationContext context)
Add the properties from the underlying map to the environment owned by an
ApplicationContext. |
void |
applyTo(org.springframework.core.env.ConfigurableEnvironment environment)
Add the properties from the underlying map to the environment.
|
void |
applyTo(org.springframework.core.env.ConfigurableEnvironment environment,
TestPropertyValues.Type type)
Add the properties from the underlying map to the environment using the specified
property source type.
|
void |
applyTo(org.springframework.core.env.ConfigurableEnvironment environment,
TestPropertyValues.Type type,
java.lang.String name)
Add the properties from the underlying map to the environment using the specified
property source type and name.
|
<T> T |
applyToSystemProperties(java.util.concurrent.Callable<T> call)
Add the properties to the
system properties for the
duration of the call, restoring previous values when the call completes. |
static TestPropertyValues |
empty()
Return an empty
TestPropertyValues instance. |
static TestPropertyValues |
of(java.lang.Iterable<java.lang.String> pairs)
Return a new
TestPropertyValues with the underlying map populated with the
given property pairs. |
static TestPropertyValues |
of(java.util.Map<java.lang.String,java.lang.String> map)
Return a new
TestPropertyValues with the underlying map populated with the
given map entries. |
static TestPropertyValues |
of(java.util.stream.Stream<java.lang.String> pairs)
Return a new
TestPropertyValues with the underlying map populated with the
given property pairs. |
static <T> TestPropertyValues |
of(java.util.stream.Stream<T> stream,
java.util.function.Function<T,TestPropertyValues.Pair> mapper)
Return a new
TestPropertyValues with the underlying map populated with the
given stream. |
static TestPropertyValues |
of(java.lang.String... pairs)
Return a new
TestPropertyValues with the underlying map populated with the
given property pairs. |
public TestPropertyValues and(java.lang.String... pairs)
TestPropertyValues instance with additional entries.
Name-value pairs can be specified with colon (":") or equals ("=") separators.pairs - the property pairs to addTestPropertyValues instancepublic TestPropertyValues and(java.lang.Iterable<java.lang.String> pairs)
TestPropertyValues instance with additional entries.
Name-value pairs can be specified with colon (":") or equals ("=") separators.pairs - the property pairs to addTestPropertyValues instancepublic TestPropertyValues and(java.util.stream.Stream<java.lang.String> pairs)
TestPropertyValues instance with additional entries.
Name-value pairs can be specified with colon (":") or equals ("=") separators.pairs - the property pairs to addTestPropertyValues instancepublic TestPropertyValues and(java.util.Map<java.lang.String,java.lang.String> map)
TestPropertyValues instance with additional entries.map - the map of properties that need to be added to the environmentTestPropertyValues instancepublic <T> TestPropertyValues and(java.util.stream.Stream<T> stream, java.util.function.Function<T,TestPropertyValues.Pair> mapper)
TestPropertyValues instance with additional entries.T - the stream element typestream - the elements that need to be added to the environmentmapper - a mapper function to convert an element from the stream into a
TestPropertyValues.PairTestPropertyValues instancepublic void applyTo(org.springframework.context.ConfigurableApplicationContext context)
ApplicationContext.context - the context with an environment to modifypublic void applyTo(org.springframework.core.env.ConfigurableEnvironment environment)
MapPropertySource.environment - the environment that needs to be modifiedpublic void applyTo(org.springframework.core.env.ConfigurableEnvironment environment,
TestPropertyValues.Type type)
environment - the environment that needs to be modifiedtype - the type of PropertySource to be added. See TestPropertyValues.Typepublic void applyTo(org.springframework.core.env.ConfigurableEnvironment environment,
TestPropertyValues.Type type,
java.lang.String name)
environment - the environment that needs to be modifiedtype - the type of PropertySource to be added. See TestPropertyValues.Typename - the name for the property sourcepublic <T> T applyToSystemProperties(java.util.concurrent.Callable<T> call)
system properties for the
duration of the call, restoring previous values when the call completes.T - the result typecall - the call to makepublic static TestPropertyValues of(java.lang.String... pairs)
TestPropertyValues with the underlying map populated with the
given property pairs. Name-value pairs can be specified with colon (":") or equals
("=") separators.pairs - the name-value pairs for properties that need to be added to the
environmentpublic static TestPropertyValues of(java.lang.Iterable<java.lang.String> pairs)
TestPropertyValues with the underlying map populated with the
given property pairs. Name-value pairs can be specified with colon (":") or equals
("=") separators.pairs - the name-value pairs for properties that need to be added to the
environmentpublic static TestPropertyValues of(java.util.stream.Stream<java.lang.String> pairs)
TestPropertyValues with the underlying map populated with the
given property pairs. Name-value pairs can be specified with colon (":") or equals
("=") separators.pairs - the name-value pairs for properties that need to be added to the
environmentpublic static TestPropertyValues of(java.util.Map<java.lang.String,java.lang.String> map)
TestPropertyValues with the underlying map populated with the
given map entries.map - the map of properties that need to be added to the environmentpublic static <T> TestPropertyValues of(java.util.stream.Stream<T> stream, java.util.function.Function<T,TestPropertyValues.Pair> mapper)
TestPropertyValues with the underlying map populated with the
given stream.T - the stream element typestream - the elements that need to be added to the environmentmapper - a mapper function to convert an element from the stream into a
TestPropertyValues.Pairpublic static TestPropertyValues empty()
TestPropertyValues instance.