Vincent-
Thanks for the response & good info. I've got it
working now by pulling the Location header and doing a
subsequent httpunit call in the endXXX()method to
check the error page.
I'd definitely be +1 for a flag though.
Thanks.
-pgm
--- Vincent Massol <[EMAIL PROTECTED]> wrote:
> Hi Pete,
>
> ----- Original Message -----
> From: "Pete McKinstry" <[EMAIL PROTECTED]>
> To: "cactus-user list"
> <[EMAIL PROTECTED]>
> Sent: Wednesday, October 17, 2001 6:52 PM
> Subject: testing redirects
>
>
> > Hello-
> >
> > I'm just getting started w/ Cactus. I have gotten
> a
> > few servlet/jsp tests working, so i think i've got
> > everything setup right.
> >
> > My current question has to do w/ servlet
> redirects.
> > I'd like to test that my servlet is correctly
> > redirecting to the error page if the wrong
> parameters
> > are passed in the request. So I do this:
> >
> > public void testCreateWithNoParams() throws
> Exception
> > {
> > CreateWorkflowServlet servlet = new
> > CreateWorkflowServlet();
> > servlet.service(request, response);
> > }
> >
> > public void endCreateWithNoParams(WebResponse
> resp)
> > throws Exception {
> > String text = resp.getText();
> > System.out.println("response page = " + text );
> > // do some asserts on the page text to check
> that
> > // it's the error page.
> > }
> >
> > When i run it, i'm getting a 302 error page back,
> but
> > what I want is the page after that. What am i
> doing
> > wrong? (i'm using tomcat 4.0 if that makes a
> > difference.)
> >
> > Thanks a lot for any tips.
> >
>
> What you are getting is right ! The goal of Cactus
> is to provide unit
> testing (only) and not end to end functional
> testing. So what Cactus
> provides, in your case, is verifying that your code
> (i.e. servlet.service())
> is doing what it should do, i.e. return a 302
> message. This is the intent of
> Cactus and is done on purpose.
>
> To tell the truth, before version 1.2 I had made a
> mistake and allowed
> redirection to happen, so a Cactus user rightly
> complained that he couldn't
> test that he returned a 302 response ... I fixed
> this by disallowing
> redirect in HttpURLConnection ... This is for the
> story.
>
> Again, the goal is to test unit actions. Now, if you
> also wish to verify
> that you can call such page, you can write a second
> test. Then when you have
> finished writing unit tests, you should write
> functional tests, which will
> verify that full use cases are working ok. These
> could be written with
> HttpUnit for example.
>
> We could of course decide to set a flag in Cactus so
> that it does redirect
> or not, depending on this flag. At the current time,
> I think it would lead
> us away from the idea of unit tests. The goal of
> Cactus at this point is not
> to completely replace functional testing frameworks.
> However, I can see your
> point (have a single framework that would also allow
> you to test these
> redirects in addition to unit testing your code),
> and if enough users find
> this feature useful, we could implement it.
>
> What do others think ?
>
> > -pgm
>
> -Vincent
>
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com