Hi,

please find the second patch for JDO-58 attached.

This patch includes the check on an open PMF instance when TCK tests have added tear down instances and/or classes.

Furthermore, it renames 2 methods and two fields:

1) method deleteRemoveTearDownInstances -> deleteTearDownInstances
2) method deleteRemoveTearDownClasses -> deleteTearDownClasses
3) field oids -> tearDownInstances
4) field pcClasses -> tearDownClasses

Regards,
Michael
--
-------------------------------------------------------------------
Michael Watzek                  [EMAIL PROTECTED] Engineering GmbH
mailto:[EMAIL PROTECTED]        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------
Index: test/java/org/apache/jdo/tck/JDO_Test.java
===================================================================
--- test/java/org/apache/jdo/tck/JDO_Test.java  (revision 179392)
+++ test/java/org/apache/jdo/tck/JDO_Test.java  (working copy)
@@ -145,13 +145,13 @@
      * A list of registered oid instances. 
      * Corresponding pc instances are deleted in <code>localTearDown</code>.
      */
-    private Collection oids = new LinkedList();
+    private Collection tearDownInstances = new LinkedList();
     
     /** 
      * A list of registered pc classes. 
      * Th extents of these classes are deleted in <code>localTearDown</code>.
      */
-    private Collection pcClasses = new LinkedList();
+    private Collection tearDownClasses = new LinkedList();
     
     /** */
     protected JDO_Test() {
@@ -233,6 +233,10 @@
             setTearDownThrowable("cleanupPM", t);
         }
         
+        if ((pmf == null || pmf.isClosed()) && 
+            (this.tearDownInstances.size() > 0 || this.tearDownClasses.size() 
> 0))
+            throw new JDOFatalException ("PMF must not be nullified or closed 
when tear down instances and /or classes have been added.");
+        
         if (pmf != null && pmf.isClosed())
             pmf = null;
         
@@ -266,8 +270,8 @@
      * that they have allocated in method <code>localSetUp</code>.
      */
     protected void localTearDown() {
-        deleteRemoveTearDownInstances();
-        deleteRemoveTearDownClasses();
+        deleteTearDownInstances();
+        deleteTearDownClasses();
     }
 
     protected void addTearDownObjectId(Object oid) {
@@ -275,7 +279,7 @@
         if (JDOHelper.getObjectId(oid) != null ||
             JDOHelper.isTransactional(oid))
             throw new IllegalArgumentException("oid");
-        this.oids.add(oid);
+        this.tearDownInstances.add(oid);
     }
     
     protected void addTearDownInstance(Object pc) {
@@ -284,7 +288,7 @@
     }
     
     protected void addTearDownClass(Class pcClass) {
-        this.pcClasses.add(pcClass);
+        this.tearDownClasses.add(pcClass);
     }
     
     protected void addTearDownClass(Class[] pcClasses) {
@@ -302,12 +306,12 @@
      * exactly in the order they have been added.
      * Tear down instances are deleted in a separate transaction.
      */
-    protected void deleteRemoveTearDownInstances() {
-        if (this.oids.size() > 0) {
+    protected void deleteTearDownInstances() {
+        if (this.tearDownInstances.size() > 0) {
             getPM();
             try {
                 this.pm.currentTransaction().begin();
-                for (Iterator i = this.oids.iterator(); i.hasNext(); ) {
+                for (Iterator i = this.tearDownInstances.iterator(); 
i.hasNext(); ) {
                     Object pc;
                     try {
                         pc = this.pm.getObjectById(i.next(), true);
@@ -324,7 +328,7 @@
                 this.pm.currentTransaction().commit();
             }
             finally {
-                this.oids.clear();
+                this.tearDownInstances.clear();
                 cleanupPM();
             }
         }
@@ -339,18 +343,18 @@
      * Tear down classes are deleted in a separate transaction.
      * Deleting a tear down class means to delete the extent.
      */
-    protected void deleteRemoveTearDownClasses() {
-        if (this.pcClasses.size() > 0) {
+    protected void deleteTearDownClasses() {
+        if (this.tearDownClasses.size() > 0) {
             getPM();
             try {
                 this.pm.currentTransaction().begin();
-                for (Iterator i = this.pcClasses.iterator(); i.hasNext(); ) {
+                for (Iterator i = this.tearDownClasses.iterator(); 
i.hasNext(); ) {
                     this.pm.deletePersistentAll(getAllObjects(this.pm, 
(Class)i.next()));
                 }
                 this.pm.currentTransaction().commit();
             }
             finally {
-                this.pcClasses.clear();
+                this.tearDownClasses.clear();
                 cleanupPM();
             }
         }

Reply via email to