jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1324657 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
Date Wed, 11 Apr 2012 09:06:40 GMT
Author: thomasm
Date: Wed Apr 11 09:06:40 2012
New Revision: 1324657

URL: http://svn.apache.org/viewvc?rev=1324657&view=rev
Log:
OAK-28 Query implementation (undo changed from the last commit; simplify a bit)

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java?rev=1324657&r1=1324656&r2=1324657&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
Wed Apr 11 09:06:40 2012
@@ -21,17 +21,8 @@ package org.apache.jackrabbit.oak.query.
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -41,13 +32,6 @@ public class TraversingCursorTest {
 
     private final MicroKernel mk = new MicroKernelImpl();
 
-    String head;
-
-    @Before
-    public void setUp() {
-        head = mk.getHeadRevision();
-    }
-
     @Test
     public void traverse() throws Exception {
         TraversingIndex t = new TraversingIndex(mk);
@@ -62,27 +46,32 @@ public class TraversingCursorTest {
     }
 
     private void traverse(TraversingIndex t) {
-        head = mk.commit("/", "+ \"parents\": { \"p0\": {\"id\": \"0\"}, \"p1\": {\"id\":
\"1\"}, \"p2\": {\"id\": \"2\"}}", head, "");
-        head = mk.commit("/", "+ \"children\": { \"c1\": {\"p\": \"1\"}, \"c2\": {\"p\":
\"1\"}, \"c3\": {\"p\": \"2\"}, \"c4\": {\"p\": \"3\"}}", head, "");
+        String head = mk.getHeadRevision();
+        head = mk.commit("/",
+                "+ \"parents\": { \"p0\": {\"id\": \"0\"}, \"p1\": {\"id\": \"1\"}, \"p2\":
{\"id\": \"2\"}}",
+                head, "");
+        head = mk.commit("/",
+                "+ \"children\": { \"c1\": {\"p\": \"1\"}, \"c2\": {\"p\": \"1\"}, \"c3\":
{\"p\": \"2\"}, \"c4\": {\"p\": \"3\"}}",
+                head, "");
         Filter f = new Filter(null);
- 
+
         f.setPath("/");
-        List<String> paths = new ArrayList<String>();
+        // also check the iteration order
+        String[] list = {"/", "/parents", "/parents/p0", "/parents/p1",  "/parents/p2",
+                "/children", "/children/c1", "/children/c2", "/children/c3", "/children/c4"};
         Cursor c = t.query(f, head);
-        while (c.next()) {
-            paths.add(c.currentPath());
+        for (String s : list) {
+            assertTrue(c.next());
+            assertEquals(s, c.currentPath());
         }
-        Collections.sort(paths);
-        assertEquals(Arrays.asList(
-                "/", "/children", "/children/c1", "/children/c2",
-                "/children/c3", "/children/c4", "/parents",
-                "/parents/p0", "/parents/p1",  "/parents/p2"),
-                paths);
+        assertFalse(c.next());
+        // endure it stays false
         assertFalse(c.next());
 
         f.setPath("/nowhere");
         c = t.query(f, head);
         assertFalse(c.next());
+        // endure it stays false
         assertFalse(c.next());
     }
 



Mime
View raw message