jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cki...@apache.org
Subject svn commit: r613221 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
Date Fri, 18 Jan 2008 18:41:06 GMT
Author: ckiehl
Date: Fri Jan 18 10:40:56 2008
New Revision: 613221

URL: http://svn.apache.org/viewvc?rev=613221&view=rev
Log:
JCR-1323: Fixed and test case added

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=613221&r1=613220&r2=613221&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
Fri Jan 18 10:40:56 2008
@@ -411,11 +411,11 @@
          * nodes or the session does not have access to a node.
          */
         public long getSize() {
-            int totalSize = getTotalSize();
-            if (limit > 0 && totalSize > limit) {
+            long size = getTotalSize() - offset;
+            if (limit > 0 && size > limit) {
                 return limit;
             } else {
-                return totalSize - offset;
+                return size;
             }
         }
 

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=613221&r1=613220&r2=613221&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
Fri Jan 18 10:40:56 2008
@@ -63,6 +63,10 @@
         return (QueryImpl) queryManager.createQuery(xpath, Query.XPATH);
     }
 
+    protected void checkResult(QueryResult result, Node[] expectedNodes) throws RepositoryException
{
+        assertEquals(expectedNodes.length, result.getNodes().getSize());
+    }
+    
     public void testLimit() throws Exception {
         query.setLimit(1);
         QueryResult result = query.execute();
@@ -111,6 +115,12 @@
         query.setLimit(2);
         result = query.execute();
         checkResult(result, new Node[] { node1, node2 });
+
+        // Added for JCR-1323
+        query.setOffset(0);
+        query.setLimit(4);
+        result = query.execute();
+        checkResult(result, new Node[] { node1, node2, node3 });
     }
 
     public void testOffsetAndSkip() throws Exception {



Mime
View raw message