Make TestPropertyValues immutable
Update `TestPropertyValues` so that it is totally immutable. Methods now return a new instance rather than changing existing state. See gh-9875
This commit is contained in:
@@ -95,7 +95,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
|
||||
System.setProperty(key, "value");
|
||||
try {
|
||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||
get().withSystemProperty(key, null).run((loaded) -> {
|
||||
get().withSystemProperties(key + "=").run((loaded) -> {
|
||||
assertThat(System.getProperties()).doesNotContainKey(key);
|
||||
});
|
||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||
|
||||
@@ -89,8 +89,8 @@ public class TestPropertyValuesTests {
|
||||
|
||||
@Test
|
||||
public void andShouldChainAndAddSingleKeyValue() throws Exception {
|
||||
TestPropertyValues.of("foo.bar=baz").and("hello.world", "hi")
|
||||
.and("bling.blah", "bing").applyTo(this.environment, Type.MAP);
|
||||
TestPropertyValues.of("foo.bar=baz").and("hello.world=hi").and("bling.blah=bing")
|
||||
.applyTo(this.environment, Type.MAP);
|
||||
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("baz");
|
||||
assertThat(this.environment.getProperty("hello.world")).isEqualTo("hi");
|
||||
assertThat(this.environment.getProperty("bling.blah")).isEqualTo("bing");
|
||||
@@ -127,7 +127,7 @@ public class TestPropertyValuesTests {
|
||||
throws Exception {
|
||||
System.setProperty("foo", "bar1");
|
||||
try {
|
||||
TestPropertyValues.ofPair("foo", null).applyToSystemProperties(() -> {
|
||||
TestPropertyValues.of("foo").applyToSystemProperties(() -> {
|
||||
assertThat(System.getProperties()).doesNotContainKey("foo");
|
||||
return null;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user