|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wamblee.test.transactions.SimpleTransactionManager
public class SimpleTransactionManager
Simple transaction manager provides a simple mechanism to manage transactions
in test code through the UserTransaction object. To construct the
transaction manager use:
SimpleTransactionManager manager = new SimpleTransactionManager(
new DefaultUserTransactionFactory());
Next, add resources to manage using addResource(TransactionResource):
manager.addResource(jpaTester.getJpaBuilder());
As you can see from the above, JpaBuilder is a resource that can be
used so this mechanism can be used with JPA testing.
The next step is to manage transactions using the standard
UserTransaction APIs:
UserTransaction transaction = manager.getTransaction();
transaction.begin();
... do work...
transaction.commit();
| Constructor Summary | |
|---|---|
SimpleTransactionManager(UserTransactionFactory aFactory)
Constructs the transaction manager. |
|
| Method Summary | |
|---|---|
void |
addResource(TransactionResource aResource)
Adds a resource to manage. |
javax.transaction.UserTransaction |
getTransaction()
Gets the user transaction. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleTransactionManager(UserTransactionFactory aFactory)
aFactory - Factory to create transactions with.| Method Detail |
|---|
public void addResource(TransactionResource aResource)
aResource - Resource.public javax.transaction.UserTransaction getTransaction()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||