Skip to content

Commit

Permalink
Hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Oct 28, 2019
1 parent 027bfdb commit 2bea177
Showing 1 changed file with 34 additions and 0 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -1487,6 +1496,31 @@ public void setMap(Map<String, String> map) {

}

@EnableConfigurationProperties
@ConfigurationProperties(prefix = "test")
static class WithWildcardMapProperties {

private Map<String, List<InetAddress>> map1;

private Map<String, ? extends List<? extends InetAddress>> map2;

public Map<String, List<InetAddress>> getMap1() {
return this.map1;
}

public void setMap1(Map<String, List<InetAddress>> map1) {
this.map1 = map1;
}

public Map<String, ? extends List<? extends InetAddress>> getMap2() {
return this.map2;
}

public void setMap2(Map<String, ? extends List<? extends InetAddress>> map2) {
this.map2 = map2;
}
}

@EnableConfigurationProperties
@ConfigurationProperties(prefix = "test")
static class WithComplexMapProperties {
Expand Down

0 comments on commit 2bea177

Please sign in to comment.