You can also define "testSpring.xml" with mockup spring beans that you otherwise would have to set yourself, and inject that into configuration and let stripes do binding.
________________________________ From: Ben Gunter [mailto:gunter...@gmail.com] Sent: Friday, December 19, 2008 5:11 AM To: Stripes Users List Subject: Re: [Stripes-users] RedirectResolution in Unit Tests Yes, I think it depends on how you want to do your tests. If you actually want to use Stripes' MockRoundTrip then you should try to set up all the filters and stuff just like they'll execute inside the app server. That will give a true indication of how everything will work. It sounds like your case might not be that simple. On the other hand, I just did a quick test that looks good for you. I created an ActionBean and called an event handler that returns a RedirectResolution and got the exception you saw that kicked off this thread. Then I copied StripesTestFixture verbatim into my test package, added a line that calls StripesTestFixture.getServletContext() before creating the ActionBean and everything worked just fine. So you probably can solve your problem just by copying a file and adding one line of code to execute before your test suite runs. -Ben On Fri, Dec 19, 2008 at 7:58 AM, Oscar Westra van Holthe - Kind <kin...@xs4all.nl<mailto:kin...@xs4all.nl>> wrote: On 19-12-2008 at 06:49, Asleson, Ryan wrote: > From what I can see there's one problem with MockRoundTrip: I can tell > it the class of the ActionBean I want to test, but I can't pass to it an > instance of an ActionBean. Instead, it seems to rely on creating an > ActionBean instance when the round trip is executed. This doesn't work > for me, as I need to create an instance of the ActionBean myself so I > can set mock collaborators on it. My ActionBeans use Spring beans, and > in my unit tests I mock out these Spring beans with EasyMock and inject > them myself into the ActionBean under test. > > Since MockRoundTrip creates an instance of the ActionBean on the fly, > and doesn't let me create my own instance of the ActionBean, I can't set > mock objects on the ActionBean. > > Is this correct, and if so, can you recommend any work around? This is correct, but IIRC the MockROundTrip does a full cycle: filters, servlets, interceptors, etc. So a correctly configured fixture will have Spring inject the objects as usual -- apart from the fact that Spring uses your mocked objects via EasyMock. The actual configuration for this is too long ago for me though. -- ,-_ Oscar Westra van holthe - Kind http://www.xs4all.nl/~kindop/<http://www.xs4all.nl/%7Ekindop/> /() ) (__ ( I love deadlines. I like the whooshing sound they make as they fly =/ () by. -- Douglas Adams ------------------------------------------------------------------------------ _______________________________________________ Stripes-users mailing list Stripes-users@lists.sourceforge.net<mailto:Stripes-users@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
_______________________________________________ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users