[SPR-6025] support for recursive property placeholder replacement in system properties

This commit is contained in:
Rob Harrop
2009-09-08 17:13:02 +00:00
parent 3fe09d70cd
commit d16faafc4f
4 changed files with 106 additions and 40 deletions

View File

@@ -43,6 +43,26 @@ public class PropertyPlaceholderUtilsTests {
assertEquals("foo=bar,bar=baz", PropertyPlaceholderUtils.replacePlaceholders(text, props));
}
@Test
public void testRecurseInProperty() {
String text = "foo=${bar}";
Properties props = new Properties();
props.setProperty("bar", "${baz}");
props.setProperty("baz", "bar");
assertEquals("foo=bar", PropertyPlaceholderUtils.replacePlaceholders(text, props));
}
@Test
public void testRecurseInPlaceholder() {
String text = "foo=${b${inner}}";
Properties props = new Properties();
props.setProperty("bar", "bar");
props.setProperty("inner", "ar");
assertEquals("foo=bar", PropertyPlaceholderUtils.replacePlaceholders(text, props));
}
@Test
public void testWithResolver() {
String text = "foo=${foo}";

View File

@@ -31,6 +31,14 @@ public class SystemPropertyUtilsTests {
assertEquals("bar", resolved);
}
@Test
public void testRecursiveFromSystemProperty() {
System.setProperty("test.prop", "foo=${bar}");
System.setProperty("bar", "baz");
String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop}");
assertEquals("foo=baz", resolved);
}
@Test
public void testReplaceFromEnv() {
Map<String,String> env = System.getenv();