jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r791527 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query: IndexingAggregateTest.java TestAll.java lucene/IndexingAggregateTest.java lucene/TestAll.java
Date Mon, 06 Jul 2009 15:53:52 GMT
Author: mreutegg
Date: Mon Jul  6 15:53:51 2009
New Revision: 791527

URL: http://svn.apache.org/viewvc?rev=791527&view=rev
Log:
JCR-2191: IndexingAggregateTest#testNtFileAggregate fails occasionally

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
  (contents, props changed)
      - copied, changed from r791508, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingAggregateTest.java
Removed:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingAggregateTest.java
Modified:
    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/TestAll.java

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=791527&r1=791526&r2=791527&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
Mon Jul  6 15:53:51 2009
@@ -57,7 +57,6 @@
         suite.addTestSuite(SynonymProviderTest.class);
         suite.addTestSuite(ArrayHitsTest.class);
         suite.addTestSuite(ExcerptTest.class);
-        suite.addTestSuite(IndexingAggregateTest.class);
         suite.addTestSuite(IndexFormatVersionTest.class);
         suite.addTestSuite(IndexingRuleTest.class);
         suite.addTestSuite(ShareableNodeTest.class);

Copied: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
(from r791508, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingAggregateTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java?p2=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java&p1=jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingAggregateTest.java&r1=791508&r2=791527&rev=791527&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/IndexingAggregateTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
Mon Jul  6 15:53:51 2009
@@ -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.RepositoryException;
 import javax.jcr.Node;
@@ -24,20 +24,21 @@
 import java.io.Writer;
 import java.io.OutputStreamWriter;
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.util.Calendar;
 import java.util.List;
 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
  * aggregate defined in workspace indexing-test works properly.
  */
 public class IndexingAggregateTest extends AbstractIndexingTest {
 
-    public void testNtFileAggregate() throws RepositoryException, IOException {
+    public void testNtFileAggregate() throws Exception {
         String sqlBase = "SELECT * FROM nt:file"
                 + " WHERE jcr:path LIKE '" + testRoot + "/%"
                 + "' AND CONTAINS";
@@ -57,6 +58,7 @@
         resource.setProperty("jcr:data", new ByteArrayInputStream(out.toByteArray()));
 
         testRootNode.save();
+        waitUntilQueueEmpty();
 
         executeSQLQuery(sqlDog, new Node[]{file});
 
@@ -66,6 +68,7 @@
         writer.flush();
         resource.setProperty("jcr:data", new ByteArrayInputStream(out.toByteArray()));
         testRootNode.save();
+        waitUntilQueueEmpty();
 
         executeSQLQuery(sqlCat, new Node[]{file});
 
@@ -92,10 +95,22 @@
         resource.setProperty("jcr:mimeType", "text/plain");
         resource.setProperty("jcr:data", new ByteArrayInputStream(out.toByteArray()));
         testRootNode.save();
+        waitUntilQueueEmpty();
 
         executeSQLQuery(sqlCat, new Node[]{file});
     }
 
+    protected void waitUntilQueueEmpty() throws Exception {
+        SearchIndex index = (SearchIndex) getQueryHandler();
+        IndexingQueue queue = index.getIndex().getIndexingQueue();
+        index.getIndex().flush();
+        synchronized (index.getIndex()) {
+            while (queue.getNumPendingDocuments() > 0) {
+                index.getIndex().wait(50);
+            }
+        }
+    }
+
     public void testContentLastModified() throws RepositoryException {
         List expected = new ArrayList();
         long time = System.currentTimeMillis();
@@ -148,7 +163,7 @@
         for (int i = 0; i < 3; i++) {
             long time = System.currentTimeMillis();
             Query query = qm.createQuery(xpath, Query.XPATH);
-            ((QueryImpl) query).setLimit(20);
+            query.setLimit(20);
             query.execute().getNodes().getSize();
             time = System.currentTimeMillis() - time;
             System.out.println("executed query in " + time + " ms.");

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.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=791527&r1=791526&r2=791527&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
Mon Jul  6 15:53:51 2009
@@ -38,6 +38,7 @@
 
         suite.addTestSuite(IndexingQueueTest.class);
         suite.addTestSuite(DecimalConvertTest.class);
+        suite.addTestSuite(IndexingAggregateTest.class);
 
         return suite;
     }



Mime
View raw message