|
17 | 17 | package org.springframework.boot.context.properties;
|
18 | 18 |
|
19 | 19 | import java.util.List;
|
| 20 | +import java.util.Map; |
20 | 21 |
|
21 | 22 | import javax.annotation.PostConstruct;
|
22 | 23 | import javax.validation.constraints.NotNull;
|
|
47 | 48 | import org.springframework.validation.ValidationUtils;
|
48 | 49 | import org.springframework.validation.Validator;
|
49 | 50 | import org.springframework.validation.annotation.Validated;
|
| 51 | +import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; |
50 | 52 |
|
51 | 53 | import static org.assertj.core.api.Assertions.assertThat;
|
52 | 54 | import static org.junit.Assert.fail;
|
@@ -330,6 +332,17 @@ public void multiplePropertySourcesPlaceholderConfigurer() throws Exception {
|
330 | 332 | "Multiple PropertySourcesPlaceholderConfigurer beans registered");
|
331 | 333 | }
|
332 | 334 |
|
| 335 | + @Test |
| 336 | + public void propertiesWithMap() throws Exception { |
| 337 | + this.context = new AnnotationConfigApplicationContext(); |
| 338 | + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, |
| 339 | + "test.map.foo=bar"); |
| 340 | + this.context.register(PropertiesWithMap.class); |
| 341 | + this.context.refresh(); |
| 342 | + assertThat(this.context.getBean(PropertiesWithMap.class).getMap()) |
| 343 | + .containsEntry("foo", "bar"); |
| 344 | + } |
| 345 | + |
333 | 346 | private void assertBindingFailure(int errorCount) {
|
334 | 347 | try {
|
335 | 348 | this.context.refresh();
|
@@ -608,6 +621,28 @@ public static PropertySourcesPlaceholderConfigurer configurer() {
|
608 | 621 |
|
609 | 622 | }
|
610 | 623 |
|
| 624 | + @Configuration |
| 625 | + @EnableConfigurationProperties |
| 626 | + @ConfigurationProperties(prefix = "test") |
| 627 | + public static class PropertiesWithMap { |
| 628 | + |
| 629 | + @Bean |
| 630 | + public Validator validator() { |
| 631 | + return new LocalValidatorFactoryBean(); |
| 632 | + } |
| 633 | + |
| 634 | + private Map<String, String> map; |
| 635 | + |
| 636 | + public Map<String, String> getMap() { |
| 637 | + return this.map; |
| 638 | + } |
| 639 | + |
| 640 | + public void setMap(Map<String, String> map) { |
| 641 | + this.map = map; |
| 642 | + } |
| 643 | + |
| 644 | + } |
| 645 | + |
611 | 646 | @Configuration
|
612 | 647 | @EnableConfigurationProperties
|
613 | 648 | public static class ConfigurationPropertiesWithFactoryBean {
|
|
0 commit comments