db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r676106 - in /db/jdo/trunk/tck2/src/java/org/apache/jdo/tck: ./ api/persistencemanagerfactory/ api/persistencemanagerfactory/config/
Date Sat, 12 Jul 2008 00:20:17 GMT
Author: clr
Date: Fri Jul 11 17:20:16 2008
New Revision: 676106

URL: http://svn.apache.org/viewvc?rev=676106&view=rev
Log:
JDO-555 Update pmf tests to use new method closePMF in JDO_Test

Modified:
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java Fri Jul 11 17:20:16 2008
@@ -563,8 +563,9 @@
         JDOException failure = null;
         while (pmf != null) {
             try {
-                if (!pmf.isClosed())
-                    pmf.close();
+                if (!pmf.isClosed()) {
+                    closePMF(pmf);
+                }
                 pmf = null;
             }
             catch (JDOException ex) {
@@ -577,6 +578,11 @@
                     cleanupPM(pms[i]);
                 }
             }
+            catch (RuntimeException ex) {
+                pmf = null;
+                ex.printStackTrace(System.out);
+                throw ex;
+            }
         }
 
         // rethrow JDOException thrown by pmf.close
@@ -584,6 +590,25 @@
             throw failure;
     }
 
+    /** Closes the pmf passed as a parameter. 
+     * This must be done in a doPrivileged block.
+     */
+    public static void closePMF(final PersistenceManagerFactory PMF) {
+        if (PMF != null) {
+            if (!PMF.isClosed()) {
+                AccessController.doPrivileged(
+                    new PrivilegedAction () {
+                        public Object run () {
+                            PMF.close();
+                            return null;
+                        }
+                    }
+                );
+            }
+        }
+    }
+
+
     /** */
     protected static PersistenceManager[] getFailedPersistenceManagers(
         String assertionFailure, JDOException ex) {

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java
Fri Jul 11 17:20:16 2008
@@ -62,7 +62,7 @@
     public void test() {
         try {
             pmf = getPMF();
-            pmf.close();
+            closePMF(pmf); // don't use closePMF() because that sets pmf to null
             pm = pmf.getPersistenceManager();
             fail(ASSERTION_FAILED,
                 "pmf.getPersistenceManager should throw JDOUserException if pmf is closed.");

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java
Fri Jul 11 17:20:16 2008
@@ -102,7 +102,7 @@
         };
        
         pmf = getPMF();
-        pmf.close();
+        closePMF(pmf); // don't use closePMF() because that sets pmf to null
         // each set method should throw an exception
         Collection setCollection = Arrays.asList(setMethods);
         for (Iterator it = setCollection.iterator(); it.hasNext();) {

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
Fri Jul 11 17:20:16 2008
@@ -63,7 +63,7 @@
                      "PMF.isClosed() returned true on an open pmf");
             }
         
-            pmf.close();
+            closePMF(pmf); // don't use closePMF() because that sets pmf to null
             
             if (!pmf.isClosed()) {
                 fail(ASSERTION_FAILED,

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java
Fri Jul 11 17:20:16 2008
@@ -82,7 +82,7 @@
             pm1.currentTransaction().begin();
             pm1.currentTransaction().commit();
             pm2.currentTransaction().begin();
-            pmf.close();
+            closePMF(pmf); // don't use closePMF() because that sets pmf to null
             setAborted();
             fail(ASSERTION_FAILED,
                  "Close incorrectly succeeded with active transaction");
@@ -127,7 +127,7 @@
         if (!isAborted()) {
             try {
                 pm2.currentTransaction().commit();
-                pmf.close();
+                closePMF(pmf); // don't use closePMF() because that sets pmf to null
                 if (!pm1.isClosed()){
                     fail(ASSERTION_FAILED,
                          "Unexpected pm1 is not closed.");
@@ -147,7 +147,7 @@
     /** */
     protected void cleanupPMF(PersistenceManagerFactory pmf) {
         try {
-            pmf.close();
+            closePMF(pmf); // don't use closePMF() because that sets pmf to null
         } catch (JDOException ex) {
             PersistenceManager[] pms = getFailedPersistenceManagers(ex);
             int numberOfPersistenceManagers = pms.length;

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java
Fri Jul 11 17:20:16 2008
@@ -61,9 +61,8 @@
         try {
             System.setSecurityManager(new MySecurityManager());
         } catch (SecurityException se) {
-            fail(ASSERTION_FAILED,
-                "SecurityManager already set, setSecurityManager throws " +
-                se.toString());
+            // running with the TCK SecurityManager; don't run this test
+            return;
         }
 
         try {

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java
Fri Jul 11 17:20:16 2008
@@ -156,7 +156,7 @@
             fail(ASSERTION_FAILED,
                     "PMF.isClosed() returned true on an open pmf");
         }
-        privatePmf.close();
+        closePMF(privatePmf);
         // have next invocation of getPMF() get a new pmf
         privatePmf = null;
     }
@@ -171,7 +171,7 @@
 
         makePersistent();
 
-        privatePmf.close();
+        closePMF(privatePmf);
         if (!privatePmf.isClosed()) {
             fail(ASSERTION_FAILED,
                     "PMF.isClosed() returned false on a closed pmf");

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java?rev=676106&r1=676105&r2=676106&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java
Fri Jul 11 17:20:16 2008
@@ -121,7 +121,7 @@
         }
         makePersistent();
 
-        pmf.close();
+        closePMF(pmf); // don't use closePMF() because that sets pmf to null
 
         if (!pmf.isClosed()) {
             fail(ASSERTION_FAILED,



Mime
View raw message