@Test
public void testUsingClientTransaction() throws Exception {
// calls a method that starts a transaction
sfsbBeanManagedTransaction.insertTableWithoutCommitTransaction();
// gets the transaction
UserTransaction utx = TransactionHelper.getInternalUserTransaction();
// starts the transaction
utx.begin();
// makes a rollback in the bean transaction, the container
// must to resume the user transaction and execute the
// bean transaction in other transaction
sfsbBeanManagedTransaction.setRollback();
// tries to commit the transaction to avoid a nested transaction
try {
utx.commit();
} catch (Exception e) {
logger.debug("Error when the transaction made a rollback {0}", e);
}
Integer[] expected = {new Integer(Status.STATUS_COMMITTED), new Integer(Status.STATUS_NO_TRANSACTION) };
// the user transaction must be active yet.
Assert.assertEquals(new Integer(utx.getStatus()), expected,
"After the commit the transaction must be commited or not_transaction");
}