--- Leonardo Francalanci <[EMAIL PROTECTED]> wrote:
> In my DB tier I use an interface to get the connection.
> When used under Tomcat, the class that implements the connection gets
> the connecton through JNDI.
> I want to test these classes outside of Tomcat.
> Is there a simple way to put objects in the Context,
> I mean a simple way to emulate Tomcat behavior?
> I read the JNDI tutorial, but is the worse thing I've ever read.
> 
> At this moment I created a class that implements my interface
> and that open a simple connection to the db, but in this way I need
> to set the right interface (JNDI/Simple) in each class a want to test.

The most common solution to this problem is using a Factory Method to
return the correct implementation of the interface.  Your classes should
never know which implementation is in use because they will all ask the
Factory Method for the object.  You just need to change the one line in
the method to return a different object for testing.

David


> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to