db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1026673 - in /db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods: SupportedCollectionMethods.java SupportedListMethods.java
Date Sat, 23 Oct 2010 20:00:06 GMT
Author: mbo
Date: Sat Oct 23 20:00:05 2010
New Revision: 1026673

URL: http://svn.apache.org/viewvc?rev=1026673&view=rev
Log:
JDO-633: refactoring to avoid code duplication

Modified:
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java

Modified: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java?rev=1026673&r1=1026672&r2=1026673&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java
(original)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java
Sat Oct 23 20:00:05 2010
@@ -168,8 +168,9 @@ public class SupportedCollectionMethods 
                 expectedResult[index]);
         
         index++;
-        Object[] parameters = new Object[]{
-                getParameter(Employee.class, "personid == 1", true)};
+        getPM().currentTransaction().begin();
+        Object[] parameters = new Object[]{1, getPersistentCompanyModelInstance("emp1")};
+        getPM().currentTransaction().commit(); 
         executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
                 parameters, expectedResult[index]);
         executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
@@ -202,30 +203,5 @@ public class SupportedCollectionMethods 
         addTearDownClass(CompanyModelReader.getTearDownClasses());
         loadAndPersistCompanyModel(getPM());
     }
-    
-    /** */
-    private Object getParameter(
-            Class candidateClass, String filter, boolean unique) {
-        Object result;
-        PersistenceManager pm = getPM();
-        Transaction transaction = pm.currentTransaction();
-        transaction.begin();
-        try {
-            Query query = filter == null ? pm.newQuery(candidateClass) :
-                pm.newQuery(candidateClass, filter);
-            if (unique) {
-                query.setUnique(unique);
-            }
-            try {
-                result = query.execute();
-            } finally {
-                query.closeAll();
-            }
-        } finally {
-            if (transaction.isActive()) {
-                transaction.rollback();
-            }
-        }
-        return result;
-    }
+
 }

Modified: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java?rev=1026673&r1=1026672&r2=1026673&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java
(original)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java
Sat Oct 23 20:00:05 2010
@@ -108,8 +108,9 @@ public class SupportedListMethods extend
     /** */
     public void testGetInFilter() {
         int index = 0;
-        Object[] parameters = new Object[]{1, 
-                getParameter(MeetingRoom.class, "roomid == 2", true)};
+        getPM().currentTransaction().begin();
+        Object[] parameters = new Object[]{1, getPersistentCompanyModelInstance("room2")};
+        getPM().currentTransaction().commit(); 
         executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
                 parameters, expectedResult[index]);
         executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
@@ -132,29 +133,5 @@ public class SupportedListMethods extend
         addTearDownClass(CompanyModelReader.getTearDownClasses());
         loadAndPersistCompanyModel(getPM());
     }
-    
-    /** */
-    private Object getParameter(Class candidateClass, String filter, boolean unique) {
-        Object result;
-        PersistenceManager pm = getPM();
-        Transaction transaction = pm.currentTransaction();
-        transaction.begin();
-        try {
-            Query query = filter == null ? pm.newQuery(candidateClass) :
-                pm.newQuery(candidateClass, filter);
-            if (unique) {
-                query.setUnique(unique);
-            }
-            try {
-                result = query.execute();
-            } finally {
-                query.closeAll();
-            }
-        } finally {
-            if (transaction.isActive()) {
-                transaction.rollback();
-            }
-        }
-        return result;
-    }
+
 }



Mime
View raw message