jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1394523 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/mk/index/ main/java/org/apache/jackrabbit/oak/plugins/index/ main/java/org/apache/jackrabbit/oak/plugins/index/old/ main/java/org/apache/jackrabbit/oak/query/...
Date Fri, 05 Oct 2012 13:50:13 GMT
Author: alexparvulescu
Date: Fri Oct  5 13:50:12 2012
New Revision: 1394523

URL: http://svn.apache.org/viewvc?rev=1394523&view=rev
Log:
OAK-368 Unify all index definitions under oak:index

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixContentIndex.java
      - copied, changed from r1394459, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java   (contents, props changed)
      - copied, changed from r1394459, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java   (contents, props changed)
      - copied, changed from r1394499, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/old/QueryTest.java   (contents, props changed)
      - copied, changed from r1394476, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java   (contents, props changed)
      - copied, changed from r1394476, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/index/IndexWrapper.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_explain.txt
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/index/IndexWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/index/IndexWrapper.java?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/index/IndexWrapper.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/index/IndexWrapper.java Fri Oct  5 13:50:12 2012
@@ -52,6 +52,12 @@ public class IndexWrapper extends MicroK
         indexer.init();
     }
 
+    public IndexWrapper(MicroKernel mk, String indexConfigPath) {
+        this.mk = MicroKernelWrapperBase.wrap(mk);
+        this.indexer = new Indexer(mk, indexConfigPath);
+        indexer.init();
+    }
+
     public Indexer getIndexer() {
         return indexer;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java Fri Oct  5 13:50:12 2012
@@ -26,8 +26,6 @@ import javax.annotation.Nonnull;
  */
 public interface IndexDefinition {
 
-    String TYPE_PROPERTY_NAME = "type";
-
     String UNIQUE_PROPERTY_NAME = "unique";
 
     String INDEX_DATA_CHILD_NAME = ":data";

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java Fri Oct  5 13:50:12 2012
@@ -33,15 +33,14 @@ import org.apache.jackrabbit.oak.spi.sta
 import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
 import static org.apache.jackrabbit.oak.api.Type.STRING;
 import static org.apache.jackrabbit.oak.plugins.index.IndexDefinition.INDEX_DATA_CHILD_NAME;
-import static org.apache.jackrabbit.oak.plugins.index.IndexDefinition.TYPE_PROPERTY_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexDefinition.UNIQUE_PROPERTY_NAME;
 
-public class IndexUtils {
+public class IndexUtils implements IndexConstants {
 
     /**
      * switch to "oak:index" as soon as it is possible
      */
-    public static final String DEFAULT_INDEX_HOME = "/oak-index";
+    public static final String DEFAULT_INDEX_HOME = "/oak:index";
 
     private static final String TYPE_UNKNOWN = "unknown";
 

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixContentIndex.java (from r1394459, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixContentIndex.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixContentIndex.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java&r1=1394459&r2=1394523&rev=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PrefixContentIndex.java Fri Oct  5 13:50:12 2012
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.jackrabbit.oak.query.index;
+package org.apache.jackrabbit.oak.plugins.index.old;
 
 import java.util.Iterator;
 
@@ -24,7 +24,7 @@ import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.kernel.CoreValueMapper;
-import org.apache.jackrabbit.oak.plugins.index.old.PrefixIndex;
+import org.apache.jackrabbit.oak.query.index.IndexRowImpl;
 import org.apache.jackrabbit.oak.spi.query.Cursor;
 import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.query.IndexRow;

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java (from r1394459, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java&r1=1394459&r2=1394523&rev=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java Fri Oct  5 13:50:12 2012
@@ -16,11 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.jackrabbit.oak.query.index;
+package org.apache.jackrabbit.oak.plugins.index.old;
 
 import java.util.Iterator;
 import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.plugins.index.old.PropertyIndex;
+import org.apache.jackrabbit.oak.query.index.IndexRowImpl;
 import org.apache.jackrabbit.oak.spi.query.Cursor;
 import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.query.IndexRow;

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyContentIndex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java Fri Oct  5 13:50:12 2012
@@ -24,8 +24,6 @@ import javax.annotation.Nonnull;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinition;
 import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
-import org.apache.jackrabbit.oak.query.index.PrefixContentIndex;
-import org.apache.jackrabbit.oak.query.index.PropertyContentIndex;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java (from r1394499, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java&r1=1394499&r2=1394523&rev=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java Fri Oct  5 13:50:12 2012
@@ -16,82 +16,49 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.lucene;
 
-import java.util.Iterator;
-
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.query.AbstractQueryTest;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
-import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.DEFAULT_INDEX_HOME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 /**
- * base class for lucene search tests
+ * Tests the query engine using the default index implementation: the
+ * {@link LuceneIndexProvider}
  */
-public class LuceneQueryTest extends AbstractQueryTest implements
+public class LuceneIndexQueryTest extends AbstractQueryTest implements
         LuceneIndexConstants {
 
-    protected static final String SQL2 = "JCR-SQL2";
-
     @Override
-    @Before
-    public void before() throws Exception {
-        super.before();
-        createIndexNode();
+    protected void createTestIndexNode() throws Exception {
+        Tree index = root.getTree("/");
+        createTestIndexNode(index, TYPE);
+        root.commit();
     }
 
     @Override
     protected ContentRepository createRepository() {
         QueryIndexProvider qip = new CompositeQueryIndexProvider(
-                new LuceneIndexProvider(DEFAULT_INDEX_HOME));
-        CommitHook ch = new CompositeHook(new LuceneReindexHook(
-                DEFAULT_INDEX_HOME), new LuceneHook(DEFAULT_INDEX_HOME));
+                new LuceneIndexProvider(TEST_INDEX_HOME));
+        CommitHook ch = new CompositeHook(
+                new LuceneReindexHook(TEST_INDEX_HOME), new LuceneHook(
+                        TEST_INDEX_HOME));
         MicroKernel mk = new MicroKernelImpl();
         createDefaultKernelTracker().available(mk);
         return new Oak(mk).with(qip).with(ch).createContentRepository();
     }
 
-    protected void createIndexNode() throws Exception {
-        Tree index = root.getTree("/");
-        for (String p : PathUtils.elements(DEFAULT_INDEX_HOME)) {
-            if (index.hasChild(p)) {
-                index = index.getChild(p);
-            } else {
-                index = index.addChild(p);
-            }
-        }
-        index.addChild("test-lucene").setProperty("type", "lucene");
-        root.commit();
-    }
-
     @Test
-    public void simpleSql2() throws Exception {
-
-        Tree test = root.getTree("/").addChild("test");
-        test.addChild("a").setProperty("name", "hello");
-        test.addChild("b").setProperty("name", "nothello");
-        root.commit();
-
-        String sql = "select * from [nt:base] where name = 'hello'";
-
-        Iterator<? extends ResultRow> result;
-        result = executeQuery(sql, SQL2, null).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("/test/a", result.next().getPath());
-        assertFalse(result.hasNext());
+    @Ignore("OAK-367")
+    public void sql2() throws Exception {
+        test("sql2.txt");
     }
 
 }
\ No newline at end of file

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/old/QueryTest.java (from r1394476, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/old/QueryTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/old/QueryTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java&r1=1394476&r2=1394523&rev=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/old/QueryTest.java Fri Oct  5 13:50:12 2012
@@ -11,40 +11,20 @@
  * KIND, either express or implied. See the License for the specific language
  * governing permissions and limitations under the License.
  */
-package org.apache.jackrabbit.oak.query;
-
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
+package org.apache.jackrabbit.oak.plugins.index.old;
 
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.mk.index.IndexWrapper;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.Result;
-import org.apache.jackrabbit.oak.api.ResultRow;
-import org.apache.jackrabbit.oak.plugins.index.old.Indexer;
-import org.apache.jackrabbit.oak.plugins.index.old.PropertyIndexer;
+import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.query.AbstractQueryTest;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
+import org.junit.Ignore;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 /**
  * Test the query feature.
  */
@@ -54,7 +34,8 @@ public class QueryTest extends AbstractQ
     protected ContentRepository createRepository() {
 
         // the property and prefix index currently require the index wrapper
-        IndexWrapper mk = new IndexWrapper(new MicroKernelImpl());
+        IndexWrapper mk = new IndexWrapper(new MicroKernelImpl(),
+                PathUtils.concat(TEST_INDEX_HOME, TEST_INDEX_NAME));
         Indexer indexer = mk.getIndexer();
 
         // MicroKernel mk = new MicroKernelImpl();
@@ -68,210 +49,14 @@ public class QueryTest extends AbstractQ
     }
 
     @Test
-    public void sql1() throws Exception {
-        test("sql1.txt");
-    }
-
-    @Test
-    public void sql2() throws Exception {
-        test("sql2.txt");
-    }
-
-    @Test
     public void sql2Explain() throws Exception {
         test("sql2_explain.txt");
     }
 
     @Test
-    public void sql2_measure() throws Exception {
-        test("sql2_measure.txt");
-    }
-
-    @Test
-    public void xpath() throws Exception {
-        test("xpath.txt");
-    }
-
-    @Test
-    public void bindVariableTest() throws Exception {
-        JsopUtil.apply(
-                root,
-                "/ + \"test\": { \"hello\": {\"id\": \"1\"}, \"world\": {\"id\": \"2\"}}",
-                vf);
-        root.commit();
-
-        HashMap<String, CoreValue> sv = new HashMap<String, CoreValue>();
-        sv.put("id", vf.createValue("1"));
-        Iterator<? extends ResultRow> result;
-        result = executeQuery("select * from [nt:base] where id = $id",
-                QueryEngineImpl.SQL2, sv).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("/test/hello", result.next().getPath());
-
-        sv.put("id", vf.createValue("2"));
-        result = executeQuery("select * from [nt:base] where id = $id",
-                QueryEngineImpl.SQL2, sv).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("/test/world", result.next().getPath());
-
-        result = executeQuery("explain select * from [nt:base] where id = 1 order by id",
-                QueryEngineImpl.SQL2, null).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("[nt:base] as [nt:base] " +
-                "/* traverse \"//*\" where [nt:base].[id] = cast('1' as long) */",
-                result.next().getValue("plan").getString());
-
-    }
-
-    private void test(String file) throws Exception {
-        InputStream in = getClass().getResourceAsStream(file);
-        LineNumberReader r = new LineNumberReader(new InputStreamReader(in));
-        PrintWriter w = new PrintWriter(new OutputStreamWriter(
-                new FileOutputStream("target/" + file)));
-        HashSet<String> knownQueries = new HashSet<String>();
-        boolean errors = false;
-        try {
-            while (true) {
-                String line = r.readLine();
-                if (line == null) {
-                    break;
-                }
-                line = line.trim();
-                if (line.startsWith("#") || line.length() == 0) {
-                    w.println(line);
-                } else if (line.startsWith("xpath2sql")) {
-                    line = line.substring("xpath2sql".length()).trim();
-                    w.println("xpath2sql " + line);
-                    XPathToSQL2Converter c = new XPathToSQL2Converter();
-                    String got;
-                    try {
-                        got = c.convert(line);
-                        executeQuery(got, QueryEngineImpl.SQL2, null);
-                    } catch (ParseException e) {
-                        got = "invalid: " + e.getMessage().replace('\n', ' ');
-                    } catch (Exception e) {
-                        // e.printStackTrace();
-                        got = "error: " + e.toString().replace('\n', ' ');
-                    }
-                    if (!knownQueries.add(line)) {
-                        got = "duplicate xpath2sql query";
-                    }
-                    line = r.readLine().trim();
-                    w.println(got);
-                    if (!line.equals(got)) {
-                        errors = true;
-                    }
-                } else if (line.startsWith("select") ||
-                        line.startsWith("explain") ||
-                        line.startsWith("measure") ||
-                        line.startsWith("sql1") ||
-                        line.startsWith("xpath")) {
-                    w.println(line);
-                    String language = QueryEngineImpl.SQL2;
-                    if (line.startsWith("sql1 ")) {
-                        language = QueryEngineImpl.SQL;
-                        line = line.substring("sql1 ".length());
-                    } else if (line.startsWith("xpath ")) {
-                        language = QueryEngineImpl.XPATH;
-                        line = line.substring("xpath ".length());
-                    }
-                    boolean readEnd = true;
-                    for (String resultLine : executeQuery(line, language)) {
-                        w.println(resultLine);
-                        if (readEnd) {
-                            line = r.readLine();
-                            if (line == null) {
-                                errors = true;
-                                readEnd = false;
-                            } else {
-                                line = line.trim();
-                                if (line.length() == 0) {
-                                    errors = true;
-                                    readEnd = false;
-                                } else {
-                                    if (!line.equals(resultLine)) {
-                                        errors = true;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    w.println("");
-                    if (readEnd) {
-                        while (true) {
-                            line = r.readLine();
-                            if (line == null) {
-                                break;
-                            }
-                            line = line.trim();
-                            if (line.length() == 0) {
-                                break;
-                            }
-                            errors = true;
-                        }
-                    }
-                } else if (line.startsWith("commit")) {
-                    w.println(line);
-                    line = line.substring("commit".length()).trim();
-                    JsopUtil.apply(root, line, vf);
-                    root.commit();
-                }
-                w.flush();
-            }
-        } finally {
-            w.close();
-            r.close();
-        }
-        if (errors) {
-            throw new Exception("Results in target/" + file + " don't match expected " +
-                    "results in src/test/resources/" + file + "; compare the files for details");
-        }
-    }
-
-    private List<String> executeQuery(String query, String language) {
-        long time = System.currentTimeMillis();
-        List<String> lines = new ArrayList<String>();
-        try {
-            Result result = executeQuery(query, language, null);
-            for (ResultRow row : result.getRows()) {
-                lines.add(readRow(row));
-            }
-            if (!query.contains("order by")) {
-                Collections.sort(lines);
-            }
-        } catch (ParseException e) {
-            lines.add(e.toString());
-        } catch (IllegalArgumentException e) {
-            lines.add(e.toString());
-        }
-        time = System.currentTimeMillis() - time;
-        if (time > 3000 && !isDebugModeEnabled()) {
-            fail("Query took too long: " + query + " took " + time + " ms");
-        }
-        return lines;
-    }
-
-    private static String readRow(ResultRow row) {
-        StringBuilder buff = new StringBuilder();
-        CoreValue[] values = row.getValues();
-        for (int i = 0; i < values.length; i++) {
-            if (i > 0) {
-                buff.append(", ");
-            }
-            CoreValue v = values[i];
-            buff.append(v == null ? "null" : v.getString());
-        }
-        return buff.toString();
-    }
-
-    /**
-     * Check whether the test is running in debug mode.
-     * 
-     * @return true if debug most is (most likely) enabled
-     */
-    private static boolean isDebugModeEnabled() {
-        return java.lang.management.ManagementFactory.getRuntimeMXBean().
-                getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
+    @Ignore("OAK-288 prevents the index from seeing updates that happened directly on the mk")
+    public void sql2() throws Exception {
+        test("sql2.txt");
     }
 
 }

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/old/QueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java?rev=1394523&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java Fri Oct  5 13:50:12 2012
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.property;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.query.AbstractQueryTest;
+import org.apache.jackrabbit.oak.spi.commit.CommitHook;
+import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
+import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
+import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
+
+/**
+ * Tests the query engine using the default index implementation: the
+ * {@link PropertyIndexProvider}
+ */
+public class PropertyIndexQueryTest extends AbstractQueryTest {
+
+    @Override
+    protected ContentRepository createRepository() {
+        QueryIndexProvider qip = new CompositeQueryIndexProvider(
+                new PropertyIndexProvider());
+        CommitHook ch = new CompositeHook(new PropertyIndexHook());
+        MicroKernel mk = new MicroKernelImpl();
+        createDefaultKernelTracker().available(mk);
+        return new Oak(mk).with(qip).with(ch).createContentRepository();
+    }
+
+}
\ No newline at end of file

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java Fri Oct  5 13:50:12 2012
@@ -16,22 +16,50 @@
  */
 package org.apache.jackrabbit.oak.query;
 
+import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.DEFAULT_INDEX_HOME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
 
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.AbstractOakTest;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * AbstractQueryTest...
  */
-public abstract class AbstractQueryTest extends AbstractOakTest {
+public abstract class AbstractQueryTest extends AbstractOakTest implements
+        IndexConstants {
+
+    protected static final String TEST_INDEX_NAME = "test-index";
+    protected static final String TEST_INDEX_HOME = DEFAULT_INDEX_HOME;
+    protected static final String INDEX_DEFINITION_NODE_TYPE = "nam:oak:queryIndexDefinition";
 
     protected CoreValueFactory vf;
     protected SessionQueryEngine qe;
@@ -46,11 +74,238 @@ public abstract class AbstractQueryTest 
         root = session.getLatestRoot();
         qe = root.getQueryEngine();
         vf = root.getValueFactory();
+        createTestIndexNode();
+    }
+
+    /**
+     * Override this method to add your default index definition
+     * 
+     * {@link #createTestIndexNode(Tree, String)} for a helper method
+     */
+    protected void createTestIndexNode() throws Exception {
+        Tree index = root.getTree("/");
+        createTestIndexNode(index, "unknown");
+        root.commit();
     }
 
-    protected Result executeQuery(String statement, String language, HashMap<String, CoreValue> sv) throws ParseException {
+    protected static Tree createTestIndexNode(Tree index, String type)
+            throws Exception {
+        Tree indexDef = index;
+        for (String p : PathUtils.elements(TEST_INDEX_HOME)) {
+            if (indexDef.hasChild(p)) {
+                indexDef = indexDef.getChild(p);
+            } else {
+                indexDef = indexDef.addChild(p);
+            }
+        }
+        indexDef = indexDef.addChild(TEST_INDEX_NAME);
+        indexDef.setProperty(JcrConstants.JCR_PRIMARYTYPE,
+                INDEX_DEFINITION_NODE_TYPE);
+        indexDef.setProperty(TYPE_PROPERTY_NAME, type);
+        return indexDef;
+    }
+
+    protected Result executeQuery(String statement, String language,
+            HashMap<String, CoreValue> sv) throws ParseException {
         return qe.executeQuery(statement, language, Long.MAX_VALUE, 0, sv,
                 session.getLatestRoot(), null);
     }
 
+    @Test
+    public void sql1() throws Exception {
+        test("sql1.txt");
+    }
+
+    @Test
+    public void sql2() throws Exception {
+        test("sql2.txt");
+    }
+
+    @Test
+    public void xpath() throws Exception {
+        test("xpath.txt");
+    }
+
+    @Test
+    @Ignore("OAK-336")
+    public void sql2_measure() throws Exception {
+        test("sql2_measure.txt");
+    }
+
+    @Test
+    public void bindVariableTest() throws Exception {
+        JsopUtil.apply(
+                root,
+                "/ + \"test\": { \"hello\": {\"id\": \"1\"}, \"world\": {\"id\": \"2\"}}",
+                vf);
+        root.commit();
+
+        HashMap<String, CoreValue> sv = new HashMap<String, CoreValue>();
+        sv.put("id", vf.createValue("1"));
+        Iterator<? extends ResultRow> result;
+        result = executeQuery("select * from [nt:base] where id = $id",
+                QueryEngineImpl.SQL2, sv).getRows().iterator();
+        assertTrue(result.hasNext());
+        assertEquals("/test/hello", result.next().getPath());
+
+        sv.put("id", vf.createValue("2"));
+        result = executeQuery("select * from [nt:base] where id = $id",
+                QueryEngineImpl.SQL2, sv).getRows().iterator();
+        assertTrue(result.hasNext());
+        assertEquals("/test/world", result.next().getPath());
+    }
+
+    protected void test(String file) throws Exception {
+        InputStream in = AbstractQueryTest.class.getResourceAsStream(file);
+        LineNumberReader r = new LineNumberReader(new InputStreamReader(in));
+        PrintWriter w = new PrintWriter(new OutputStreamWriter(
+                new FileOutputStream("target/" + getClass().getName() + "_"
+                        + file)));
+        HashSet<String> knownQueries = new HashSet<String>();
+        boolean errors = false;
+        try {
+            while (true) {
+                String line = r.readLine();
+                if (line == null) {
+                    break;
+                }
+                line = line.trim();
+                if (line.startsWith("#") || line.length() == 0) {
+                    w.println(line);
+                } else if (line.startsWith("xpath2sql")) {
+                    line = line.substring("xpath2sql".length()).trim();
+                    w.println("xpath2sql " + line);
+                    XPathToSQL2Converter c = new XPathToSQL2Converter();
+                    String got;
+                    try {
+                        got = c.convert(line);
+                        executeQuery(got, QueryEngineImpl.SQL2, null);
+                    } catch (ParseException e) {
+                        got = "invalid: " + e.getMessage().replace('\n', ' ');
+                    } catch (Exception e) {
+                        // e.printStackTrace();
+                        got = "error: " + e.toString().replace('\n', ' ');
+                    }
+                    if (!knownQueries.add(line)) {
+                        got = "duplicate xpath2sql query";
+                    }
+                    line = r.readLine().trim();
+                    w.println(got);
+                    if (!line.equals(got)) {
+                        errors = true;
+                    }
+                } else if (line.startsWith("select")
+                        || line.startsWith("explain")
+                        || line.startsWith("measure")
+                        || line.startsWith("sql1") || line.startsWith("xpath")) {
+                    w.println(line);
+                    String language = QueryEngineImpl.SQL2;
+                    if (line.startsWith("sql1 ")) {
+                        language = QueryEngineImpl.SQL;
+                        line = line.substring("sql1 ".length());
+                    } else if (line.startsWith("xpath ")) {
+                        language = QueryEngineImpl.XPATH;
+                        line = line.substring("xpath ".length());
+                    }
+                    boolean readEnd = true;
+                    for (String resultLine : executeQuery(line, language)) {
+                        w.println(resultLine);
+                        if (readEnd) {
+                            line = r.readLine();
+                            if (line == null) {
+                                errors = true;
+                                readEnd = false;
+                            } else {
+                                line = line.trim();
+                                if (line.length() == 0) {
+                                    errors = true;
+                                    readEnd = false;
+                                } else {
+                                    if (!line.equals(resultLine)) {
+                                        errors = true;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    w.println("");
+                    if (readEnd) {
+                        while (true) {
+                            line = r.readLine();
+                            if (line == null) {
+                                break;
+                            }
+                            line = line.trim();
+                            if (line.length() == 0) {
+                                break;
+                            }
+                            errors = true;
+                        }
+                    }
+                } else if (line.startsWith("commit")) {
+                    w.println(line);
+                    line = line.substring("commit".length()).trim();
+                    JsopUtil.apply(root, line, vf);
+                    root.commit();
+                }
+                w.flush();
+            }
+        } finally {
+            w.close();
+            r.close();
+        }
+        if (errors) {
+            throw new Exception("Results in target/" + file
+                    + " don't match expected "
+                    + "results in src/test/resources/" + file
+                    + "; compare the files for details");
+        }
+    }
+
+    protected List<String> executeQuery(String query, String language) {
+        long time = System.currentTimeMillis();
+        List<String> lines = new ArrayList<String>();
+        try {
+            Result result = executeQuery(query, language, null);
+            for (ResultRow row : result.getRows()) {
+                lines.add(readRow(row));
+            }
+            if (!query.contains("order by")) {
+                Collections.sort(lines);
+            }
+        } catch (ParseException e) {
+            lines.add(e.toString());
+        } catch (IllegalArgumentException e) {
+            lines.add(e.toString());
+        }
+        time = System.currentTimeMillis() - time;
+        if (time > 3000 && !isDebugModeEnabled()) {
+            fail("Query took too long: " + query + " took " + time + " ms");
+        }
+        return lines;
+    }
+
+    protected static String readRow(ResultRow row) {
+        StringBuilder buff = new StringBuilder();
+        CoreValue[] values = row.getValues();
+        for (int i = 0; i < values.length; i++) {
+            if (i > 0) {
+                buff.append(", ");
+            }
+            CoreValue v = values[i];
+            buff.append(v == null ? "null" : v.getString());
+        }
+        return buff.toString();
+    }
+
+    /**
+     * Check whether the test is running in debug mode.
+     * 
+     * @return true if debug most is (most likely) enabled
+     */
+    protected static boolean isDebugModeEnabled() {
+        return java.lang.management.ManagementFactory.getRuntimeMXBean()
+                .getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
+    }
+
 }
\ No newline at end of file

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java (from r1394476, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java&r1=1394476&r2=1394523&rev=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java Fri Oct  5 13:50:12 2012
@@ -11,267 +11,25 @@
  * KIND, either express or implied. See the License for the specific language
  * governing permissions and limitations under the License.
  */
-package org.apache.jackrabbit.oak.query;
-
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
+package org.apache.jackrabbit.oak.query.index;
 
+import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.mk.index.IndexWrapper;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.Result;
-import org.apache.jackrabbit.oak.api.ResultRow;
-import org.apache.jackrabbit.oak.plugins.index.old.Indexer;
-import org.apache.jackrabbit.oak.plugins.index.old.PropertyIndexer;
-import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
-import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
-import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.apache.jackrabbit.oak.query.AbstractQueryTest;
 
 /**
- * Test the query feature.
+ * Tests the query engine using the default index implementation: the
+ * {@link TraversingIndex}
  */
-public class QueryTest extends AbstractQueryTest {
+public class TraversingIndexQueryTest extends AbstractQueryTest {
 
     @Override
     protected ContentRepository createRepository() {
-
-        // the property and prefix index currently require the index wrapper
-        IndexWrapper mk = new IndexWrapper(new MicroKernelImpl());
-        Indexer indexer = mk.getIndexer();
-
-        // MicroKernel mk = new MicroKernelImpl();
-        // Indexer indexer = new Indexer(mk);
-
-        PropertyIndexer pi = new PropertyIndexer(indexer);
-        QueryIndexProvider qip = new CompositeQueryIndexProvider(pi);
-        CompositeHook hook = new CompositeHook(pi);
+        MicroKernel mk = new MicroKernelImpl();
         createDefaultKernelTracker().available(mk);
-        return new Oak(mk).with(qip).with(hook).createContentRepository();
-    }
-
-    @Test
-    public void sql1() throws Exception {
-        test("sql1.txt");
-    }
-
-    @Test
-    public void sql2() throws Exception {
-        test("sql2.txt");
-    }
-
-    @Test
-    public void sql2Explain() throws Exception {
-        test("sql2_explain.txt");
-    }
-
-    @Test
-    public void sql2_measure() throws Exception {
-        test("sql2_measure.txt");
-    }
-
-    @Test
-    public void xpath() throws Exception {
-        test("xpath.txt");
-    }
-
-    @Test
-    public void bindVariableTest() throws Exception {
-        JsopUtil.apply(
-                root,
-                "/ + \"test\": { \"hello\": {\"id\": \"1\"}, \"world\": {\"id\": \"2\"}}",
-                vf);
-        root.commit();
-
-        HashMap<String, CoreValue> sv = new HashMap<String, CoreValue>();
-        sv.put("id", vf.createValue("1"));
-        Iterator<? extends ResultRow> result;
-        result = executeQuery("select * from [nt:base] where id = $id",
-                QueryEngineImpl.SQL2, sv).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("/test/hello", result.next().getPath());
-
-        sv.put("id", vf.createValue("2"));
-        result = executeQuery("select * from [nt:base] where id = $id",
-                QueryEngineImpl.SQL2, sv).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("/test/world", result.next().getPath());
-
-        result = executeQuery("explain select * from [nt:base] where id = 1 order by id",
-                QueryEngineImpl.SQL2, null).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("[nt:base] as [nt:base] " +
-                "/* traverse \"//*\" where [nt:base].[id] = cast('1' as long) */",
-                result.next().getValue("plan").getString());
-
-    }
-
-    private void test(String file) throws Exception {
-        InputStream in = getClass().getResourceAsStream(file);
-        LineNumberReader r = new LineNumberReader(new InputStreamReader(in));
-        PrintWriter w = new PrintWriter(new OutputStreamWriter(
-                new FileOutputStream("target/" + file)));
-        HashSet<String> knownQueries = new HashSet<String>();
-        boolean errors = false;
-        try {
-            while (true) {
-                String line = r.readLine();
-                if (line == null) {
-                    break;
-                }
-                line = line.trim();
-                if (line.startsWith("#") || line.length() == 0) {
-                    w.println(line);
-                } else if (line.startsWith("xpath2sql")) {
-                    line = line.substring("xpath2sql".length()).trim();
-                    w.println("xpath2sql " + line);
-                    XPathToSQL2Converter c = new XPathToSQL2Converter();
-                    String got;
-                    try {
-                        got = c.convert(line);
-                        executeQuery(got, QueryEngineImpl.SQL2, null);
-                    } catch (ParseException e) {
-                        got = "invalid: " + e.getMessage().replace('\n', ' ');
-                    } catch (Exception e) {
-                        // e.printStackTrace();
-                        got = "error: " + e.toString().replace('\n', ' ');
-                    }
-                    if (!knownQueries.add(line)) {
-                        got = "duplicate xpath2sql query";
-                    }
-                    line = r.readLine().trim();
-                    w.println(got);
-                    if (!line.equals(got)) {
-                        errors = true;
-                    }
-                } else if (line.startsWith("select") ||
-                        line.startsWith("explain") ||
-                        line.startsWith("measure") ||
-                        line.startsWith("sql1") ||
-                        line.startsWith("xpath")) {
-                    w.println(line);
-                    String language = QueryEngineImpl.SQL2;
-                    if (line.startsWith("sql1 ")) {
-                        language = QueryEngineImpl.SQL;
-                        line = line.substring("sql1 ".length());
-                    } else if (line.startsWith("xpath ")) {
-                        language = QueryEngineImpl.XPATH;
-                        line = line.substring("xpath ".length());
-                    }
-                    boolean readEnd = true;
-                    for (String resultLine : executeQuery(line, language)) {
-                        w.println(resultLine);
-                        if (readEnd) {
-                            line = r.readLine();
-                            if (line == null) {
-                                errors = true;
-                                readEnd = false;
-                            } else {
-                                line = line.trim();
-                                if (line.length() == 0) {
-                                    errors = true;
-                                    readEnd = false;
-                                } else {
-                                    if (!line.equals(resultLine)) {
-                                        errors = true;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    w.println("");
-                    if (readEnd) {
-                        while (true) {
-                            line = r.readLine();
-                            if (line == null) {
-                                break;
-                            }
-                            line = line.trim();
-                            if (line.length() == 0) {
-                                break;
-                            }
-                            errors = true;
-                        }
-                    }
-                } else if (line.startsWith("commit")) {
-                    w.println(line);
-                    line = line.substring("commit".length()).trim();
-                    JsopUtil.apply(root, line, vf);
-                    root.commit();
-                }
-                w.flush();
-            }
-        } finally {
-            w.close();
-            r.close();
-        }
-        if (errors) {
-            throw new Exception("Results in target/" + file + " don't match expected " +
-                    "results in src/test/resources/" + file + "; compare the files for details");
-        }
-    }
-
-    private List<String> executeQuery(String query, String language) {
-        long time = System.currentTimeMillis();
-        List<String> lines = new ArrayList<String>();
-        try {
-            Result result = executeQuery(query, language, null);
-            for (ResultRow row : result.getRows()) {
-                lines.add(readRow(row));
-            }
-            if (!query.contains("order by")) {
-                Collections.sort(lines);
-            }
-        } catch (ParseException e) {
-            lines.add(e.toString());
-        } catch (IllegalArgumentException e) {
-            lines.add(e.toString());
-        }
-        time = System.currentTimeMillis() - time;
-        if (time > 3000 && !isDebugModeEnabled()) {
-            fail("Query took too long: " + query + " took " + time + " ms");
-        }
-        return lines;
-    }
-
-    private static String readRow(ResultRow row) {
-        StringBuilder buff = new StringBuilder();
-        CoreValue[] values = row.getValues();
-        for (int i = 0; i < values.length; i++) {
-            if (i > 0) {
-                buff.append(", ");
-            }
-            CoreValue v = values[i];
-            buff.append(v == null ? "null" : v.getString());
-        }
-        return buff.toString();
-    }
-
-    /**
-     * Check whether the test is running in debug mode.
-     * 
-     * @return true if debug most is (most likely) enabled
-     */
-    private static boolean isDebugModeEnabled() {
-        return java.lang.management.ManagementFactory.getRuntimeMXBean().
-                getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
+        return new Oak(mk).createContentRepository();
     }
 
 }

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt Fri Oct  5 13:50:12 2012
@@ -119,12 +119,11 @@ select * from [nt:base] as b where local
 
 select * from [nt:base] as x where isdescendantnode(x, '/') and not isdescendantnode(x, '/jcr:system')
 /jcr:system
-/oak-index
-/oak-index/indexes
 /oak:index
 /oak:index/jcr:uuid
 /oak:index/rep:authorizableId
 /oak:index/rep:principalName
+/oak:index/test-index
 /rep:security
 /rep:security/rep:authorizables
 /rep:security/rep:authorizables/rep:users
@@ -156,7 +155,6 @@ select * from [nt:base] as [p] where [p]
 select * from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2, p) where p.[jcr:path] = '/'
 /, /children
 /, /jcr:system
-/, /oak-index
 /, /oak:index
 /, /parents
 /, /rep:security
@@ -213,12 +211,11 @@ commit / + "test2": { "id":"1", "x": "2"
 select * from [nt:base] where not isdescendantnode('/jcr:system')
 /
 /jcr:system
-/oak-index
-/oak-index/indexes
 /oak:index
 /oak:index/jcr:uuid
 /oak:index/rep:authorizableId
 /oak:index/rep:principalName
+/oak:index/test-index
 /rep:security
 /rep:security/rep:authorizables
 /rep:security/rep:authorizables/rep:users
@@ -245,12 +242,11 @@ select * from [nt:base] where id = '1' o
 select * from [nt:base] where not (id = '1' or x = '2') and not isdescendantnode('/jcr:system')
 /
 /jcr:system
-/oak-index
-/oak-index/indexes
 /oak:index
 /oak:index/jcr:uuid
 /oak:index/rep:authorizableId
 /oak:index/rep:principalName
+/oak:index/test-index
 /rep:security
 /rep:security/rep:authorizables
 /rep:security/rep:authorizables/rep:users
@@ -265,12 +261,11 @@ select * from [nt:base] where not (id = 
 select * from [nt:base] where x is null and not isdescendantnode('/jcr:system')
 /
 /jcr:system
-/oak-index
-/oak-index/indexes
 /oak:index
 /oak:index/jcr:uuid
 /oak:index/rep:authorizableId
 /oak:index/rep:principalName
+/oak:index/test-index
 /rep:security
 /rep:security/rep:authorizables
 /rep:security/rep:authorizables/rep:users

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_explain.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_explain.txt?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_explain.txt (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_explain.txt Fri Oct  5 13:50:12 2012
@@ -36,9 +36,8 @@ explain select * from [nt:base] where pr
 select * from [nt:base] where property([*], 'REFERENCE') = CAST('123' AS REFERENCE)
 /test/a
 
-commit / + "oak-index": {}
-commit /oak-index + "indexes": { "type": "property" }
-commit /oak-index/indexes + "prefix@ref:": {}
+commit /oak:index + "indexes": { "type": "property" }
+commit /oak:index/indexes + "prefix@ref:": {}
 
 explain select * from [nt:base] where property([*], 'REFERENCE') = CAST('123' AS REFERENCE)
 [nt:base] as [nt:base] /* prefixIndex "ref:123" where property([nt:base].[*], 'reference') = cast('123' as reference) */
@@ -53,12 +52,12 @@ select * from [nt:base] where property(i
 /test/a
 
 commit / - "test"
-commit /oak-index/indexes - "prefix@ref:"
+commit /oak:index/indexes - "prefix@ref:"
 
 # test the property content index
 
 commit / + "test": { "a": { "id": "10" }, "b": { "id" : "20" }}
-commit /oak-index/indexes + "property@id,unique": {}
+commit /oak:index/indexes + "property@id,unique": {}
 
 # combining 'not' and 'and'
 
@@ -82,7 +81,7 @@ explain select * from [nt:base] where id
 [nt:base] as [nt:base] /* traverse "//*" where [nt:base].[id] > cast('10' as string) */
 
 commit / - "test"
-commit /oak-index/indexes - "property@id,unique"
+commit /oak:index/indexes - "property@id,unique"
 
 # other tests
 
@@ -108,6 +107,9 @@ explain select * from [nt:base] as p inn
 explain select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
 [nt:base] as [p] /* traverse "//*" where [p].[id] is not null */ inner join [nt:base] as [c] /* traverse "//*" where [c].[p] is not null */ on [p].[id] = [c].[p]
 
+explain select * from [nt:base] where id = 1 order by id
+[nt:base] as [nt:base] /* traverse "//*" where [nt:base].[id] = cast('1' as long) */
+
 commit / - "parents"
 commit / - "children"
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt?rev=1394523&r1=1394522&r2=1394523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt Fri Oct  5 13:50:12 2012
@@ -27,52 +27,52 @@ commit / + "parents": { "p0": {"id": "0"
 commit / + "children": { "c1": {"p": "1"}, "c2": {"p": "1"}, "c3": {"p": "2"}, "c4": {"p": "3"}}
 
 measure select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where p.id is not null and not isdescendantnode(p, '/jcr:system')
-c, 672
-p, 224
+c, 669
+p, 223
 query, 4
 
 measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not null
-c, 672
-p, 224
+c, 669
+p, 223
 query, 4
 
 measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not null and c.p is null
-c, 672
-p, 224
+c, 669
+p, 223
 query, 1
 
 measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not null and c.p is not null
-c, 672
-p, 224
+c, 669
+p, 223
 query, 3
 
 measure select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
-c, 672
-p, 224
+c, 669
+p, 223
 query, 3
 
 measure select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where p.id is not null and not isdescendantnode(p, '/jcr:system')
-c, 672
-p, 224
+c, 669
+p, 223
 query, 4
 
 measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not null
-c, 672
-p, 224
+c, 669
+p, 223
 query, 4
 
 measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not null and c.p is null
-c, 672
-p, 224
+c, 669
+p, 223
 query, 1
 
 measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not null and c.p is not null
-c, 672
-p, 224
+c, 669
+p, 223
 query, 3
 
 measure select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
-c, 672
-p, 224
+c, 669
+p, 223
 query, 3
 



Mime
View raw message