jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1387639 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query: ./ lucene/
Date Wed, 19 Sep 2012 15:25:20 GMT
Author: alexparvulescu
Date: Wed Sep 19 15:25:19 2012
New Revision: 1387639

URL: http://svn.apache.org/viewvc?rev=1387639&view=rev
Log:
JCR-3429 Make query tests (more) independent

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexFormatVersionTest.java
  (contents, props changed)
      - copied, changed from r1387068, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexFormatVersionTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingRuleTest.java
  (contents, props changed)
      - copied, changed from r1387068, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/LargeResultSetTest.java
  (contents, props changed)
      - copied, changed from r1387068, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LargeResultSetTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TextExtractionQueryTest.java
  (with props)
Removed:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexFormatVersionTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LargeResultSetTest.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractIndexingTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ShareableNodeTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractIndexingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractIndexingTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractIndexingTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractIndexingTest.java
Wed Sep 19 15:25:19 2012
@@ -17,9 +17,12 @@
 package org.apache.jackrabbit.core.query;
 
 import javax.jcr.Node;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.query.QueryManager;
 
 import org.apache.jackrabbit.core.TestHelper;
+import org.apache.jackrabbit.core.query.lucene.SearchIndex;
 
 /**
  * <code>AbstractIndexingTest</code> is a base class for all indexing
@@ -62,4 +65,37 @@ public class AbstractIndexingTest extend
         TestHelper.waitForTextExtractionTasksToFinish(session);
         flushSearchIndex();
     }
+
+    protected void flushSearchIndex() throws RepositoryException {
+        SearchIndex si = getSearchIndex();
+        if (si != null) {
+            si.flush();
+        }
+    }
+
+    /**
+     * Returns a reference to the underlying search index.
+     * 
+     * @return the query handler inside the {@link #qm query manager}.
+     */
+    protected SearchIndex getSearchIndex() {
+        if (qm instanceof QueryManagerImpl) {
+            return (SearchIndex) ((QueryManagerImpl) qm).getQueryHandler();
+        }
+        return null;
+    }
+
+    /**
+     * Returns a reference to the session's search index.
+     * 
+     * @return the session's query handler.
+     */
+    protected static SearchIndex getSearchIndex(Session session)
+            throws RepositoryException {
+        QueryManager qm = session.getWorkspace().getQueryManager();
+        if (qm instanceof QueryManagerImpl) {
+            return (SearchIndex) ((QueryManagerImpl) qm).getQueryHandler();
+        }
+        return null;
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
Wed Sep 19 15:25:19 2012
@@ -38,7 +38,6 @@ import javax.jcr.query.qom.QueryObjectMo
 
 import org.apache.jackrabbit.commons.JcrUtils;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
-import org.apache.jackrabbit.core.query.lucene.SearchIndex;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
 /**
@@ -50,8 +49,17 @@ public class AbstractQueryTest extends A
 
     protected QueryObjectModelFactory qomFactory;
 
+    /**
+     * true if this is a Jackrabbit JCR implementation
+     */
+    boolean isJackrabbitImpl = true;
+    private static final String DESCRIPTOR_NAME = "jcr.repository.name";
+    private static final String DESCRIPTOR_VALUE = "Jackrabbit";
+
     protected void setUp() throws Exception {
         super.setUp();
+        isJackrabbitImpl = DESCRIPTOR_VALUE.equals(getHelper().getRepository()
+                .getDescriptor(DESCRIPTOR_NAME));
         qm = superuser.getWorkspace().getQueryManager();
         qomFactory = qm.getQOMFactory();
     }
@@ -143,7 +151,6 @@ public class AbstractQueryTest extends A
      */
     protected void executeXPathQuery(String xpath, Node[] nodes)
             throws RepositoryException {
-        flushSearchIndex();
         QueryResult res = qm.createQuery(xpath, Query.XPATH).execute();
         checkResult(res, nodes);
     }
@@ -158,7 +165,6 @@ public class AbstractQueryTest extends A
      */
     protected void executeSQLQuery(String sql, Node[] nodes)
             throws RepositoryException {
-        flushSearchIndex();
         QueryResult res = qm.createQuery(sql, Query.SQL).execute();
         checkResult(res, nodes);
     }
@@ -251,7 +257,6 @@ public class AbstractQueryTest extends A
      */
     protected QueryResult executeQuery(String statement)
             throws RepositoryException {
-        flushSearchIndex();
         if (statement.trim().toLowerCase().startsWith("select")) {
             return qm.createQuery(statement, Query.SQL).execute();
         } else {
@@ -266,27 +271,7 @@ public class AbstractQueryTest extends A
 
     protected void executeSQL2Query(String statement, Node[] nodes)
             throws RepositoryException {
-        flushSearchIndex();
         QueryResult res = qm.createQuery(statement, JCR_SQL2).execute();
         checkResult(res, nodes);
     }
-
-    protected void flushSearchIndex() throws RepositoryException {
-        SearchIndex si = getSearchIndex();
-        if (si != null) {
-            si.flush();
-        }
-    }
-
-    /**
-     * Returns a reference to the underlying search index.
-     *
-     * @return the query handler inside the {@link #qm query manager}.
-     */
-    protected SearchIndex getSearchIndex() {
-        if (qm instanceof QueryManagerImpl) {
-            return (SearchIndex) ((QueryManagerImpl) qm).getQueryHandler();
-        }
-        return null;
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
Wed Sep 19 15:25:19 2012
@@ -16,15 +16,15 @@
  */
 package org.apache.jackrabbit.core.query;
 
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.util.Calendar;
 
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
 /**
  * <code>ChildAxisQueryTest</code> tests queries with a child axis in their
  * predicates.

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java
Wed Sep 19 15:25:19 2012
@@ -16,14 +16,11 @@
  */
 package org.apache.jackrabbit.core.query;
 
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.Callable;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
@@ -339,34 +336,6 @@ public class FulltextQueryTest extends A
         assertContainsQuery(statement, match);
     }
 
-    public void testFileContains() throws Exception {
-        assertFileContains(
-                "test.txt", "text/plain", "AE502DBEA2C411DEBD340AD156D89593");
-        assertFileContains(
-                "test.rtf", "text/rtf", "quick brown fox");
-    }
-
-    private void assertFileContains(
-            String name, String type, String... statements) throws Exception {
-        while (testRootNode.hasNode(nodeName1)) {
-            testRootNode.getNode(nodeName1).remove();
-        }
-        Node resource = testRootNode.addNode(nodeName1, NodeType.NT_RESOURCE);
-        resource.setProperty("jcr:mimeType", type);
-        InputStream stream = FulltextQueryTest.class.getResourceAsStream(name);
-        try {
-            resource.setProperty("jcr:data", stream);
-        } finally {
-            stream.close();
-        }
-        testRootNode.save();
-        flushSearchIndex();
-
-        for (String statement : statements) {
-            assertContainsQuery(statement, true);
-        }
-    }
-
     private void assertContainsQuery(String statement, boolean match)
             throws InvalidQueryException, RepositoryException {
         StringBuffer stmt = new StringBuffer();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
Wed Sep 19 15:25:19 2012
@@ -32,7 +32,7 @@ public class LimitAndOffsetTest extends 
     private Node node2;
     private Node node3;
 
-    private QueryImpl query;
+    private Query query;
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -57,10 +57,10 @@ public class LimitAndOffsetTest extends 
         super.tearDown();
     }
 
-    private QueryImpl createXPathQuery(String xpath)
+    private Query createXPathQuery(String xpath)
             throws InvalidQueryException, RepositoryException {
         QueryManager queryManager = superuser.getWorkspace().getQueryManager();
-        return (QueryImpl) queryManager.createQuery(xpath, Query.XPATH);
+        return queryManager.createQuery(xpath, Query.XPATH);
     }
 
     protected void checkResult(QueryResult result, Node[] expectedNodes) throws RepositoryException
{
@@ -136,7 +136,9 @@ public class LimitAndOffsetTest extends 
         QueryResult result = query.execute();
         NodeIterator nodes = result.getNodes();
         assertEquals(2, nodes.getSize());
-        assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        if (isJackrabbitImpl) {
+            assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        }
 
         // JCR-2684: offset higher than total result => size == 0
         query.setOffset(10);
@@ -144,14 +146,18 @@ public class LimitAndOffsetTest extends 
         nodes = result.getNodes();
         assertFalse(nodes.hasNext());
         assertEquals(0, nodes.getSize());
-        assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        if (isJackrabbitImpl) {
+            assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        }
 
         query.setOffset(1);
         query.setLimit(1);
         result = query.execute();
         nodes = result.getNodes();
         assertEquals(1, nodes.getSize());
-        assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        if (isJackrabbitImpl) {
+            assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+        }
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
Wed Sep 19 15:25:19 2012
@@ -23,8 +23,8 @@ import java.util.Calendar;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeTypeManager;
 
-import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.commons.cnd.CndImporter;
 
 /**
@@ -36,8 +36,7 @@ public class MixinTest extends AbstractQ
     protected void setUp() throws Exception {
         super.setUp();
 
-        JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
-            superuser.getWorkspace().getNodeTypeManager();
+        NodeTypeManager manager = superuser.getWorkspace().getNodeTypeManager();
         if (!manager.hasNodeType("test:mimeType")) {
             String cnd =
                 "<test='http://www.apache.org/jackrabbit/test'>\n"

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ShareableNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ShareableNodeTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ShareableNodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ShareableNodeTest.java
Wed Sep 19 15:25:19 2012
@@ -16,12 +16,10 @@
  */
 package org.apache.jackrabbit.core.query;
 
-import javax.jcr.RepositoryException;
 import javax.jcr.Node;
-import javax.jcr.Workspace;
 import javax.jcr.NodeIterator;
-
-import org.apache.jackrabbit.core.NodeImpl;
+import javax.jcr.RepositoryException;
+import javax.jcr.Workspace;
 
 /**
  * <code>ShareableNodeTest</code> performs query tests with shareable nodes.

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
Wed Sep 19 15:25:19 2012
@@ -16,13 +16,12 @@
  */
 package org.apache.jackrabbit.core.query;
 
-import org.apache.jackrabbit.core.query.lucene.hits.ArrayHitsTest;
-import org.apache.jackrabbit.test.ConcurrentTestSuite;
-
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.jackrabbit.test.ConcurrentTestSuite;
+
 /**
  * Test suite that includes all testcases for the Search module.
  */
@@ -56,10 +55,7 @@ public class TestAll extends TestCase {
         suite.addTestSuite(FnNameQueryTest.class);
         suite.addTestSuite(PathQueryNodeTest.class);
         suite.addTestSuite(SynonymProviderTest.class);
-        suite.addTestSuite(ArrayHitsTest.class);
         suite.addTestSuite(ExcerptTest.class);
-        suite.addTestSuite(IndexFormatVersionTest.class);
-        suite.addTestSuite(IndexingRuleTest.class);
         suite.addTestSuite(ShareableNodeTest.class);
         suite.addTestSuite(ParentNodeTest.class);
         suite.addTestSuite(SimilarQueryTest.class);

Copied: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexFormatVersionTest.java
(from r1387068, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexFormatVersionTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexFormatVersionTest.java?p2=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexFormatVersionTest.java&p1=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexFormatVersionTest.java&r1=1387068&r2=1387639&rev=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexFormatVersionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexFormatVersionTest.java
Wed Sep 19 15:25:19 2012
@@ -14,21 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.core.query;
-
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.core.query.lucene.IndexFormatVersion;
-import org.apache.jackrabbit.core.query.lucene.SearchIndex;
+package org.apache.jackrabbit.core.query.lucene;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.query.QueryManager;
+
+import org.apache.jackrabbit.core.query.AbstractIndexingTest;
 
 /**
  * <code>IndexFormatVersionTest</code> checks if the various index format
  * versions are correctly read from the index.
  */
-public class IndexFormatVersionTest extends AbstractJCRTest {
+public class IndexFormatVersionTest extends AbstractIndexingTest {
 
     public void testVersionOne() throws RepositoryException {
         checkIndexFormatVersion("index-format-v1", IndexFormatVersion.V1);
@@ -47,9 +44,7 @@ public class IndexFormatVersionTest exte
             throws RepositoryException {
         Session session = getHelper().getSuperuserSession(wspName);
         try {
-            QueryManager qm = session.getWorkspace().getQueryManager();
-            QueryHandler handler = ((QueryManagerImpl) qm).getQueryHandler();
-            SearchIndex index = (SearchIndex) handler;
+            SearchIndex index = getSearchIndex(session);
             assertEquals("Wrong index format", version.getVersion(),
                     index.getIndexFormatVersion().getVersion());
         } finally {

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexFormatVersionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
Wed Sep 19 15:25:19 2012
@@ -20,6 +20,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Node;
 import javax.jcr.query.Query;
 
+import org.apache.jackrabbit.core.query.AbstractIndexingTest;
+
 import java.io.ByteArrayOutputStream;
 import java.io.Writer;
 import java.io.OutputStreamWriter;
@@ -30,7 +32,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 
-import org.apache.jackrabbit.core.query.AbstractIndexingTest;
 
 /**
  * <code>IndexingAggregateTest</code> checks if the nt:file nt:resource

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
Wed Sep 19 15:25:19 2012
@@ -27,7 +27,7 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.query.AbstractQueryTest;
+import org.apache.jackrabbit.core.query.AbstractIndexingTest;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
@@ -38,7 +38,7 @@ import org.xml.sax.SAXException;
 /**
  * <code>IndexingConfigurationImplTest</code>...
  */
-public class IndexingConfigurationImplTest extends AbstractQueryTest {
+public class IndexingConfigurationImplTest extends AbstractIndexingTest {
 
     private static final Name FOO = NameFactoryImpl.getInstance().create("", "foo");
 
@@ -49,7 +49,7 @@ public class IndexingConfigurationImplTe
         super.setUp();
         Node n = testRootNode.addNode(nodeName1, ntUnstructured);
         n.addMixin(mixReferenceable);
-        superuser.save();
+        session.save();
         nState = (NodeState) getSearchIndex().getContext().getItemStateManager().getItemState(
                 new NodeId(n.getIdentifier()));
     }
@@ -75,7 +75,7 @@ public class IndexingConfigurationImplTe
     public void testAddNodeTypeToRegistry() throws Exception {
         IndexingConfiguration config = createConfig("config4");
         // add node type
-        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
+        NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
         String baseName = "indexingTextNodeType";
         int i = 0;
         String nt;
@@ -89,7 +89,7 @@ public class IndexingConfigurationImplTe
         ntMgr.registerNodeType(ntTemplate, false);
         // create node
         Node n = testRootNode.addNode(nodeName2, nt);
-        superuser.save();
+        session.save();
         // get state
         NodeState state = (NodeState) getSearchIndex().getContext().getItemStateManager().getItemState(
                 new NodeId(n.getIdentifier()));

Copied: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingRuleTest.java
(from r1387068, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingRuleTest.java?p2=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingRuleTest.java&p1=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java&r1=1387068&r2=1387639&rev=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingRuleTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingRuleTest.java
Wed Sep 19 15:25:19 2012
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.core.query;
+package org.apache.jackrabbit.core.query.lucene;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -22,6 +22,9 @@ import javax.jcr.Value;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.RowIterator;
 
+import org.apache.jackrabbit.core.query.AbstractIndexingTest;
+
+
 /**
  * <code>IndexingRuleTest</code> performs indexing rule tests.
  */

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingRuleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/LargeResultSetTest.java
(from r1387068, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LargeResultSetTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/LargeResultSetTest.java?p2=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/LargeResultSetTest.java&p1=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LargeResultSetTest.java&r1=1387068&r2=1387639&rev=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LargeResultSetTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/LargeResultSetTest.java
Wed Sep 19 15:25:19 2012
@@ -14,21 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.core.query;
+package org.apache.jackrabbit.core.query.lucene;
 
-import javax.jcr.RepositoryException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
 import javax.jcr.query.Query;
-import javax.jcr.query.RowIterator;
 import javax.jcr.query.QueryResult;
+import javax.jcr.query.RowIterator;
 
-import org.apache.jackrabbit.core.query.lucene.SearchIndex;
+import org.apache.jackrabbit.core.query.AbstractIndexingTest;
+import org.apache.jackrabbit.core.query.QueryImpl;
 
 /**
  * <code>LargeResultSetTest</code>...
+ * 
+ * TODO what does this test actually do?
  */
-public class LargeResultSetTest extends AbstractQueryTest {
+public class LargeResultSetTest extends AbstractIndexingTest {
 
     public void testResultSet() throws RepositoryException {
         createNodes(testRootNode, 10, 5, 0);

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/LargeResultSetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TestAll.java?rev=1387639&r1=1387638&r2=1387639&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TestAll.java
Wed Sep 19 15:25:19 2012
@@ -16,11 +16,13 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.test.ConcurrentTestSuite;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.jackrabbit.core.query.lucene.hits.ArrayHitsTest;
+import org.apache.jackrabbit.test.ConcurrentTestSuite;
+
 /**
  * Test suite that includes all testcases for the Search module.
  */
@@ -46,6 +48,10 @@ public class TestAll extends TestCase {
         suite.addTestSuite(SQL2IndexingAggregateTest2.class);
         suite.addTestSuite(LazyTextExtractorFieldTest.class);
         suite.addTestSuite(IndexInfosTest.class);
+        suite.addTestSuite(IndexingRuleTest.class);
+        suite.addTestSuite(TextExtractionQueryTest.class);
+        suite.addTestSuite(ArrayHitsTest.class);
+        suite.addTestSuite(IndexFormatVersionTest.class);
 
         return suite;
     }

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TextExtractionQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TextExtractionQueryTest.java?rev=1387639&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TextExtractionQueryTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TextExtractionQueryTest.java
Wed Sep 19 15:25:19 2012
@@ -0,0 +1,77 @@
+/*
+ * 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.core.query.lucene;
+
+import java.io.InputStream;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.Query;
+
+import org.apache.jackrabbit.core.query.AbstractIndexingTest;
+import org.apache.jackrabbit.core.query.FulltextQueryTest;
+
+public class TextExtractionQueryTest extends AbstractIndexingTest {
+
+    public void testFileContains() throws Exception {
+        assertFileContains("test.txt", "text/plain",
+                "AE502DBEA2C411DEBD340AD156D89593");
+        assertFileContains("test.rtf", "text/rtf", "quick brown fox");
+    }
+
+    private void assertFileContains(String name, String type,
+            String... statements) throws Exception {
+        while (testRootNode.hasNode(nodeName1)) {
+            testRootNode.getNode(nodeName1).remove();
+        }
+        Node resource = testRootNode.addNode(nodeName1, NodeType.NT_RESOURCE);
+        resource.setProperty("jcr:mimeType", type);
+        InputStream stream = FulltextQueryTest.class.getResourceAsStream(name);
+        try {
+            resource.setProperty("jcr:data", stream);
+        } finally {
+            stream.close();
+        }
+        testRootNode.save();
+        flushSearchIndex();
+        for (String statement : statements) {
+            assertContainsQuery(statement, true);
+        }
+    }
+
+    private void assertContainsQuery(String statement, boolean match)
+            throws InvalidQueryException, RepositoryException {
+        StringBuffer stmt = new StringBuffer();
+        stmt.append("/jcr:root").append(testRoot).append("/*");
+        stmt.append("[jcr:contains(., '").append(statement);
+        stmt.append("')]");
+
+        Query q = qm.createQuery(stmt.toString(), Query.XPATH);
+        checkResult(q.execute(), match ? 1 : 0);
+
+        stmt = new StringBuffer();
+        stmt.append("SELECT * FROM nt:base ");
+        stmt.append("WHERE jcr:path LIKE '").append(testRoot).append("/%' ");
+        stmt.append("AND CONTAINS(., '").append(statement).append("')");
+
+        q = qm.createQuery(stmt.toString(), Query.SQL);
+        checkResult(q.execute(), match ? 1 : 0);
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TextExtractionQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/TextExtractionQueryTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message