openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r619175 - /openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryPagination.java
Date Wed, 06 Feb 2008 22:04:17 GMT
Author: pcl
Date: Wed Feb  6 14:04:15 2008
New Revision: 619175

URL: http://svn.apache.org/viewvc?rev=619175&view=rev
Log:
Merge from ../../trunk. svn merge -c 596523 ../../trunk; svn merge -c 596661 ../../trunk Merge
from ../../trunk. svn merge -c 596661 ../../trunk

Modified:
    openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryPagination.java

Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryPagination.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryPagination.java?rev=619175&r1=619174&r2=619175&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryPagination.java
(original)
+++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryPagination.java
Wed Feb  6 14:04:15 2008
@@ -18,19 +18,23 @@
  */
 package org.apache.openjpa.persistence.query;
 
+import java.util.List;
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 
-import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.DerbyDictionary;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
 
 /**
  * Test that query pagination works properly.
  */
 public class TestQueryPagination
-    extends SingleEMFTestCase {
+    extends SQLListenerTestCase {
 
     public void setUp() {
-        setUp(SimpleEntity.class, CLEAR_TABLES);
+        setUp(SimpleEntity.class, CLEAR_TABLES, "openjpa.Log", "SQL=TRACE");
 
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
@@ -70,12 +74,31 @@
 
     private void helper(boolean firstFirst, int first, int max, int expected) {
         EntityManager em = emf.createEntityManager();
-        Query q = em.createQuery("select e from simple e");
+        Query q = em.createQuery("select e from simple e order by e.value");
+        sql.clear();
+        List<SimpleEntity> fullList = q.getResultList();
         if (firstFirst)
             q.setFirstResult(first).setMaxResults(max);
         else
             q.setMaxResults(max).setFirstResult(first);
-        assertEquals(expected, q.getResultList().size());
+        List<SimpleEntity> list = q.getResultList();
+        checkSQL();
+        assertEquals(expected, list.size());
+        for (int i = 0; i < list.size(); i++) {
+            assertEquals("bar" + (first + i), list.get(i).getValue());
+        }
         em.close();
+    }
+
+    private void checkSQL() {
+        assertEquals(2, sql.size());
+        String noRange = this.sql.get(0);
+        String withRange = this.sql.get(1);
+        DBDictionary dict = ((JDBCConfiguration) emf.getConfiguration())
+            .getDBDictionaryInstance();
+        if (dict.supportsSelectStartIndex || dict.supportsSelectEndIndex)
+            assertNotEquals(noRange, withRange);
+        else
+            assertEquals(noRange, withRange);
     }
 }



Mime
View raw message