Hi Vincent,
I want to test an application which uses cocoon framework , for now I am
just accessing the middle page of application and trying to test wheather
session is valid or present for a perticular user or not. But I am not able
to access that page thro' cactus and rather not getting any session object
after accessing that page,
here is my code....
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
mport javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletConfig;
public class TestLogin extends ServletTestCase
{
public TestLogin(String theName)
{
super(theName);
}
String loginUrl = "/test/admin/index.jsp";
String logoutUrl = "/test/logout.jsp";
String errMsgUrl = "/test/index.jsp?error='Please Enter Login and
Password' ";
/**
* initialize parameters
*/
public void beginValidateLogin(WebRequest webRequest)
{
webRequest.addParameter("username", "aol");
webRequest.addParameter("password", "secret");
}
/**
* test to check wheather session is valid or not and verify that by
* default the session implicit object is available and can be used.
*/
public void testValidateLogin() throws ServletException
{
try
{
//ServletConfig theConfig;
RequestDispatcher dispatch =
config.getServletContext().getRequestDispatcher("/test/do-login");
dispatch.forward(request, response);
HttpSession session = request.getSession(false);
assertNotNull(session);
// Perform verification that test was successful
assertEquals("aol",session.getAttribute("IDENTITY"));
assertEquals("admin",session.getAttribute("ROLE"));
}
catch (Exception ex)
{
System.out.println("Exception" + ex);
// ex.printStackTrace();
} // end of catch
} // end of test method
/**
* test to check wheather user has successfully logged out.
*/
public void testLogout() throws ServletException
{
try
{
RequestDispatcher dispatch =
this.config.getServletContext().getRequestDispatcher(logoutUrl);
dispatch.include(request, response);
assertNotNull(session.getAttribute("IDENTITY"));
} // end of try
catch (Exception se)
{
System.out.println(se);
} // end of catch
} // end of test method
public static Test suite()
{
return new TestSuite(TestLogin.class);
}
}
Tell me if I am doing anything wrong out here.....
-----Original Message-----
From: Vincent Massol [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 26, 2002 3:20 AM
To: 'Cactus Users List'
Subject: RE: Cactus wth cocoon help.
Hi Vidya,
Short answer is yes. What do you want to unit test from Cocoon?
Thanks
-Vincent
> -----Original Message-----
> From: Vidya Deshmukh [mailto:[EMAIL PROTECTED]]
> Sent: 25 September 2002 06:14
> To: [EMAIL PROTECTED]
> Subject: Cactus wth cocoon help.
>
>
> Hi!
> Can anyone tell me wheater it is possible to Write test cases for
> cocoon
> framework? I am trying for it but getting some error while using
> requestDispatcher object, and not able to acces jsp pages and not
getting
> any request or response or session object from any jsp page.
>
> Regards,
> Vidya
>
>
> --
> To unsubscribe, e-mail: <mailto:cactus-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:cactus-user-
> [EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>