Package io.ebean.test
Class ForTests
- java.lang.Object
-
- io.ebean.test.ForTests
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForTests.RollbackAllA wrapping transaction used in test code to rollback all changes.
-
Constructor Summary
Constructors Constructor Description ForTests()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ForTests.RollbackAllcreateRollbackAll()Create and return a RollbackAll which should be closed at the end of the test(s).static voidenableTransactional(boolean enable)Enable or disable@Transactionalmethods.static voidnoTransactional(Runnable run)Run the closure with@Transactionalmethods effectively disabled (they won't create/commit transactions).static voidrollbackAll(Runnable run)All transactions started in the closure are effectively rolled back.
-
-
-
Constructor Detail
-
ForTests
public ForTests()
-
-
Method Detail
-
enableTransactional
public static void enableTransactional(boolean enable)
Enable or disable@Transactionalmethods.This is intended for testing purposes such that tests on code with
@Transactionalmethods don't actually start or complete transactions.- Parameters:
enable- Set false to disable@Transactionalmethods
-
noTransactional
public static void noTransactional(Runnable run)
Run the closure with@Transactionalmethods effectively disabled (they won't create/commit transactions).
-
rollbackAll
public static void rollbackAll(Runnable run)
All transactions started in the closure are effectively rolled back.This creates a wrapping transaction that uses
Transaction.setNestedUseSavepoint(). All nested transactions are created as savepoints. On completion the wrapping transaction is rolled back.- Parameters:
run- Closure that runs such that all the transactions are rolled back.
-
createRollbackAll
public static ForTests.RollbackAll createRollbackAll()
Create and return a RollbackAll which should be closed at the end of the test(s).In tests for
@Beforewe create the rollbackAll and on@Afterweclose()it effectively rolling back all changes made during test execution.{@code private ForTests.RollbackAll rollbackAll;
-
-