Hi Charlie,
What Cactus will do (in the current version) is that it will effectively
perform the real forward to the other servlet (or JSP). What I suggest to
test this (although I don't know enough about the context) is to use one of
the following approaches :
Solution 1:
* you write a test servlet, which is part of your suite of tests that just
returns a simple string for example.
* in your beginXXX() method you use setURL() to set your simulated path,
setting a pathInfo value that will call this test servlet. Note: Depending
on how you wrote your generic servlet that may or may not be possible
* in endXXX() verify that the returned message is the one returned by your
test servlet
Solution 2:
* simply use the real servlet (the one called by the first servlet) and
assert some result
Solution 3:
* Add a counting feature to Cactus, meaning that it is possible to know how
many times a given Servlet API method (for instance) has been called so that
we can assert this. However, the goal of Cactus is to verify that your code
runs correctly in the container, so introducing a flag to not perform the
forward would not be in line with Cactus's goals.
Thanks
-Vincent
----- Original Message -----
From: "Charlie Cano" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 01, 2001 2:04 AM
Subject: Testing RequestDispatcher.forward
I've read through the docs and I can't seem to figure out how to use the
Cactus framework to test forwards (e.g. Servlet chaining).
Example:
I have a servlet that simply looks at the pathInfo of the incoming
request, and forwards the request to another Servlet based on the path
info. I want to unit test the main Servlet, but I'm not sure how to
check whether or not it is forwarding to the correct Servlet.
Is there a way to intercept the forward call? How would one test this?
Any help or pointers to existing help would be great.
- Charlie