Re: Testing servlet redirects

Kazuhito SUGURI <[email protected]>
Newsgroups gmane.comp.jakarta.cactus.user
Message-ID <[email protected]>
Hi Dennis,

In article <[email protected]>,
Sat, 17 Jun 2006 14:20:15 +0200,
"Dennis Kempin" <[email protected]> wrote: 
dennis> i am using the JettyTestSetup to test a simple Servlet. This servlet
dennis> sometimes calls
dennis> getServletContext().getNamedDispatcher("default").forward(request,
dennis> response); to redirect requests to the default servlet to serve static
dennis> resources.
dennis> 
dennis> Well this is what Jetty returns as response when such a redirect happens:
dennis> HTTP ERROR: 404 /core/ServletRedirector Not Found
dennis> RequestURI=/core/ServletRedirector
dennis> Where core is the context path.

Do you mean that the 404 response is the expected behavior of
RequestDispatcher#foward() performed by your servlet?


dennis> It is not important for me to test what the redirect returns, its more
dennis> important that the servlet performs the redirect. That is what I want to
dennis> test.
dennis> Any ideas on how to test that (Testing for this error message would be a
dennis> very hacky solution)?

I don't think the error message is the expected result, however,
I think you need to evaluate the response at endXXX(WebResponse) method
to test RequestDispatcher#forward works as expected.

Regards,
----
Kazuhito SUGURI
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.