It will be great i we can use our own
implementations/class which extends ActionServlet with
StrutsTestCase. Unfortunately, this seems to be very
difficult, due to the way MockStrutsTestCase is
initialized and that this class doen't look to the
values provided in the web.xml file of the application
for finding the proper classes to instantiate.
For example i have the following in the web.xml file
for my application :
<!-- Standard Action Servlet Configuration -->
<servlet>
<servlet-name>BaseActionServlet</servlet-name>
<servlet-class>fr.factory.struts.servlet.BaseActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
</init-param>
....
</servlet>
And if one read the source code from
MockStrutsTestCase, we clearly see :
setUp() {
...
if (actionServlet == null)
actionServlet = new ActionServlet();
...
}
So the MockStrutsTestCase must be redesigned for taking
this cases into account, i think.
I had want to do this but it's a little bit difficult
to extends MockStrutsTestCase because a lot of fields
are private in this class.
So i suggest that all the fields of MockStrutsTestCase
became protected so one can write a subclass with
appropriate behavior (custom action servlet, plugging
DAO layers...) more easily (actually i must customize
my source distro of StrutsTestCase for doing this but
perhaps that i'm not the only to suffer from this
limitations).
Thanks for the work already done on this API, it's a
very good starting point for mock testing a Struts
application.
ludovic.maitre@dbfc.fr
Logged In: YES
user_id=602077
Yeah, I ran into the same problem.
For now you can do this:
In your setUp(), use:
super.setUp();
setActionServlet(new
fr.factory.struts.servlet.BaseActionServlet());