db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r453089 - /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java
Date Thu, 05 Oct 2006 02:45:38 GMT
Author: clr
Date: Wed Oct  4 19:45:37 2006
New Revision: 453089

URL: http://svn.apache.org/viewvc?view=rev&rev=453089
Log:
JDO-415 
Three problems with the original test case are fixed with this patch. 

1. As the bug noted, the DataStoreConnection is acquired outside a 
transaction, and there is no guarantee that the DataStoreConnection 
is even valid after beginning a transaction. The code now acquires 
the DataStoreConnection only after beginning a transaction. 

2. If the implementation supports Optimistic transactions, 
then the test should be repeated for both optimistic and 
datastore transactions. 

3. The transaction is never committed. This is fixed by putting 
the DataStoreConnection close and the transaction.commit into 
the finally block. 

Modified:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java?view=diff&rev=453089&r1=453088&r2=453089
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java
(original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java
Wed Oct  4 19:45:37 2006
@@ -86,12 +86,26 @@
                     "getDataStoreConnection AND SQLSupported.");
             return;
         }
+        getPM().currentTransaction().setOptimistic(false);
+        executeSQLWithDataStoreConnection();
+        if (!isOptimisticSupported()) {
+            printUnsupportedOptionalFeatureNotTested(
+                    this.getClass().getName(),
+                    "getDataStoreConnection AND SQLSupported AND Optimistic.");
+            return;
+        }
+        getPM().currentTransaction().setOptimistic(true);
+        executeSQLWithDataStoreConnection();
+    }
+
+    private void executeSQLWithDataStoreConnection() {
         String schema = getPMFProperty("javax.jdo.mapping.Schema");
         String sql = "SELECT X, Y FROM " + schema + ".PCPoint";
-        JDOConnection jconn = pm.getDataStoreConnection();
-        Connection conn = (Connection)jconn;
+        JDOConnection jconn = null;
         try {
             getPM().currentTransaction().begin();
+            jconn = pm.getDataStoreConnection();
+            Connection conn = (Connection)jconn;
             if (conn.getAutoCommit()) {
                 appendMessage(ASSERTION_FAILED + 
                         "Autocommit must not be true in JDO connection.");
@@ -123,6 +137,7 @@
             appendMessage(ASSERTION_FAILED + " caught exception:" + ex);
         } finally {
             jconn.close();
+            getPM().currentTransaction().commit();
             failOnError();
         }
     }



Mime
View raw message