Hi Vincent,
        My test gets fail on forward and not getting any session values after
accessing that page which is mentioned in URL ["/test/do-login"]. I think it
is not accessing that page only. Bust instead of dispatch.forword() if I
include dispatch.include() then test case passes but does not show any
session values as request does not  come back from that page. And the main
application is coded in cocoon.

> -----Original Message-----
> From: Vincent Massol [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 27, 2002 11:54 PM
> To: 'Cactus Users List'
> Subject: RE: Cactus wth cocoon help.
>
>
> Vidya,
>
> Can you send the stack trace you're getting and the stdout erros that
> appear on your server console?
>
> I can see one potential issue (but I'm not sure): You are manipulating
> the request after you did a forward(). I'm not sure this is allowed by
> the Servlet spec.
>
> The first thing we need to know is if your test goes past the
forward()
> or if it fails on the forward.
>
> Question: What does this have to do with Cocoon testing?
>
> Cheers,
> -Vincent
>
> > -----Original Message-----
> > From: Vidya Deshmukh [mailto:[EMAIL PROTECTED]]
> > Sent: 27 September 2002 06:00
> > To: 'Cactus Users List'
> > Subject: RE: Cactus wth cocoon help.
> >
> >
> > 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", "username");
> >     webRequest.addParameter("password", "passsword");
> >   }
> >
> >   /**
> >    * 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("username",session.getAttribute("username"));
> >         assertEquals("password",session.getAttribute("password"));
> >     }
> >     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("username"));
> >     } // 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: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]>

Reply via email to