Return-Path: <214060@infosys.com> list-help: list-unsubscribe: List-Post: List-Id: Mailing-List: contact cactus-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list cactus-user@jakarta.apache.org Received: (qmail 61811 invoked by uid 99); 19 Jan 2006 04:40:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jan 2006 20:40:15 -0800 X-ASF-Spam-Status: No, hits=2.4 required=10.0 tests=DNS_FROM_RFC_ABUSE,FROM_ALL_NUMS,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [216.251.50.9] (HELO SFOVWL03.infosys.com) (216.251.50.9) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jan 2006 20:40:13 -0800 Received: from indhubbhs04.ad.infosys.com ([192.168.200.84]) by SFOVWL03.infosys.com with InterScan Messaging Security Suite; Wed, 18 Jan 2006 20:35:09 -0800 Received: from BLRKECMSG04.ad.infosys.com ([172.25.213.134]) by indhubbhs04.ad.infosys.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 19 Jan 2006 10:08:27 +0530 Received: from BLRKECMSG13.ad.infosys.com ([172.22.147.5]) by BLRKECMSG04.ad.infosys.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 19 Jan 2006 10:08:22 +0530 Content-class: urn:content-classes:message Subject: testing output stream of doGet failed Date: Thu, 19 Jan 2006 09:51:37 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C61CAF.CE7265C8" Message-ID: X-MS-Has-Attach: X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 X-MS-TNEF-Correlator: Thread-Topic: testing output stream of doGet failed Thread-Index: AcYcr9aYyHKyVVv+TgqeyoRb1xfE6A== From: "214060 - Shou Jiesong" <214060@infosys.com> To: X-OriginalArrivalTime: 19 Jan 2006 04:38:22.0149 (UTC) FILETIME=[2D9A6F50:01C61CB2] X-Virus-Checked: Checked by ClamAV on apache.org ------_=_NextPart_001_01C61CAF.CE7265C8 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, I creates a servlet with a doGet() method. public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session =3D request.getSession(); =0D Integer count =3D (Integer)session.getAttribute("Count"); if (count =3D=3D null) count =3D new Integer(0); count =3D new Integer(count.intValue() + 1); session.setAttribute("Count", count); response.setContentType("text/html"); PrintWriter out =3D response.getWriter(); =0D out.print("Testing Servlets" + "

Count is " + count + "

"); out.close(); // System.out.println("doget"); } Everytime doget() is called, count will increase by 1. =0D In my test case class, I want to test the output stream of the servlet. public void testDoGet() throws ServletException, IOException{ SessionTrackingServlet servlet =3D new SessionTrackingServlet(); servlet.doGet(request, response); System.out.println(session.getAttribute("Count")); servlet.doGet(request, response); System.out.println(session.getAttribute("Count")); =0D =0D } =0D public void endDoGet(WebResponse response){ String expected =3D "Testing Servlets" + "

Count is " + "2" + "

"; assertEquals(expected, response.getText()); } =0D I observed that the test failed. I called doGet() twice and it was suppose to increase count to 2. it does in testDoGet() since I could see the printed result; it was 2.=0D But in endDoGet(), the count was always 1 whatever how many times doGet() was called in testDoGet(). =0D Thanks & Regards, Jason **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended= solely for the use of the addressee(s). If you are not the intended= recipient, please notify the sender by e-mail and delete the original= message. Further, you are not to copy, disclose, or distribute this e-mail= or its contents to any other person and any such actions are unlawful.= This e-mail may contain viruses. Infosys has taken every reasonable= precaution to minimize this risk, but is not liable for any damage you may= sustain as a result of any virus in this e-mail. You should carry out your= own virus checks before opening the e-mail or attachment. Infosys reserves= the right to monitor and review the content of all messages sent to or= from this e-mail address. Messages sent to or from this e-mail address may= be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS*** ------_=_NextPart_001_01C61CAF.CE7265C8--