tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: Transactions controlled by Unit Tests
Date Wed, 13 Feb 2008 01:29:16 GMT

I wrote up a doc for you better describing the pattern I created for  
Alex.  It shows usage for transactions, but the same pattern can be  
used for security as well.

That approach works great and still keeps you free of any OpenEJB- 
specific code in your test cases.

If you don't have any issues with your test cases extending an OpenEJB  
specific TestCase implementation then I'm pretty sure we could find a  
way to support @TransactionAttribute and @RunAs on the test methods  
themselves (as well as dependency injection).  If that sounds  
attractive to you, I'll create a JIRA for it.  We'd probably implement  
it as syntactic sugar on the above approach.


On Feb 12, 2008, at 8:39 AM, Jack Cox wrote:

> I'll break etiquette and reply to my own post.
> I was mistaken (i.e. I'm stupid) regarding the delete operation.   
> The entity
> does disappear from the JPA context.
> That not withstanding, I still have need to control the transaction
> demarcation from the junit test case.
> Jack
> Jack Cox wrote:
>> Is there a way in the 'out-of-container' testing paradigm with  
>> openejb for
>> the unit test method to control the demarcation of transactions?
>> Here's the use case:
>> 1) The unit test is doing entity bean testing, calling various  
>> methods on
>> the entity facade to test CRUD operations.
>> 2) The unit test needs to demarcate transactions so that it can  
>> insert,
>> delete, then attempt to retrieve deleted entities.  Of course the  
>> last
>> retrieval should fail because the entity is deleted.
>> 3) But, JPA has the interesting behavior that deleted entities  
>> continue to
>> be accessible within the deleting transaction.
>> 4) Therefore, the unit test needs to demarcate a transaction around  
>> the
>> delete so that the entity is really removed prior to the last  
>> retrieval
>> test.
>> So, how can one demarcate transactions within a junit test case?
>> Thanks,
>> Jack
> -- 
> View this message in context:
> Sent from the OpenEJB User mailing list archive at

View raw message