tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Rollback transactions in unit testing
Date Thu, 09 Oct 2008 07:24:39 GMT

On Sep 29, 2008, at 8:39 AM, Glauber Ferreira wrote:

> Hi all.
>
> I need to rollback transactions in order to revert all data modified
> (deleted, updated, created) by my tests. How can I do that in the  
> test code
> listed in this link:
> http://openejb.apache.org/3.0/unit-testing-transactions.html

Suggestions in this thread are pretty good.  A couple additional  
possibilities to throw on the stack..  If you throw a runtime  
exception from the TransactionBean call method the container will  
rollback the transaction.  Another option is to call the  
setRollbackOnly() method on the javax.ejb.SessionContext object.  A  
session ejb can have it injected with a field declared like "@Resource  
SessionContext sessionContext;"

-David


Mime
View raw message