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/08/23 20:12:46 UTC

svn commit: r806997 - /commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java

Author: oheger
Date: Sun Aug 23 18:12:46 2009
New Revision: 806997

URL: http://svn.apache.org/viewvc?rev=806997&view=rev
Log:
Test class for FlatNodeHandler

Added:
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java
      - copied, changed from r800941, commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java

Copied: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java (from r800941, commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java?p2=commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java&p1=commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java&r1=800941&r2=806997&rev=806997&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodeHandler.java Sun Aug 23 18:12:46 2009
@@ -14,21 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.configuration2.flat;
+package org.apache.commons.configuration2.base;
 
 import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.apache.commons.configuration2.AbstractConfiguration;
 import org.apache.commons.configuration2.ConfigurationRuntimeException;
-import org.apache.commons.configuration2.event.ConfigurationEvent;
-import org.apache.commons.configuration2.event.ConfigurationListener;
 
 /**
  * Test class for FlatNodeHandler.
  *
- * @author <a href="http://commons.apache.org/configuration/team-list.html">Commons
+ * @author <a
+ *         href="http://commons.apache.org/configuration/team-list.html">Commons
  *         Configuration team</a>
  * @version $Id$
  */
@@ -45,8 +43,8 @@
     /** The node handler to be tested. */
     private FlatNodeHandler handler;
 
-    /** The mock configuration associated with the node handler. */
-    private AbstractConfiguration config;
+    /** The configuration source associated with the node handler. */
+    private ConfigurationSource source;
 
     /** Stores the internal update flag of the node handler. */
     private Boolean internalUpdate;
@@ -55,19 +53,20 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        config = new BaseConfiguration();
-        config.clearConfigurationListeners();
-        config.addConfigurationListener(new ConfigurationListener()
+        source = new ConfigurationSourceEventWrapper(
+                new MapConfigurationSource());
+        source.addConfigurationSourceListener(new ConfigurationSourceListener()
         {
             /**
              * Tests the internal update status of the node handler.
              */
-            public void configurationChanged(ConfigurationEvent event)
+            public void configurationSourceChanged(
+                    ConfigurationSourceEvent event)
             {
                 internalUpdate = handler.isInternalUpdate();
             }
         });
-        handler = new FlatNodeHandler(config);
+        handler = new FlatNodeHandler(source);
     }
 
     /**
@@ -109,11 +108,13 @@
     }
 
     /**
-     * Tests whether the correct configuration is returned by the handler.
+     * Tests whether the correct configuration source is returned by the
+     * handler.
      */
-    public void testGetConfiguration()
+    public void testGetConfigurationSource()
     {
-        assertSame("Configuration not set", config, handler.getConfiguration());
+        assertSame("Configuration source not set", source, handler
+                .getConfigurationSource());
     }
 
     /**
@@ -197,9 +198,10 @@
         FlatNode node = setUpTestNode();
         FlatNode child = handler.addChild(node, NAME);
         assertEquals("Wrong name of child", NAME, child.getName());
-        assertTrue("Config not empty", config.isEmpty());
-        child.setValue(config, TestFlatNodes.VALUE);
-        assertEquals("Value not added", TestFlatNodes.VALUE, config.getProperty(NAME));
+        assertTrue("Config not empty", source.isEmpty());
+        child.setValue(source, TestFlatNodes.VALUE);
+        assertEquals("Value not added", TestFlatNodes.VALUE, source
+                .getProperty(NAME));
         checkUpdate(false);
     }
 
@@ -209,13 +211,13 @@
     public void testRemoveChild()
     {
         FlatNode node = setUpTestNode();
-        config.setProperty(NAME, "test");
+        source.setProperty(NAME, "test");
         FlatNode child = node.addChild(NAME);
         handler.removeChild(node, child);
         List<FlatNode> children = node.getChildren();
         assertEquals("No child removed", CHILD_NAMES.length, children.size());
         assertFalse("Child still found", children.contains(child));
-        assertFalse("Property not removed", config.containsKey(NAME));
+        assertFalse("Property not removed", source.containsKey(NAME));
         checkUpdate(true);
     }
 
@@ -228,7 +230,7 @@
         FlatNode child = node.addChild(NAME);
         handler.setValue(child, TestFlatNodes.VALUE);
         assertEquals("Property not added to config", TestFlatNodes.VALUE,
-                config.getProperty(NAME));
+                source.getProperty(NAME));
         checkUpdate(true);
     }
 
@@ -238,7 +240,7 @@
     public void testGetValue()
     {
         FlatNode node = setUpTestNode();
-        config.setProperty(NAME, TestFlatNodes.VALUE);
+        source.setProperty(NAME, TestFlatNodes.VALUE);
         checkUpdate(false);
         FlatNode child = node.addChild(NAME);
         assertEquals("Wrong value of node", TestFlatNodes.VALUE, handler