/**
  * Tests that an {@link javax.ejb.ApplicationException} thrown by a SLSB method is returned back
  * to the client correctly
  *
  * @throws Exception
  */
 @Test
 public void testApplicationExceptionOnSLSBMethod() throws Exception {
   final StatelessEJBLocator<ExceptionThrowingRemote> locator =
       new StatelessEJBLocator<ExceptionThrowingRemote>(
           ExceptionThrowingRemote.class,
           APP_NAME,
           MODULE_NAME,
           ExceptionThrowingBean.class.getSimpleName(),
           "");
   final ExceptionThrowingRemote exceptionThrowingBean = EJBClient.createProxy(locator);
   Assert.assertNotNull("Received a null proxy", exceptionThrowingBean);
   final String exceptionState = "2342348723Dsbjlfjal#";
   try {
     exceptionThrowingBean.alwaysThrowApplicationException(exceptionState);
     Assert.fail("Expected a " + StatefulApplicationException.class.getName() + " exception");
   } catch (StatefulApplicationException sae) {
     // expected
     logger.info("Received the expected exception", sae);
     Assert.assertEquals(
         "Unexpected state in the application exception", exceptionState, sae.getState());
   }
 }
 /**
  * Tests that a system exception thrown from a SLSB method is conveyed back to the client
  *
  * @throws Exception
  */
 @Test
 public void testSystemExceptionOnSLSBMethod() throws Exception {
   final StatelessEJBLocator<ExceptionThrowingRemote> locator =
       new StatelessEJBLocator<ExceptionThrowingRemote>(
           ExceptionThrowingRemote.class,
           APP_NAME,
           MODULE_NAME,
           ExceptionThrowingBean.class.getSimpleName(),
           "");
   final ExceptionThrowingRemote exceptionThrowingBean = EJBClient.createProxy(locator);
   Assert.assertNotNull("Received a null proxy", exceptionThrowingBean);
   final String exceptionState = "bafasfaj;l";
   try {
     exceptionThrowingBean.alwaysThrowSystemException(exceptionState);
     Assert.fail("Expected a " + EJBException.class.getName() + " exception");
   } catch (EJBException ejbe) {
     // expected
     logger.info("Received the expected exception", ejbe);
     final Throwable cause = ejbe.getCause();
     Assert.assertTrue("Unexpected cause in EJBException", cause instanceof RuntimeException);
     Assert.assertEquals(
         "Unexpected state in the system exception", exceptionState, cause.getMessage());
   }
 }