Cactus does not configure a transaction for you. If you haven't started a
transaction manually, then each method call on your CMP beans execute in its
own transaction.
To manually start a transaction do something like this:
public class MyTest extends ServletTestCase
{
private UserTransaction _ut = null;
...
public void setUp() throws Exception
{
Context ctx = new InitialContext();
_ut = (UserTransaction)
ctx.lookup("javax.transaction.UserTransaction");
_ut.begin();
}
public void tearDown() throws Exception
{
_ut.commit();
}
...
}
This will cause each test case to run in its own transaction. If you use any
CMR fields in your beans you must do this, as you have to access CMRs in the
context of a transaction.
Jason
-----Original Message-----
From: Ajay Gullapalli [mailto:Ajay_Gullapalli@;compaid.com]
Sent: Thursday, November 07, 2002 8:42 AM
To: [EMAIL PROTECTED]
Subject: Transactions and EJB testing
Hi,
I was wondering if someone could post how transactions work in Cactus
when testing EJBs. I have a test case that has several testXXX in it
that test some container managed beans. When I run the test case, all
the individual tests seem to run under one transaction.
When does Cactus start a transaction? When does it commit or abort this
transaction. Does it start and run under one single transaction for the
entire test case?
Thank you.
Ajay
--
To unsubscribe, e-mail: <mailto:cactus-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@;jakarta.apache.org>