commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r555737 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Date Thu, 12 Jul 2007 19:59:26 GMT
Author: oheger
Date: Thu Jul 12 12:59:25 2007
New Revision: 555737

URL: http://svn.apache.org/viewvc?view=rev&rev=555737
Log:
CONFIGURATION-283: ConfigurationUtils.convertToHierarchical() now correctly deals with properties
whose values contain (escaped) list delimiters

Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCombinedConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java
    jakarta/commons/proper/configuration/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java?view=diff&rev=555737&r1=555736&r2=555737
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java
Thu Jul 12 12:59:25 2007
@@ -188,7 +188,11 @@
         else
         {
             HierarchicalConfiguration hc = new HierarchicalConfiguration();
+            // Workaround for problem with copy()
+            boolean delimiterParsingStatus = hc.isDelimiterParsingDisabled();
+            hc.setDelimiterParsingDisabled(true);
             ConfigurationUtils.copy(conf, hc);
+            hc.setDelimiterParsingDisabled(delimiterParsingStatus);
             return hc;
         }
     }

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCombinedConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCombinedConfiguration.java?view=diff&rev=555737&r1=555736&r2=555737
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCombinedConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCombinedConfiguration.java
Thu Jul 12 12:59:25 2007
@@ -559,6 +559,17 @@
     }
 
     /**
+     * Tests whether escaped list delimiters are treated correctly.
+     */
+    public void testEscapeListDelimiters()
+    {
+        PropertiesConfiguration sub = new PropertiesConfiguration();
+        sub.addProperty("test.pi", "3\\,1415");
+        config.addConfiguration(sub);
+        assertEquals("Wrong value", "3,1415", config.getString("test.pi"));
+    }
+
+    /**
      * Helper method for writing a file.
      *
      * @param file the file to be written

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java?view=diff&rev=555737&r1=555736&r2=555737
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java
Thu Jul 12 12:59:25 2007
@@ -48,10 +48,10 @@
 
         config.setProperty("two", "2");
         assertEquals("String representation of a configuration", "one=1" + lineSeparator
+ "two=2" , ConfigurationUtils.toString(config));
-        
+
         config.clearProperty("one");
         assertEquals("String representation of a configuration", "two=2" , ConfigurationUtils.toString(config));
-                
+
         config.setProperty("one","1");
         assertEquals("String representation of a configuration", "two=2" + lineSeparator
+ "one=1" , ConfigurationUtils.toString(config));
     }
@@ -75,7 +75,7 @@
         URL url = ConfigurationUtils.getURL(null, "config.xml");
         assertEquals("file", url.getProtocol());
         assertEquals("", url.getHost());
-        
+
         assertEquals(
             "http://localhost:8080/webapp/config/config.xml",
             ConfigurationUtils
@@ -97,7 +97,7 @@
         assertEquals(
             absFile.toURL(),
             ConfigurationUtils.getURL(null, absFile.getAbsolutePath()));
-        
+
 		assertEquals(absFile.toURL(),
 		ConfigurationUtils.getURL(absFile.getParent(), "config.xml"));
     }
@@ -180,10 +180,10 @@
     {
         File directory = new File("target");
         File reference = new File(directory, "test.txt").getAbsoluteFile();
-        
+
         assertEquals(reference, ConfigurationUtils.getFile(null, reference.getAbsolutePath()));
         assertEquals(reference, ConfigurationUtils.getFile(directory.getAbsolutePath(), reference.getAbsolutePath()));
-        assertEquals(reference, ConfigurationUtils.getFile(directory.getAbsolutePath(), reference.getName()));
       
+        assertEquals(reference, ConfigurationUtils.getFile(directory.getAbsolutePath(), reference.getName()));
         assertEquals(reference, ConfigurationUtils.getFile(directory.toURL().toString(),
reference.getName()));
         assertEquals(reference, ConfigurationUtils.getFile("invalid", reference.toURL().toString()));
         assertEquals(reference, ConfigurationUtils.getFile(
@@ -249,6 +249,22 @@
     {
         assertNull("Wrong conversion result for null config",
                 ConfigurationUtils.convertToHierarchical(null));
+    }
+
+    /**
+     * Tests converting a configuration into a hierarchical one if some of its
+     * properties contain escaped list delimiter characters.
+     */
+    public void testConvertToHierarchicalDelimiters()
+    {
+        Configuration conf = new BaseConfiguration();
+        conf.addProperty("test.key", "1\\,2\\,3");
+        assertEquals("Wrong property value", "1,2,3", conf
+                .getString("test.key"));
+        HierarchicalConfiguration hc = ConfigurationUtils
+                .convertToHierarchical(conf);
+        assertEquals("Escaped list delimiters not correctly handled", "1,2,3",
+                hc.getString("test.key"));
     }
 
     /**

Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diff&rev=555737&r1=555736&r2=555737
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Thu Jul 12 12:59:25 2007
@@ -23,6 +23,12 @@
 
   <body>
     <release version="1.5-SNAPSHOT" date="in SVN" description="">
+      <action dev="oheger" type="fix" issue="CONFIGURATION-283">
+        ConfigurationUtils.convertToHierarchical() now correctly deals with
+        property values containing escaped list delimiters. This also affects
+        CombinedConfiguration when sub configurations with such property values
+        are contained.
+      </action>
       <action dev="oheger" type="fix" issue="CONFIGURATION-275">
         AbstractConfiguration.addProperty() now correctly deals with list and
         array properties if delimiter parsing is disabled.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message