> -----Original Message----- > From: J. B. Rainsberger [mailto:[EMAIL PROTECTED] > Sent: 25 May 2004 03:40 > To: Cactus Users List > Subject: Re: Testing MDB > > [EMAIL PROTECTED] wrote: > > > The problem with this approach, which I also found at > > http://marc.theaimsgroup.com/?l=cactus-user&m=100879309609213&w=2 and > tried > > is, the MDB calls a session ejb and this might again call another MDB > > (There is a complex workflow design behind that). So it may be possible > to > > make a call to the first MDB's onMessage(), but this will return back > soon > > and the testXXX() methods might fail like the previous scenario. > > Presumably the MDB retrieves the Session EJB from JNDI. The standard > solution to this is this: > > 1. Move the code that retrieves the Session EJB to the top of the > onMessage() method. > 2. Apply Extract Method to the rest of onMessage() so that the new > method takes the Session EJB remote component interface as a parameter. > 3. Test the newly extracted method directly without the container. > 4. Verify your deployment descriptor to make sure that you deploy the > Session EJB correctly. > > See JUnit Recipes: Practical Programmer Testing Methods for more. :)
... or "JUnit in Action" which also shows how to unit test MDBs :-) Thanks -Vincent --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
