You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2009/10/27 21:05:08 UTC

svn commit: r830322 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/base/ test/java/org/apache/commons/configuration2/base/

Author: oheger
Date: Tue Oct 27 20:05:06 2009
New Revision: 830322

URL: http://svn.apache.org/viewvc?rev=830322&view=rev
Log:
Ported changes from the flat package to the flat node classes in base: the configuration source is now stored in the flat root node rather than in the node handler.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatLeafNode.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNode.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeHandler.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeSourceAdapter.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatRootNode.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeSourceAdapter.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatLeafNode.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatLeafNode.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatLeafNode.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatLeafNode.java Tue Oct 27 20:05:06 2009
@@ -161,13 +161,12 @@
      * from the passed in {@code ConfigurationSource}. It also takes its value
      * index into account if the represented property has multiple values.
      *
-     * @param config the associated {@code ConfigurationSource}
      * @return the value of the represented property
      */
     @Override
-    public Object getValue(FlatConfigurationSource config)
+    public Object getValue()
     {
-        Object value = config.getProperty(getName());
+        Object value = getConfigurationSource().getProperty(getName());
         if (value instanceof Collection<?>)
         {
             int valueIndex = getValueIndex();
@@ -208,12 +207,11 @@
      * Removes a child from this node. Leaf nodes do not support children, so
      * this implementation always throws a runtime exception.
      *
-     * @param config the associated {@code ConfigurationSource}
      * @param child the node to be removed
      * @throws ConfigurationRuntimeException if the child cannot be removed
      */
     @Override
-    public void removeChild(FlatConfigurationSource config, FlatNode child)
+    public void removeChild(FlatNode child)
     {
         throw new ConfigurationRuntimeException(
                 "Cannot remove a child from a leaf node!");
@@ -226,29 +224,40 @@
      * represented property. Otherwise the corresponding property value is
      * overridden.
      *
-     * @param config the associated {@code ConfigurationSource}
      * @param value the new value
      */
     @Override
-    public void setValue(FlatConfigurationSource config, Object value)
+    public void setValue(Object value)
     {
         if (hasValue)
         {
             int index = getValueIndex();
             if (index != INDEX_UNDEFINED)
             {
-                parent.setMultiProperty(config, this, index, value);
+                parent.setMultiProperty(getConfigurationSource(), this, index, value);
             }
             else
             {
-                config.setProperty(getName(), value);
+                getConfigurationSource().setProperty(getName(), value);
             }
         }
 
         else
         {
-            config.addProperty(getName(), value);
+            getConfigurationSource().addProperty(getName(), value);
             hasValue = true;
         }
     }
+
+    /**
+     * Returns the {@code FlatConfigurationSource} this node belongs to. This
+     * implementation fetches the source from the parent node.
+     *
+     * @return the owning {@code FlatConfigurationSource}
+     */
+    @Override
+    public FlatConfigurationSource getConfigurationSource()
+    {
+        return getParent().getConfigurationSource();
+    }
 }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNode.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNode.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNode.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNode.java Tue Oct 27 20:05:06 2009
@@ -76,20 +76,18 @@
      * Returns the value of this node. An implementation can access the passed
      * in {@code ConfigurationSource} to obtain the value.
      *
-     * @param config the owning {@code ConfigurationSource}
      * @return the value of this node
      */
-    public abstract Object getValue(FlatConfigurationSource config);
+    public abstract Object getValue();
 
     /**
      * Sets the value of this node. An implementation can access the passed in
      * {@code ConfigurationSource} to set the value.
      *
-     * @param config the owning {@code ConfigurationSource}
      * @param value the new value
      * @throws ConfigurationRuntimeException if the value cannot be set
      */
-    public abstract void setValue(FlatConfigurationSource config, Object value);
+    public abstract void setValue(Object value);
 
     /**
      * Returns the index of the value represented by this node. This is needed
@@ -158,9 +156,15 @@
      * owning {@code ConfigurationSource}, so this object is also passed to this
      * method.
      *
-     * @param config the owning {@code ConfigurationSource}
      * @param child the child to be removed
      * @throws ConfigurationRuntimeException if the child cannot be removed
      */
-    public abstract void removeChild(FlatConfigurationSource config, FlatNode child);
+    public abstract void removeChild(FlatNode child);
+
+    /**
+     * Returns the {@code FlatConfigurationSource} object this node belongs to.
+     *
+     * @return the owning {@code FlatConfigurationSource}
+     */
+    public abstract FlatConfigurationSource getConfigurationSource();
 }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeHandler.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeHandler.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeHandler.java Tue Oct 27 20:05:06 2009
@@ -57,9 +57,6 @@
  */
 class FlatNodeHandler extends AbstractNodeHandler<FlatNode>
 {
-    /** Stores the associated ConfigurationSource. */
-    private final FlatConfigurationSource configurationSource;
-
     /**
      * A flag whether an update of the configuration was caused by an operation
      * on its node structure.
@@ -67,28 +64,6 @@
     private boolean internalUpdate;
 
     /**
-     * Creates a new instance of {@code FlatNodeHandler} and initializes it with
-     * the associated {@code ConfigurationSource}.
-     *
-     * @param config the {@code ConfigurationSource}
-     */
-    public FlatNodeHandler(FlatConfigurationSource config)
-    {
-        configurationSource = config;
-    }
-
-    /**
-     * Returns the {@code ConfigurationSource} associated with this node
-     * handler.
-     *
-     * @return the associated {@code ConfigurationSource}
-     */
-    public FlatConfigurationSource getConfigurationSource()
-    {
-        return configurationSource;
-    }
-
-    /**
      * Returns a flag whether an update of the associated {@code
      * ConfigurationSource} was caused by this node handler. Whenever the
      * {@code ConfigurationSource} adapter receives a change event, it asks the
@@ -228,7 +203,7 @@
      */
     public Object getValue(FlatNode node)
     {
-        return node.getValue(getConfigurationSource());
+        return node.getValue();
     }
 
     /**
@@ -264,7 +239,7 @@
         internalUpdate = true;
         try
         {
-            node.removeChild(getConfigurationSource(), child);
+            node.removeChild(child);
         }
         finally
         {
@@ -299,7 +274,7 @@
         internalUpdate = true;
         try
         {
-            node.setValue(getConfigurationSource(), value);
+            node.setValue(value);
         }
         finally
         {

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeSourceAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeSourceAdapter.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeSourceAdapter.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatNodeSourceAdapter.java Tue Oct 27 20:05:06 2009
@@ -78,7 +78,7 @@
         }
 
         originalSource = wrappedSource;
-        nodeHandler = new FlatNodeHandler(wrappedSource);
+        nodeHandler = new FlatNodeHandler();
         wrappedSource.addConfigurationSourceListener(this);
     }
 
@@ -209,7 +209,7 @@
      */
     protected FlatNode constructNodeHierarchy()
     {
-        FlatRootNode root = new FlatRootNode();
+        FlatRootNode root = new FlatRootNode(getOriginalSource());
         for (Iterator<String> it = getOriginalSource().getKeys(); it.hasNext();)
         {
             String key = it.next();

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatRootNode.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatRootNode.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatRootNode.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatRootNode.java Tue Oct 27 20:05:06 2009
@@ -61,13 +61,19 @@
     /** A map for direct access to child nodes by name. */
     private final Map<String, ChildNodeManager> childrenByName;
 
+    /** Stores the configuration source this node belongs to. */
+    private final FlatConfigurationSource configurationSource;
+
     /**
-     * Creates a new instance of {@code FlatRootNode}.
+     * Creates a new instance of {@code FlatRootNode} and initializes it with
+     * the {@code FlatConfigurationSource} it belongs to.
+     * @param source the owning {@code FlatConfigurationSource}
      */
-    public FlatRootNode()
+    public FlatRootNode(FlatConfigurationSource source)
     {
         children = new ArrayList<FlatNode>();
         childrenByName = new HashMap<String, ChildNodeManager>();
+        configurationSource = source;
     }
 
     /**
@@ -186,11 +192,10 @@
      * Returns the value of this node. The root node does not have a value, so
      * result is always <b>null</b>.
      *
-     * @param config the associated {@code ConfigurationSource}
      * @return the value of this node
      */
     @Override
-    public Object getValue(FlatConfigurationSource config)
+    public Object getValue()
     {
         return null;
     }
@@ -211,13 +216,12 @@
      * Removes the specified child node. The corresponding value in the
      * associated {@code ConfigurationSource} will also be removed.
      *
-     * @param config the associated {@code ConfigurationSource}
      * @param child the node to be removed
      * @throws ConfigurationRuntimeException if this node is not a child of this
      *         node
      */
     @Override
-    public void removeChild(FlatConfigurationSource config, FlatNode child)
+    public void removeChild(FlatNode child)
     {
         if (child != null)
         {
@@ -228,11 +232,11 @@
 
             if (index != INDEX_UNDEFINED)
             {
-                changeMultiProperty(config, child, index, null, true);
+                changeMultiProperty(getConfigurationSource(), child, index, null, true);
             }
             else
             {
-                config.clearProperty(child.getName());
+                getConfigurationSource().clearProperty(child.getName());
             }
         }
         else
@@ -247,18 +251,28 @@
      * Sets the value of this node. A root node cannot have a value. This
      * implementation will throw an exception.
      *
-     * @param config the associated {@code ConfigurationSource}
      * @param value the new value
      * @throws ConfigurationRuntimeException if the value cannot be set
      */
     @Override
-    public void setValue(FlatConfigurationSource config, Object value)
+    public void setValue(Object value)
     {
         throw new ConfigurationRuntimeException(
                 "Cannot set the value of the root node of a flat configuration!");
     }
 
     /**
+     * Returns the {@code FlatConfigurationSource} this node belongs to. The
+     * source was passed when this object was created.
+     * @return the owning {@code FlatConfigurationSource}
+     */
+    @Override
+    public FlatConfigurationSource getConfigurationSource()
+    {
+        return configurationSource;
+    }
+
+    /**
      * Returns the value index for the specified child node. This method is used
      * to determine the index of the value of a property with multiple values
      * that corresponds to the given child node. It counts the occurrences of

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java Tue Oct 27 20:05:06 2009
@@ -66,7 +66,7 @@
                 internalUpdate = handler.isInternalUpdate();
             }
         });
-        handler = new FlatNodeHandler(source);
+        handler = new FlatNodeHandler();
     }
 
     /**
@@ -87,7 +87,7 @@
      */
     private FlatNode setUpTestNode()
     {
-        FlatRootNode root = new FlatRootNode();
+        FlatRootNode root = new FlatRootNode(source);
         for (String c : CHILD_NAMES)
         {
             root.addChild(c);
@@ -108,16 +108,6 @@
     }
 
     /**
-     * Tests whether the correct configuration source is returned by the
-     * handler.
-     */
-    public void testGetConfigurationSource()
-    {
-        assertSame("Configuration source not set", source, handler
-                .getConfigurationSource());
-    }
-
-    /**
      * Tests querying the child nodes of a node.
      */
     public void testGetChildren()
@@ -199,7 +189,7 @@
         FlatNode child = handler.addChild(node, NAME);
         assertEquals("Wrong name of child", NAME, child.getName());
         assertTrue("Config not empty", source.isEmpty());
-        child.setValue(source, TestFlatNodes.VALUE);
+        child.setValue(TestFlatNodes.VALUE);
         assertEquals("Value not added", TestFlatNodes.VALUE, source
                 .getProperty(NAME));
         checkUpdate(false);

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeSourceAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeSourceAdapter.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeSourceAdapter.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeSourceAdapter.java Tue Oct 27 20:05:06 2009
@@ -194,7 +194,8 @@
         FlatNodeSourceAdapter adapter = new FlatNodeSourceAdapter(src);
         try
         {
-            adapter.setRootNode(new FlatRootNode());
+            adapter.setRootNode(new FlatRootNode(EasyMock
+                    .createNiceMock(FlatConfigurationSource.class)));
             fail("Could set a new root node!");
         }
         catch (UnsupportedOperationException uex)

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java?rev=830322&r1=830321&r2=830322&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java Tue Oct 27 20:05:06 2009
@@ -16,13 +16,20 @@
  */
 package org.apache.commons.configuration2.base;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.configuration2.ConfigurationRuntimeException;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Test class for the FlatNode classes.
@@ -31,7 +38,7 @@
  *         Configuration team</a>
  * @version $Id$
  */
-public class TestFlatNodes extends TestCase
+public class TestFlatNodes
 {
     /** Constant for the name of the test node. */
     private static final String NAME = "testFlatNode";
@@ -39,23 +46,45 @@
     /** Constant for a test value. */
     static final Object VALUE = 42;
 
+    /** The owning configuration. */
+    private MapConfigurationSource config;
+
     /** The parent node. */
     private FlatRootNode parent;
 
     /** The node to be tested. */
     private FlatLeafNode node;
 
-    @Override
-    protected void setUp() throws Exception
+    @Before
+    public void setUp() throws Exception
     {
-        super.setUp();
-        parent = new FlatRootNode();
+        config = new MapConfigurationSource();
+        parent = new FlatRootNode(config);
         node = (FlatLeafNode) parent.addChild(NAME);
     }
 
     /**
+     * Tests whether the root node returns the correct configuration source.
+     */
+    @Test
+    public void testGetConfigurationSourceRoot()
+    {
+        assertEquals("Wrong source", config, parent.getConfigurationSource());
+    }
+
+    /**
+     * Tests whether the leaf node returns the correct configuration source.
+     */
+    @Test
+    public void testGetConfigurationSourceLeaf()
+    {
+        assertEquals("Wrong source", config, node.getConfigurationSource());
+    }
+
+    /**
      * Tests querying the name of a leaf node.
      */
+    @Test
     public void testGetNameLeaf()
     {
         assertEquals("Wrong node name", NAME, node.getName());
@@ -64,6 +93,7 @@
     /**
      * Tests querying the parent node.
      */
+    @Test
     public void testGetParent()
     {
         assertSame("Wrong parent node", parent, node.getParent());
@@ -73,6 +103,7 @@
      * Tests querying a leaf node's children. A leaf node has no children, so
      * result should always be an empty list.
      */
+    @Test
     public void testGetChildrenLeaf()
     {
         assertTrue("Children not empty", node.getChildren().isEmpty());
@@ -82,6 +113,7 @@
      * Tests querying a leaf's child nodes with a specific name. Because a leaf
      * node cannot have any children result should always be an empty list.
      */
+    @Test
     public void testGetChildrenNameLeaf()
     {
         assertTrue("Named children not empty", node.getChildren("test")
@@ -92,6 +124,7 @@
      * Tests querying the number of children of a leaf node. Result should
      * always be 0.
      */
+    @Test
     public void testGetChildrenCountLeaf()
     {
         assertEquals("Wrong number of total children", 0, node
@@ -104,6 +137,7 @@
      * Tests the getChild() method on a leaf. Because leafs have no children,
      * this method will always throw an exception.
      */
+    @Test
     public void testGetChildLeaf()
     {
         for (int i = 0; i < 10; i++)
@@ -124,6 +158,7 @@
      * Tests querying the index of a child node if this node is the only child
      * with this name.
      */
+    @Test
     public void testGetValueIndexLeafSingle()
     {
         assertEquals("Wrong index for single child node",
@@ -133,6 +168,7 @@
     /**
      * Tests querying the indices of child nodes.
      */
+    @Test
     public void testGetValueIndexLeafMulti()
     {
         FlatNode c1 = parent.addChild(NAME);
@@ -146,88 +182,88 @@
     /**
      * Tests querying a simple value.
      */
+    @Test
     public void testGetValueSimple()
     {
-        MapConfigurationSource conf = new MapConfigurationSource();
-        conf.setProperty(NAME, VALUE);
-        assertEquals("Wrong property value", VALUE, node.getValue(conf));
+        config.setProperty(NAME, VALUE);
+        assertEquals("Wrong property value", VALUE, node.getValue());
     }
 
     /**
      * Tests the getValue() method when the value is a collection, but no index
      * is specified. In this case the whole collection should be returned.
      */
+    @Test
     public void testGetValueCollectionNoIndex()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         Collection<Object> values = new ArrayList<Object>();
         values.add(VALUE);
         config.addProperty(NAME, values);
-        assertSame("Wrong value collection", values, node.getValue(config));
+        assertSame("Wrong value collection", values, node.getValue());
     }
 
     /**
      * Tests the getValue() method when multiple values are involved.
      */
+    @Test
     public void testGetValueCollection()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         Collection<Object> values = new ArrayList<Object>();
         values.add(VALUE);
         values.add(2);
         config.setProperty(NAME, values);
         FlatNode c2 = parent.addChild(NAME);
-        assertEquals("Wrong value index 1", VALUE, node.getValue(config));
-        assertEquals("Wrong value index 2", 2, c2.getValue(config));
+        assertEquals("Wrong value index 1", VALUE, node.getValue());
+        assertEquals("Wrong value index 2", 2, c2.getValue());
     }
 
     /**
      * Tests the getValue() method when multiple values are involved, but the
      * index is out of range. In this case null should be returned.
      */
+    @Test
     public void testGetValueCollectionInvalidIndex()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         config.addProperty(NAME, 2);
         parent.addChild(NAME);
         FlatNode c2 = parent.addChild(NAME);
-        assertNull("Found value for invalid index", c2.getValue(config));
+        assertNull("Found value for invalid index", c2.getValue());
     }
 
     /**
      * Tests the setValue() method for a new value.
      */
+    @Test
     public void testSetValueNew()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
-        node.setValue(config, VALUE);
+        node.setValue(VALUE);
         assertEquals("Value was not set", VALUE, config.getProperty(NAME));
     }
 
     /**
      * Tests the setValue() method for an existing value.
      */
+    @Test
     public void testSetValueExisting()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         // remove node, so that there is only a single child with this name
-        parent.removeChild(config, node);
+        parent.removeChild(node);
         FlatNode child = parent.addChild(NAME, true);
-        child.setValue(config, VALUE);
+        child.setValue(VALUE);
         assertEquals("Value was not set", VALUE, config.getProperty(NAME));
     }
 
     /**
      * Tests setting a value for a property with multiple values.
      */
+    @Test
     public void testSetValueCollection()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, 1);
         config.addProperty(NAME, 2);
         FlatNode child = parent.addChild(NAME, true);
-        child.setValue(config, VALUE);
+        child.setValue(VALUE);
         List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 1", 1, values.get(0));
@@ -239,14 +275,14 @@
      * value index is involved. This case should not happen normally. No
      * modification should be performed.
      */
+    @Test
     public void testSetValueCollectionInvalidIndex()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         config.addProperty(NAME, 2);
         parent.addChild(NAME, true);
         FlatNode child = parent.addChild(NAME, true);
-        child.setValue(config, "new");
+        child.setValue("new");
         List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 0", VALUE, values.get(0));
@@ -258,12 +294,12 @@
      * configuration does not return a collection. This should normally not
      * happen. In this case no modification should be performed.
      */
+    @Test
     public void testSetValueCollectionInvalidValue()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         FlatNode child = parent.addChild(NAME, true);
-        child.setValue(config, "new");
+        child.setValue("new");
         assertEquals("Value was changed", VALUE, config.getProperty(NAME));
     }
 
@@ -271,15 +307,15 @@
      * Tests calling setValue() twice. The first time, the value should be
      * added. The second time it should be overridden.
      */
+    @Test
     public void testSetValueNewAndExisting()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.setProperty(NAME, 1);
-        node.setValue(config, VALUE);
+        node.setValue(VALUE);
         List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Value was not added", 2, values.size());
         assertEquals("Wrong value", VALUE, values.get(1));
-        node.setValue(config, "new");
+        node.setValue("new");
         assertEquals("Value was not changed", "new", config.getProperty(NAME));
     }
 
@@ -287,26 +323,26 @@
      * Tests removing a child node. The associated configuration should also be
      * updated,
      */
+    @Test
     public void testRemoveChild()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
-        parent.removeChild(config, node);
+        parent.removeChild(node);
         assertFalse("Property not removed", config.containsKey(NAME));
     }
 
     /**
      * Tests removing a child node for a property with multiple values.
      */
+    @Test
     public void testRemoveChildCollection()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, 1);
         config.addProperty(NAME, 2);
         config.addProperty(NAME, 3);
         FlatNode n2 = parent.addChild(NAME, true);
         parent.addChild(NAME, true);
-        parent.removeChild(config, n2);
+        parent.removeChild(n2);
         List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 1", 1, values.get(0));
@@ -317,13 +353,13 @@
      * Tests the behavior of removeChild() if after the operation only a single
      * collection element remains.
      */
+    @Test
     public void testRemoveChildCollectionSingleElement()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         config.addProperty(NAME, 2);
         FlatNode n2 = parent.addChild(NAME, true);
-        parent.removeChild(config, n2);
+        parent.removeChild(n2);
         assertEquals("Wrong value", VALUE, config.getProperty(NAME));
     }
 
@@ -331,14 +367,14 @@
      * Tests removeChild() if the child has an invalid index. This should
      * normally not happen. In this case no modification should be performed.
      */
+    @Test
     public void testRemoveChildCollectionInvalidIndex()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         config.addProperty(NAME, 2);
         parent.addChild(NAME, true);
         FlatNode n2 = parent.addChild(NAME, true);
-        parent.removeChild(config, n2);
+        parent.removeChild(n2);
         List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 1", VALUE, values.get(0));
@@ -350,12 +386,12 @@
      * configuration does not return a collection. This should normally not
      * happen. In this case no modification should be performed.
      */
+    @Test
     public void testRemoveChildeCollectionInvalidValue()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         FlatNode n2 = parent.addChild(NAME, true);
-        parent.removeChild(config, n2);
+        parent.removeChild(n2);
         assertEquals("Wrong value", VALUE, config.getProperty(NAME));
     }
 
@@ -363,44 +399,29 @@
      * Tries to remove a child node that does not belong to the parent. This
      * should cause an exception.
      */
+    @Test(expected = ConfigurationRuntimeException.class)
     public void testRemoveChildWrongParent()
     {
         FlatLeafNode child = new FlatLeafNode(null, "test", true);
-        MapConfigurationSource config = new MapConfigurationSource();
-        try
-        {
-            parent.removeChild(config, child);
-            fail("Could remove non existing child!");
-        }
-        catch (ConfigurationRuntimeException crex)
-        {
-            // ok
-        }
+        parent.removeChild(child);
     }
 
     /**
      * Tries to remove a null child node. This should cause an exception.
      */
+    @Test(expected = ConfigurationRuntimeException.class)
     public void testRemoveChildNull()
     {
-        try
-        {
-            parent.removeChild(new MapConfigurationSource(), null);
-            fail("Could remove null child!");
-        }
-        catch (ConfigurationRuntimeException crex)
-        {
-            // ok
-        }
+        parent.removeChild(null);
     }
 
     /**
      * Tests corner cases when adding and removing child nodes.
      */
+    @Test
     public void testAddAndRemoveChild()
     {
         final int count = 5;
-        MapConfigurationSource config = new MapConfigurationSource();
         List<FlatNode> nodes = new ArrayList<FlatNode>(count);
         nodes.add(node);
         for (int i = 0; i < count; i++)
@@ -414,18 +435,18 @@
         for (int i = 0; i < count; i++)
         {
             assertEquals("Wrong value", Integer.valueOf(i), nodes.get(i)
-                    .getValue(config));
+                    .getValue());
         }
         for (int j = count - 1; j > 0; j--)
         {
-            parent.removeChild(config, nodes.get(j));
+            parent.removeChild(nodes.get(j));
             List<FlatNode> remainingChildren = parent.getChildren(NAME);
             assertEquals("Wrong children", nodes.subList(0, j),
                     remainingChildren);
         }
         assertEquals("Wrong remaining value", Integer.valueOf(0), config
                 .getProperty(NAME));
-        parent.removeChild(config, nodes.get(0));
+        parent.removeChild(nodes.get(0));
         assertFalse("Property still found", config.containsKey(NAME));
         assertEquals("Wrong number of children", 0, parent
                 .getChildrenCount(NAME));
@@ -434,39 +455,25 @@
     /**
      * Tests adding a child node to a leaf. This should cause an exception.
      */
+    @Test(expected = ConfigurationRuntimeException.class)
     public void testAddChildLeaf()
     {
-        try
-        {
-            node.addChild(NAME);
-            fail("Could add a child to a leaf node!");
-        }
-        catch (ConfigurationRuntimeException crex)
-        {
-            // ok
-        }
+        node.addChild(NAME);
     }
 
     /**
      * Tests removing a child from a leaf. This should cause an exception.
      */
+    @Test(expected = ConfigurationRuntimeException.class)
     public void testRemoveChildLeaf()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
-        try
-        {
-            node.removeChild(config, parent);
-            fail("Could remove child from a leaf!");
-        }
-        catch (ConfigurationRuntimeException crex)
-        {
-            // ok
-        }
+        node.removeChild(parent);
     }
 
     /**
      * Tests the getChildren() method of a root node.
      */
+    @Test
     public void testGetChildren()
     {
         FlatNode c1 = parent.addChild("child1");
@@ -481,6 +488,7 @@
     /**
      * Tests querying child nodes by their name.
      */
+    @Test
     public void testGetChildrenName()
     {
         FlatNode c1 = parent.addChild("child1");
@@ -497,6 +505,7 @@
     /**
      * Tests querying child nodes with a non existing name.
      */
+    @Test
     public void testGetChildrenNameUnknown()
     {
         List<FlatNode> children = parent.getChildren("unknownName");
@@ -506,6 +515,7 @@
     /**
      * Tests accessing child nodes by its index.
      */
+    @Test
     public void testGetChild()
     {
         FlatNode c1 = parent.addChild("child1");
@@ -518,6 +528,7 @@
     /**
      * Tests querying the number of child nodes.
      */
+    @Test
     public void testGetChildrenCount()
     {
         parent.addChild("child1");
@@ -531,6 +542,7 @@
     /**
      * Tests querying the total number of child nodes.
      */
+    @Test
     public void testGetChildrenCountTotal()
     {
         parent.addChild("child1");
@@ -542,6 +554,7 @@
     /**
      * Tests querying the number of non existing children.
      */
+    @Test
     public void testGetChildrenCountUnknown()
     {
         assertEquals("Found unknown children", 0, parent
@@ -551,6 +564,7 @@
     /**
      * Tests querying the name of the root node. The answer should be null.
      */
+    @Test
     public void testGetNameRoot()
     {
         assertNull("Wrong root name", parent.getName());
@@ -560,6 +574,7 @@
      * Tests querying the parent of the root node. Of course, this node has no
      * parent.
      */
+    @Test
     public void testGetParentRoot()
     {
         assertNull("Root node has a parent", parent.getParent());
@@ -569,6 +584,7 @@
      * Tests querying the root node for its value index. This index is
      * undefined.
      */
+    @Test
     public void testGetValueIndexRoot()
     {
         assertEquals("Wrong root value index", FlatNode.INDEX_UNDEFINED, parent
@@ -578,27 +594,19 @@
     /**
      * Tests querying the value from the root node. The root never has a value.
      */
+    @Test
     public void testGetValueRoot()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
-        assertNull("Wrong value of root node", parent.getValue(config));
+        assertNull("Wrong value of root node", parent.getValue());
     }
 
     /**
      * Tests setting the value of the root node. This should cause an exception
      * because the root node does not support a value.
      */
+    @Test(expected = ConfigurationRuntimeException.class)
     public void testSetValueRoot()
     {
-        MapConfigurationSource config = new MapConfigurationSource();
-        try
-        {
-            parent.setValue(config, VALUE);
-            fail("Could set value of root node!");
-        }
-        catch (ConfigurationRuntimeException crex)
-        {
-            // ok
-        }
+        parent.setValue(VALUE);
     }
 }