Re:Cactus test case

2008-02-11 Thread Raghunandan B
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


How to test method that return object of other class

2008-02-11 Thread Sunny Choudhary
 

 

  _  

From: Sunny Choudhary [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 12, 2008 11:54 AM
To: 'cactus-user@jakarta.apache.org'
Subject: How to test method that return object of other class

 

Hi

 

I want to test a method of a class which returns an object of
some other class that contains other objects and primitives.

How can I use the assert statements to unit test this and if the
method is returning the object (containing many variables) then how to enter
it in the assert statements.

 

-Sunny

 


DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.


How to test method that return object of other class

2008-02-11 Thread Sunny Choudhary
 

 

Hi

 

I want to test a method of a class which returns an object of
some other class that contains other objects and primitives.

How can I use the assert statements to unit test this and if the
method is returning the object (containing many variables) then how to enter
it in the assert statements.

 

-Sunny

 


DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.