From 2bea177f237ab350b1ecd908e5ad6893ea238e8e Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 28 Oct 2019 14:17:55 +0100 Subject: [PATCH] Hacking See gh-18767 --- .../ConfigurationPropertiesTests.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index 292d14921ccb..928197d39ff3 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -18,6 +18,7 @@ import java.beans.PropertyEditorSupport; import java.io.File; +import java.net.InetAddress; import java.time.Duration; import java.util.ArrayList; import java.util.Collections; @@ -421,6 +422,14 @@ public void loadShouldBindToMap() { assertThat(bean.getMap()).containsOnly(entry("foo", "bar")); } + @Test + public void loadShouldBindToWildCardMap() { + load(WithWildcardMapProperties.class, "test.map1.foo=127.0.0.1", "test.map2.foo=127.0.0.1"); + WithWildcardMapProperties bean = this.context.getBean(WithWildcardMapProperties.class); + assertThat(bean.getMap1().get("foo").get(0)).isInstanceOf(InetAddress.class); + assertThat(bean.getMap2().get("foo").get(0)).isInstanceOf(InetAddress.class); + } + @Test public void loadShouldBindToMapWithNumericKey() { load(MapWithNumericKeyProperties.class, "sample.properties.1.name=One"); @@ -1487,6 +1496,31 @@ public void setMap(Map map) { } + @EnableConfigurationProperties + @ConfigurationProperties(prefix = "test") + static class WithWildcardMapProperties { + + private Map> map1; + + private Map> map2; + + public Map> getMap1() { + return this.map1; + } + + public void setMap1(Map> map1) { + this.map1 = map1; + } + + public Map> getMap2() { + return this.map2; + } + + public void setMap2(Map> map2) { + this.map2 = map2; + } + } + @EnableConfigurationProperties @ConfigurationProperties(prefix = "test") static class WithComplexMapProperties {