com.mockrunner.mock.ejb
Class MockUserTransaction

java.lang.Object
  extended by com.mockrunner.mock.ejb.MockUserTransaction
All Implemented Interfaces:
javax.transaction.UserTransaction

public class MockUserTransaction
extends java.lang.Object
implements javax.transaction.UserTransaction

Mock implementation of UserTransaction.


Constructor Summary
MockUserTransaction()
           
 
Method Summary
 void begin()
          Starts the transaction.
 void commit()
          Commits the transaction.
 int getNumberBeginCalls()
          Returns the number of overall begin() calls.
 int getNumberCommitCalls()
          Returns the number of overall commit() calls.
 int getNumberRollbackCalls()
          Returns the number of overall rollback() calls.
 int getNumberRollbackOnlyCalls()
          Returns the number of overall setRollbackOnly() calls.
 int getStatus()
          Returns the status of this transaction.
 int getTransactionTimeout()
          Returns the transaction timeout.
 void reset()
          Resets the state, i.e. sets the status to Status.STATUS_NO_TRANSACTION and the number of calls to 0.
 void rollback()
          Rolls back the transaction.
 void setRollbackOnly()
          Sets the rollback only flag.
 void setTransactionTimeout(int timeout)
          Sets the transaction timeout.
 boolean wasBeginCalled()
          Returns if begin() was called.
 boolean wasCommitCalled()
          Returns if commit() was called.
 boolean wasRollbackCalled()
          Returns if rollback() was called.
 boolean wasRollbackOnlyCalled()
          Returns if setRollbackOnly() was called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockUserTransaction

public MockUserTransaction()
Method Detail

reset

public void reset()
Resets the state, i.e. sets the status to Status.STATUS_NO_TRANSACTION and the number of calls to 0.


wasBeginCalled

public boolean wasBeginCalled()
Returns if begin() was called.

Returns:
was begin() called

wasCommitCalled

public boolean wasCommitCalled()
Returns if commit() was called.

Returns:
was commit() called

wasRollbackCalled

public boolean wasRollbackCalled()
Returns if rollback() was called.

Returns:
was rollback() called

wasRollbackOnlyCalled

public boolean wasRollbackOnlyCalled()
Returns if setRollbackOnly() was called.

Returns:
was setRollbackOnly() called

getTransactionTimeout

public int getTransactionTimeout()
Returns the transaction timeout.

Returns:
the transaction timeout

getNumberBeginCalls

public int getNumberBeginCalls()
Returns the number of overall begin() calls.

Returns:
the number of overall begin() calls

getNumberCommitCalls

public int getNumberCommitCalls()
Returns the number of overall commit() calls.

Returns:
the number of overall commit() calls

getNumberRollbackCalls

public int getNumberRollbackCalls()
Returns the number of overall rollback() calls.

Returns:
the number of overall rollback() calls

getNumberRollbackOnlyCalls

public int getNumberRollbackOnlyCalls()
Returns the number of overall setRollbackOnly() calls.

Returns:
the number of overall setRollbackOnly() calls

getStatus

public int getStatus()
              throws javax.transaction.SystemException
Returns the status of this transaction.

Specified by:
getStatus in interface javax.transaction.UserTransaction
Returns:
the status of this transaction
Throws:
javax.transaction.SystemException

begin

public void begin()
           throws javax.transaction.NotSupportedException,
                  javax.transaction.SystemException
Starts the transaction. The status will be Status.STATUS_ACTIVE and the flags regarding wasXYZCalled are reset to false. This method does not reset the number of overall calls.

Specified by:
begin in interface javax.transaction.UserTransaction
Throws:
javax.transaction.NotSupportedException
javax.transaction.SystemException

commit

public void commit()
            throws javax.transaction.RollbackException,
                   javax.transaction.HeuristicMixedException,
                   javax.transaction.HeuristicRollbackException,
                   java.lang.SecurityException,
                   java.lang.IllegalStateException,
                   javax.transaction.SystemException
Commits the transaction.

Specified by:
commit in interface javax.transaction.UserTransaction
Throws:
javax.transaction.RollbackException
javax.transaction.HeuristicMixedException
javax.transaction.HeuristicRollbackException
java.lang.SecurityException
java.lang.IllegalStateException
javax.transaction.SystemException

rollback

public void rollback()
              throws java.lang.IllegalStateException,
                     java.lang.SecurityException,
                     javax.transaction.SystemException
Rolls back the transaction.

Specified by:
rollback in interface javax.transaction.UserTransaction
Throws:
java.lang.IllegalStateException
java.lang.SecurityException
javax.transaction.SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws java.lang.IllegalStateException,
                            javax.transaction.SystemException
Sets the rollback only flag.

Specified by:
setRollbackOnly in interface javax.transaction.UserTransaction
Throws:
java.lang.IllegalStateException
javax.transaction.SystemException

setTransactionTimeout

public void setTransactionTimeout(int timeout)
                           throws javax.transaction.SystemException
Sets the transaction timeout.

Specified by:
setTransactionTimeout in interface javax.transaction.UserTransaction
Parameters:
timeout - the transaction timeout
Throws:
javax.transaction.SystemException