db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r614649 - in /db/jdo/trunk: tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/ tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/
Date Wed, 23 Jan 2008 20:26:03 GMT
Author: mbo
Date: Wed Jan 23 12:26:00 2008
New Revision: 614649

URL: http://svn.apache.org/viewvc?rev=614649&view=rev
Log:
JDO-568: add helper method returning all persistent employees

Modified:
    db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
    db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
    db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
    db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java

Modified: db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
(original)
+++ db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
Wed Jan 23 12:26:00 2008
@@ -78,7 +78,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);

Modified: db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
(original)
+++ db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
Wed Jan 23 12:26:00 2008
@@ -92,7 +92,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);
@@ -130,7 +130,7 @@
                         false, new Object[] {hired}, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);
@@ -163,7 +163,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);

Modified: db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
(original)
+++ db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
Wed Jan 23 12:26:00 2008
@@ -86,7 +86,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);
@@ -123,7 +123,7 @@
                         false, new Object[]{hired}, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);

Modified: db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java
(original)
+++ db/jdo/trunk/tck2-legacy/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java
Wed Jan 23 12:26:00 2008
@@ -17,7 +17,13 @@
  
 package org.apache.jdo.tck.query.jdoql.subqueries;
 
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
 import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.pc.company.Employee;
 
 /**
  * Superclass for all subquery test classes.
@@ -34,5 +40,24 @@
      */
     protected String getCompanyTestDataResource() {
         return SUBQUERIES_TEST_COMPANY_TESTDATA;
+    }
+
+    /** 
+     * Helper method retuning all Employee instances.
+     * @param pm the PersistenceManager 
+     * @return a List including all persistent Employee instances
+     */
+    protected List getAllEmployees(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            List allEmployees = (List)pm.newQuery(Employee.class).execute();
+            tx.commit();
+            return allEmployees;
+        } finally { 
+            if ((tx != null) && tx.isActive()) {
+                tx.rollback();
+            }
+        }
     }
 }

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java
Wed Jan 23 12:26:00 2008
@@ -78,7 +78,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java
Wed Jan 23 12:26:00 2008
@@ -92,7 +92,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);
@@ -130,7 +130,7 @@
                         false, new Object[] {hired}, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);
@@ -163,7 +163,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java
Wed Jan 23 12:26:00 2008
@@ -86,7 +86,7 @@
                         false, null, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);
@@ -123,7 +123,7 @@
                         false, new Object[]{hired}, expectedResult, true);
 
         // API query against memory model
-        List allEmployees = (List)pm.newQuery(Employee.class).execute();
+        List allEmployees = getAllEmployees(pm);
         apiQuery.setCandidates(allEmployees);
         executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, 
                         false, null, expectedResult, true);

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java?rev=614649&r1=614648&r2=614649&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java
Wed Jan 23 12:26:00 2008
@@ -17,7 +17,13 @@
  
 package org.apache.jdo.tck.query.jdoql.subqueries;
 
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
 import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.pc.company.Employee;
 
 /**
  * Superclass for all subquery test classes.
@@ -34,5 +40,24 @@
      */
     protected String getCompanyTestDataResource() {
         return SUBQUERIES_TEST_COMPANY_TESTDATA;
+    }
+
+    /** 
+     * Helper method retuning all Employee instances.
+     * @param pm the PersistenceManager 
+     * @return a List including all persistent Employee instances
+     */
+    protected List getAllEmployees(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            List allEmployees = (List)pm.newQuery(Employee.class).execute();
+            tx.commit();
+            return allEmployees;
+        } finally { 
+            if ((tx != null) && tx.isActive()) {
+                tx.rollback();
+            }
+        }
     }
 }



Mime
View raw message