jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1394006 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak: plugins/index/lucene/ query/ query/ast/ query/index/
Date Thu, 04 Oct 2012 11:58:11 GMT
Author: alexparvulescu
Date: Thu Oct  4 11:58:10 2012
New Revision: 1394006

URL: http://svn.apache.org/viewvc?rev=1394006&view=rev
Log:
OAK-362 Unify all the existing index implementations under one package

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
      - copied, changed from r1393983, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java
  (contents, props changed)
      - copied, changed from r1393983, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AbstractLuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java
      - copied, changed from r1393970, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/LikePatternTest.java
  (contents, props changed)
      - copied, changed from r1393970, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java
  (contents, props changed)
      - copied, changed from r1393970, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AbstractLuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/Sql2QueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java
    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/AbstractQueryTest.java
    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/query/index/FilterTest.java

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
(from r1393983, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditorTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditorTest.java&r1=1393983&r2=1394006&rev=1394006&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
Thu Oct  4 11:58:10 2012
@@ -40,7 +40,7 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.junit.Test;
 
-public class LuceneEditorTest implements LuceneIndexConstants {
+public class LuceneIndexTest implements LuceneIndexConstants {
 
     @Test
     public void testLucene() throws Exception {

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java
(from r1393983, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AbstractLuceneQueryTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AbstractLuceneQueryTest.java&r1=1393983&r2=1394006&rev=1394006&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/AbstractLuceneQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneQueryTest.java
Thu Oct  4 11:58:10 2012
@@ -17,48 +17,39 @@
 package org.apache.jackrabbit.oak.plugins.index.lucene;
 
 import static org.apache.jackrabbit.oak.spi.query.IndexUtils.DEFAULT_INDEX_HOME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-import java.text.ParseException;
+import java.util.Iterator;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.oak.AbstractOakTest;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.api.ContentSession;
-import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.api.Result;
-import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.api.SessionQueryEngine;
+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.Test;
 
 /**
  * base class for lucene search tests
  */
-public abstract class AbstractLuceneQueryTest extends AbstractOakTest implements
+public class LuceneQueryTest extends AbstractQueryTest implements
         LuceneIndexConstants {
 
     protected static final String SQL2 = "JCR-SQL2";
 
-    protected ContentSession session;
-    protected CoreValueFactory vf;
-    protected SessionQueryEngine qe;
-    protected Root root;
-
     @Override
     @Before
     public void before() throws Exception {
         super.before();
-        session = createAdminSession();
-        root = session.getLatestRoot();
-        vf = session.getCoreValueFactory();
-        qe = root.getQueryEngine();
         createIndexNode();
     }
 
@@ -87,8 +78,21 @@ public abstract class AbstractLuceneQuer
         root.commit();
     }
 
-    protected Result executeQuery(String statement) throws ParseException {
-        return qe.executeQuery(statement, SQL2, Long.MAX_VALUE, 0, null,
-                session.getLatestRoot(), null);
+    @Test
+    public void simpleSql2() throws Exception {
+
+        Tree test = root.getTree("/").addChild("test");
+        test.addChild("a").setProperty("name", vf.createValue("hello"));
+        test.addChild("b").setProperty("name", vf.createValue("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());
     }
+
 }
\ No newline at end of file

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

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=1394006&r1=1394005&r2=1394006&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
Thu Oct  4 11:58:10 2012
@@ -16,20 +16,16 @@
  */
 package org.apache.jackrabbit.oak.query;
 
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.mk.index.IndexWrapper;
+import java.text.ParseException;
+import java.util.HashMap;
+
 import org.apache.jackrabbit.oak.AbstractOakTest;
-import org.apache.jackrabbit.oak.Oak;
-import org.apache.jackrabbit.oak.api.ContentRepository;
 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.Root;
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
-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.Before;
 
 /**
@@ -43,23 +39,6 @@ public abstract class AbstractQueryTest 
     protected Root root;
 
     @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);
-        createDefaultKernelTracker().available(mk);
-        return new Oak(mk).with(qip).with(hook).createContentRepository();
-    }
-
-    @Override
     @Before
     public void before() throws Exception {
         super.before();
@@ -69,4 +48,9 @@ public abstract class AbstractQueryTest 
         qe = root.getQueryEngine();
     }
 
+    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);
+    }
+
 }
\ No newline at end of file

Modified: 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/QueryTest.java?rev=1394006&r1=1394005&r2=1394006&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/QueryTest.java
Thu Oct  4 11:58:10 2012
@@ -27,9 +27,18 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 
+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;
@@ -41,6 +50,23 @@ import static org.junit.Assert.fail;
  */
 public class QueryTest 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);
+        createDefaultKernelTracker().available(mk);
+        return new Oak(mk).with(qip).with(hook).createContentRepository();
+    }
+
     @Test
     public void sql1() throws Exception {
         test("sql1.txt");
@@ -238,11 +264,6 @@ public class QueryTest extends AbstractQ
         return buff.toString();
     }
 
-    private 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);
-    }
-
     /**
      * Check whether the test is running in debug mode.
      * 

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java
(from r1393970, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java&r1=1393970&r2=1394006&rev=1394006&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java
Thu Oct  4 11:58:10 2012
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.query;
+package org.apache.jackrabbit.oak.query.ast;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/LikePatternTest.java
(from r1393970, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/LikePatternTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/LikePatternTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java&r1=1393970&r2=1394006&rev=1394006&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/LikePatternTest.java
Thu Oct  4 11:58:10 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.query.ast;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;

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

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java?rev=1394006&r1=1394005&r2=1394006&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
Thu Oct  4 11:58:10 2012
@@ -21,10 +21,12 @@ package org.apache.jackrabbit.oak.query.
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import java.util.ArrayList;
 import java.util.Random;
+
 import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.query.AbstractQueryTest;
+import org.apache.jackrabbit.oak.plugins.memory.StringValue;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.junit.Test;
@@ -32,12 +34,13 @@ import org.junit.Test;
 /**
  * Tests the Filter class.
  */
-public class FilterTest extends AbstractQueryTest {
+public class FilterTest {
 
     @Test
     public void propertyRestriction() {
-        CoreValue one = vf.createValue("1");
-        CoreValue two = vf.createValue("2");
+
+        CoreValue one = new StringValue("1");
+        CoreValue two = new StringValue("2");
 
         FilterImpl f = new FilterImpl(null);
         assertTrue(null == f.getPropertyRestriction("x"));

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java
(from r1393970, 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/TraversingIndexTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java&r1=1393970&r2=1394006&rev=1394006&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/TraversingIndexTest.java
Thu Oct  4 11:58:10 2012
@@ -37,7 +37,7 @@ import com.google.common.cache.LoadingCa
 /**
  * Tests the TraversingCursor.
  */
-public class TraversingCursorTest {
+public class TraversingIndexTest {
 
     private final MicroKernel mk = new MicroKernelImpl();
 

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



Mime
View raw message