commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r703563 - in /commons/proper/configuration/branches/configuration2_experimental: src/main/java/org/apache/commons/configuration2/ src/test/java/org/apache/commons/configuration2/ src/test/resources/ xdocs/
Date Fri, 10 Oct 2008 19:35:25 GMT
Author: oheger
Date: Fri Oct 10 12:35:24 2008
New Revision: 703563

URL: http://svn.apache.org/viewvc?rev=703563&view=rev
Log:
[CONFIGURATION-338] PropertiesConfiguration now performs interpolation when searching for
include files; thanks to David Donn (david_donn at pacific dot net dot au) for the patch.
Porting this patch to configuration2 branch.

Added:
    commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
  (with props)
Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/resources/test.properties
    commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java?rev=703563&r1=703562&r2=703563&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
Fri Oct 10 12:35:24 2008
@@ -448,6 +448,7 @@
      *
      * @param basePath The new basePath to set.
      */
+    @Override
     public void setBasePath(String basePath)
     {
         super.setBasePath(basePath);
@@ -459,6 +460,7 @@
      *
      * @return the copy
      */
+    @Override
     public Object clone()
     {
         PropertiesConfiguration copy = (PropertiesConfiguration) super.clone();
@@ -504,9 +506,9 @@
                 {
                     files = new String[]{value};
                 }
-                for (int i = 0; i < files.length; i++)
+                for (String file : files)
                 {
-                    loadIncludeFile(files[i].trim());
+                    loadIncludeFile(interpolate(file.trim()));
                 }
             }
             result = false;

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java?rev=703563&r1=703562&r2=703563&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
Fri Oct 10 12:35:24 2008
@@ -114,6 +114,16 @@
         assertEquals("true", loaded);
     }
 
+    /**
+     * test if includes properties from interpolated file
+     * name get loaded
+     */
+    public void testLoadIncludeInterpol() throws Exception
+    {
+        String loaded = conf.getString("include.interpol.loaded");
+        assertEquals("true", loaded);
+    }
+
     public void testSetInclude() throws Exception
     {
         // change the include key

Added: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties?rev=703563&view=auto
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
(added)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
Fri Oct 10 12:35:24 2008
@@ -0,0 +1,4 @@
+include.interpol.loaded = true
+
+
+

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/test.properties
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/test.properties?rev=703563&r1=703562&r2=703563&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/test.properties
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/test.properties
Fri Oct 10 12:35:24 2008
@@ -5,6 +5,9 @@
 
 include = include.properties
 
+include.file = include-interpol.properties
+include = ${include.file}
+
 test.unescape = This \n string \t contains \" escaped \\ character\u0073
 test.unescape.list-separator = This string contains \, an escaped list separator
 

Modified: commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml?rev=703563&r1=703562&r2=703563&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml (original)
+++ commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml Fri
Oct 10 12:35:24 2008
@@ -85,6 +85,11 @@
     </release>
 
     <release version="1.6" date="in SVN" description="">
+      <action dev="oheger" type="add" issue="CONFIGURATION-338" due-to="David Donn">
+        PropertiesConfiguration now also performs interpolation when searching
+        for include files. This means that the name of a file to include can be
+        determined by another property.
+      </action>
       <action dev="oheger" type="add" issue="CONFIGURATION-337" due-to="Ralph Goers">
         DefaultConfigurationBuilder now supports defining new configuration
         providers in the configuration definition file.



Mime
View raw message