Author: pcl
Date: Mon Dec 10 18:15:28 2007
New Revision: 603119
URL: http://svn.apache.org/viewvc?rev=603119&view=rev
Log:
Tweak test case to report original error instead of cleanup error in the case
where a test case failed and put things in a state that prevents cleanup from
succeeding.
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
Modified:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java?rev=603119&r1=603118&r2=603119&view=diff
==============================================================================
---
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
(original)
+++
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/PersistenceTestCase.java
Mon Dec 10 18:15:28 2007
@@ -29,6 +29,7 @@
import javax.persistence.Persistence;
import junit.framework.TestCase;
+import junit.framework.TestResult;
import org.apache.openjpa.kernel.AbstractBrokerFactory;
import org.apache.openjpa.kernel.Broker;
import org.apache.openjpa.meta.ClassMetaData;
@@ -48,6 +49,11 @@
protected static final Object CLEAR_TABLES = new Object();
/**
+ * The [EMAIL PROTECTED] TestResult} instance for the current test run.
+ */
+ private TestResult testResult;
+
+ /**
* Create an entity manager factory. Put [EMAIL PROTECTED] #CLEAR_TABLES}
in
* this list to tell the test framework to delete all table contents
* before running the tests.
@@ -110,8 +116,22 @@
createEntityManagerFactory(pu, map);
}
+ @Override
+ public void run(TestResult testResult) {
+ this.testResult = testResult;
+ super.run(testResult);
+ }
+
+ @Override
public void tearDown() throws Exception {
- super.tearDown();
+ try {
+ super.tearDown();
+ } catch (Exception e) {
+ // if a test failed, swallow any exceptions that happen
+ // during tear-down, as these just mask the original problem.
+ if (testResult.wasSuccessful())
+ throw e;
+ }
}
/**