jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Arndt <jarndt...@yahoo.com>
Subject Re: Simple test for my login JSP
Date Fri, 14 Mar 2003 22:54:45 GMT
Have you LoginWebTest extend JspTestCase instead of
ServletTestCase.

--- "White, Melissa" <mwhite@triactive.com> wrote:
> I am trying to use Cactus to unit test our JSPs, but
> am having difficulty
> getting a simple test to work. I have a test case
> defined as follows:
> 
> public class LoginWebTest extends ServletTestCase
> {
>   private static Cookie jsessionid = null;
> 
>   public LoginWebTest(String name)
>   {
>     super(name);
>   }
> 
>   public static void main(String[] args)
>   {
>     junit.textui.TestRunner.run(suite());
>   }
> 
>   public static Test suite()
>   {
>     final TestSuite suite = new TestSuite();
>     suite.addTest(new
> LoginWebTest("testGetJsessionid"));
>     suite.addTest(new LoginWebTest("testLogin"));
>     return suite;
>   }
>   public void beginGetJsessionid(WebRequest
> webRequest)
>   {
>     webRequest.setURL("localhost:8101", "",
> "/portal/login.jsp", null,
> null);
>   }
> 
>   public void testGetJsessionid() {}
> 
>   public void endGetJsessionid(WebResponse
> webResponse)
>   {
>     Cookie c =
> webResponse.getCookieIgnoreCase("jsessionid");
>     assertNotNull(c);
>     this.jsessionid = c;
>   }
> 
>   public void beginLogin(WebRequest webRequest)
>   {
>     webRequest.setURL("localhost:8101", "",
> "/portal/doLogin.jsp", null,
> null);
>     webRequest.addParameter("company", "mwhite");
>     webRequest.addParameter("username", "admin");
>     webRequest.addParameter("password", "adminpwd");
>   }
> 
>   public void testLogin()
>   {
>     assertEquals("mwhite",
> request.getParameter("company"));
>     SpecialistValue sv =
>
(SpecialistValue)session.getAttribute(SpecialistKeys.CURRENT);
>     assertNotNull("SpecialistValue not found in
> session", sv);
>   }
> }
> 
> The assertNotNull in testLogin fails, but it is not
> clear to me that
> doLogin.jsp is ever being reached. If it is, there
> should be some output in
> my JRun log, but there is none. After doLogin.jsp is
> executed, I should be
> able to retrieve the SpecialistValue object from the
> session. Am I missing
> something?
> 
> I'm using JRun 3.1.  Any help would be greatly
> appreciated.
> 
> -- Melissa
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com

Mime
View raw message