commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r225563 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/HierarchicalConfiguration.java test/org/apache/commons/configuration/TestXMLConfiguration.java
Date Wed, 27 Jul 2005 18:18:50 GMT
Author: oheger
Date: Wed Jul 27 11:18:32 2005
New Revision: 225563

URL: http://svn.apache.org/viewcvs?rev=225563&view=rev
Log:
Fixed a bug in HierarchicalConfiguration.CloneVisitor

Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java?rev=225563&r1=225562&r2=225563&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
Wed Jul 27 11:18:32 2005
@@ -1023,7 +1023,9 @@
         {
             try
             {
-                return super.clone();
+                Node copy = (Node) super.clone();
+                copy.children = null;
+                return copy;
             }
             catch (CloneNotSupportedException cex)
             {
@@ -1263,10 +1265,10 @@
          */
         public void visitAfterChildren(Node node, ConfigurationKey key)
         {
-            copyStack.pop();
+            Node copy = (Node) copyStack.pop();
             if (copyStack.isEmpty())
             {
-                result = node;
+                result = copy;
             }
         }
 
@@ -1279,7 +1281,6 @@
         public void visitBeforeChildren(Node node, ConfigurationKey key)
         {
             Node copy = (Node) node.clone();
-            copy.removeChildren();
 
             if (!copyStack.isEmpty())
             {

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java?rev=225563&r1=225562&r2=225563&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
Wed Jul 27 11:18:32 2005
@@ -547,5 +547,25 @@
         assertNull(copy.getDocument());
         assertNotNull(conf.getFileName());
         assertNull(copy.getFileName());
+        
+        copy.setProperty("element3", "clonedValue");
+        assertEquals("value", conf.getString("element3"));
+        conf.setProperty("element3[@name]", "originalFoo");
+        assertEquals("foo", copy.getString("element3[@name]"));
+    }
+    
+    public void testSubset() throws ConfigurationException
+    {
+        conf = new XMLConfiguration();
+        conf.load(new File("conf/testHierarchicalXMLConfiguration.xml"));
+        conf.subset("tables.table(0)");
+        if(testSaveConf.exists())
+        {
+            assertTrue(testSaveConf.delete());
+        }
+        conf.save(testSaveConf);
+        
+        conf = new XMLConfiguration(testSaveConf);
+        assertEquals("users", conf.getString("tables.table(0).name"));
     }
 }



---------------------------------------------------------------------
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