[SPR-6025] support for recursive property placeholder replacement in system properties
This commit is contained in:
@@ -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}";
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user