Title: Access to HttpServletRequest.getInputStream() in Cactus
Hi Vincent,
 
       Thank you very much for clearing it up.
 
cheers,
Amar..
-----Original Message-----
From: Vincent Massol [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 13, 2001 6:29 AM
To: [EMAIL PROTECTED]
Subject: Re: unittesting struts using cactus

Hi Amar,
----- Original Message -----
Sent: Tuesday, May 08, 2001 8:16 PM
Subject: unittesting struts using cactus

Hi Guys,
 
           I am trying to unit-test my individual classes using cactus. I am using struts 1.0 beta . I mapped each jsp page to an Action class. What i want to do is set the values of the ActionForms from the html (jsp) page and when i submit the info, the corresponding ActionTest class kicks in and i get a result back stating whether the test is a success or a failure. Does cactus support this kinf of testing ?
 
Not sure why you would want to do this. There are 2 goals in Cactus :
- to provide a unit testing framework
- to formalize a methodology for automating unit testing in containers
 
If you have to enter form values before each test, it does not bring the benefit of automation.
 
The reson for my question is.. if i take the Login scenario as an example........ I can have a valid login (or) invalid login. Right now i have hardcoded the login and password when unit testing the LoginAction. I am using the ServletRedirector. When we go live, this hardcoded values will not exist anymore. So if any changes are made in the future, the test cases will fail. I was thinking of using the JspRedirector for having an interactive testing (where the login and password are entered at runtime). Is it possible. any code/suggestions will be helpful.
 
Cactus is about unit testing, meaning you don't test interations from end to end, this would be functional testing (using a tool like HttpUnit). What you unit test however, is for example the LogonForm class. This class has several methods but the most interesting one to test is the validate() method. This method takes 2 parameters : a ActionMapping object and a HttpServletRequest object. What you'll write in your unit test is different scenarios corresponding to different values set in these 2 classes in order to verify the correct behaviour of LogonForm in different cases. Cactus provides a simulated HttpServletRequest for you. However fror the ActionMapping, you have to construct one yourself, as part of your test initialization.
 
Is that clear ?
 
 
cheers,
Amar..
 
 
Cheers,
Vincent

Reply via email to