cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r634039 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/access/ClientServerChannelQueryTest.java resources/dml/access.ClientServerChannelQueryTest.xml
Date Wed, 05 Mar 2008 21:33:07 GMT
Author: aadamchik
Date: Wed Mar  5 13:33:06 2008
New Revision: 634039

URL: http://svn.apache.org/viewvc?rev=634039&view=rev
Log:
CAY-998 ROP paginated lists must recover from server LRU query cache overflow
(unit test to demonstrate the problem)

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java?rev=634039&r1=634038&r2=634039&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java
Wed Mar  5 13:33:06 2008
@@ -22,11 +22,12 @@
 import java.util.List;
 
 import org.apache.cayenne.CayenneContext;
-import org.apache.cayenne.DataChannel;
+import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ValueHolder;
-import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.cache.QueryCache;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.query.NamedQuery;
+import org.apache.cayenne.query.Ordering;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.remote.ClientChannel;
 import org.apache.cayenne.remote.service.LocalConnection;
@@ -40,18 +41,53 @@
 
 public class ClientServerChannelQueryTest extends CayenneCase {
 
+    private ObjectContext context;
+    private ClientServerChannel serverChannel;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        serverChannel = new ClientServerChannel(getDomain());
+        LocalConnection connector = new LocalConnection(
+                serverChannel,
+                LocalConnection.HESSIAN_SERIALIZATION);
+
+        context = new CayenneContext(new ClientChannel(connector));
+    }
+
     @Override
     protected AccessStack buildAccessStack() {
-        return CayenneResources
-                .getResources()
-                .getAccessStack(MULTI_TIER_ACCESS_STACK);
+        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
+    }
+
+    public void testPaginatedQueryServerCacheOverflow() throws Exception {
+        createTestData("testPaginatedQueryServerCacheOverflow");
+
+        SelectQuery query = new SelectQuery(ClientMtTable1.class);
+        query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, Ordering.ASC);
+        query.setPageSize(3);
+
+        List<?> results = context.performQuery(query);
+
+        // read page 1
+        assertTrue(results.get(0) instanceof ClientMtTable1);
+
+        // now kick out the server-side list from local cache, and see if the query would
+        // recover...
+        QueryCache qc = serverChannel.getQueryCache();
+        assertEquals(1, qc.size());
+        qc.clear();
+        assertEquals(0, qc.size());
+
+        // assertTrue(results.get(3) instanceof ClientMtTable1);
     }
 
     public void testNamedQuery() throws Exception {
         createTestData("prepare");
 
         NamedQuery q = new NamedQuery("AllMtTable1");
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(2, results.size());
         assertTrue(results.get(0) instanceof ClientMtTable1);
@@ -61,7 +97,7 @@
         createTestData("prepare");
 
         SelectQuery q = new SelectQuery("MtTable1");
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(2, results.size());
 
@@ -72,7 +108,7 @@
         createTestData("prepare");
 
         SelectQuery q = new SelectQuery(ClientMtTable1.class);
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(2, results.size());
         assertTrue(results.get(0) instanceof ClientMtTable1);
@@ -83,7 +119,7 @@
 
         SelectQuery q = new SelectQuery(ClientMtTable1.class, Expression
                 .fromString("globalAttribute1 = 'g1'"));
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());
 
@@ -95,7 +131,7 @@
 
         SelectQuery q = new SelectQuery(ClientMtTable1.class, Expression
                 .fromString("table2Array.globalAttribute = 'g1'"));
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());
         assertTrue(results.get(0) instanceof ClientMtTable1);
@@ -106,7 +142,7 @@
 
         SelectQuery q = new SelectQuery("MtTable1");
         q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, true);
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(2, results.size());
 
@@ -119,7 +155,7 @@
 
         q.clearOrderings();
         q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, false);
-        List<?> results1 = buildContext().performQuery(q);
+        List<?> results1 = context.performQuery(q);
 
         assertEquals(2, results1.size());
 
@@ -134,7 +170,7 @@
         SelectQuery q = new SelectQuery(ClientMtTable2.class, Expression
                 .fromString("globalAttribute = 'g1'"));
         q.addPrefetch(ClientMtTable2.TABLE1_PROPERTY);
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());
 
@@ -156,7 +192,7 @@
         SelectQuery q = new SelectQuery(ClientMtTable1.class, Expression
                 .fromString("globalAttribute1 = 'g1'"));
         q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
-        List<?> results = buildContext().performQuery(q);
+        List<?> results = context.performQuery(q);
 
         assertEquals(1, results.size());
 
@@ -168,18 +204,5 @@
         PersistentObjectList objectHolder = (PersistentObjectList) holder;
         assertFalse(objectHolder.isFault());
         assertEquals(2, objectHolder.size());
-    }
-
-    /**
-     * Prepares ClientObjectContext that would access regular Cayenne stack over local
-     * adapter with Hessian serialization.
-     */
-    protected CayenneContext buildContext() {
-        DataChannel handler = new ClientServerChannel(getDomain());
-        LocalConnection connector = new LocalConnection(
-                handler,
-                LocalConnection.HESSIAN_SERIALIZATION);
-
-        return new CayenneContext(new ClientChannel(connector));
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.ClientServerChannelQueryTest.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.ClientServerChannelQueryTest.xml?rev=634039&r1=634038&r2=634039&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.ClientServerChannelQueryTest.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.ClientServerChannelQueryTest.xml
Wed Mar  5 13:33:06 2008
@@ -34,6 +34,41 @@
 		</value></constructor-arg>
 	</bean>
 	
+	<bean id="INSERT_MT_TABLE13" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.mt.MtTable1</value></constructor-arg>
+		<constructor-arg><value>
+		insert into MT_TABLE1 (TABLE1_ID, GLOBAL_ATTRIBUTE1, SERVER_ATTRIBUTE1) values (3, 'g3',
's3')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="INSERT_MT_TABLE14" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.mt.MtTable1</value></constructor-arg>
+		<constructor-arg><value>
+		insert into MT_TABLE1 (TABLE1_ID, GLOBAL_ATTRIBUTE1, SERVER_ATTRIBUTE1) values (4, 'g4',
's4')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="INSERT_MT_TABLE15" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.mt.MtTable1</value></constructor-arg>
+		<constructor-arg><value>
+		insert into MT_TABLE1 (TABLE1_ID, GLOBAL_ATTRIBUTE1, SERVER_ATTRIBUTE1) values (5, 'g5',
's5')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="INSERT_MT_TABLE16" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.mt.MtTable1</value></constructor-arg>
+		<constructor-arg><value>
+		insert into MT_TABLE1 (TABLE1_ID, GLOBAL_ATTRIBUTE1, SERVER_ATTRIBUTE1) values (6, 'g6',
's6')
+		</value></constructor-arg>
+	</bean>
+	
+	<bean id="INSERT_MT_TABLE17" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
+		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.mt.MtTable1</value></constructor-arg>
+		<constructor-arg><value>
+		insert into MT_TABLE1 (TABLE1_ID, GLOBAL_ATTRIBUTE1, SERVER_ATTRIBUTE1) values (7, 'g7',
's7')
+		</value></constructor-arg>
+	</bean>
+	
 	<bean id="INSERT_MT_TABLE21" class="org.apache.cayenne.unit.util.UpdatingSQLTemplate">
 		<constructor-arg type="java.lang.Class"><value>org.apache.cayenne.testdo.mt.MtTable2</value></constructor-arg>
 		<constructor-arg><value>
@@ -62,6 +97,22 @@
 				<ref bean="INSERT_MT_TABLE12"/>
 				<ref bean="INSERT_MT_TABLE21"/>
 				<ref bean="INSERT_MT_TABLE22"/>
+			</list>
+		</constructor-arg>
+	</bean>
+	
+	<bean id="testPaginatedQueryServerCacheOverflow" class="java.util.ArrayList">
+		<constructor-arg>
+			<list>
+				<ref bean="DELETE_MT_TABLE2"/>
+				<ref bean="DELETE_MT_TABLE1"/>
+				<ref bean="INSERT_MT_TABLE11"/>
+				<ref bean="INSERT_MT_TABLE12"/>
+				<ref bean="INSERT_MT_TABLE13"/>
+				<ref bean="INSERT_MT_TABLE14"/>
+				<ref bean="INSERT_MT_TABLE15"/>
+				<ref bean="INSERT_MT_TABLE16"/>
+				<ref bean="INSERT_MT_TABLE17"/>
 			</list>
 		</constructor-arg>
 	</bean>



Mime
View raw message