Ejemplo n.º 1
0
  @Test
  public void testCMTInTxTimeout()
      throws InterruptedException, NamingException, SystemException, NotSupportedException,
          RollbackException, HeuristicRollbackException, HeuristicMixedException {
    /*
    Stateful test Bean.
       */

    UserTransaction userTransaction =
        (UserTransaction) new InitialContext().lookup("javax.transaction.UserTransaction");
    ITimeoutBean simpleTimeoutBean =
        (ITimeoutBean) new InitialContext().lookup("simpleTimeoutBean");
    userTransaction.begin();
    simpleTimeoutBean.init();
    Thread.sleep(200);
    // Initially it should  return a NoSuchEJBException immediately after the lookup but there is a
    // running transaction
    simpleTimeoutBean.ping();
    userTransaction.commit();
    // Now transaction is committed
    Thread.sleep(100);
    try {
      simpleTimeoutBean.ping();
    } catch (NoSuchEJBException e) {
      // Should return a  NoSuchEJBException immediately after the end of the transaction
      return;
    }
    Assert.fail("Timeout exceeded and call to the EJB doesn't throw a NoSuchEJBException");
  }
Ejemplo n.º 2
0
 @Test
 public void testBMTInTxTimeout() throws InterruptedException, NamingException {
   /*
    Stateful test Bean.
   */
   ITimeoutBean inTxTimeoutBean = (ITimeoutBean) new InitialContext().lookup("BMTInTxBean");
   inTxTimeoutBean.init();
   Thread.sleep(200);
   // Initially it should  return a NoSuchEJBException immediately after the lookup but there is a
   // running transaction
   inTxTimeoutBean.ping();
   // Now transaction is committed
   Thread.sleep(100);
   try {
     inTxTimeoutBean.ping();
   } catch (NoSuchEJBException e) {
     // Should return a  NoSuchEJBException immediately after the end of the transaction
     return;
   }
   Assert.fail("Timeout exceeded and call to the EJB doesn't throw a NoSuchEJBException");
 }