commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r800941 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/flat/FlatNodeHandler.java test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java
Date Tue, 04 Aug 2009 19:59:33 GMT
Author: oheger
Date: Tue Aug  4 19:59:33 2009
New Revision: 800941

URL: http://svn.apache.org/viewvc?rev=800941&view=rev
Log:
FlatNodeHandler now operates on a plain Configuration rather than an AbstractFlatConfiguration.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/flat/FlatNodeHandler.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/flat/FlatNodeHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/flat/FlatNodeHandler.java?rev=800941&r1=800940&r2=800941&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/flat/FlatNodeHandler.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/flat/FlatNodeHandler.java
Tue Aug  4 19:59:33 2009
@@ -19,6 +19,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.configuration2.Configuration;
 import org.apache.commons.configuration2.ConfigurationRuntimeException;
 import org.apache.commons.configuration2.expr.AbstractNodeHandler;
 import org.apache.commons.configuration2.expr.NodeHandler;
@@ -60,8 +61,8 @@
  */
 class FlatNodeHandler extends AbstractNodeHandler<FlatNode>
 {
-    /** Stores the associated flat configuration. */
-    private AbstractFlatConfiguration configuration;
+    /** Stores the associated configuration. */
+    private final Configuration configuration;
 
     /**
      * A flag whether an update of the configuration was caused by an operation
@@ -75,7 +76,7 @@
      *
      * @param config the configuration
      */
-    public FlatNodeHandler(AbstractFlatConfiguration config)
+    public FlatNodeHandler(Configuration config)
     {
         configuration = config;
     }
@@ -85,7 +86,7 @@
      *
      * @return the associated configuration
      */
-    public AbstractFlatConfiguration getConfiguration()
+    public Configuration getConfiguration()
     {
         return configuration;
     }

Modified: 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/flat/TestFlatNodeHandler.java?rev=800941&r1=800940&r2=800941&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/flat/TestFlatNodeHandler.java
Tue Aug  4 19:59:33 2009
@@ -18,12 +18,13 @@
 
 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;
 
-import junit.framework.TestCase;
-
 /**
  * Test class for FlatNodeHandler.
  *
@@ -38,11 +39,14 @@
             "child1", "anotherChild", "differentChild", "child1", "againAChild"
     };
 
+    /** Constant for the name of a test property. */
+    private static final String NAME = "testProperty";
+
     /** The node handler to be tested. */
     private FlatNodeHandler handler;
 
     /** The mock configuration associated with the node handler. */
-    private FlatConfigurationMockImpl config;
+    private AbstractConfiguration config;
 
     /** Stores the internal update flag of the node handler. */
     private Boolean internalUpdate;
@@ -51,7 +55,7 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        config = new FlatConfigurationMockImpl();
+        config = new BaseConfiguration();
         config.clearConfigurationListeners();
         config.addConfigurationListener(new ConfigurationListener()
         {
@@ -191,12 +195,11 @@
     public void testAddChild()
     {
         FlatNode node = setUpTestNode();
-        final String childName = FlatConfigurationMockImpl.NAME;
-        FlatNode child = handler.addChild(node, childName);
-        assertEquals("Wrong name of child", childName, child.getName());
-        config.expectAdd = true;
+        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.property);
+        assertEquals("Value not added", TestFlatNodes.VALUE, config.getProperty(NAME));
         checkUpdate(false);
     }
 
@@ -206,12 +209,13 @@
     public void testRemoveChild()
     {
         FlatNode node = setUpTestNode();
-        FlatNode child = node.addChild(FlatConfigurationMockImpl.NAME);
+        config.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));
-        assertTrue("Configuration not removed", config.clearProperty);
+        assertFalse("Property not removed", config.containsKey(NAME));
         checkUpdate(true);
     }
 
@@ -221,11 +225,10 @@
     public void testSetValue()
     {
         FlatNode node = setUpTestNode();
-        FlatNode child = node.addChild(FlatConfigurationMockImpl.NAME);
-        config.expectAdd = true;
+        FlatNode child = node.addChild(NAME);
         handler.setValue(child, TestFlatNodes.VALUE);
         assertEquals("Property not added to config", TestFlatNodes.VALUE,
-                config.property);
+                config.getProperty(NAME));
         checkUpdate(true);
     }
 
@@ -235,8 +238,9 @@
     public void testGetValue()
     {
         FlatNode node = setUpTestNode();
-        FlatNode child = node.addChild(FlatConfigurationMockImpl.NAME);
-        config.property = TestFlatNodes.VALUE;
+        config.setProperty(NAME, TestFlatNodes.VALUE);
+        checkUpdate(false);
+        FlatNode child = node.addChild(NAME);
         assertEquals("Wrong value of node", TestFlatNodes.VALUE, handler
                 .getValue(child));
     }



Mime
View raw message