jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robertson, Jason" <Jason.Robert...@acs-inc.com>
Subject RE: CMR testing
Date Thu, 08 Aug 2002 14:16:51 GMT
You can create a transaction by hand, for example:


import javax.naming.Context;
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
...

public class MyTest extends ServletTestCase
{
   private Context         _ctx = null;
   private UserTransaction _ut  = null;

   public void setUp() throws Exception
   {
      _ctx = new InitialContext();
      _ut = (UserTransaction)
_ctx.lookup("javax.transaction.UserTransaction");
      _ut.begin();
   }

   public void tearDown() throws Exception
   {
      if (_ut != null) _ut.commit();
      if (_ctx != null) _ctx.close();
   }

   ...
}

Each testXXX method will now be in the context of a transaction.

Jason


-----Original Message-----
From: Gustavo Hexsel [mailto:GHexsel@mercador.com]
Sent: Wednesday, August 07, 2002 6:32 PM
To: 'cactus-user@jakarta.apache.org'
Subject: CMR testing


	Does Cactus provide any facilities to test CMR on CMP2.x beans? 
	I tried a servlet redirector, but it seems I cannot use CMR
collections outside their creation transactions, and I think that creating a
session bean to test an entity bean would be overkill!

	Thanks a lot,
		Quartz

--
To unsubscribe, e-mail:
<mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:cactus-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message