cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r412674 - in /incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne: access/DataContextTst.java access/IncrementalFaultListTst.java remote/RemoteIncrementalFaultListTst.java
Date Thu, 08 Jun 2006 06:45:30 GMT
Author: aadamchik
Date: Wed Jun  7 23:45:30 2006
New Revision: 412674

URL: http://svn.apache.org/viewvc?rev=412674&view=rev
Log:
extra unit tests for IncrementalFaultList

Modified:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextTst.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/IncrementalFaultListTst.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/remote/RemoteIncrementalFaultListTst.java

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextTst.java?rev=412674&r1=412673&r2=412674&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextTst.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextTst.java
Wed Jun  7 23:45:30 2006
@@ -426,6 +426,22 @@
         assertTrue(((IncrementalFaultList) objects).elements.get(0) instanceof Artist);
         assertTrue(((IncrementalFaultList) objects).elements.get(7) instanceof Map);
     }
+    
+    public void testPerformPaginatedQueryBigPage() throws Exception {
+        SelectQuery query = new SelectQuery("Artist");
+        query.setPageSize(DataContextTst.artistCount + 2);
+        List objects = context.performQuery(query);
+        assertNotNull(objects);
+        assertTrue(objects instanceof IncrementalFaultList);
+
+        blockQueries();
+        try {
+            assertEquals(DataContextTst.artistCount, objects.size());
+        }
+        finally {
+            unblockQueries();
+        }
+    }
 
     public void testPerformDataRowQuery() throws Exception {
         SelectQuery query = new SelectQuery("Artist");

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/IncrementalFaultListTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/IncrementalFaultListTst.java?rev=412674&r1=412673&r2=412674&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/IncrementalFaultListTst.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/IncrementalFaultListTst.java
Wed Jun  7 23:45:30 2006
@@ -70,14 +70,14 @@
 import org.objectstyle.cayenne.unit.CayenneTestCase;
 
 /**
- * @author Andrei Adamchik
+ * @author Andrus Adamchik
  */
 public class IncrementalFaultListTst extends CayenneTestCase {
 
     protected IncrementalFaultList list;
     protected Query query;
 
-    protected void setUp() throws Exception {
+    protected void prepareList(int pageSize) throws Exception {
         super.setUp();
         deleteTestData();
         createTestData("testArtists");
@@ -86,17 +86,29 @@
 
         // make sure total number of objects is not divisable
         // by the page size, to test the last smaller page
-        q.setPageSize(6);
+        q.setPageSize(pageSize);
         q.addOrdering("db:ARTIST_ID", Ordering.ASC);
         query = q;
         list = new IncrementalFaultList(super.createDataContext(), query);
     }
 
     public void testSize() throws Exception {
+        prepareList(6);
+        assertEquals(DataContextTst.artistCount, list.size());
+    }
+    
+    public void testSmallList() throws Exception {
+        prepareList(49);
+        assertEquals(DataContextTst.artistCount, list.size());
+    }
+    
+    public void testOnePageList() throws Exception {
+        prepareList(DataContextTst.artistCount);
         assertEquals(DataContextTst.artistCount, list.size());
     }
 
     public void testIterator() throws Exception {
+        prepareList(6);
         Iterator it = list.iterator();
         int counter = 0;
         while (it.hasNext()) {
@@ -119,6 +131,7 @@
     }
 
     public void testListIterator() throws Exception {
+        prepareList(6);
         ListIterator it = list.listIterator();
         int counter = 0;
         while (it.hasNext()) {
@@ -141,6 +154,7 @@
     }
 
     public void testUnfetchedObjects() throws Exception {
+        prepareList(6);
         assertEquals(DataContextTst.artistCount - 6, list.getUnfetchedObjects());
         list.get(7);
         assertEquals(DataContextTst.artistCount - 12, list.getUnfetchedObjects());
@@ -149,6 +163,7 @@
     }
 
     public void testPageIndex() throws Exception {
+        prepareList(6);
         assertEquals(0, list.pageIndex(0));
         assertEquals(0, list.pageIndex(1));
         assertEquals(1, list.pageIndex(6));
@@ -163,6 +178,7 @@
     }
 
     public void testPagesRead1() throws Exception {
+        prepareList(6);
         assertTrue(list.elements.get(0) instanceof Artist);
         assertTrue(list.elements.get(8) instanceof Map);
 
@@ -174,6 +190,7 @@
     }
 
     public void testGet1() throws Exception {
+        prepareList(6);
         assertTrue(list.elements.get(0) instanceof Artist);
         assertTrue(list.elements.get(8) instanceof Map);
 
@@ -185,6 +202,7 @@
     }
 
     public void testGet2() throws Exception {
+        prepareList(6);
         ((SelectQuery) query).setFetchingDataRows(true);
         assertTrue(list.elements.get(0) instanceof Artist);
         assertTrue(list.elements.get(8) instanceof Map);
@@ -196,7 +214,7 @@
     }
 
     public void testIndexOf() throws Exception {
-
+        prepareList(6);
         Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
         SelectQuery query = new SelectQuery(Artist.class, qual);
         List artists = list.dataContext.performQuery(query);
@@ -210,7 +228,7 @@
     }
 
     public void testLastIndexOf() throws Exception {
-
+        prepareList(6);
         Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
         SelectQuery query = new SelectQuery(Artist.class, qual);
         List artists = list.dataContext.performQuery(query);

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/remote/RemoteIncrementalFaultListTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/remote/RemoteIncrementalFaultListTst.java?rev=412674&r1=412673&r2=412674&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/remote/RemoteIncrementalFaultListTst.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/remote/RemoteIncrementalFaultListTst.java
Wed Jun  7 23:45:30 2006
@@ -115,27 +115,27 @@
     }
     
     public void testIteratorPageSize1() throws Exception {
-        testIterator(1);
+        doTestIterator(1);
     }
     
     public void testIteratorPageSize5() throws Exception {
         // size divisiable by page size
-        testIterator(5);
+        doTestIterator(5);
     }
 
     public void testIteratorPageSize6() throws Exception {
         // size not divisable by page size
-        testIterator(6);
+        doTestIterator(6);
     }
     
     public void testIteratorPageSize25() throws Exception {
         // size equals to page size
-        testIterator(COUNT);
+        doTestIterator(COUNT);
     }
     
     public void testIteratorPageSize26() throws Exception {
         // size exceeding page size
-        testIterator(COUNT + 1);
+        doTestIterator(COUNT + 1);
     }
 
     public void testListIterator() throws Exception {
@@ -243,7 +243,7 @@
         assertEquals(-1, list.lastIndexOf(list.context.newObject(ClientMtTable1.class)));
     }
     
-    private void testIterator(int size) throws Exception {
+    private void doTestIterator(int size) throws Exception {
         prepareList(size);
         Iterator it = list.iterator();
 



Mime
View raw message