commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1515443 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
Date Mon, 19 Aug 2013 14:31:32 GMT
Author: oheger
Date: Mon Aug 19 14:31:31 2013
New Revision: 1515443

URL: http://svn.apache.org/r1515443
Log:
Inlined the interpolate() helper method from PropertyConverter.

This was the only place this method was used. The plan is to remove
interpolate() from PropertyConverter, so that this class can focus only on
conversions.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java?rev=1515443&r1=1515442&r2=1515443&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
Mon Aug 19 14:31:31 2013
@@ -27,7 +27,7 @@ import java.util.Map;
 import org.apache.commons.configuration.ConfigurationRuntimeException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.configuration.SubnodeConfiguration;
-import org.apache.commons.configuration.convert.PropertyConverter;
+import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
 import org.apache.commons.configuration.tree.ConfigurationNode;
 import org.apache.commons.configuration.tree.DefaultConfigurationNode;
 
@@ -448,8 +448,9 @@ public class XMLBeanDeclaration implemen
      */
     protected Object interpolate(Object value)
     {
-        return PropertyConverter.interpolate(value, getConfiguration()
-                .getParent());
+        ConfigurationInterpolator interpolator =
+                getConfiguration().getParent().getInterpolator();
+        return (interpolator != null) ? interpolator.interpolate(value) : value;
     }
 
     /**

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java?rev=1515443&r1=1515442&r2=1515443&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/beanutils/TestXMLBeanDeclaration.java
Mon Aug 19 14:31:31 2013
@@ -484,6 +484,24 @@ public class TestXMLBeanDeclaration
     }
 
     /**
+     * Tests interpolate() if no ConfigurationInterpolator is available.
+     */
+    @Test
+    public void testInterpolateNoInterpolator()
+    {
+        HierarchicalConfiguration config = new BaseHierarchicalConfiguration();
+        config.addProperty("value", "expectedValue");
+        setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
+        String value = "${value}";
+        config.addProperty(KEY + ".config-constrarg[@config-value]", value);
+        config.setInterpolator(null);
+        XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
+        Collection<ConstructorArg> args = decl.getConstructorArgs();
+        ConstructorArg arg = args.iterator().next();
+        assertEquals("Value was changed", value, arg.getValue());
+    }
+
+    /**
      * Initializes a configuration object with a bean declaration. Under the
      * specified key the given properties will be added.
      *



Mime
View raw message