Add flag spring.cloud.config.overrideNone
If true (and spring.cloud.config.allowOverride=true) then the bootstrap property source is added *last*, so all other property sources can override it (including local config files). Fixes gh-26, fixes gh-27.
This commit is contained in:
@@ -156,6 +156,32 @@ public class BootstrapConfigurationTests {
|
||||
assertEquals("bar", this.context.getEnvironment().getProperty("bootstrap.foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void systemPropertyOverrideFalseWhenOverrideAllowed() {
|
||||
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
|
||||
PropertySourceConfiguration.MAP.put(
|
||||
"spring.cloud.config.overrideSystemProperties", "false");
|
||||
PropertySourceConfiguration.MAP.put("spring.cloud.config.allowOverride", "true");
|
||||
System.setProperty("bootstrap.foo", "system");
|
||||
this.context = new SpringApplicationBuilder().web(false)
|
||||
.sources(BareConfiguration.class).run();
|
||||
assertEquals("system", this.context.getEnvironment().getProperty("bootstrap.foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideAllWhenOverrideAllowed() {
|
||||
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
|
||||
PropertySourceConfiguration.MAP.put("spring.cloud.config.overrideNone", "true");
|
||||
PropertySourceConfiguration.MAP.put("spring.cloud.config.allowOverride", "true");
|
||||
ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
environment.getPropertySources().addLast(
|
||||
new MapPropertySource("last", Collections.<String, Object> singletonMap(
|
||||
"bootstrap.foo", "splat")));
|
||||
this.context = new SpringApplicationBuilder().web(false).environment(environment)
|
||||
.sources(BareConfiguration.class).run();
|
||||
assertEquals("splat", this.context.getEnvironment().getProperty("bootstrap.foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationNameInBootstrapAndMain() {
|
||||
System.setProperty("expected.name", "main");
|
||||
|
||||
Reference in New Issue
Block a user