commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1571049 - 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, 23 Feb 2014 18:35:41 GMT
Author: oheger
Date: Sun Feb 23 18:35:40 2014
New Revision: 1571049

URL: http://svn.apache.org/r1571049
Log:
InMemoryNodeModel.clearProperty() now handles attributes correctly.

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=1571049&r1=1571048&r2=1571049&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 23 18:35:40 2014
@@ -265,8 +265,15 @@ public class InMemoryNodeModel implement
                         .getCurrentData().getRoot(), key,
                         InMemoryNodeModel.this))
                 {
-                    // TODO handle attribute results
-                    tx.addClearNodeValueOperation(result.getNode());
+                    if (result.isAttributeResult())
+                    {
+                        tx.addRemoveAttributeOperation(result.getNode(),
+                                result.getAttributeName());
+                    }
+                    else
+                    {
+                        tx.addClearNodeValueOperation(result.getNode());
+                    }
                 }
                 return true;
             }

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=1571049&r1=1571048&r2=1571049&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 23 18:35:40 2014
@@ -968,4 +968,28 @@ public class TestInMemoryNodeModel
         ImmutableNode node = nodeForKey(model, nodeKey);
         assertNull("Value not cleared", node.getValue());
     }
+
+    /**
+     * Tests whether a property value stored as an attribute can be cleared.
+     */
+    @Test
+    public void testClearPropertyAttribute()
+    {
+        NodeKeyResolver resolver = EasyMock.createMock(NodeKeyResolver.class);
+        InMemoryNodeModel model =
+                new InMemoryNodeModel(NodeStructureHelper.ROOT_PERSONAE_TREE);
+        final String nodeKey =
+                "Prospero/The Tempest/" + NodeStructureHelper.ELEM_ORG_VALUE;
+        EasyMock.expect(resolver.resolveKey(model.getRootNode(), KEY, model))
+                .andReturn(
+                        Collections.singletonList(QueryResult
+                                .createAttributeResult(
+                                        nodeForKey(model, nodeKey),
+                                        NodeStructureHelper.ATTR_TESTED)));
+        EasyMock.replay(resolver);
+
+        model.clearProperty(KEY, resolver);
+        ImmutableNode node = nodeForKey(model, nodeKey);
+        assertTrue("Attribute not removed", node.getAttributes().isEmpty());
+    }
 }



Mime
View raw message