struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JEWea...@thoughtworks.com
Subject ServletUnit with Struts
Date Fri, 24 Aug 2001 20:58:32 GMT

Hi,

I'm trying to test ActionObjects painlessly with Mock Objects of some kind;
I don't want in-container test cases particularly.  I'm trying to use
ServletUnit, which is part of HttpUnit, as a starting point and am having a
difficulty, not surprisinglym with the ActionServlet initialization.

Here's a snippet of the test code:

      WebRequest request = new PostMethodWebRequest
("http://test.meterware.com/actionServlet");
      request.setParameter.... etc.  set some parms for testing...

      WebResponse response = sc.getResponse(request);

The above line throws an exception when I run the testcase:
javax.servlet.UnavailableException: Missing configuration resource for path
/WEB-INF/struts-config.xml
     at
org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1316)
     at org.apache.struts.action.ActionServlet.init(ActionServlet.java:465)
     at javax.servlet.GenericServlet.init(GenericServlet.java:258)
     at
com.meterware.servletunit.InvocationContext.getServlet(InvocationContext.java:69)

I have added the war file for my application, which includes the
/WEB-INF/struts-config.xml, at the bottom of my classpath that the testcase
runs under junit with.

Hmmm, just putting this email together I spotted something.  The resource
is obtained via getServletContext().getResourceAsStream
("/WEB-INF/struts-config.xml").  The servlet context must not be such that
it is able to find that path in my war.

Anybody used ServletUnit with Struts?  Or some other Mock Objects solution?

tia,
Jim Weaver



Mime
View raw message