Adds support for non-enumerable property sources in bootstrap.
Fixes gh-724
This commit is contained in:
@@ -416,12 +416,37 @@ public class BootstrapConfigurationTests {
|
||||
.isEqualTo("Hello added!");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonEnumerablePropertySourceWorks() {
|
||||
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
|
||||
.sources(BareConfiguration.class)
|
||||
.properties("spring.cloud.bootstrap.name=nonenumerable").run();
|
||||
then(this.context.getEnvironment().getProperty("foo")).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties
|
||||
protected static class BareConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
// This is added to bootstrap context as a source in bootstrap.properties
|
||||
protected static class SimplePropertySourceConfiguration
|
||||
implements PropertySourceLocator {
|
||||
|
||||
@Override
|
||||
public PropertySource<?> locate(Environment environment) {
|
||||
return new PropertySource("testBootstrapSimple", this) {
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
return ("foo".equals(name)) ? "bar" : null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConfigurationProperties("expected")
|
||||
// This is added to bootstrap context as a source in bootstrap.properties
|
||||
|
||||
Reference in New Issue
Block a user