You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Vincent Massol <vm...@pivolis.com> on 2004/05/16 11:55:52 UTC

RE: how to mock TuxedoConnectionFactory for catus tests

Hi Mark,

Yes, it's possible. Here's a code snippet from my JUnit in Action book:

http://tinyurl.com/27p6l

You can get the full book source code at
http://sourceforge.net/projects/junitbook

Hope it helps,
-Vincent

> -----Original Message-----
> From: Mark Lybarger [mailto:Mark.Lybarger@CBC-Companies.com]
> Sent: 21 April 2004 15:25
> To: 'Cactus-User (E-mail)
> Subject: how to mock TuxedoConnectionFactory for catus tests
> 
> I'd like to run my stateless session EJB tests w/o dependancy on the
data
> returned from a tuxedo call the EJB makes.  I'd like control in my
tests
> over the data returned from the call.
> 
> There's two main objects being used:
> weblogic.wtc.gwt.TuxedoConnection,
> and weblogic.wtc.gwt.TuxedoConnectionFactory
> 
> My EJB's get the factory during their create from the IC as:
> 
> factory = ( TuxedoConnectionFactory ) new InitialContext().lookup(
> "tuxedo.services.TuxedoConnection" );
> 
> (note, I'm not sure why it's getting a new IC here, as the
> setSessionContext has already been called at the point of the
ejbCreate,
> correct?)
> 
> Then, when it needs to make a call in a business method, it does so
as:
> 
> connection = factory.getTuxedoConnection();
> ...
> reply = connection.tpcall( "TuxedoServiceName", inputData, 0 );
> 
> The easy way seems to be to have the IC be able to give a
> MockTuxedoConnectionFactory during my tests which return a
MockConnection
> object, which returns the data I mock up.
> 
> I'm just not sure if it's possible from a ServletTestCase to be able
to
> force this to happen?  Any suggestions/ideas would be most
appreciated.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org