jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicholas Lesiecki" <n...@eblox.com>
Subject RE: WebResponse problems
Date Thu, 21 Feb 2002 19:31:44 GMT
Alan,

I can't be sure without some digging, but I think the short answer to your
question is that CactusStrutsTestCase does not actually forward to your
eventual destination, it just verifies that the code correctly signaled that
a forward should occur. Thus the request and response never make it to your
final JSP (or whatever outputs your HTML). To verify this, take a look at
the source for CactusStrutsTestCase. It should tell you whether it actually
does any forwarding.

Cheers,

Nick

-----Original Message-----
From: Alan Halley [mailto:alan_halley2001@yahoo.com]
Sent: Wednesday, February 20, 2002 2:28 AM
To: Cactus Users List
Subject: RE: WebResponse problems




package com.cisco.salesit.tests.ppm.struts;
import java.util.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;
import java.io.*;
import servletunit.struts.CactusStrutsTestCase;
import junit.framework.*;
import org.apache.log4j.*;
import org.apache.cactus.*;
import com.cisco.salesit.ppm.dataaccessclasses.DBUser;
import com.cisco.salesit.ppm.dataaccessclasses.BusinessEntityDAO;
import com.cisco.salesit.ppm.IConstants;
import com.cisco.salesit.ppm.BusinessEntity;
/**
 * Cactus unit tests for testing exception handling of
 * <code>ServletTestCase</code>.
 *
 * These tests should not really be part of the sample application
functional
 * tests as they are unit tests for Cactus. However, they are unit tests
that
 * need a servlet environment running for their execution, so they have been
 * package here for convenience. They can also be read by end-users to
 * understand how Cactus work.
 * <br><br>
 * Note : This class extends
 * <code>TestLoginAction_InterceptorServletTestCase</code> (which itself
 * extends <code>ServletTestCase</code>) because we need to be able to
verify
 * exception handling in our unit test cases so we must not let these
exceptions
 * get through to JUnit (otherwise the test will appear as failed).
 *
 * @author <a href="Vincent'>mailto:vmassol@apache.org">Vincent Massol</a>
 *
 * @version $Id: TestLoginAction.java,v 1.5 2001/09/14 20:24:13 pier Exp $
 */
public class TestViewHQDetailsAction
    extends CactusStrutsTestCase
{
 private Category  cat =
Category.getInstance(TestViewHQDetailsAction.class.getName());
    /**
     * Defines the testcase name for JUnit.
     *
     * @param theName the testcase's name.
     */
    public TestViewHQDetailsAction(String theName)
    {
        super(theName);
    }
    /**
     * Start the tests.
     *
     * @param theArgs the arguments. Not used
     */
    public static void main(String[] theArgs)
    {
        junit.ui.TestRunner.main(new String[] {
            TestViewHQDetailsAction.class.getName()});
    }
    /**
     * @return a test suite (<code>TestSuite</code>) that includes all
methods
     *         starting with "test"
     */
    public static Test suite()
    {
        // All methods starting with "test" will be executed in the test
suite.
        return new TestSuite(TestViewHQDetailsAction.class);
    }

 public void beginViewHQDetailsAction(WebRequest theRequest)
  {
   //HttpSession session=theRequest.getSession();

   theRequest.addParameter("BEId","13003");
         theRequest.addParameter("countryCode","AUSTRIA");

  }
  public void setUp()
  {
   super.setUp();
   DBUser user=new DBUser();
   user.setUserId("ppeault");
   cat.debug("Saving to Session");
   session.setAttribute(IConstants.SESSION.IDBUSER,user);
   try
   {
   BusinessEntityDAO beDAO=new BusinessEntityDAO(request);
   cat.debug("Going for user names");
         BusinessEntity be=beDAO.getUserNames();
         be.loadHQLocations(request);
         cat.debug("Map is "+be.getHQLocationsMap());

session.setAttribute(IConstants.SESSION.HQLOCATIONSMAP,be.getHQLocationsMap(
));
   }
   catch(Exception e)
   {
    cat.debug("setUP failed "+e.getMessage());
   }
  }
  public void testViewHQDetailsAction()
  {
    setRequestPathInfo("/viewhqdetails");//?BEId=56860&countryCode=USA");
       actionPerform();
    verifyForward("success");
    verifyNoActionErrors();
  }
  public void endViewHQDetailsAction(com.meterware.httpunit.WebResponse
response)throws Exception
  {
   try
   {
   String title=response.getTitle();
   System.out.println("Title is "+title);
   System.out.println(""+(response.getLinks()).length);
   System.out.println("Charset is "+response.getCharacterSet());
   org.w3c.dom.Document dom=response.getDOM();
   System.out.println("DOM is "+dom.toString());
   //assertEquals("Page has wrong title","View HQ Details",title);
   }
   catch(Exception e)
   {
    System.out.println("Exception in end method "+e.getMessage());
   }
   System.out.println(response.getText());
   System.out.println("Response Object is "+response.toString());
  }
  public void tearDown()
  {
   cat.debug("Tear down running");
  }
}
  Nicholas Lesiecki <nick@eblox.com> wrote: Ok, can you give us your test
case?

Cheers,

nick

-----Original Message-----
From: Alan Halley [mailto:alan_halley2001@yahoo.com]
Sent: Tuesday, February 19, 2002 9:15 AM
To: Cactus Users List
Subject: RE: WebResponse problems



Hi Nick,
Thanks for responding so quickly.
If I access the Struts action with the browser then the page is correctly
displayed.
Alan

Nicholas Lesiecki wrote: What's your response supposed to
contain? I ran into a something like this
once, and discovered that if I didn't cross a few t's and dot a few i's,
tomcat would not print anything to the response. So without knowing your
problem, this is hard to debug.

Cheers,

Nick

-----Original Message-----
From: Alan Halley [mailto:alan_halley2001@yahoo.com]
Sent: Tuesday, February 19, 2002 8:38 AM
To: cactus-user@jakarta.apache.org
Subject: WebResponse problems


Hi,

I am having problems with com.meterware.httpunit.WebResponse. The
getTitle,getText methods all return an empty string.

The response object is valid as can be seen by the output below.

[java] 2002-02-19 13:52:23,489 DEBUG (BaseLog.java:199)- [junit] Title is
[junit] [Lcom.meterware.httpunit.WebLink;@fb1f7
[junit]
[junit] Response Object is [headers={CONTENT-TYPE=text/html,
SET-COOKIE2=JSESSIONID=vojozv4l72;V
ersion=1;Discard;Path="/test", SERVLET-ENGINE=Tomcat Web Server/3.2.3
(JSP 1.1; Servlet 2.2; Java 1.
3.1_01; Windows 2000 5.0 x86; java.vendor=Sun Microsystems Inc.),
SET-COOKIE=JSESSIONID=vojozv4l72;P
ath=/test}]
[junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 42.682
sec

I am using cactus 2.2 with Tomcat 3.2.3. I believe this is probably a
configuration issue but can't track it down.

Any help would be greatly appreciated.

Regards,

Alan Halley




---------------------------------
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games


--
To unsubscribe, e-mail:
For additional commands, e-mail:



---------------------------------
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games


--
To unsubscribe, e-mail:
For additional commands, e-mail:



---------------------------------
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games


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