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 19:34:54 GMT
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>


Mime
View raw message