Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3182D96EC for ; Wed, 11 Apr 2012 09:07:04 +0000 (UTC) Received: (qmail 72699 invoked by uid 500); 11 Apr 2012 09:07:03 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 72625 invoked by uid 500); 11 Apr 2012 09:07:03 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-commits@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 72451 invoked by uid 99); 11 Apr 2012 09:07:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Apr 2012 09:07:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Apr 2012 09:07:01 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0B7D823888FE; Wed, 11 Apr 2012 09:06:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: oak-commits@jackrabbit.apache.org From: thomasm@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120411090641.0B7D823888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 paths = new ArrayList(); + // 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()); }