mirror of https://github.com/apache/openjpa.git
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.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@603119 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c00f3b5b78
commit
265be5d1bd
|
@ -29,6 +29,7 @@ import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.Persistence;
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestResult;
|
||||||
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
||||||
import org.apache.openjpa.kernel.Broker;
|
import org.apache.openjpa.kernel.Broker;
|
||||||
import org.apache.openjpa.meta.ClassMetaData;
|
import org.apache.openjpa.meta.ClassMetaData;
|
||||||
|
@ -47,6 +48,11 @@ public abstract class PersistenceTestCase
|
||||||
*/
|
*/
|
||||||
protected static final Object CLEAR_TABLES = new Object();
|
protected static final Object CLEAR_TABLES = new Object();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link TestResult} instance for the current test run.
|
||||||
|
*/
|
||||||
|
private TestResult testResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an entity manager factory. Put {@link #CLEAR_TABLES} in
|
* Create an entity manager factory. Put {@link #CLEAR_TABLES} in
|
||||||
* this list to tell the test framework to delete all table contents
|
* this list to tell the test framework to delete all table contents
|
||||||
|
@ -110,8 +116,22 @@ public abstract class PersistenceTestCase
|
||||||
createEntityManagerFactory(pu, map);
|
createEntityManagerFactory(pu, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(TestResult testResult) {
|
||||||
|
this.testResult = testResult;
|
||||||
|
super.run(testResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void tearDown() throws Exception {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue