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:[EMAIL PROTECTED] > Sent: 13 April 2004 00:11 > To: [EMAIL PROTECTED] > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
