use of javax.ejb.EJBTransactionRequiredException in project wildfly by wildfly.
the class EjbTransactionDescriptorTestCase method testRemoteMethodHasMandatory.
@Test
public void testRemoteMethodHasMandatory() throws SystemException, NotSupportedException, NamingException {
final UserTransaction userTransaction = (UserTransaction) new InitialContext().lookup("java:jboss/UserTransaction");
final TransactionRemote bean = (TransactionRemote) initialContext.lookup("java:module/" + DescriptorBean.class.getSimpleName() + "!" + TransactionRemote.class.getName());
userTransaction.begin();
try {
Assert.assertEquals(Status.STATUS_ACTIVE, bean.transactionStatus());
} finally {
userTransaction.rollback();
}
try {
bean.transactionStatus();
throw new RuntimeException("Expected an exception");
} catch (EJBTransactionRequiredException e) {
//ignore
}
}
use of javax.ejb.EJBTransactionRequiredException in project Payara by payara.
the class SafeProperties method mapLocal3xException.
private Throwable mapLocal3xException(Throwable t) {
Throwable mappedException = null;
if (t instanceof TransactionRolledbackLocalException) {
mappedException = new EJBTransactionRolledbackException();
mappedException.initCause(t);
} else if (t instanceof TransactionRequiredLocalException) {
mappedException = new EJBTransactionRequiredException();
mappedException.initCause(t);
} else if (t instanceof NoSuchObjectLocalException) {
mappedException = new NoSuchEJBException();
mappedException.initCause(t);
} else if (t instanceof AccessLocalException) {
mappedException = new EJBAccessException();
mappedException.initCause(t);
}
return (mappedException != null) ? mappedException : t;
}
use of javax.ejb.EJBTransactionRequiredException in project wildfly by wildfly.
the class EjbTransactionDescriptorTestCase method testRemoteMethodHasMandatoryNoMethodIntf.
@Test
public void testRemoteMethodHasMandatoryNoMethodIntf() throws SystemException, NotSupportedException, NamingException {
final UserTransaction userTransaction = (UserTransaction) new InitialContext().lookup("java:jboss/UserTransaction");
final TransactionRemote bean = (TransactionRemote) initialContext.lookup("java:module/" + DescriptorBean.class.getSimpleName() + "!" + TransactionRemote.class.getName());
userTransaction.begin();
try {
Assert.assertEquals(Status.STATUS_ACTIVE, bean.transactionStatus2());
} finally {
userTransaction.rollback();
}
try {
bean.transactionStatus2();
throw new RuntimeException("Expected an exception");
} catch (EJBTransactionRequiredException e) {
//ignore
}
}
Aggregations