Which version of HttpUnit are you using ? I tried the following simple
example with version 1.2.6 and it works fine :

    public void testHttpUnitGetText() throws IOException
    {
        PrintWriter pw = response.getWriter();
        pw.print("something to return for the test");
    }

    public void endHttpUnitGetText(
        com.meterware.httpunit.WebResponse theResponse) throws IOException
    {
        String text = theResponse.getText();
        assertEquals("something to return for the test", text);
    }

Can you try it too ?
-Vincent

----- Original Message -----
From: "Karthik Kumar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Vincent Massol" <[EMAIL PROTECTED]>
Sent: Friday, September 28, 2001 2:21 PM
Subject: WebResponse.loadResponseText throws NullPointerException ...


> Hello,
>    Sorry for my previous mail with the wrong subject.
>
>    I was looking for a server-side testing tool to test my JSP pages, and
then
> I came across Cactus. First of all, let me tell you Vincent, it is really
kool
> and simple. I could immediately jump-start on testing my very trivial JSP
> pages.
>   I encountered a problem when I used the jsp:useBean tag.
> I am just pasting a page fragement here.
>
> FetchEmp.jsp:
>
> <jsp:useBean id = "empBean" class = "myapp.Employee" scope = "page"/>
> <html>
> <head><title>Hello World</title></head>
> <body>
> <tr><td>
> <% out.print(empBean.getSalary().toString() );  %>
> </tr></td>
> </body>
> </html>
>
>
> I am using WebLogic v 6.1 . I run the server under default context and
this,
> JSP has been deployed such a way that we can refer to it as,
>
> http://localhost:7001/employee/FetchEmp.jsp
>
> Employee.java:
> ==============
>
> package myapp;
> public class Employee {
>     static int Salary; //Should be double..
>
>     static {
>         Salary  = 6000;
>     }
>
>     public static String getSalary() {
>         return Salary;
>     }
> }
>
> Now my test case is something like this.
>
>  < --- >
> import org.apache.cactus.JspTestCase;
> import com.meterware.httpunit.WebTable;
>
> import java.io.IOException;
> import javax.servlet.ServletException;
> import org.xml.sax.SAXException;
>
> public class TestBeanCase extends JspTestCase
> {
>     public TestBeanCase(String theName)
>     {
>         super(theName);
>     }
>
>
>     public void testOut() throws IOException, ServletException
>     {
>         pageContext.forward("/employee/FetchEmp.jsp");
>     }
>
>     public void endOut(com.meterware.httpunit.WebResponse resp)
>             throws IOException , ServletException,
>                     ParserConfigurationException,
>                     SAXException {
>         System.out.println( resp.getText() );
>     }
> }
>
>  ------- --------------------
> When I run the JUnit task I get,
>
> java.lang.NullPointerException
>
> at
com.meterware.httpunit.WebResponse.loadResponseText(WebResponse.java:472)
> at com.meterware.httpunit.WebResponse.getText(WebResponse.java:186)
> at TestBeanCase.endOut(TestBeanCase.java:50)
> at
org.apache.cactus.AbstractTestCase.callEndMethod(AbstractTestCase.java:304)
> at
org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:425)
> at org.apache.cactus.JspTestCase.runTest(JspTestCase.java:107)
> at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:371)
>
> Actually the line,
>  TestBeanCase.java : 50 is
>
>   System.out.println( resp.getText() );
>
> mentioned above.
>
> Can anybody help me?
>
> Thanks.
> Karthik Kumar.
>
> __________________________________________________
> Do You Yahoo!?
> Listen to your Yahoo! Mail messages from any phone.
> http://phone.yahoo.com
>

Reply via email to