commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1568833 - in /commons/proper/configuration/branches/immutableNodes/src: main/java/org/apache/commons/configuration/tree/InMemoryNodeModel.java test/java/org/apache/commons/configuration/tree/TestInMemoryNodeModel.java
Date Sun, 16 Feb 2014 21:20:10 GMT
Author: oheger
Date: Sun Feb 16 21:20:09 2014
New Revision: 1568833

URL: http://svn.apache.org/r1568833
Log:
InMemoryNodeModel.clearTree() now handles the special case that the root node is cleared.

Modified:
    commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/InMemoryNodeModel.java
    commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestInMemoryNodeModel.java

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/InMemoryNodeModel.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/InMemoryNodeModel.java?rev=1568833&r1=1568832&r2=1568833&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/InMemoryNodeModel.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/InMemoryNodeModel.java
Sun Feb 16 21:20:09 2014
@@ -236,6 +236,12 @@ public class InMemoryNodeModel implement
             }
             else
             {
+                if (result.getNode() == currentStructure.getRoot())
+                {
+                    // the whole model is to be cleared
+                    clear();
+                    return;
+                }
                 tx.addRemoveNodeOperation(
                         currentStructure.getParent(result.getNode()),
                         result.getNode());

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestInMemoryNodeModel.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestInMemoryNodeModel.java?rev=1568833&r1=1568832&r2=1568833&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestInMemoryNodeModel.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestInMemoryNodeModel.java
Sun Feb 16 21:20:09 2014
@@ -1015,4 +1015,24 @@ public class TestInMemoryNodeModel
         assertEquals("Root name was changed", rootAuthorsTree.getNodeName(),
                 model.getRootNode().getNodeName());
     }
+
+    /**
+     * Tests whether clearTree() handles the root node in a special way.
+     */
+    @Test
+    public void testClearTreeRootNode()
+    {
+        NodeKeyResolver resolver = EasyMock.createMock(NodeKeyResolver.class);
+        InMemoryNodeModel model = new InMemoryNodeModel(rootAuthorsTree);
+        List<QueryResult<ImmutableNode>> results =
+                new ArrayList<QueryResult<ImmutableNode>>(2);
+        results.add(QueryResult.createNodeResult(nodeForKey(model, AUTHORS[0])));
+        results.add(QueryResult.createNodeResult(rootAuthorsTree));
+        EasyMock.expect(resolver.resolveKey(rootAuthorsTree, KEY, model))
+                .andReturn(results);
+        EasyMock.replay(resolver);
+
+        model.clearTree(KEY, resolver);
+        assertFalse("Got still data", model.isDefined(model.getRootNode()));
+    }
 }



Mime
View raw message