jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hane <ch...@hane.com>
Subject Httpunit Content-type Error
Date Tue, 30 Oct 2001 09:30:36 GMT

I've been trying to test a struts action/jsp using cactus/httpunit and have 
run into the following error as displayed by junit:

com.meterware.httpunit.NotHTMLException: The content type of the response 
is 'text/plain': it must be 'text/html' in order to be recognized as HTML
         at 
com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:789)
         at com.meterware.httpunit.WebResponse.getForms(WebResponse.java:261)
         at com.hane.lms.pages.loginTest.endLogin(loginTest.java:63)
         at 
org.apache.cactus.AbstractTestCase.callEndMethod(AbstractTestCase.java:304)
         at 
org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:425)
         at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:130)
         at 
org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:371)

I'm trying to understand how cactus works so that I can integrate it into 
my development cycle.  I have a single test that I'm trying to execute that 
uses the struts.ActionServlet.  The only logic the struts.Action contains 
is to return a forward to a jsp page.  I'm not changing the content-type 
that should be returned.  By what I can tell, the ActionServlet 
content-type default to return is 'text/html'.  I've also tried adding a 
content-type to the jsp file; however, the <meta> tag doesn't seem to have 
any change.

Any thoughts on what I've got going on here would be appreciated?  I've 
also included some of the specific example I'm using below:

My setup is as follows:
   cactus 1.3dev
   httpunit1.2.7
   struts nightly build from 9/24/01
   junit 3.7
   tomcat 4.0

The TestClass I'm using:
public class loginTest extends ServletTestCase {
[setup/standard code deleted....]

    public void beginLogin(WebRequest theRequest) {
       theRequest.setURL("localhost:8080","/LMS","/cgi/login",null,null);
    }

    public void testLogin() {
       org.apache.struts.action.ActionServlet servlet = new ActionServlet();
       try{
          servlet.init(config);
          servlet.doPost(request,response);
       } catch (Exception ex){
          //do nothing right now....
       }
    }

    public void endLogin( com.meterware.httpunit.WebResponse response) {
       try{
          com.meterware.httpunit.WebForm wf = response.getForms()[0];
          assertNull(wf.getParameterValue("userName"));
          assertNull(wf.getParameterValue("userPassword"));
          assertNull(wf.getParameterValue("resumeWorkflow"));
       }catch(org.xml.sax.SAXException ex){
          //does nothing right now...
       }
}

The jsp file being returned by the struts forward:

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="htmlStruts" %>

<html>
    <head>
       <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
       <title>LMS - Login</title>
       <htmlStruts:base/>
    </head>
    <body>
       <H1>Welcome</H1><BR/>
       <B>This the the LMS demonstration.  Before continuing you will need 
to login.</B><BR/>
       <htmlStruts:errors/></BR>
       <htmlStruts:form action="/login">
          <TABLE>
             <TR><TD>User Name</TD><TD><htmlStruts:text property="userName"

size="50"/></TD></TR>
             <TR><TD>Password</TD> <TD><htmlStruts:password 
property="userPassword" size="50" redisplay="false"/></TD></TR>
          </TABLE>
          <htmlStruts:hidden property="resumeWorkflow"/>
          <htmlStruts:submit>Login</htmlStruts:submit>
       </htmlStruts:form>
    </body>
</html>

Thanks,
Chris....


--
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