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-configuration.git


The following commit(s) were added to refs/heads/master by this push:
     new 27880dd63 Add 
TestConfigurationInterpolator.testInterpolationDefaultValueNestedDefaultPrefix()
27880dd63 is described below

commit 27880dd63048c04889581ea1defeadceec4546b8
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jul 8 15:51:20 2026 -0400

    Add 
TestConfigurationInterpolator.testInterpolationDefaultValueNestedDefaultPrefix()
---
 .../interpol/TestConfigurationInterpolator.java         | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
 
b/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
index 721d3d9cc..8f208c75a 100644
--- 
a/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
+++ 
b/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
@@ -48,6 +48,7 @@ import java.util.function.Function;
 import org.apache.commons.text.lookup.StringLookupFactory;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
 
 /**
  * Test class for ConfigurationInterpolator.
@@ -57,6 +58,8 @@ public class TestConfigurationInterpolator {
     /** Constant for a test variable name. */
     private static final String TEST_NAME = "varname";
 
+    private static final String SP_KEY = 
"TestConfigurationInterpolator.testSystemProperty";
+
     /** Constant for a test variable prefix. */
     private static final String TEST_PREFIX = "prefix";
 
@@ -480,6 +483,20 @@ public class TestConfigurationInterpolator {
         assertEquals("123", 
confInt.interpolate("${UnknownKey1:-${UnknownKey2:-${UnknownKey3:-123}}}"));
     }
 
+    @Test
+    @SetSystemProperty(key = SP_KEY, value = "42")
+    void testInterpolationDefaultValueNestedDefaultPrefix() {
+        final Object value = 42;
+        final String valueStr = Objects.toString(value);
+        final ConfigurationInterpolator confInt = new 
ConfigurationInterpolator();
+        confInt.setEnableSubstitutionInVariables(true);
+        confInt.registerLookup("sys", 
DefaultLookups.SYSTEM_PROPERTIES.getLookup());
+        assertEquals(valueStr, confInt.interpolate("${sys:UnknownKey1:-${sys:" 
+ SP_KEY + ":-123}}"));
+        assertEquals(valueStr, 
confInt.interpolate("${sys:UnknownKey1:-${sys:UnknownKey2:-${sys:" + SP_KEY + 
":-123}}}"));
+        assertEquals(valueStr, 
confInt.interpolate("${sys:UnknownKey1:-${sys:UnknownKey2:-${sys:UnknownKey3:-${sys:"
 + SP_KEY + ":-123}}}}"));
+        assertEquals("123", 
confInt.interpolate("${sys:UnknownKey1:-${sys:UnknownKey2:-${sys:UnknownKey3:-123}}}"));
+    }
+
     /**
      * Tests an interpolation that consists of a single undefined variable 
only with and without a default value.
      */

Reply via email to