mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
initial add of EbeanORM server based on v2.8.1
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.avaje.tests.lib;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestResult;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.Transaction;
|
||||
|
||||
/**
|
||||
* The base class for all Ebean test to get access to the Ebean server and do
|
||||
* some cleanup stuff after a test has run
|
||||
*/
|
||||
public abstract class EbeanTestCase extends TestCase {
|
||||
|
||||
@Override
|
||||
public void run(TestResult testResult) {
|
||||
try {
|
||||
super.run(testResult);
|
||||
} finally {
|
||||
Transaction tx = getServer().currentTransaction();
|
||||
if (tx != null && tx.isActive()) {
|
||||
// transaction left running after the test, rollback it to make
|
||||
// the environment ready for the next test
|
||||
tx.rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EbeanServer getServer() {
|
||||
|
||||
return Ebean.getServer(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user