commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r359621 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/ConfigurationKey.java test/org/apache/commons/configuration/TestConfigurationKey.java
Date Wed, 28 Dec 2005 20:23:26 GMT
Author: oheger
Date: Wed Dec 28 12:23:19 2005
New Revision: 359621

URL: http://svn.apache.org/viewcvs?rev=359621&view=rev
Log:
Fixed a bug in ConfigurationKey related to attributes with indices

Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationKey.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationKey.java

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationKey.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationKey.java?rev=359621&r1=359620&r2=359621&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationKey.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationKey.java
Wed Dec 28 12:23:19 2005
@@ -506,15 +506,9 @@
             indexValue = -1;
             String key = findNextIndices();
 
-            attribute = checkAttribute(key);
-            if (!attribute)
-            {
-                hasIndex = checkIndex(key);
-                if (!hasIndex)
-                {
-                    current = key;
-                }
-            }
+            current = key;
+            hasIndex = checkIndex(key);
+            attribute = checkAttribute(current);
 
             return currentKey(decorated);
         }

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationKey.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationKey.java?rev=359621&r1=359620&r2=359621&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationKey.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationKey.java
Wed Dec 28 12:23:19 2005
@@ -222,4 +222,23 @@
         assertTrue(it.hasIndex());
         assertEquals(0, it.getIndex());
     }
+    
+    /**
+     * Tests iterating over an attribute key that has an index.
+     */
+    public void testAttributeKeyWithIndex()
+    {
+        ConfigurationKey k = new ConfigurationKey(TESTATTR);
+        k.appendIndex(0);
+        assertEquals("Wrong attribute key with index", TESTATTR + "(0)", k.toString());
+        
+        ConfigurationKey.KeyIterator it = k.iterator();
+        assertTrue("No first element", it.hasNext());
+        it.next();
+        assertTrue("Index not found", it.hasIndex());
+        assertEquals("Incorrect index", 0, it.getIndex());
+        assertTrue("Attribute not found", it.isAttribute());
+        assertEquals("Wrong plain key", "dataType", it.currentKey(false));
+        assertEquals("Wrong decorated key", TESTATTR, it.currentKey(true));
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message