Hi Raghunandan ,

The Cactus project has a really good documentation. One point to start is
the sample projects. Have a look at the sample projects, that come with the
distribution, and once you run these sample projects, try to look in them
what part of the HTTP
layer is tested with Cactus - cookies, request/session attributes,
parameters, etc.
Then try to test those things in your servlet.
Some links to the Cactus documentation:

http://jakarta.apache.org/cactus/writing/howto_testcase_servlet.html
http://jakarta.apache.org/cactus/integration/index.html

Cheers, Petar.

2008/2/7, Raghunandan B <[EMAIL PROTECTED]>:
>
> Hi,
> How do i write cactus test case to test this servlet
>
>
> import java.io.*;
>
> import javax.servlet.http.*;
> import javax.servlet.*;
> import java.net.*;
> import java.util.*;
>
>
>
> public class SampleServlet extends HttpServlet
> {
>
> public void doGet(HttpServletRequest request,
>                     HttpServletResponse response)
>       throws ServletException, IOException {
>     response.setContentType("text/html");
>     PrintWriter out = response.getWriter();
>     String title = "Session Tracking Example";
>     HttpSession session = request.getSession(true);
>     String heading;
>     Integer accessCount =
>       (Integer)session.getAttribute("accessCount");
>     if (accessCount == null) {
>         accessCount = new Integer(0);
>               } else {
>
>         accessCount = new Integer(accessCount.intValue() + 1);
>       }
>
>     // Use setAttribute instead of putValue in version 2.2.
>     session.setAttribute("accessCount", accessCount);
>
>     out.println(
>                 "<BODY>\n"+ " <p align=center>"+
>         "Session ID" +
>
>                  session.getId() + "<br>"
>                 +
>                 "  Creation Time\n" +
>
>                 new Date(session.getCreationTime()) + "\n" + "<br>"
>                 +
>
>                 "  Time of Last Access\n" +
>
>                 new Date(session.getLastAccessedTime()) + "\n" +"<br>"
>                 +
>
>                 "  Number of Previous Accesses\n" +
>                  accessCount + "\n" + "</p>"+
>
>                 "</BODY></HTML>");
>
>   }
>
>   /** Handle GET and POST requests identically. */
>
>   public void doPost(HttpServletRequest request,
>                      HttpServletResponse response)
>       throws ServletException, IOException {
>     doGet(request, response);
>   }
> }
>
>
>
> Regards,
>
> Raghu
>



-- 
Regards, Petar!
Karlovo, Bulgaria.

EOOXML Objections
http://www.grokdoc.net/index.php/EOOXML_objections

Public PGP Key at:
https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611

Reply via email to