commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1587014 - in /commons/proper/configuration/branches/immutableNodes/src: main/java/org/apache/commons/configuration/tree/TrackedNodeModel.java test/java/org/apache/commons/configuration/tree/TestTrackedNodeModel.java
Date Sun, 13 Apr 2014 16:00:42 GMT
Author: oheger
Date: Sun Apr 13 16:00:42 2014
New Revision: 1587014

URL: http://svn.apache.org/r1587014
Log:
Implemented getInMemoryRepresentation() in TrackedNodeModel.

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

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/TrackedNodeModel.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/TrackedNodeModel.java?rev=1587014&r1=1587013&r2=1587014&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/TrackedNodeModel.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/TrackedNodeModel.java
Sun Apr 13 16:00:42 2014
@@ -196,11 +196,14 @@ public class TrackedNodeModel implements
         getParentModel().clearTree(null, getSelector(), resolver);
     }
 
+    /**
+     * {@inheritDoc} This implementation returns the tracked node instance
+     * acting as root node of this model.
+     */
     @Override
     public ImmutableNode getInMemoryRepresentation()
     {
-        // TODO implementation
-        throw new UnsupportedOperationException("Not yet implemented!");
+        return getNodeHandler().getRootNode();
     }
 
     /**

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestTrackedNodeModel.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestTrackedNodeModel.java?rev=1587014&r1=1587013&r2=1587014&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestTrackedNodeModel.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestTrackedNodeModel.java
Sun Apr 13 16:00:42 2014
@@ -106,16 +106,28 @@ public class TestTrackedNodeModel
     }
 
     /**
-     * Tests whether a node handler can be queried.
+     * Creates a mock for a node handler and prepares the parent model to expect
+     * a request for the tracked node handler.
+     *
+     * @return the mock for the node handler
      */
-    @Test
-    public void testGetNodeHandler()
+    private NodeHandler<ImmutableNode> expectGetNodeHandler()
     {
         @SuppressWarnings("unchecked")
         NodeHandler<ImmutableNode> handler =
                 EasyMock.createMock(NodeHandler.class);
         EasyMock.expect(parentModel.getTrackedNodeHandler(selector)).andReturn(
                 handler);
+        return handler;
+    }
+
+    /**
+     * Tests whether a node handler can be queried.
+     */
+    @Test
+    public void testGetNodeHandler()
+    {
+        NodeHandler<ImmutableNode> handler = expectGetNodeHandler();
         EasyMock.replay(handler, parentModel);
 
         assertSame("Wrong node handler", handler, setUpModel().getNodeHandler());
@@ -232,4 +244,19 @@ public class TestTrackedNodeModel
         model.close();
         EasyMock.verify(parentModel);
     }
+
+    /**
+     * Tests whether the correct in-memory representation can be queried.
+     */
+    @Test
+    public void testGetInMemoryRepresentation()
+    {
+        NodeHandler<ImmutableNode> handler = expectGetNodeHandler();
+        ImmutableNode root = NodeStructureHelper.createNode("Root", null);
+        EasyMock.expect(handler.getRootNode()).andReturn(root);
+        EasyMock.replay(handler, parentModel);
+
+        TrackedNodeModel model = setUpModel();
+        assertSame("Wrong root node", root, model.getInMemoryRepresentation());
+    }
 }



Mime
View raw message