jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. B. Rainsberger" <jbra...@rogers.com>
Subject Re: how to test Session Facade without database
Date Wed, 21 Apr 2004 13:26:59 GMT
Mark Lybarger wrote:

> I'd like to be able to test my Stateless Session EJB's w/o relying on data in the database.
(initially... later, i'd like to remove dependancy on a remote tuxedo call we also do).  
What's the best way to do this?  Mock the database? Hypersonic database for testing?

My usual approach is to mock the database by a three step approach:

1. Centralize data access as much as possible
2. Extract Interface
3. Mock the new interface with EasyMock/jMock

> Our DAO layer is similar to the torque peer setup.  We have EJBs that call other EJB's
or that call static methods on Peer classes.  The Peer classes return DTOs filled with data
from the db.  All database access is done through these Peer classes.  I've read in some XP
book someplace how to test database methods by mocking the database objects, (record set mocks,
connection mocks), but I'm just not sure how that would work out if we're not directly testing
the Peer classes, but testing the EJB interface itself.  We're implementing the session facade
pattern now (moving code from turbine actions) to make functionality more available to other
processes.  And IMO, having testing on this functionality is essential.  Any insights would
be most appreciated.

Get rid of the class-level (static) methods immediately, and if you can, 
quickly. They provide no value unless you consider excessive coupling 
valuable. :)
-- 
J. B. Rainsberger,
Diaspar Software Services
http://www.diasparsoftware.com :: +1 416 791-8603
Let's write software that people understand

Mime
View raw message