commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1580037 - /commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
Date Fri, 21 Mar 2014 20:33:36 GMT
Author: oheger
Date: Fri Mar 21 20:33:35 2014
New Revision: 1580037

URL: http://svn.apache.org/r1580037
Log:
Fixed compilation failures and failing test cases.

Modified:
    commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java?rev=1580037&r1=1580036&r2=1580037&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
Fri Mar 21 20:33:35 2014
@@ -124,12 +124,12 @@ public class TestAbstractHierarchicalCon
         Object prop = testConfig.getProperty("tables.table(0).fields.field.name");
         assertNotNull(prop);
         assertTrue(prop instanceof Collection);
-        assertEquals(5, ((Collection<?>) prop).size());
+        assertEquals(NodeStructureHelper.fieldsLength(0), ((Collection<?>) prop).size());
 
         prop = testConfig.getProperty("tables.table.fields.field.name");
         assertNotNull(prop);
         assertTrue(prop instanceof Collection);
-        assertEquals(10, ((Collection<?>) prop).size());
+        assertEquals(totalFieldCount(), ((Collection<?>) prop).size());
 
         prop = testConfig.getProperty("tables.table.fields.field(3).name");
         assertNotNull(prop);
@@ -220,7 +220,7 @@ public class TestAbstractHierarchicalCon
         prop = config.getProperty("tables.table.fields.field.name");
         assertNotNull(prop);
         assertTrue(prop instanceof Collection);
-        assertEquals(5, ((Collection<?>) prop).size());
+        assertEquals(NodeStructureHelper.fieldsLength(1), ((Collection<?>) prop).size());
 
         config.clearTree("tables.table(1)");
         assertNull(config.getProperty("tables.table.fields.field.name"));
@@ -486,8 +486,10 @@ public class TestAbstractHierarchicalCon
     @Test
     public void testGetMaxIndex()
     {
-        assertEquals(4, config.getMaxIndex("tables.table(0).fields.field"));
-        assertEquals(4, config.getMaxIndex("tables.table(1).fields.field"));
+        assertEquals(NodeStructureHelper.fieldsLength(0) - 1,
+                config.getMaxIndex("tables.table(0).fields.field"));
+        assertEquals(NodeStructureHelper.fieldsLength(1) - 1,
+                config.getMaxIndex("tables.table(1).fields.field"));
         assertEquals(1, config.getMaxIndex("tables.table"));
         assertEquals(1, config.getMaxIndex("tables.table.name"));
         assertEquals(0, config.getMaxIndex("tables.table(0).name"));
@@ -782,7 +784,7 @@ public class TestAbstractHierarchicalCon
     {
         BaseHierarchicalConfiguration copy =
                 new BaseHierarchicalConfiguration(
-                        (HierarchicalConfiguration) null);
+                        (BaseHierarchicalConfiguration) null);
         assertTrue("Configuration not empty", copy.isEmpty());
     }
 
@@ -838,12 +840,12 @@ public class TestAbstractHierarchicalCon
         Object prop = config.getProperty("tables/table[0]/fields/field/name");
         assertNotNull(prop);
         assertTrue(prop instanceof Collection);
-        assertEquals(5, ((Collection<?>) prop).size());
+        assertEquals(NodeStructureHelper.fieldsLength(0), ((Collection<?>) prop).size());
 
         prop = config.getProperty("tables/table/fields/field/name");
         assertNotNull(prop);
         assertTrue(prop instanceof Collection);
-        assertEquals(10, ((Collection<?>) prop).size());
+        assertEquals(totalFieldCount(), ((Collection<?>) prop).size());
 
         prop = config.getProperty("tables/table/fields/field[3]/name");
         assertNotNull(prop);
@@ -863,6 +865,21 @@ public class TestAbstractHierarchicalCon
     }
 
     /**
+     * Returns the total number of fields in the test data structure.
+     *
+     * @return the total number of fields
+     */
+    private static int totalFieldCount()
+    {
+        int fieldCount = 0;
+        for (int i = 0; i < NodeStructureHelper.tablesLength(); i++)
+        {
+            fieldCount += NodeStructureHelper.fieldsLength(i);
+        }
+        return fieldCount;
+    }
+
+    /**
      * Checks the content of the passed in configuration object. Used by some
      * tests that copy a configuration.
      *
@@ -922,12 +939,12 @@ public class TestAbstractHierarchicalCon
             throw new UnsupportedOperationException("Unexpected method call!");
         }
 
-        public List<SubnodeConfiguration> configurationsAt(String key)
+        public List<HierarchicalConfiguration<ImmutableNode>> configurationsAt(String
key)
         {
             throw new UnsupportedOperationException("Unexpected method call!");
         }
 
-        public List<SubnodeConfiguration> childConfigurationsAt(String key)
+        public List<HierarchicalConfiguration<ImmutableNode>> childConfigurationsAt(String
key)
         {
             throw new UnsupportedOperationException("Unexpected method call!");
         }



Mime
View raw message