struts-user mailing list archives

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


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
      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
     at org.apache.struts.action.ActionServlet.init(
     at javax.servlet.GenericServlet.init(

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?

Jim Weaver

View raw message