chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r936988 - /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
Date Thu, 22 Apr 2010 18:05:08 GMT
Author: dcaruana
Date: Thu Apr 22 18:05:07 2010
New Revision: 936988

URL: http://svn.apache.org/viewvc?rev=936988&view=rev
Log:
Extend paging list tests for total number of items.

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java?rev=936988&r1=936987&r2=936988&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
Thu Apr 22 18:05:07 2010
@@ -55,12 +55,15 @@ public class PagingListTest {
                     hasMoreItems = Boolean.FALSE;
                 }
 
+                //. simulate rolling total number of items (for repositories that don't necessarily
know up front)
+                int totalItems = (to == data.length) ? to : to + 1;
+                
                 for (int i = from; i < to; i++) {
                     page.add(data[i]);
                 }
 
                 PageFetchResult<String> result = new AbstractPageFetch.PageFetchResult<String>(page,
BigInteger
-                        .valueOf(data.length), hasMoreItems);
+                        .valueOf(totalItems), hasMoreItems);
 
                 return result;
             }
@@ -113,20 +116,28 @@ public class PagingListTest {
         this.loopSkip(this.data0, 0, 5);
     }
 
+    @Test
+    public void totalNumItems() {
+        int pageSize = 5;
+        PagingIterable<String> p = this.getIterable(this.data10, pageSize);
+        assertNotNull(p);
+        PagingIterator<String> i = (PagingIterator<String>) p.iterator();
+        assertNotNull(i);
+        assertEquals(pageSize + 1, i.getTotalNumItems());
+        for (int idx = 0; i.hasNext() && idx < (pageSize + 1); idx++) {
+            i.next();
+        }
+        assertEquals(pageSize + 1, i.getPosition());
+        assertEquals(this.data10.length, i.getTotalNumItems());
+    }
+    
     private void loopSkip(String[] data, int skipCount, int pageSize) {
         System.out.println("\nloopSkip (" + skipCount + ", " + pageSize + ")");
 
         PagingIterable<String> p = this.getIterable(data, pageSize);
         assertNotNull(p);
-        PagingIterator<String> i = (PagingIterator<String>) p.iterator();
-        assertNotNull(i);
-        assertEquals(data.length, i.getTotalNumItems());
-
         PagingIterable<String> pp = p.skipTo(skipCount);
         assertNotNull(pp);
-        PagingIterator<String> ii = (PagingIterator<String>) pp.iterator();
-        assertNotNull(ii);
-        assertEquals(data.length, ii.getTotalNumItems());
 
         int count = 0;
         for (String s : pp) {
@@ -144,9 +155,6 @@ public class PagingListTest {
 
         PagingIterable<String> p = this.getIterable(data, pageSize);
         assertNotNull(p);
-        PagingIterator<String> i = (PagingIterator<String>) p.iterator();
-        assertNotNull(i);
-        assertEquals(data.length, i.getTotalNumItems());
 
         int count = 0;
         for (String s : p) {



Mime
View raw message