|
|
|
@ -51,7 +51,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp |
|
|
|
public void runWithSystemPropertiesShouldSetAndRemoveProperties() { |
|
|
|
public void runWithSystemPropertiesShouldSetAndRemoveProperties() { |
|
|
|
String key = "test." + UUID.randomUUID().toString(); |
|
|
|
String key = "test." + UUID.randomUUID().toString(); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
get().withSystemProperties(key + "=value").run(loaded -> { |
|
|
|
get().withSystemProperties(key + "=value").run((loaded) -> { |
|
|
|
assertThat(System.getProperties()).containsEntry(key, "value"); |
|
|
|
assertThat(System.getProperties()).containsEntry(key, "value"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
@ -63,7 +63,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp |
|
|
|
String key = "test." + UUID.randomUUID().toString(); |
|
|
|
String key = "test." + UUID.randomUUID().toString(); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
get().withSystemProperties(key + "=value") |
|
|
|
get().withSystemProperties(key + "=value") |
|
|
|
.withUserConfiguration(FailingConfig.class).run(loaded -> { |
|
|
|
.withUserConfiguration(FailingConfig.class).run((loaded) -> { |
|
|
|
assertThat(loaded).hasFailed(); |
|
|
|
assertThat(loaded).hasFailed(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
assertThat(System.getProperties().containsKey(key)).isFalse(); |
|
|
|
@ -76,7 +76,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp |
|
|
|
System.setProperty(key, "value"); |
|
|
|
System.setProperty(key, "value"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
get().withSystemProperties(key + "=newValue").run(loaded -> { |
|
|
|
get().withSystemProperties(key + "=newValue").run((loaded) -> { |
|
|
|
assertThat(System.getProperties()).containsEntry(key, "newValue"); |
|
|
|
assertThat(System.getProperties()).containsEntry(key, "newValue"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
@ -93,7 +93,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp |
|
|
|
System.setProperty(key, "value"); |
|
|
|
System.setProperty(key, "value"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
get().withSystemProperty(key, null).run(loaded -> { |
|
|
|
get().withSystemProperty(key, null).run((loaded) -> { |
|
|
|
assertThat(System.getProperties()).doesNotContainKey(key); |
|
|
|
assertThat(System.getProperties()).doesNotContainKey(key); |
|
|
|
}); |
|
|
|
}); |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
assertThat(System.getProperties().getProperty(key)).isEqualTo("value"); |
|
|
|
@ -106,7 +106,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void runWithMultiplePropertyValuesShouldAllAllValues() throws Exception { |
|
|
|
public void runWithMultiplePropertyValuesShouldAllAllValues() throws Exception { |
|
|
|
get().withPropertyValues("test.foo=1").withPropertyValues("test.bar=2") |
|
|
|
get().withPropertyValues("test.foo=1").withPropertyValues("test.bar=2") |
|
|
|
.run(loaded -> { |
|
|
|
.run((loaded) -> { |
|
|
|
Environment environment = loaded.getEnvironment(); |
|
|
|
Environment environment = loaded.getEnvironment(); |
|
|
|
assertThat(environment.getProperty("test.foo")).isEqualTo("1"); |
|
|
|
assertThat(environment.getProperty("test.foo")).isEqualTo("1"); |
|
|
|
assertThat(environment.getProperty("test.bar")).isEqualTo("2"); |
|
|
|
assertThat(environment.getProperty("test.bar")).isEqualTo("2"); |
|
|
|
@ -117,7 +117,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp |
|
|
|
public void runWithPropertyValuesWhenHasExistingShouldReplaceValue() |
|
|
|
public void runWithPropertyValuesWhenHasExistingShouldReplaceValue() |
|
|
|
throws Exception { |
|
|
|
throws Exception { |
|
|
|
get().withPropertyValues("test.foo=1").withPropertyValues("test.foo=2") |
|
|
|
get().withPropertyValues("test.foo=1").withPropertyValues("test.foo=2") |
|
|
|
.run(loaded -> { |
|
|
|
.run((loaded) -> { |
|
|
|
Environment environment = loaded.getEnvironment(); |
|
|
|
Environment environment = loaded.getEnvironment(); |
|
|
|
assertThat(environment.getProperty("test.foo")).isEqualTo("2"); |
|
|
|
assertThat(environment.getProperty("test.foo")).isEqualTo("2"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|