jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1371110 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query: AbstractIndexingTest.java AbstractQueryTest.java FulltextQueryTest.java
Date Thu, 09 Aug 2012 09:11:57 GMT
Author: alexparvulescu
Date: Thu Aug  9 09:11:57 2012
New Revision: 1371110

URL: http://svn.apache.org/viewvc?rev=1371110&view=rev
Log:
JCR-3408 Query tests should avoid casting to QueryManagerImpl

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/FulltextQueryTest.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=1371110&r1=1371109&r2=1371110&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
Thu Aug  9 09:11:57 2012
@@ -60,6 +60,6 @@ public class AbstractIndexingTest extend
      */
     protected void waitForTextExtractionTasksToFinish() throws Exception {
         TestHelper.waitForTextExtractionTasksToFinish(session);
-        getSearchIndex().flush();
+        flushSearchIndex();
     }
 }

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=1371110&r1=1371109&r2=1371110&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
Thu Aug  9 09:11:57 2012
@@ -143,7 +143,7 @@ public class AbstractQueryTest extends A
      */
     protected void executeXPathQuery(String xpath, Node[] nodes)
             throws RepositoryException {
-        getSearchIndex().flush();
+        flushSearchIndex();
         QueryResult res = qm.createQuery(xpath, Query.XPATH).execute();
         checkResult(res, nodes);
     }
@@ -158,7 +158,7 @@ public class AbstractQueryTest extends A
      */
     protected void executeSQLQuery(String sql, Node[] nodes)
             throws RepositoryException {
-        getSearchIndex().flush();
+        flushSearchIndex();
         QueryResult res = qm.createQuery(sql, Query.SQL).execute();
         checkResult(res, nodes);
     }
@@ -251,7 +251,7 @@ public class AbstractQueryTest extends A
      */
     protected QueryResult executeQuery(String statement)
             throws RepositoryException {
-        getSearchIndex().flush();
+        flushSearchIndex();
         if (statement.trim().toLowerCase().startsWith("select")) {
             return qm.createQuery(statement, Query.SQL).execute();
         } else {
@@ -266,17 +266,27 @@ public class AbstractQueryTest extends A
 
     protected void executeSQL2Query(String statement, Node[] nodes)
             throws RepositoryException {
-        getSearchIndex().flush();
+        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() {
-        return (SearchIndex) ((QueryManagerImpl) qm).getQueryHandler();
+        if (qm instanceof QueryManagerImpl) {
+            return (SearchIndex) ((QueryManagerImpl) qm).getQueryHandler();
+        }
+        return null;
     }
 }

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=1371110&r1=1371109&r2=1371110&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
Thu Aug  9 09:11:57 2012
@@ -360,7 +360,7 @@ public class FulltextQueryTest extends A
             stream.close();
         }
         testRootNode.save();
-        getSearchIndex().flush();
+        flushSearchIndex();
 
         for (String statement : statements) {
             assertContainsQuery(statement, true);



Mime
View raw message