I haven't seen ServletUnit. Where do you get it from? Can it be used to
load-test a site?

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 24, 2001 1:59 PM
> To: [EMAIL PROTECTED]
> Subject: ServletUnit with Struts
> 
> 
> 
> 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(ActionServl
> et.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(Invocat
> ionContext.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
> 
> 

Reply via email to