commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r564927 - in /commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java src/test/org/apache/commons/configuration/TestXMLConfiguration.java xdocs/changes.xml
Date Sat, 11 Aug 2007 14:51:30 GMT
Author: oheger
Date: Sat Aug 11 07:51:29 2007
New Revision: 564927

URL: http://svn.apache.org/viewvc?view=rev&rev=564927
Log:
CONFIGURATION-291: AbstractHierarchicalFileConfiguration.addNodes() now correctly triggers
the auto save mechanism

Modified:
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
    commons/proper/configuration/trunk/xdocs/changes.xml

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java?view=diff&rev=564927&r1=564926&r2=564927
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
Sat Aug 11 07:51:29 2007
@@ -23,6 +23,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
@@ -323,6 +324,20 @@
     {
         reload();
         return super.isEmpty();
+    }
+
+    /**
+     * Directly adds sub nodes to this configuration. This implementation checks
+     * whether auto save is necessary after executing the operation.
+     *
+     * @param the key where the nodes are to be added
+     * @param nodes a collection with the nodes to be added
+     * @since 1.5
+     */
+    public void addNodes(String key, Collection nodes)
+    {
+        super.addNodes(key, nodes);
+        delegate.possiblySave();
     }
 
     /**

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java?view=diff&rev=564927&r1=564926&r2=564927
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
Sat Aug 11 07:51:29 2007
@@ -26,6 +26,8 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
@@ -1155,6 +1157,23 @@
         XMLConfiguration checkConf = new XMLConfiguration();
         checkConf.setFile(testSaveConf);
         checkSavedConfig(checkConf);
+    }
+
+    /**
+     * Tests whether the addNodes() method triggers an auto save.
+     */
+    public void testAutoSaveAddNodes() throws ConfigurationException
+    {
+        conf.setFile(testSaveConf);
+        conf.setAutoSave(true);
+        HierarchicalConfiguration.Node node = new HierarchicalConfiguration.Node(
+                "addNodesTest", Boolean.TRUE);
+        Collection nodes = new ArrayList(1);
+        nodes.add(node);
+        conf.addNodes("test.autosave", nodes);
+        XMLConfiguration c2 = new XMLConfiguration(testSaveConf);
+        assertTrue("Added nodes are not saved", c2
+                .getBoolean("test.autosave.addNodesTest"));
     }
 
     /**

Modified: commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/xdocs/changes.xml?view=diff&rev=564927&r1=564926&r2=564927
==============================================================================
--- commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ commons/proper/configuration/trunk/xdocs/changes.xml Sat Aug 11 07:51:29 2007
@@ -23,6 +23,10 @@
 
   <body>
     <release version="1.5-SNAPSHOT" date="in SVN" description="">
+      <action dev="oheger" type="fix" issue="CONFIGURATION-291">
+        The addNodes() method of hierarchical file-based configurations now
+        correctly triggers an auto save.
+      </action>
       <action dev="oheger" type="fix" issue="CONFIGURATION-287">
         HierarchicalConfiguration.addNodes() now resets the reference property
         of all nodes to be added. This fixes a problem with XMLConfiguration,



Mime
View raw message