use of javax.ejb.EJBException in project wildfly by wildfly.
the class EjbTransactionDescriptorTestCase method testLocalMethodHasNever.
@Test
public void testLocalMethodHasNever() throws SystemException, NotSupportedException, NamingException {
final UserTransaction userTransaction = (UserTransaction) new InitialContext().lookup("java:jboss/UserTransaction");
final TransactionLocal bean = (TransactionLocal) initialContext.lookup("java:module/" + DescriptorBean.class.getSimpleName() + "!" + TransactionLocal.class.getName());
Assert.assertEquals(Status.STATUS_NO_TRANSACTION, bean.transactionStatus());
try {
userTransaction.begin();
bean.transactionStatus();
throw new RuntimeException("Expected an exception");
} catch (EJBException e) {
//ignore
} finally {
userTransaction.rollback();
}
}
use of javax.ejb.EJBException in project wildfly by wildfly.
the class EarModulesPPTestCase method checkPropertyEjb.
/**
* Checks access to a system property on the server using EJB.
*
* @param moduleName
* @param propertyName
* @param exceptionExpected
* @param expectedValue
* @throws Exception
*/
private void checkPropertyEjb(final String moduleName, final String propertyName, final boolean exceptionExpected, final String expectedValue) throws Exception {
LOGGER.debug("Checking if '" + propertyName + "' property is available");
ReadSystemPropertyRemote bean = lookupEjb(moduleName, EJBAPP_BASE_NAME + moduleName, ReadSystemPropertyBean.class.getSimpleName(), ReadSystemPropertyRemote.class);
assertNotNull(bean);
Exception ex = null;
String propertyValue = null;
try {
propertyValue = bean.readSystemProperty(propertyName);
} catch (Exception e) {
ex = e;
}
if (ex instanceof EJBException && ex.getCause() instanceof AccessControlException) {
assertTrue("AccessControlException came, but it was not expected", exceptionExpected);
} else if (ex != null) {
throw ex;
} else if (exceptionExpected) {
fail("AccessControlException was expected");
}
if (ex == null && expectedValue != null) {
assertEquals("System property value doesn't match the expected one.", expectedValue, propertyValue);
}
}
use of javax.ejb.EJBException in project wildfly by wildfly.
the class RemoteLocalCallProfileTestCase method testStatefulLocalFromRemote.
@Test
@OperateOnDeployment("client")
public void testStatefulLocalFromRemote(@ArquillianResource InitialContext ctx) throws Exception {
InitialContext jndiContext = new InitialContext();
StatelessRemote bean = (StatelessRemote) jndiContext.lookup("java:module/" + StatelessBean.class.getSimpleName() + "!" + StatelessRemote.class.getName());
Assert.assertNotNull(bean);
try {
bean.localCall();
Assert.fail("should not be allowed to call local interface remotely");
} catch (EJBException e) {
// it's OK
} catch (Exception ee) {
if (!(ee.getCause() instanceof EJBException)) {
Assert.fail("should be " + EJBException.class.getName());
}
}
}
use of javax.ejb.EJBException in project wildfly by wildfly.
the class RemoteLocalCallTestCase method testStatefulLocalFromRemote.
@Test
@OperateOnDeployment("client")
public void testStatefulLocalFromRemote(@ArquillianResource InitialContext ctx) throws Exception {
InitialContext jndiContext = new InitialContext();
StatelessRemote bean = (StatelessRemote) jndiContext.lookup("java:module/" + StatelessBean.class.getSimpleName() + "!" + StatelessRemote.class.getName());
Assert.assertNotNull(bean);
try {
bean.localCall();
Assert.fail("should not be allowed to call local interface remotely");
} catch (EJBException e) {
// it's OK
} catch (Exception ee) {
if (!(ee.getCause() instanceof EJBException)) {
Assert.fail("should be " + EJBException.class.getName());
}
}
}
use of javax.ejb.EJBException in project wildfly by wildfly.
the class RemoteLocalCallTestCase method testStatefulLocalHomeFromRemoteHome.
@Test
@OperateOnDeployment("client")
public void testStatefulLocalHomeFromRemoteHome(@ArquillianResource InitialContext ctx) throws Exception {
InitialContext jndiContext = new InitialContext();
StatelessRemoteHome home = (StatelessRemoteHome) jndiContext.lookup("java:module/" + StatelessBean.class.getSimpleName() + "!" + StatelessRemoteHome.class.getName());
StatelessRemote bean = home.create();
Assert.assertNotNull(bean);
try {
bean.localHomeCall();
Assert.fail("should not be allowed to call local interface remotely");
} catch (EJBException e) {
// it's OK
} catch (Exception ee) {
if (!(ee.getCause() instanceof EJBException)) {
Assert.fail("should be " + EJBException.class.getName());
}
}
}
Aggregations