Return-Path: 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 52521 invoked by uid 99); 2 Sep 2006 11:44:23 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Sep 2006 04:44:23 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [82.113.63.73] (HELO titan.startnet.cz) (82.113.63.73) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Sep 2006 04:44:21 -0700 Received: (qmail 2127 invoked from network); 2 Sep 2006 13:43:58 +0200 Received: from unknown (HELO ?192.168.1.4?) (miroslav.sulc@startnet.cz@10.15.192.25) by titan.local.startnet.cz with ESMTPA; 2 Sep 2006 13:43:58 +0200 Message-ID: <44F96E76.2010402@startnet.cz> Date: Sat, 02 Sep 2006 13:43:50 +0200 From: =?windows-1252?Q?Miroslav_=8Aulc?= Organization: StartNet s.r.o. User-Agent: Thunderbird 1.5.0.5 (X11/20060729) MIME-Version: 1.0 To: Cactus Users List Subject: Re: Servlet redirection testing References: <20060902112241.76474.qmail@web36515.mail.mud.yahoo.com> In-Reply-To: <20060902112241.76474.qmail@web36515.mail.mud.yahoo.com> Content-Type: multipart/mixed; boundary="------------060008050800000204000606" X-Virus-Checked: Checked by ClamAV on apache.org --------------060008050800000204000606 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Hi Prithvi, I'm still in the "before newbie" stage but I guess it won't work the way you expect. I think it works this way: You say: "Hey, give me http://localhost/" And you get: "Hey, you should send request for http://localhost/default.html (or http://localhost/tp/default.html) to the server" And then in the next request you can get the content of the page you are redirected to. So what you get is the information that you should send request for another page, not the new page itself. You'll get the new page on the next request (if you make the next request). I hope this helps. -- Miroslav Prithvi Bhat wrote: > Hi All, > I am going mad with testing servlet redirections > using cactus.There are tons of articles on cactus on > the internet.None of them did help.I bought Vincent > Massol's book "Junit in Action" that too did not help. > Any one's help in this regard would be deeply > appreciated. > > My sample servlet to be tested is as below > ============================================== > > import java.io.IOException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletResponse; > import javax.servlet.http.HttpServletRequest; > > > public class SampleServlet extends HttpServlet > { > > public void RedirectPage(HttpServletRequest > request,HttpServletResponse response) > throws IOException > { > String strRedirectorFlag = > request.getParameter("strRedirectorFlag"); > > System.out.println("strRedirectorFlag"+strRedirectorFlag); > > if (strRedirectorFlag.equals("1") ) > { > > > response.sendRedirect("http://localhost/default.html"); > } > else > { > > > response.sendRedirect("http://localhost/tp/default.html"); > } > > } > }//class SampleServlet > =================================================== > My test servlet is as below > =================================================== > import java.io.IOException; > import junit.framework.Test; > import junit.framework.TestSuite; > > import org.apache.cactus.ServletTestCase; > import org.apache.cactus.WebRequest; > import org.apache.cactus.WebResponse; > > public class TestSampleServlet extends > ServletTestCase > { > > public void beginRedirection(WebRequest > webRequest) > { > webRequest.addParameter("strRedirectorFlag","1"); > } > > public void testRedirection() > throws IOException > { > SampleServlet servlet = new > SampleServlet(); > > servlet.RedirectPage(request,response); > } > > public void endRedirection(WebResponse > webResponse) > { > > System.out.println("Response"+webResponse.getText()); > > assertTrue("udupi",webResponse.getText().indexOf("prithvibhat.com > - Comprehensive information on Udupi") > > 0); > } > > } > > =================================================== > > If you see the code carefully in my Test case I want > to check whether the redirection in my servlet was to > > http://localhost/default.html or > http://localhost/tp/default.html > > So I use the response.getText() method to compare it > with the page contents.Unfortunately getText() method > always returns me NULL! > > Please help... > > Best Regards, > Prithvi > > --------------------------------------------------------------------- > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: cactus-user-help@jakarta.apache.org > > --------------060008050800000204000606--