jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1378173 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak: plugins/lucene/AbstractLuceneQueryTest.java query/AbstractQueryTest.java
Date Tue, 28 Aug 2012 15:21:29 GMT
Author: alexparvulescu
Date: Tue Aug 28 15:21:28 2012
New Revision: 1378173

URL: http://svn.apache.org/viewvc?rev=1378173&view=rev
Log:
OAK-269 Query: IndexManager to manage existing indexes
 - refactored test classes to use the IndexManager

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java?rev=1378173&r1=1378172&r2=1378173&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
Tue Aug 28 15:21:28 2012
@@ -16,10 +16,15 @@
  */
 package org.apache.jackrabbit.oak.plugins.lucene;
 
+import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_NAME;
+import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.createIndexNode;
+import static org.apache.jackrabbit.oak.spi.query.IndexUtils.DEFAULT_INDEX_HOME;
+
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.List;
 
+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.api.ContentRepository;
@@ -32,6 +37,7 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
+import org.apache.jackrabbit.oak.plugins.index.PropertyIndexFactory;
 import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
 import org.apache.jackrabbit.oak.plugins.type.DefaultTypeEditor;
@@ -42,12 +48,11 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
 import org.apache.jackrabbit.oak.spi.commit.ValidatingEditor;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
+import org.apache.jackrabbit.oak.spi.query.IndexManager;
+import org.apache.jackrabbit.oak.spi.query.IndexManagerImpl;
+import org.apache.jackrabbit.oak.spi.query.IndexUtils;
 import org.junit.Before;
 
-import static org.apache.jackrabbit.oak.spi.query.IndexUtils.DEFAULT_INDEX_HOME;
-import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_NAME;
-import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.createIndexNode;
-
 /**
  * base class for lucene search tests
  */
@@ -57,6 +62,7 @@ public abstract class AbstractLuceneQuer
 
     private static final String TEST_INDEX_NAME = DEFAULT_INDEX_NAME;
 
+    protected MicroKernel mk;
     protected ContentSession session;
     protected CoreValueFactory vf;
     protected SessionQueryEngine qe;
@@ -75,16 +81,19 @@ public abstract class AbstractLuceneQuer
 
     @Override
     protected ContentRepository createRepository() {
-        return new ContentRepositoryImpl(new MicroKernelImpl(),
-                new LuceneIndexProvider(DEFAULT_INDEX_HOME),
-                buildDefaultCommitEditor());
+        mk = new MicroKernelImpl();
+        return new ContentRepositoryImpl(mk, new LuceneIndexProvider(
+                DEFAULT_INDEX_HOME), buildDefaultCommitEditor());
     }
 
-    private static CommitEditor buildDefaultCommitEditor() {
+    private CommitEditor buildDefaultCommitEditor() {
+        IndexManager im = new IndexManagerImpl(IndexUtils.DEFAULT_INDEX_HOME,
+                mk, new PropertyIndexFactory(), new LuceneIndexFactory());
+
         List<CommitEditor> editors = new ArrayList<CommitEditor>();
         editors.add(new DefaultTypeEditor());
         editors.add(new ValidatingEditor(createDefaultValidatorProvider()));
-        editors.add(new LuceneEditor());
+        editors.add(im);
         return new CompositeEditor(editors);
     }
 

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=1378173&r1=1378172&r2=1378173&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
Tue Aug 28 15:21:28 2012
@@ -16,37 +16,44 @@
  */
 package org.apache.jackrabbit.oak.query;
 
+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.AbstractOakTest;
+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.SessionQueryEngine;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
-import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
-
-import javax.jcr.GuestCredentials;
+import org.apache.jackrabbit.oak.plugins.index.PropertyIndexFactory;
+import org.apache.jackrabbit.oak.spi.query.IndexManager;
+import org.apache.jackrabbit.oak.spi.query.IndexManagerImpl;
+import org.apache.jackrabbit.oak.spi.query.IndexUtils;
+import org.junit.Before;
 
 /**
  * AbstractQueryTest...
  */
-public abstract class AbstractQueryTest {
+public abstract class AbstractQueryTest extends AbstractOakTest {
+
+    protected MicroKernel mk;
+    protected ContentSession session;
+    protected CoreValueFactory vf;
+    protected SessionQueryEngine qe;
+
+    @Override
+    protected ContentRepository createRepository() {
+        mk = new MicroKernelImpl();
+        IndexManager im = new IndexManagerImpl(IndexUtils.DEFAULT_INDEX_HOME,
+                mk, new PropertyIndexFactory());
+        return new ContentRepositoryImpl(mk, null, im);
+    }
 
-    protected final IndexWrapper mk;
-    protected final ContentRepositoryImpl rep;
-    protected final CoreValueFactory vf;
-    protected final SessionQueryEngine qe;
-    protected final ContentSession session;
-
-    {
-        mk = new IndexWrapper(new MicroKernelImpl());
-        rep = new ContentRepositoryImpl(mk, null, (ValidatorProvider) null);
-        try {
-            session = rep.login(new GuestCredentials(), "default");
-            vf = session.getCoreValueFactory();
-            qe = session.getQueryEngine();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
+    @Before
+    public void before() throws Exception {
+        super.before();
+        session = createGuestSession();
+        vf = session.getCoreValueFactory();
+        qe = session.getQueryEngine();
     }
 
 }
\ No newline at end of file



Mime
View raw message