|
44 | 44 | import org.springframework.context.ConfigurableApplicationContext;
|
45 | 45 | import org.springframework.context.annotation.Bean;
|
46 | 46 | import org.springframework.context.annotation.Configuration;
|
| 47 | +import org.springframework.core.env.ConfigurableEnvironment; |
47 | 48 | import org.springframework.core.env.Environment;
|
| 49 | +import org.springframework.core.env.MapPropertySource; |
| 50 | +import org.springframework.core.env.PropertySource; |
48 | 51 | import org.springframework.mock.env.MockPropertySource;
|
49 | 52 | import org.springframework.util.unit.DataSize;
|
50 | 53 |
|
@@ -143,6 +146,21 @@ void descriptorWithDurationProperty() {
|
143 | 146 | .isEqualTo(Duration.ofSeconds(10).toString())));
|
144 | 147 | }
|
145 | 148 |
|
| 149 | + @Test // gh-36076 |
| 150 | + void descriptorWithWrapperProperty() { |
| 151 | + this.contextRunner.withUserConfiguration(TestPropertiesConfiguration.class).withInitializer((context) -> { |
| 152 | + ConfigurableEnvironment environment = context.getEnvironment(); |
| 153 | + Map<String, Object> map = Collections.singletonMap("test.wrapper", 10); |
| 154 | + PropertySource<?> propertySource = new MapPropertySource("test", map); |
| 155 | + environment.getPropertySources().addLast(propertySource); |
| 156 | + }) |
| 157 | + .run(assertProperties("test", (properties) -> assertThat(properties.get("wrapper")).isEqualTo(10), |
| 158 | + (inputs) -> { |
| 159 | + Map<String, Object> wrapper = (Map<String, Object>) inputs.get("wrapper"); |
| 160 | + assertThat(wrapper.get("value")).isEqualTo(10); |
| 161 | + })); |
| 162 | + } |
| 163 | + |
146 | 164 | @Test
|
147 | 165 | void descriptorWithNonCamelCaseProperty() {
|
148 | 166 | this.contextRunner.withUserConfiguration(MixedCasePropertiesConfiguration.class)
|
@@ -476,6 +494,8 @@ public static class TestProperties {
|
476 | 494 |
|
477 | 495 | private String ignored = "dummy";
|
478 | 496 |
|
| 497 | + private Integer wrapper; |
| 498 | + |
479 | 499 | public String getDbPassword() {
|
480 | 500 | return this.dbPassword;
|
481 | 501 | }
|
@@ -512,6 +532,14 @@ public String getIgnored() {
|
512 | 532 | return this.ignored;
|
513 | 533 | }
|
514 | 534 |
|
| 535 | + public Integer getWrapper() { |
| 536 | + return this.wrapper; |
| 537 | + } |
| 538 | + |
| 539 | + public void setWrapper(Integer wrapper) { |
| 540 | + this.wrapper = wrapper; |
| 541 | + } |
| 542 | + |
515 | 543 | }
|
516 | 544 |
|
517 | 545 | @Configuration(proxyBeanMethods = false)
|
|
0 commit comments