db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mz...@apache.org
Subject svn commit: r389307 - /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
Date Mon, 27 Mar 2006 22:16:43 GMT
Author: mzaun
Date: Mon Mar 27 14:16:41 2006
New Revision: 389307

URL: http://svn.apache.org/viewcvs?rev=389307&view=rev
Log:
JDO-189 - Extended test for PMF.isClosed()

Modified:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java?rev=389307&r1=389306&r2=389307&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
(original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
Mon Mar 27 14:16:41 2006
@@ -27,10 +27,12 @@
  *<BR>
  *<B>Keywords:</B> persistencemanagerfactory
  *<BR>
- *<B>Assertion IDs:</B> A11.4-2
+ *<B>Assertion IDs:</B> A11.4-2, A11.4-10
  *<BR>
  *<B>Assertion Description: </B>
  * PersistenceManagerFactory.close() closes this PersistenceManagerFactory.
+ *<B>Assertion Description: </B>
+ * PersistenceManagerFactory.isClosed(); Return true if this PersistenceManagerFactory is
closed; and false otherwise.
  */
 
 
@@ -38,8 +40,8 @@
     
     /** */
     private static final String ASSERTION_FAILED = 
-        "Assertions A11.4-2 (Close) failed: ";
-    
+        "Assertions A11.4-2 (Close), A11.4-10 (isClosed) failed: ";
+
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -52,8 +54,31 @@
     /** */
     public void test() {
         pmf = getPMF();
-        pmf.close();
-        //check that pmf is really closed by trying to get a getPersistenceManager
+
+        // check pmf.isClosed() before and after pmf.close()
+        try {
+            if (pmf.isClosed()) {
+                fail(ASSERTION_FAILED,
+                     "PMF.isClosed() returned true on an open pmf");
+            }
+        
+            pmf.close();
+            
+            if (!pmf.isClosed()) {
+                fail(ASSERTION_FAILED,
+                     "PMF.isClosed() returned false on a closed pmf");
+            }
+        } catch (JDOUserException ex) {
+            // unexpected exception
+            fail(ASSERTION_FAILED, 
+                 "Unexpected exception at pmf.close()/isClosed(): " + ex);
+        } catch (JDOFatalUserException ex) {
+            // unexpected exception
+            fail(ASSERTION_FAILED, 
+                 "Unexpected exception at pmf.close()/isClosed(): " + ex);
+        }
+        
+        // trying to get a getPersistenceManager should result in a exception
         try {
             pm = pmf.getPersistenceManager();
             fail(ASSERTION_FAILED,
@@ -69,5 +94,8 @@
                 "Wrong exception thrown from getPersistenceManager after close.\n" +
                     "Expected JDOUserException, got JDOFatalUserException.");
         }
+
+        // have next invocation of getPMF() get a new pmf
+        pmf = null;
     }
 }



Mime
View raw message