You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Lindholm <gl...@yahoo.com> on 2008/06/26 22:11:08 UTC

Unit Testing - change ObjectFactory - override config

I want to change the ObjectFactory to use for unit testing so (I think) I need to be able to override struts.xml config settings.

I'm writing some code to unit test actions with the Interceptor stack.
I followed the links off the Guides page under "Unit Testing (TODO)'... these gave me some hints on how to proceed but since they both use Spring (and I don't) I could not get either to work.

Anyway... I was able to get a Dispatcher built using a mock ServletContext (not Spring's) and I was able to use it to create an ActionProxy.  So I feel I'm getting close.
(If anyone knows a better way or where better instructions on how to do this are please let me know.)

I'm using Guice for an ObjectFactory, declared using constants in the struts.xml file. 

I need to be able to change the ObjectFactory for unit testing. Either turn off Guice so the default is used (and I will inject objects after I get the proxy) or be able to specify an alternate config (Guice module) for testing. 

How can I override the settings in struts.xml for unit testing when creating the Dispatcher ?

Or, if there is a better way any advice would help.

Thanks.





      

Re: Unit Testing - change ObjectFactory - override config

Posted by Lukasz Lenart <lu...@googlemail.com>.
Hi,

How do you start your unit testing? If with Ant, you should prepare
separate struts.xml just for testing and setup it when you starting
junit task. The same you have by convention when you use maven.


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org