Hi Nicholas!
Nicholas Lesiecki wrote:
> Hmmm, am I missing something here? I have the following code:
[code snippet]
> That is executed as part of my testXXX methods, and it works just fine
> without any other proxies or classfile editing... In fact I was just about
> to write the list favoring IC testing because of the transparent support of
> things like JNDI and connection pooling when tests are run in the container.
Yes, that is one possibility. But sometimes you want to test your
classes without deploying and/or restarting the server each time. It's a
necessity if you're doing XP: [change a bit, compile, test] cycles of
ten minutes.
That's when mock objects come to the rescue. A mock Home object will
return the desired bean outside the container, in fact locally.
Phil's approach is to have custom mock Home objects for each EJB.
My approach is to have a generic mock Home object that works for every
EJB in your app; no need to add special code.
> For instance Resin-CMP has advanced support for EJB 2.0, something which
> would be a large project to write MockObjects for, but if I use cactus to
> run the tests in-container, I can test that my code works when integrated
> with the container's services.
Not so much work. I have support for stateless SessionBeans 1.1 almost
ready in 3 days (still doing the deployment-descriptor bit). Stateful
and EntityBeans would take a bit longer, but is certainly doable.
Un saludo,
Alex.