Skip to content

Commit

Permalink
fix number type is lost in yaml config file (#1401)
Browse files Browse the repository at this point in the history
* #1399 fi

* update test
  • Loading branch information
lovepoem authored and beiwei30 committed Feb 27, 2018
1 parent 84124c4 commit 91f9250
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public static Map<String, String> getSubProperties(PropertySources propertySourc
if (name.startsWith(normalizedPrefix)) {
String subName = name.substring(normalizedPrefix.length());
Object value = source.getProperty(name);
if (value instanceof String) {
subProperties.put(subName, String.valueOf(value));
}
subProperties.put(subName, String.valueOf(value));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ public void testGetSubProperties() {

propertySources.addFirst(propertySource);

Map<String, String> result = PropertySourcesUtils.getSubProperties(propertySources, "user");
String KEY_PREFIX = "user";
String KEY_NAME = "name";
String KEY_AGE = "age";
Map<String, String> result = PropertySourcesUtils.getSubProperties(propertySources, KEY_PREFIX);

Assert.assertEquals(Collections.emptyMap(), result);

source.put("user.name", "Mercy");
source.put("user.age", "31");
source.put(KEY_PREFIX + "." + KEY_NAME, "Mercy");
source.put(KEY_PREFIX + "." + KEY_AGE, 31);

Map<String, Object> expected = new HashMap<String, Object>();
expected.put("name", "Mercy");
expected.put("age", "31");

result = PropertySourcesUtils.getSubProperties(propertySources, "user");
expected.put(KEY_NAME, "Mercy");
expected.put(KEY_AGE, "31");

result = PropertySourcesUtils.getSubProperties(propertySources, KEY_PREFIX);
Assert.assertEquals(expected, result);

result = PropertySourcesUtils.getSubProperties(propertySources, "");
Expand Down

0 comments on commit 91f9250

Please sign in to comment.