ENH: backdoor to disable @Transactional during unit testing (#1756)

This commit is contained in:
André Camilo
2019-07-16 23:09:04 +12:00
committed by Rob Bygrave
parent 945175c533
commit f77388738b
2 changed files with 31 additions and 2 deletions
@@ -2,6 +2,7 @@ package io.ebeaninternal.api;
import io.ebean.Ebean;
import io.ebean.TxScope;
import org.junit.Assert;
import org.junit.Test;
import org.tests.model.basic.Contact;
import org.tests.model.basic.Customer;
@@ -33,4 +34,17 @@ public class HelpScopeTransTest {
HelpScopeTrans.exit(null, 1);
}
@Test
public void disableTransaction() {
HelpScopeTrans.setEnabled(false);
try {
HelpScopeTrans.enter(TxScope.required());
Assert.assertNull(Ebean.getDefaultServer().currentTransaction());
HelpScopeTrans.exit(null, 1);
} finally {
HelpScopeTrans.setEnabled(true);
}
}
}