db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r385184 - in /db/jdo/trunk/tck20: maven.xml src/java/org/apache/jdo/tck/JDO_Test.java src/java/org/apache/jdo/tck/util/BatchTestRunner.java
Date Sat, 11 Mar 2006 22:41:16 GMT
Author: mbo
Date: Sat Mar 11 14:41:14 2006
New Revision: 385184

URL: http://svn.apache.org/viewcvs?rev=385184&view=rev
Log:
JDO-335: Close PMF after running each configuration unless property jdo.tck.closePMFAfterEachTest
is set to true

Modified:
    db/jdo/trunk/tck20/maven.xml
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java

Modified: db/jdo/trunk/tck20/maven.xml
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/maven.xml?rev=385184&r1=385183&r2=385184&view=diff
==============================================================================
--- db/jdo/trunk/tck20/maven.xml (original)
+++ db/jdo/trunk/tck20/maven.xml Sat Mar 11 14:41:14 2006
@@ -381,6 +381,8 @@
                          value="${jdo.tck.requiredOptions}"/>
             <sysproperty key="jdo.tck.mapping.companyfactory"
                          value="${jdo.tck.mapping.companyfactory}"/>
+            <sysproperty key="jdo.tck.closePMFAfterEachTest"
+                         value="${jdo.tck.closePMFAfterEachTest}"/>
                          
             <jvmarg line="${database.runtck.sysproperties}"/>
             <jvmarg line="${iut.runtck.sysproperties}"/>
@@ -388,6 +390,7 @@
             
             <arg line="${jdo.tck.classes}"/>
         </java>
+        <echo>Finished configuration="${jdo.tck.cfg}" with database="${jdo.tck.database}"
identitytype="${jdo.tck.identitytype}" mapping="${jdo.tck.mapping}".</echo>
     </goal>
 
     <goal name="doRuntck.jdori">
@@ -442,6 +445,8 @@
                          value="${jdo.tck.requiredOptions}"/>
             <sysproperty key="jdo.tck.mapping.companyfactory"
                          value="${jdo.tck.mapping.companyfactory}"/>
+            <sysproperty key="jdo.tck.closePMFAfterEachTest"
+                         value="${jdo.tck.closePMFAfterEachTest}"/>
                          
             <jvmarg line="${database.runtck.sysproperties}"/>
             <jvmarg line="${jdori.runtck.sysproperties}"/>
@@ -449,7 +454,7 @@
             
             <arg line="${jdo.tck.classes}"/>
         </java>
-        <echo>Finished run with database="${jdo.tck.database}" identitytype="${jdo.tck.identitytype}"
mapping="${jdo.tck.mapping}".</echo>
+        <echo>Finished configuration="${jdo.tck.cfg}" with database="${jdo.tck.database}"
identitytype="${jdo.tck.identitytype}" mapping="${jdo.tck.mapping}".</echo>
     </goal>
 
     <goal name="result">

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java?rev=385184&r1=385183&r2=385184&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java Sat Mar 11 14:41:14 2006
@@ -155,12 +155,18 @@
      */
     protected static boolean cleanupData = 
        System.getProperty("jdo.tck.cleanupaftertest", "true").equalsIgnoreCase("true");
+
+    /** Flag indicating whether to close the PMF after each test or not.
+     * It defaults to false.
+     */   
+    protected static final boolean closePMFAfterEachTest =
+        System.getProperty("jdo.tck.closePMFAfterEachTest", "false").equalsIgnoreCase("true");
     
     /** The Properties object for the PersistenceManagerFactory. */
     protected static Properties PMFPropertiesObject;
 
     /** The PersistenceManagerFactory. */
-    protected PersistenceManagerFactory pmf;
+    protected static PersistenceManagerFactory pmf;
     
     /** The PersistenceManager. */
     protected PersistenceManager pm;
@@ -261,7 +267,11 @@
      * That exception is thrown as a nested exception of <code>JDOFatalException</code>
      * if and only if the testcase executed successful.
      * Otherwise that exception is logged using fatal log level.
-     * All other exceptions are logged using fatal log level, always.
+     * All other exceptions are logged using fatal log level, always.<p>
+     * 
+     * <b>Note:</b>By default, the method tearDown does not close the pmf. 
+     *  This is done at the end of each configuration, unless the property
+     *  jdo.tck.closePMFAfterEachTest is set to true.
      */
     protected final void tearDown() {
         try {
@@ -287,11 +297,13 @@
             setTearDownThrowable("localTearDown", t);
         }
         
-        try {
-            closePMF();
-        }
-        catch (Throwable t) {
-            setTearDownThrowable("closePMF", t);
+        if (closePMFAfterEachTest) {
+            try {
+                closePMF();
+            }
+            catch (Throwable t) {
+                setTearDownThrowable("closePMF", t);
+            }
         }
         
         if (this.tearDownThrowable != null) {
@@ -473,7 +485,7 @@
     }
 
     /** Closes the pmf stored in this instance. */
-    protected void closePMF() {
+    public static void closePMF() {
         JDOException failure = null;
         while (pmf != null) {
             try {
@@ -499,7 +511,7 @@
     }
 
     /** */
-    protected PersistenceManager[] getFailedPersistenceManagers(
+    protected static PersistenceManager[] getFailedPersistenceManagers(
         String assertionFailure, JDOException ex) {
         Throwable[] nesteds = ex.getNestedExceptions();
         int numberOfExceptions = nesteds==null ? 0 : nesteds.length;
@@ -510,7 +522,7 @@
             if (exc.getFailedObject() instanceof PersistenceManager) {
                 result[i] = (PersistenceManager)failedObject;
             } else {
-                fail(assertionFailure,
+                throw new JDOFatalException(assertionFailure,
                      "Unexpected failed object of type: " +
                      failedObject.getClass().getName());
             }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java
URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java?rev=385184&r1=385183&r2=385184&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/BatchTestRunner.java Sat Mar 11 14:41:14
2006
@@ -32,6 +32,8 @@
 
 import javax.jdo.JDOFatalException;
 
+import org.apache.jdo.tck.JDO_Test;
+
 /**
  * TestRunner class for running a single test or a test suite in batch
  * mode. The format of the test output is specified by the result printer
@@ -83,6 +85,13 @@
     /** Runs the specified test and waits until the user types RETURN. */
     public static void runAndWait(Test suite) {
         new BatchTestRunner().doRun(suite, true);
+    }
+
+    /** Runs the specified test and close the pmf. */
+    public TestResult doRun(Test test) {
+        TestResult result = doRun(test, false);
+        JDO_Test.closePMF();
+        return result;
     }
 
     /** 



Mime
View raw message