|
|
|
@ -275,15 +275,15 @@ public class ConfigurationPropertiesTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void loadWhenPrefixedPropertiesDecalredAsBeanShouldBind() { |
|
|
|
public void loadWhenPrefixedPropertiesDeclaredAsBeanShouldBind() { |
|
|
|
load(PrefixPropertiesDecalredAsBeanConfiguration.class, "spring.foo.name=foo"); |
|
|
|
load(PrefixPropertiesDeclaredAsBeanConfiguration.class, "spring.foo.name=foo"); |
|
|
|
PrefixProperties bean = this.context.getBean(PrefixProperties.class); |
|
|
|
PrefixProperties bean = this.context.getBean(PrefixProperties.class); |
|
|
|
assertThat(((BasicProperties) bean).name).isEqualTo("foo"); |
|
|
|
assertThat(((BasicProperties) bean).name).isEqualTo("foo"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void loadWhenPrefixedPropertiesDecalredAsAnnotationValueShouldBind() { |
|
|
|
public void loadWhenPrefixedPropertiesDeclaredAsAnnotationValueShouldBind() { |
|
|
|
load(PrefixPropertiesDecalredAsAnnotationValueConfiguration.class, |
|
|
|
load(PrefixPropertiesDeclaredAsAnnotationValueConfiguration.class, |
|
|
|
"spring.foo.name=foo"); |
|
|
|
"spring.foo.name=foo"); |
|
|
|
PrefixProperties bean = this.context.getBean( |
|
|
|
PrefixProperties bean = this.context.getBean( |
|
|
|
"spring.foo-" + PrefixProperties.class.getName(), PrefixProperties.class); |
|
|
|
"spring.foo-" + PrefixProperties.class.getName(), PrefixProperties.class); |
|
|
|
@ -291,8 +291,8 @@ public class ConfigurationPropertiesTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void loadWhenMultiplePrefixedPropertiesDecalredAsAnnotationValueShouldBind() { |
|
|
|
public void loadWhenMultiplePrefixedPropertiesDeclaredAsAnnotationValueShouldBind() { |
|
|
|
load(MultiplePrefixPropertiesDecalredAsAnnotationValueConfiguration.class, |
|
|
|
load(MultiplePrefixPropertiesDeclaredAsAnnotationValueConfiguration.class, |
|
|
|
"spring.foo.name=foo", "spring.bar.name=bar"); |
|
|
|
"spring.foo.name=foo", "spring.bar.name=bar"); |
|
|
|
PrefixProperties bean1 = this.context.getBean(PrefixProperties.class); |
|
|
|
PrefixProperties bean1 = this.context.getBean(PrefixProperties.class); |
|
|
|
AnotherPrefixProperties bean2 = this.context |
|
|
|
AnotherPrefixProperties bean2 = this.context |
|
|
|
@ -510,7 +510,7 @@ public class ConfigurationPropertiesTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void loadWhenOverridingPropertiesWithPlaceholderResolutionInEnvionmentShouldBindWithOverride() { |
|
|
|
public void loadWhenOverridingPropertiesWithPlaceholderResolutionInEnvironmentShouldBindWithOverride() { |
|
|
|
MutablePropertySources sources = this.context.getEnvironment() |
|
|
|
MutablePropertySources sources = this.context.getEnvironment() |
|
|
|
.getPropertySources(); |
|
|
|
.getPropertySources(); |
|
|
|
sources.addFirst(new SystemEnvironmentPropertySource("system", |
|
|
|
sources.addFirst(new SystemEnvironmentPropertySource("system", |
|
|
|
@ -790,7 +790,7 @@ public class ConfigurationPropertiesTests { |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
@EnableConfigurationProperties |
|
|
|
@EnableConfigurationProperties |
|
|
|
static class PrefixPropertiesDecalredAsBeanConfiguration { |
|
|
|
static class PrefixPropertiesDeclaredAsBeanConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public PrefixProperties prefixProperties() { |
|
|
|
public PrefixProperties prefixProperties() { |
|
|
|
@ -801,14 +801,14 @@ public class ConfigurationPropertiesTests { |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
@EnableConfigurationProperties(PrefixProperties.class) |
|
|
|
@EnableConfigurationProperties(PrefixProperties.class) |
|
|
|
static class PrefixPropertiesDecalredAsAnnotationValueConfiguration { |
|
|
|
static class PrefixPropertiesDeclaredAsAnnotationValueConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
@EnableConfigurationProperties({ PrefixProperties.class, |
|
|
|
@EnableConfigurationProperties({ PrefixProperties.class, |
|
|
|
AnotherPrefixProperties.class }) |
|
|
|
AnotherPrefixProperties.class }) |
|
|
|
static class MultiplePrefixPropertiesDecalredAsAnnotationValueConfiguration { |
|
|
|
static class MultiplePrefixPropertiesDeclaredAsAnnotationValueConfiguration { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|