commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r787009 - in /commons/proper/configuration/trunk: conf/ src/java/org/apache/commons/configuration/plist/ src/test/org/apache/commons/configuration/plist/ xdocs/
Date Sun, 21 Jun 2009 13:23:25 GMT
Author: ebourg
Date: Sun Jun 21 13:23:24 2009
New Revision: 787009

URL: http://svn.apache.org/viewvc?rev=787009&view=rev
Log:
Fixed empty dictionaries <dict/> (CONFIGURATION-362)

Modified:
    commons/proper/configuration/trunk/conf/test.plist.xml
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java
    commons/proper/configuration/trunk/xdocs/changes.xml

Modified: commons/proper/configuration/trunk/conf/test.plist.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/conf/test.plist.xml?rev=787009&r1=787008&r2=787009&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/test.plist.xml (original)
+++ commons/proper/configuration/trunk/conf/test.plist.xml Sun Jun 21 13:23:24 2009
@@ -80,5 +80,8 @@
             </dict>
         </dict>
 
+        <key>empty-dictionary</key>
+        <dict/>
+
     </dict>
 </plist>

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?rev=787009&r1=787008&r2=787009&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
Sun Jun 21 13:23:24 2009
@@ -304,6 +304,10 @@
 
             out.println(padding + "</dict>");
         }
+        else if (node.getValue() == null)
+        {
+            out.println(padding + "<dict/>");
+        }
         else
         {
             Object value = node.getValue();
@@ -400,10 +404,14 @@
             String base64 = new String(Base64.encodeBase64((byte[]) value));
             out.println(padding + "<data>" + StringEscapeUtils.escapeXml(base64) +
"</data>");
         }
-        else
+        else if (value != null)
         {
             out.println(padding + "<string>" + StringEscapeUtils.escapeXml(String.valueOf(value))
+ "</string>");
         }
+        else
+        {
+            out.println(padding + "<string/>");
+        }
     }
 
     /**

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java?rev=787009&r1=787008&r2=787009&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java
Sun Jun 21 13:23:24 2009
@@ -270,6 +270,29 @@
         }
     }
 
+    public void testSaveEmptyDictionary() throws Exception
+    {
+        File savedFile = new File("target/testsave.plist.xml");
+
+        // remove the file previously saved if necessary
+        if (savedFile.exists())
+        {
+            assertTrue(savedFile.delete());
+        }
+        
+        // save the configuration
+        String filename = savedFile.getAbsolutePath();
+        config.save(filename);
+
+        assertTrue("The saved file doesn't exist", savedFile.exists());
+
+        // read the configuration and compare the properties
+        Configuration checkConfig = new XMLPropertyListConfiguration(new File(filename));
+        
+        assertEquals(null, config.getProperty("empty-dictionary"));
+        assertEquals(null, checkConfig.getProperty("empty-dictionary"));
+    }
+
     /**
      * Ensure that setProperty doesn't alter an array of byte
      * since it's a first class type in plist file

Modified: commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/xdocs/changes.xml?rev=787009&r1=787008&r2=787009&view=diff
==============================================================================
--- commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ commons/proper/configuration/trunk/xdocs/changes.xml Sun Jun 21 13:23:24 2009
@@ -23,6 +23,10 @@
 
   <body>
     <release version="1.7" date="in SVN" description="">
+      <action dev="ebourg" type="fix" issue="CONFIGURATION-362">
+        Empty dictionary elements in an XML PropertyList are now preserved and no longer
+        turned into a string when the configuration is saved.
+      </action>
       <action dev="oheger" type="fix" issue="CONFIGURATION-385">
         DatabaseConfiguration now generates correct events for the clear() and
         clearProperty() methods.



Mime
View raw message