cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1098701 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java resources/dml/access.SimpleIdIncrementalFaultListDataRowsTest.xml
Date Mon, 02 May 2011 18:09:17 GMT
Author: aadamchik
Date: Mon May  2 18:09:17 2011
New Revision: 1098701

URL: http://svn.apache.org/viewvc?rev=1098701&view=rev
Log:
CAY-1560 CayenneCase tests conversion

patches by Dzmitry Kazimirchyk:
SimpleIdIncrementalFaultListDataRowsTest + refactoring

Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.SimpleIdIncrementalFaultListDataRowsTest.xml
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java?rev=1098701&r1=1098700&r2=1098701&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java
Mon May  2 18:09:17 2011
@@ -21,68 +21,110 @@ package org.apache.cayenne.access;
 
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.cayenne.DataRow;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 /**
  * Tests IncrementalFaultList behavior when fetching data rows.
- * 
  */
-public class SimpleIdIncrementalFaultListDataRowsTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class SimpleIdIncrementalFaultListDataRowsTest extends ServerCase {
 
-    protected SimpleIdIncrementalFaultList list;
-    protected Query query;
+    @Inject
+    private DataContext context;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Inject
+    private DataContext context1;
+
+    @Inject
+    private DBHelper dbHelper;
 
-        deleteTestData();
-        createTestData("testArtists");
+    private TableHelper tArtist;
+    private SimpleIdIncrementalFaultList<?> list;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+        createArtistsDataSet();
 
         SelectQuery q = new SelectQuery("Artist");
         q.setPageSize(6);
         q.setFetchingDataRows(true);
         q.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
 
-        query = q;
-        list = new SimpleIdIncrementalFaultList(super.createDataContext(), query);
+        list = new SimpleIdIncrementalFaultList<Object>(context, q);
+    }
+
+    protected void createArtistsDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tArtist.insert(33003, "artist3");
+        tArtist.insert(33004, "artist4");
+        tArtist.insert(33005, "artist5");
+        tArtist.insert(33006, "artist6");
+        tArtist.insert(33007, "artist7");
+        tArtist.insert(33008, "artist8");
+        tArtist.insert(33009, "artist9");
+        tArtist.insert(33010, "artist10");
+        tArtist.insert(33011, "artist11");
+        tArtist.insert(33012, "artist12");
+        tArtist.insert(33013, "artist13");
+        tArtist.insert(33014, "artist14");
+        tArtist.insert(33015, "artist15");
+        tArtist.insert(33016, "artist16");
+        tArtist.insert(33017, "artist17");
+        tArtist.insert(33018, "artist18");
+        tArtist.insert(33019, "artist19");
+        tArtist.insert(33020, "artist20");
+        tArtist.insert(33021, "artist21");
+        tArtist.insert(33022, "artist22");
+        tArtist.insert(33023, "artist23");
+        tArtist.insert(33024, "artist24");
+        tArtist.insert(33025, "artist25");
     }
 
     public void testGet1() throws Exception {
         assertEquals(1, list.idWidth);
-        assertFalse(list.elements.get(0) instanceof Map);
+        assertTrue(list.elements.get(0) instanceof Long);
         assertTrue(list.elements.get(19) instanceof Long);
 
         Object a = list.get(19);
 
         assertNotNull(a);
-        assertTrue(a instanceof Map);
-        assertEquals(3, ((Map) a).size());
-        assertEquals("artist20", ((Map) a).get("ARTIST_NAME"));
+        assertTrue(a instanceof DataRow);
+        assertEquals(3, ((DataRow) a).size());
+        assertEquals("artist20", ((DataRow) a).get("ARTIST_NAME"));
     }
 
     public void testIndexOf1() throws Exception {
-        DataContext parallelContext = createDataContext();
 
         Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
         SelectQuery query = new SelectQuery(Artist.class, qual);
         query.setFetchingDataRows(true);
-        List artists = parallelContext.performQuery(query);
+        List<?> artists = context1.performQuery(query);
 
         assertEquals(1, artists.size());
 
-        Map row = (Map) artists.get(0);
+        DataRow row = (DataRow) artists.get(0);
         assertEquals(19, list.indexOf(row));
-        
+
         DataRow clone = new DataRow(row);
         assertEquals(19, list.indexOf(clone));
 
@@ -91,19 +133,18 @@ public class SimpleIdIncrementalFaultLis
     }
 
     public void testIndexOf2() throws Exception {
-        DataContext parallelContext = createDataContext();
-        
+
         // resolve first page
         list.get(0);
 
         Expression qual = ExpressionFactory.matchExp("artistName", "artist2");
         SelectQuery query = new SelectQuery(Artist.class, qual);
         query.setFetchingDataRows(true);
-        List artists = parallelContext.performQuery(query);
+        List<?> artists = context1.performQuery(query);
 
         assertEquals(1, artists.size());
 
-        Map row = (Map) artists.get(0);
+        DataRow row = (DataRow) artists.get(0);
         assertEquals(1, list.indexOf(row));
 
         row.remove("ARTIST_NAME");
@@ -111,19 +152,18 @@ public class SimpleIdIncrementalFaultLis
     }
 
     public void testLastIndexOf1() throws Exception {
-        DataContext parallelContext = createDataContext();
-       
+
         // resolve first page
         list.get(0);
 
         Expression qual = ExpressionFactory.matchExp("artistName", "artist3");
         SelectQuery query = new SelectQuery(Artist.class, qual);
         query.setFetchingDataRows(true);
-        List artists = parallelContext.performQuery(query);
+        List<?> artists = context1.performQuery(query);
 
         assertEquals(1, artists.size());
 
-        Map row = (Map) artists.get(0);
+        DataRow row = (DataRow) artists.get(0);
         assertEquals(2, list.lastIndexOf(row));
 
         row.remove("ARTIST_NAME");
@@ -131,16 +171,15 @@ public class SimpleIdIncrementalFaultLis
     }
 
     public void testLastIndexOf2() throws Exception {
-        DataContext parallelContext = createDataContext();
 
         Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
         SelectQuery query = new SelectQuery(Artist.class, qual);
         query.setFetchingDataRows(true);
-        List artists = parallelContext.performQuery(query);
+        List<?> artists = context1.performQuery(query);
 
         assertEquals(1, artists.size());
 
-        Map row = (Map) artists.get(0);
+        DataRow row = (DataRow) artists.get(0);
         assertEquals(19, list.lastIndexOf(row));
 
         row.remove("ARTIST_ID");
@@ -150,15 +189,15 @@ public class SimpleIdIncrementalFaultLis
     public void testIterator() throws Exception {
         assertEquals(1, list.idWidth);
 
-        Iterator it = list.iterator();
+        Iterator<?> it = list.iterator();
         int counter = 0;
         while (it.hasNext()) {
             Object obj = it.next();
             assertNotNull(obj);
             assertTrue(
                     "Unexpected object class: " + obj.getClass().getName(),
-                    obj instanceof Map);
-            assertEquals(3, ((Map) obj).size());
+                    obj instanceof DataRow);
+            assertEquals(3, ((DataRow) obj).size());
 
             // iterator must be resolved page by page
             int expectedResolved = list.pageIndex(counter)



Mime
View raw message