How to test Servlet using httpunit or junit?Any advice will be helpful.
807603Nov 17 2007 — edited Nov 18 2007how to test servlet with the code below.
in method doPost or doGet,
doPost(HttpServletRequest req,HttpServletResponse resp)
{
DataInputStream dis =null;
String data="";
dis = new DataInputStream(req.getInputStream());
data=dis.readUTF();// readInt(),readBoolean() ,etc may applied
System.out.println("data:"+data);
}
if i code req.getParameter("param"); then i wrote test programm like this request.setParameter("param","something");the servlet can get the value.
my question is ,how can i test the code above?how to set the input value so that the HttpServletRequest object can read the data?