Browse Source

Add test for nested properties

pull/24/merge
Dave Syer 13 years ago
parent
commit
7a935d371b
  1. 38
      spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java

38
spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java

@ -52,6 +52,16 @@ public class EnableConfigurationPropertiesTests { @@ -52,6 +52,16 @@ public class EnableConfigurationPropertiesTests {
assertEquals("foo", this.context.getBean(TestProperties.class).name);
}
@Test
public void testNestedPropertiesBinding() {
this.context.register(NestedConfiguration.class);
TestUtils.addEnviroment(this.context, "name:foo", "nested.name:bar");
this.context.refresh();
assertEquals(1, this.context.getBeanNamesForType(NestedProperties.class).length);
assertEquals("foo", this.context.getBean(NestedProperties.class).name);
assertEquals("bar", this.context.getBean(NestedProperties.class).nested.name);
}
@Test
public void testBasicPropertiesBindingWithAnnotationOnBaseClass() {
this.context.register(DerivedConfiguration.class);
@ -190,6 +200,11 @@ public class EnableConfigurationPropertiesTests { @@ -190,6 +200,11 @@ public class EnableConfigurationPropertiesTests {
protected static class DerivedConfiguration {
}
@Configuration
@EnableConfigurationProperties(NestedProperties.class)
protected static class NestedConfiguration {
}
@Configuration
protected static class DefaultConfiguration {
@Bean
@ -225,6 +240,29 @@ public class EnableConfigurationPropertiesTests { @@ -225,6 +240,29 @@ public class EnableConfigurationPropertiesTests {
protected static class MoreConfiguration {
}
@ConfigurationProperties
protected static class NestedProperties {
private String name;
private Nested nested = new Nested();
public void setName(String name) {
this.name = name;
}
public Nested getNested() {
return this.nested;
}
protected static class Nested {
private String name;
public void setName(String name) {
this.name = name;
}
}
}
@ConfigurationProperties
protected static class BaseProperties {
private String name;

Loading…
Cancel
Save