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:11:26 UTC

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

Author: oheger
Date: Sun Aug 23 18:11:26 2009
New Revision: 806995

URL: http://svn.apache.org/viewvc?rev=806995&view=rev
Log:
Test class for the flat node classes.

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

Copied: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java (from r805568, commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodes.java)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java?p2=commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java&p1=commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodes.java&r1=805568&r2=806995&rev=806995&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodes.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/TestFlatNodes.java Sun Aug 23 18:11:26 2009
@@ -14,7 +14,7 @@
  * 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.ArrayList;
 import java.util.Collection;
@@ -148,7 +148,7 @@
      */
     public void testGetValueSimple()
     {
-        BaseConfiguration conf = new BaseConfiguration();
+        MapConfigurationSource conf = new MapConfigurationSource();
         conf.setProperty(NAME, VALUE);
         assertEquals("Wrong property value", VALUE, node.getValue(conf));
     }
@@ -159,10 +159,10 @@
      */
     public void testGetValueCollectionNoIndex()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         Collection<Object> values = new ArrayList<Object>();
         values.add(VALUE);
-        config.addPropertyDirect(NAME, values);
+        config.addProperty(NAME, values);
         assertSame("Wrong value collection", values, node.getValue(config));
     }
 
@@ -171,7 +171,7 @@
      */
     public void testGetValueCollection()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         Collection<Object> values = new ArrayList<Object>();
         values.add(VALUE);
         values.add(2);
@@ -187,7 +187,7 @@
      */
     public void testGetValueCollectionInvalidIndex()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         config.addProperty(NAME, 2);
         parent.addChild(NAME);
@@ -200,7 +200,7 @@
      */
     public void testSetValueNew()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         node.setValue(config, VALUE);
         assertEquals("Value was not set", VALUE, config.getProperty(NAME));
     }
@@ -210,7 +210,7 @@
      */
     public void testSetValueExisting()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         // remove node, so that there is only a single child with this name
         parent.removeChild(config, node);
         FlatNode child = parent.addChild(NAME, true);
@@ -223,12 +223,12 @@
      */
     public void testSetValueCollection()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, 1);
         config.addProperty(NAME, 2);
         FlatNode child = parent.addChild(NAME, true);
         child.setValue(config, VALUE);
-        List<?> values = config.getList(NAME);
+        List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 1", 1, values.get(0));
         assertEquals("Wrong value 2", VALUE, values.get(1));
@@ -241,13 +241,13 @@
      */
     public void testSetValueCollectionInvalidIndex()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        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");
-        List<?> values = config.getList(NAME);
+        List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 0", VALUE, values.get(0));
         assertEquals("Wrong value 1", 2, values.get(1));
@@ -260,7 +260,7 @@
      */
     public void testSetValueCollectionInvalidValue()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         FlatNode child = parent.addChild(NAME, true);
         child.setValue(config, "new");
@@ -273,10 +273,10 @@
      */
     public void testSetValueNewAndExisting()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         config.setProperty(NAME, 1);
         node.setValue(config, VALUE);
-        List<?> values = config.getList(NAME);
+        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");
@@ -289,7 +289,7 @@
      */
     public void testRemoveChild()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         parent.removeChild(config, node);
         assertFalse("Property not removed", config.containsKey(NAME));
@@ -300,14 +300,14 @@
      */
     public void testRemoveChildCollection()
     {
-        BaseConfiguration config = new BaseConfiguration();
-        config.addProperty(NAME, new Object[] {
-                1, 2, 3
-        });
+        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);
-        List<?> values = config.getList(NAME);
+        List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 1", 1, values.get(0));
         assertEquals("Wrong value 2", 3, values.get(1));
@@ -319,7 +319,7 @@
      */
     public void testRemoveChildCollectionSingleElement()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         config.addProperty(NAME, 2);
         FlatNode n2 = parent.addChild(NAME, true);
@@ -333,13 +333,13 @@
      */
     public void testRemoveChildCollectionInvalidIndex()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        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);
-        List<?> values = config.getList(NAME);
+        List<?> values = (List<?>) config.getProperty(NAME);
         assertEquals("Wrong number of values", 2, values.size());
         assertEquals("Wrong value 1", VALUE, values.get(0));
         assertEquals("Wrong value 2", 2, values.get(1));
@@ -352,7 +352,7 @@
      */
     public void testRemoveChildeCollectionInvalidValue()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         config.addProperty(NAME, VALUE);
         FlatNode n2 = parent.addChild(NAME, true);
         parent.removeChild(config, n2);
@@ -366,7 +366,7 @@
     public void testRemoveChildWrongParent()
     {
         FlatLeafNode child = new FlatLeafNode(null, "test", true);
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         try
         {
             parent.removeChild(config, child);
@@ -385,7 +385,7 @@
     {
         try
         {
-            parent.removeChild(new BaseConfiguration(), null);
+            parent.removeChild(new MapConfigurationSource(), null);
             fail("Could remove null child!");
         }
         catch (ConfigurationRuntimeException crex)
@@ -400,7 +400,7 @@
     public void testAddAndRemoveChild()
     {
         final int count = 5;
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         List<FlatNode> nodes = new ArrayList<FlatNode>(count);
         nodes.add(node);
         for (int i = 0; i < count; i++)
@@ -452,7 +452,7 @@
      */
     public void testRemoveChildLeaf()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         try
         {
             node.removeChild(config, parent);
@@ -580,7 +580,7 @@
      */
     public void testGetValueRoot()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         assertNull("Wrong value of root node", parent.getValue(config));
     }
 
@@ -590,7 +590,7 @@
      */
     public void testSetValueRoot()
     {
-        BaseConfiguration config = new BaseConfiguration();
+        MapConfigurationSource config = new MapConfigurationSource();
         try
         {
             parent.setValue(config, VALUE);