Files
ebean/ebean-test/src/test/java/org/tests/transaction/TestTransactionalNever.java
T
Rob Bygrave ff43672f4e Move source to Jakarta (use ./jakarta-to-javax.sh)
Moving the master branch to use jakarta based code and
dependencies. Change to use ./jakarta-to-javax.sh to convert
back to javax when releasing that.
2023-09-11 23:31:01 +12:00

50 lines
1.1 KiB
Java

package org.tests.transaction;
import io.ebean.xtest.BaseTestCase;
import io.ebean.DB;
import io.ebean.Transaction;
import io.ebean.annotation.Transactional;
import io.ebean.annotation.TxType;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.persistence.PersistenceException;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class TestTransactionalNever extends BaseTestCase {
private static final Logger log = LoggerFactory.getLogger(TestTransactionalNever.class);
private Transaction outerTxn;
@Test
public void testWithNever() {
new SomeTransactionalWithNever().doStuff();
}
@Test
public void testBarfOnExisting() {
assertThrows(PersistenceException.class, this::doWithTransaction);
}
class SomeTransactionalWithNever {
@Transactional(type = TxType.NEVER)
void doStuff() {
outerTxn = DB.currentTransaction();
log.info("currentTransaction ...{}", outerTxn);
}
}
@Transactional
private void doWithTransaction() {
// always barf
new SomeTransactionalWithNever().doStuff();
}
}