You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2009/08/10 10:22:38 UTC

svn commit: r802689 - /sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrPropertyMapTest.java

Author: cziegeler
Date: Mon Aug 10 08:22:37 2009
New Revision: 802689

URL: http://svn.apache.org/viewvc?rev=802689&view=rev
Log:
SLING-1077 :  Add iterator based tests.

Modified:
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrPropertyMapTest.java

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrPropertyMapTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrPropertyMapTest.java?rev=802689&r1=802688&r2=802689&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrPropertyMapTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/JcrPropertyMapTest.java Mon Aug 10 08:22:37 2009
@@ -19,6 +19,7 @@
  */
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Iterator;
 
 import javax.jcr.Node;
 import javax.jcr.Property;
@@ -238,4 +239,23 @@
         final ValueMap vm = this.createPropertyMap(this.rootNode);
         assertEquals("value", vm.get("a/a"));
     }
+
+    public void testIerators() throws Exception {
+        this.rootNode.setProperty(ISO9075.encode("a/a"), "value");
+        final ValueMap vm = this.createPropertyMap(this.rootNode);
+        assertTrue(vm.containsKey("a/a"));
+        search(vm.keySet().iterator(), "a/a");
+        search(vm.values().iterator(), "value");
+    }
+
+    protected void search(Iterator<?> i, Object value) {
+        boolean found = false;
+        while ( !found && i.hasNext() ) {
+            final Object current = i.next();
+            found = current.equals(value);
+        }
+        if ( !found ) {
+            fail("Value " + value + " is not found in iterator.");
+        }
+    }
 }