Skip to content

Commit

Permalink
JBPM-4557 JbpmBpmn2TestCase.tearDownClass method fix. Transactions we…
Browse files Browse the repository at this point in the history
…re rolled back after data source was freed and server stopped.
  • Loading branch information
Tibor Zimanyi authored and mswiderski committed Feb 17, 2015
1 parent 41e91cc commit 9199992
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/JbpmBpmn2TestCase.java
Expand Up @@ -251,16 +251,7 @@ public void clear() {
@AfterClass
public static void tearDownClass() throws Exception {
if (setupDataSource) {
if (ds != null) {
try {
ds.close();
} catch (Exception ex) {
// ignore
}
ds = null;
}
server.stop();
DeleteDbFiles.execute("~", "jbpm-db", true);
String runningTransactionStatus = null;

// Clean up possible transactions
Transaction tx = TransactionManagerServices.getTransactionManager()
Expand All @@ -275,12 +266,10 @@ public static void tearDownClass() throws Exception {
} catch (Throwable t) {
// do nothing..
}
Assert.fail("Transaction had status "
+ txStateName[testTxState]
+ " at the end of the test.");
runningTransactionStatus = txStateName[testTxState];
}
}

if (emf != null) {
try {
emf.close();
Expand All @@ -289,6 +278,24 @@ public static void tearDownClass() throws Exception {
}
emf = null;
}

// If everything is closed, close data source and stop server.
if (ds != null) {
try {
ds.close();
} catch (Exception ex) {
// ignore
}
ds = null;
}
server.stop();
DeleteDbFiles.execute("~", "jbpm-db", true);

if (runningTransactionStatus != null) {
Assert.fail("Transaction had status "
+ runningTransactionStatus
+ " at the end of the test.");
}
}
}

Expand Down

0 comments on commit 9199992

Please sign in to comment.