struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: ServletUnit with Struts
Date Fri, 31 Aug 2001 04:28:13 GMT

> I believe that it is primarily a functional testing tool.  I would
> that you could use it for load-testing...

I wouldn't believe it. Our attempts to load test with HttpUnit spent more
time parsing code on the client than they did generate HTTP requests.
dIon Gillard, Multitask Consulting
----- Forwarded by dIon Gillard/Multitask Consulting/AU on 31/08/2001 02:24
PM -----
RE: ServletUnit with Struts

ServletUnit is part of the open-source HttpUnit testing framework.  You can
get HttpUnit from SourceForge at:

I believe that it is primarily a functional testing tool.  I would imagine
that you could use it for load-testing...

Regarding my original problem.

The solution I am now pursuing, so far with success, is removing almost all
of the application-specific "meat" from my Action subclasses.  I will
delegate to a simple command class from the action.  The command class will
take input paramaters, access the model layer to carry out the operation,
and make available a logical forwarding name, result objects hash, and
ActionErrors which can be accessed by the Action class following command
execution.  All that will be left in the Action class will be Struts
frame-worky stuff.

The consequence is that I can unit test the command independently with
vanilla junit, without relying on a host of mock servlet / struts objects
or an in-container testing framework.  The only Struts object I'm going to
allow the commands to work with is an ActionErrors instance.  Removing that
Struts dependency would be even nicer, in that you could then survive a
departure from the struts framework with the vast bulk of your control
layer logic unaffected.  Easy to get rid of the ActionErrors and just have
the command class save the keys of the errors in a collection...

We'll see how this goes...

Jim Weaver
Software Developer - ThoughtWorks

                    Kevin"               To:
"''" <>
                    <KDuffey@BUYME       cc:
          >             Subject:     RE: ServletUnit with

                    04:17 PM
                    Please respond
                    to struts-user

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

> -----Original Message-----
> From: []
> Sent: Friday, August 24, 2001 1:59 PM
> To:
> 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
> ("");
>       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
>      at
> org.apache.struts.action.ActionServlet.init(
>      at javax.servlet.GenericServlet.init(
>      at
> com.meterware.servletunit.InvocationContext.getServlet(Invocat
> 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

              Previous Document (Embe (Embe Next Document                  
                                dded   dded                                
                                image image                                
                                moved moved                                
                                to       to                                
                                file: file:                                
                                pic26 pic19                                
                                500.p 169.p                                
                                cx)     cx)                                
                                                    Return to View         
                                                (Embedded image moved to   
                                                  file: pic15724.pcx)      

View raw message