Hi Roth,
  Thanx for your help.Ii did work!
But I had to use com.meterware.httpunit.WebResponse
instead of  org.apache.cactus.WebResponse .

  As per your suggestion on method names i know
it...it was a lazy code for work with cactus features
:-)

Best Regards,
 Prithvi
 http://www.prithvibhat.com

--- Franz Roth <[EMAIL PROTECTED]> wrote:

> hi,
> that's true; you can get the redirection-string by  
> webresponse.getHeaderField("LOCATION");
> 
> by the way: method-names should never begin
> upperCased ("RedirectPage")
> in your example it would be a good solution to
> overwrite the service-Method
> 
> bye
> 
> On Sat, 02 Sep 2006 13:43:50 +0200, Miroslav ¦ulc  
> <[EMAIL PROTECTED]> wrote:
> 
> > 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("<TITLE>prithvibhat.com
> >>             - Comprehensive information on Udupi</TITLE>")
> >
> >> 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:
> [EMAIL PROTECTED]
> >> For additional commands, e-mail:
> [EMAIL PROTECTED]
> >>
> >>
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to