cayenne-commits mailing list archives

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

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

patches by Dzmitry Kazimirchyk:
RemoteIncrementalFaultListTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java?rev=1098679&r1=1098678&r2=1098679&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java
Mon May  2 17:34:11 2011
@@ -26,36 +26,77 @@ import java.util.ListIterator;
 import org.apache.cayenne.CayenneContext;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.event.MockEventManager;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.query.SortOrder;
 import org.apache.cayenne.remote.service.LocalConnection;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.MtTable1;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class RemoteIncrementalFaultListTest extends CayenneCase {
+@UseServerRuntime("cayenne-multi-tier.xml")
+public class RemoteIncrementalFaultListTest extends ServerCase {
 
-    static final int COUNT = 25;
+    private static final int COUNT = 25;
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper tMTTable;
 
     protected RemoteIncrementalFaultList list;
     protected SelectQuery query;
 
     @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources
-                .getResources()
-                .getAccessStack(MULTI_TIER_ACCESS_STACK);
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("MT_TABLE2");
+        dbHelper.deleteAll("MT_TABLE1");
+
+        tMTTable = new TableHelper(dbHelper, "MT_TABLE1");
+        tMTTable.setColumns("TABLE1_ID", "GLOBAL_ATTRIBUTE1", "SERVER_ATTRIBUTE1");
+    }
+
+    protected void createObjectsDataSet() throws Exception {
+        tMTTable.insert(1, "g1", "s1");
+        tMTTable.insert(2, "g2", "s2");
+        tMTTable.insert(3, "g3", "s3");
+        tMTTable.insert(4, "g4", "s4");
+        tMTTable.insert(5, "g5", "s5");
+        tMTTable.insert(6, "g6", "s6");
+        tMTTable.insert(7, "g7", "s7");
+        tMTTable.insert(8, "g8", "s8");
+        tMTTable.insert(9, "g9", "s9");
+        tMTTable.insert(10, "g10", "s10");
+        tMTTable.insert(11, "g11", "s11");
+        tMTTable.insert(12, "g12", "s12");
+        tMTTable.insert(13, "g13", "s13");
+        tMTTable.insert(14, "g14", "s14");
+        tMTTable.insert(15, "g15", "s15");
+        tMTTable.insert(16, "g16", "s16");
+        tMTTable.insert(17, "g17", "s17");
+        tMTTable.insert(18, "g18", "s18");
+        tMTTable.insert(19, "g19", "s19");
+        tMTTable.insert(20, "g20", "s20");
+        tMTTable.insert(21, "g21", "s21");
+        tMTTable.insert(22, "g22", "s22");
+        tMTTable.insert(23, "g23", "s23");
+        tMTTable.insert(24, "g24", "s24");
+        tMTTable.insert(25, "g25", "s25");
     }
 
     protected void prepareList(int pageSize) throws Exception {
 
-        deleteTestData();
-        createTestData("testObjects");
+        createObjectsDataSet();
 
         this.query = new SelectQuery(ClientMtTable1.class);
 
@@ -64,11 +105,12 @@ public class RemoteIncrementalFaultListT
         query.setPageSize(pageSize);
         query.addOrdering("db:" + MtTable1.TABLE1_ID_PK_COLUMN, SortOrder.ASCENDING);
 
-        ClientServerChannel serverChannel = new ClientServerChannel(getDomain());
+        ClientServerChannel serverChannel = new ClientServerChannel(context);
         LocalConnection connection = new LocalConnection(
                 serverChannel,
                 LocalConnection.HESSIAN_SERIALIZATION);
-        ClientChannel clientChannel = new ClientChannel(connection,
+        ClientChannel clientChannel = new ClientChannel(
+                connection,
                 false,
                 new MockEventManager(),
                 false);
@@ -82,11 +124,11 @@ public class RemoteIncrementalFaultListT
         prepareList(6);
         assertEquals(COUNT, list.size());
     }
-    
+
     public void testIteratorPageSize1() throws Exception {
         doTestIterator(1);
     }
-    
+
     public void testIteratorPageSize5() throws Exception {
         // size divisiable by page size
         doTestIterator(5);
@@ -96,12 +138,12 @@ public class RemoteIncrementalFaultListT
         // size not divisable by page size
         doTestIterator(6);
     }
-    
+
     public void testIteratorPageSize25() throws Exception {
         // size equals to page size
         doTestIterator(COUNT);
     }
-    
+
     public void testIteratorPageSize26() throws Exception {
         // size exceeding page size
         doTestIterator(COUNT + 1);
@@ -109,7 +151,7 @@ public class RemoteIncrementalFaultListT
 
     public void testListIterator() throws Exception {
         prepareList(6);
-        ListIterator it = list.listIterator();
+        ListIterator<?> it = list.listIterator();
 
         assertTrue(it.hasNext());
 
@@ -188,7 +230,7 @@ public class RemoteIncrementalFaultListT
                 ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY,
                 "g20");
         SelectQuery query = new SelectQuery(ClientMtTable1.class, qual);
-        List artists = list.context.performQuery(query);
+        List<?> artists = list.context.performQuery(query);
 
         assertEquals(1, artists.size());
 
@@ -203,7 +245,7 @@ public class RemoteIncrementalFaultListT
                 ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY,
                 "g20");
         SelectQuery query = new SelectQuery(ClientMtTable1.class, qual);
-        List objects = list.context.performQuery(query);
+        List<?> objects = list.context.performQuery(query);
 
         assertEquals(1, objects.size());
 
@@ -211,10 +253,10 @@ public class RemoteIncrementalFaultListT
         assertEquals(19, list.lastIndexOf(row));
         assertEquals(-1, list.lastIndexOf(list.context.newObject(ClientMtTable1.class)));
     }
-    
+
     private void doTestIterator(int size) throws Exception {
         prepareList(size);
-        Iterator it = list.iterator();
+        Iterator<?> it = list.iterator();
 
         assertTrue(it.hasNext());
 



Mime
View raw message