Commit c25736d8 authored by Dave Syer's avatar Dave Syer Committed by Phillip Webb

Add test for nested properties

parent 4e83826b
...@@ -52,6 +52,16 @@ public class EnableConfigurationPropertiesTests { ...@@ -52,6 +52,16 @@ public class EnableConfigurationPropertiesTests {
assertEquals("foo", this.context.getBean(TestProperties.class).name); 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 @Test
public void testBasicPropertiesBindingWithAnnotationOnBaseClass() { public void testBasicPropertiesBindingWithAnnotationOnBaseClass() {
this.context.register(DerivedConfiguration.class); this.context.register(DerivedConfiguration.class);
...@@ -190,6 +200,11 @@ public class EnableConfigurationPropertiesTests { ...@@ -190,6 +200,11 @@ public class EnableConfigurationPropertiesTests {
protected static class DerivedConfiguration { protected static class DerivedConfiguration {
} }
@Configuration
@EnableConfigurationProperties(NestedProperties.class)
protected static class NestedConfiguration {
}
@Configuration @Configuration
protected static class DefaultConfiguration { protected static class DefaultConfiguration {
@Bean @Bean
...@@ -225,6 +240,29 @@ public class EnableConfigurationPropertiesTests { ...@@ -225,6 +240,29 @@ public class EnableConfigurationPropertiesTests {
protected static class MoreConfiguration { 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 @ConfigurationProperties
protected static class BaseProperties { protected static class BaseProperties {
private String name; private String name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment