This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new 0a441070 Add
StringSubstitutorWithInterpolatorStringLookupTest.testSystemPropertyDefaultDefault()
0a441070 is described below
commit 0a4410709dd246e4d713656f2e80f39df48dd28f
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jul 8 11:21:57 2026 -0400
Add
StringSubstitutorWithInterpolatorStringLookupTest.testSystemPropertyDefaultDefault()
---
...tringSubstitutorWithInterpolatorStringLookupTest.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git
a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
index 56a7b485..95c6acf4 100644
---
a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
+++
b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
@@ -254,6 +254,22 @@ class StringSubstitutorWithInterpolatorStringLookupTest {
assertEquals(System.getProperty(spKey), strSubst.replace("${sys:" +
spKey + "}"));
}
+ @Test
+ void testSystemPropertyDefaultDefault() {
+ final StringSubstitutor strSubst =
StringSubstitutor.createInterpolator();
+ strSubst.setEnableSubstitutionInVariables(true);
+ final String spKey = "user.name";
+ // check that "sys" works
+ final String spLookupStr = "${sys:" + spKey + "}";
+ final String actual = System.getProperty(spKey);
+ assertEquals(actual, strSubst.replace(spLookupStr));
+ // test "sys" with default value
+ assertEquals("foo", strSubst.replace("${sys:unknownkey1:-foo}"));
+ assertEquals(actual, strSubst.replace("${sys:unknownkey1:-" +
spLookupStr + "}"));
+ assertEquals("foo",
strSubst.replace("${sys:unknownkey1:-${sys:unknownkey2:-foo}}"));
+ assertEquals(actual,
strSubst.replace("${sys:unknownkey1:-${sys:unknownkey2:-" + spLookupStr +
"}}"));
+ }
+
@Test
void testSystemPropertyDefaultStringLookup() {
final StringSubstitutor strSubst = new StringSubstitutor(