public class MockUserTransaction
extends java.lang.Object
implements javax.transaction.UserTransaction
UserTransaction
.Constructor and Description |
---|
MockUserTransaction() |
Modifier and Type | Method and Description |
---|---|
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.
|
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. |
public void reset()
Status.STATUS_NO_TRANSACTION
and the number of calls to 0.public boolean wasBeginCalled()
begin()
was called.begin()
calledpublic boolean wasCommitCalled()
commit()
was called.commit()
calledpublic boolean wasRollbackCalled()
rollback()
was called.rollback()
calledpublic boolean wasRollbackOnlyCalled()
setRollbackOnly()
was called.setRollbackOnly()
calledpublic int getTransactionTimeout()
public int getNumberBeginCalls()
begin()
calls.begin()
callspublic int getNumberCommitCalls()
commit()
calls.commit()
callspublic int getNumberRollbackCalls()
rollback()
calls.rollback()
callspublic int getNumberRollbackOnlyCalls()
setRollbackOnly()
calls.setRollbackOnly()
callspublic int getStatus() throws javax.transaction.SystemException
getStatus
in interface javax.transaction.UserTransaction
javax.transaction.SystemException
public void begin() throws javax.transaction.NotSupportedException, javax.transaction.SystemException
Status.STATUS_ACTIVE
and the
flags regarding wasXYZCalled
are reset to false
. This method
does not reset the number of overall calls.begin
in interface javax.transaction.UserTransaction
javax.transaction.NotSupportedException
javax.transaction.SystemException
public void commit() throws javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, java.lang.IllegalStateException, javax.transaction.SystemException
commit
in interface javax.transaction.UserTransaction
javax.transaction.RollbackException
javax.transaction.HeuristicMixedException
javax.transaction.HeuristicRollbackException
java.lang.SecurityException
java.lang.IllegalStateException
javax.transaction.SystemException
public void rollback() throws java.lang.IllegalStateException, java.lang.SecurityException, javax.transaction.SystemException
rollback
in interface javax.transaction.UserTransaction
java.lang.IllegalStateException
java.lang.SecurityException
javax.transaction.SystemException
public void setRollbackOnly() throws java.lang.IllegalStateException, javax.transaction.SystemException
setRollbackOnly
in interface javax.transaction.UserTransaction
java.lang.IllegalStateException
javax.transaction.SystemException
public void setTransactionTimeout(int timeout) throws javax.transaction.SystemException
setTransactionTimeout
in interface javax.transaction.UserTransaction
timeout
- the transaction timeoutjavax.transaction.SystemException
Copyright © 2003-2018. All Rights Reserved.