jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Content type/httpunit endXxx
Date Tue, 03 Sep 2002 20:36:39 GMT


> -----Original Message-----
> From: Larry Tambascio [mailto:ltambascio@charter.net]
> Sent: 03 September 2002 21:16
> To: Cactus Users List
> Subject: Re: Content type/httpunit endXxx
> 
> Thanks Vincent,
> 
> That did it!!  I actually tried adding that line in my
> testXxx method earlier, but I added it after the forward.
>  That didn't work.  Why did putting the setContentType
> before the forward make a difference??
> 

... because the response is probably already committed at that point.

> To answer your other question, some of the test cases
> could probably exclusively be done with HttpUnit, but most
> of the testing will do some asserts in the testXxx
> methods.  And besides, I like having the best of both
> worlds in one framework.  :-)

cool. I won't contradict you here ! :-)

Cheers,
-Vincent

> 
> Thanks again!!
> -Larry
> 
> On Tue, 3 Sep 2002 20:34:54 +0100
>   "Vincent Massol" <vmassol@octo.com> wrote:
> >Hi Larry,
> >
> >> -----Original Message-----
> >> From: Larry Tambascio [mailto:ltambascio@charter.net]
> >> Sent: 03 September 2002 20:04
> >> To: cactus-user@jakarta.apache.org
> >> Subject: Content type/httpunit endXxx
> >>
> >> Hey,
> >>
> >> I'm having trouble in my endXxx method.  I'm using the
> >> HttpUnit integration to verify some of the output from
> >>my
> >> XSL translation.  I call pResponse.getTables() and I get
> >> an exception stating that the document needs to have a
> >> content type of "text/html".  I put an assert in front
> >>of
> >> that like this:
> >>
> >> 	assertEquals ("Content type", "text/html",
> >> pResponse.getContentType());
> >>
> >> And indeed the test fails with an actual value of
> >> text/plain.  When I look at the actual HTML through a
> >> browser (view/source), I get the following line:
> >>
> >> <META http-equiv="Content-Type" content="text/html;
> >> charset=UTF-8">
> >>
> >> And in the XSL stylesheet, I have the appropriate:
> >>
> >> 	<xsl:output method="html" encoding="UTF-8"
> >> doctype-public="-//W3C//DTD HTML 4.01
> >>Transitional//EN"/>
> >>
> >> So I'm not sure why Cactus/HttpUnit in the endXxx method
> >> doesn't think it has HTML.  A potential culprit could be
> >> the way I'm executing things.  In my testXxx method, I'm
> >> forwarding the request and response on to the controller
> >> servlet using the request dispatcher's forward method.
> >>  It's just too much of a nightmare to instantiate it in
> >> the test case.  Don't know if that would be getting in
> >>the
> >> way of things, but I figure it's worth mentioning.  Am I
> >> doing something wrong??
> >
> >One question I have is why do you need Cactus for that?
> >It seems to me
> >you could use HttpUnit directly, no? Or are you
> >performing some tests in
> >your testXXX() method like verifying what's in the
> >request, session,
> >etc?
> >
> >Anyway, back to your question :-)
> >
> >I believe the problem is that you're not setting the
> >content type
> >anywhere. The content type is set as a HTTP HEADER in the
> >response. The
> >META tag you're showing is not sent in the HTTP header.
> >It is content (I
> >am not sure what it is supposed to do BTW).
> >
> >Can you try to set the content type in the first line of
> >your testXXX():
> >
> >         response.setContentType("text/html");
> >
> >Thanks
> >-Vincent
> >
> >
> >--
> >To unsubscribe, e-mail:
> >  <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> ><mailto:cactus-user-help@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message