jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woo...@f00f.net (Conan)
Subject Re: beginXXX and endXXX jsp problems
Date Mon, 12 Apr 2004 23:24:12 GMT
Well, nevermind the constructor and such, most of that was copy pasted
from examples and not important.  I originally tried it with a
ServletTestCase, but I had the same problem.  My main issue is that I
would like to see the output of the servlet with the getText() method.
Do you have any ideas as to the problem?

On Tue, Apr 13, 2004 at 12:54:35AM +0200, Vincent Massol wrote:
> Hi Conan, 
> 
> You are not using Cactus correctly at all. I'd suggest you read the
> following pages:
> 
> http://jakarta.apache.org/cactus/writing/howto_testcase.html
> 
> There are several problems in your test below:
> 
> 1/ No need for a constructor
> 2/ no need for a suite() method
> 3/ no need for setUp()/tearDown()
> 4/ no need to call setURL() (and it's not being called corretly - the
> first parameter is incorrect for example)
> 5/ the cookie you're passing is a client side cookie. Whereas the cookie
> you're asserting in endJsp() is a server side cookie sent back. But your
> servlet does not send back anything in its constructor it seems...
> 6/ You're instantiating a servlet object but a servlet is not supposed
> to do anything in its constructor... and you're not calling any other
> method...
> 
> but most importantly
> 
> 7/ JspTestCase is *not* meant to be used to test JSP-generated servlets.
> 
> 
> -Vincent
> 
> > -----Original Message-----
> > From: Conan [mailto:woodsc@f00f.net]
> > Sent: 13 April 2004 00:11
> > To: cactus-user@jakarta.apache.org
> > Subject: beginXXX and endXXX jsp problems
> > 
> > Hi, I am having a ton of problems trying to verify the output of a
> jsp.
> > I assumed I could just use the theResponse.getText() method to get the
> > output of the jsp, but it doesn't seem to be working, it comes out
> with
> > an empty string instead of some content.
> > 
> > Here is my code:
> > 
> > -----snip------
> > 
> > public class TestLoginJsp extends JspTestCase {
> > 
> > public TestLoginJsp( String testName )
> > {
> >   super(testName);
> > }
> > 
> > public static Test suite()
> > {
> >   return new TestSuite(TestLoginJsp.class);
> > }
> > 
> > public void setUp()
> >   throws Exception
> > {
> >   super.setUp();
> > }
> > 
> > public void beginJsp(WebRequest theRequest)
> > {
> >   System.err.println("FOO:beginJsp"); // -> "FOO:beginJsp"
> >   theRequest.setURL("localhost", "/something", "/something/LoginJSP",
> > null, null);
> >   theRequest.addCookie("test", "cookievalue");
> > }
> > 
> > public void testJsp()
> > {
> >   LoginJSP servlet = new LoginJSP();
> >   assertEquals(1, 1);
> > }
> > 
> > public void endJsp(org.apache.cactus.WebResponse theResponse)
> > {
> >   System.err.println("FOO:endJsp"); // -> "FOO:endJsp"
> >   System.err.println(theResponse.getText()); // -> ""
> >   System.err.println(theResponse.getStatusCode()); // -> 200
> >   System.err.println(theResponse.getCookie("test")); // -> null
> > }
> > 
> > 
> > public void tearDown()
> >   throws Exception
> > {
> >   super.tearDown();
> > }
> > 
> > }
> > 
> > 
> > -----end snip------
> > 
> > Any idea what the problem could be?
> > 
> > Login.jsp is precompiled into LoginJSP
> > Cactus version: 1.5
> > Tomcat version: 4.1.30
> > Ant version: 1.6.1
> > OS: Debian GNU/Linux
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org

Mime
View raw message