FileDocCategorySizeDatePackage
TesterBean.javaAPI DocJBoss 4.2.14232Fri Jul 13 20:53:30 BST 2007org.jboss.ejb3.test.bmt

TesterBean

public class TesterBean extends Object implements TesterRemote
Comment
author
Bill Burke
version
$Revision: 60233 $

Fields Summary
StatelessLocal
stateless
TransactionManager
tm
protected static Logger
log
Constructors Summary
Methods Summary
StatefulLocalgetStateful()

      InitialContext ctx = new InitialContext();
      return (StatefulLocal)ctx.lookup("StatefulBean/local");
   
public voidtestStatefulWithTx()

      StatefulLocal stateful = getStateful();
      Transaction tx = stateful.beginNoEnd();
      stateful.endCommit(tx);
      tx = stateful.beginNoEnd();
      stateful.endRollback(tx);

      stateful.beginCommitEnd();
      stateful.beginRollbackEnd();

   
public voidtestStatefulWithoutTx()

      StatefulLocal stateful = getStateful();
      Transaction tx = stateful.beginNoEnd();
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");
      stateful.endCommit(tx);
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");
      tx = stateful.beginNoEnd();
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");
      stateful.endRollback(tx);
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");

      stateful.beginCommitEnd();
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");
      stateful.beginRollbackEnd();
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");

   
public voidtestStatelessWithTx()


       
   
      stateless.beginCommitEnd();
      stateless.beginRollbackEnd();

      try
      {
         stateless.beginNoEnd();
      }
      catch (Exception e)
      {
         if (e instanceof TestException) throw e;
         log.info("should be EJBException thrown that begin and no end was called: ", e);
      }
   
public voidtestStatelessWithoutTx()

      stateless.beginCommitEnd();
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");
      stateless.beginRollbackEnd();
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");

      try
      {
         stateless.beginNoEnd();
      }
      catch (Exception e)
      {
         if (e instanceof TestException) throw e;
         log.info("should be EJBException thrown that begin and no end was called: ", e);
      }
      if (tm.getTransaction() != null) throw new RuntimeException("tx is associated");