tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/tester/web Session07a.jsp Session07b.jsp
Date Mon, 25 Jun 2001 15:40:57 GMT
craigmcc    01/06/25 08:40:56

  Modified:    tester/src/bin tester.xml
               tester/src/tester/org/apache/tester TestClient.java
  Added:       tester/web Session07a.jsp Session07b.jsp
  Log:
  Add unit tests for maintaining a session across redirects.
  
  Revision  Changes    Path
  1.52      +17 -0     jakarta-tomcat-4.0/tester/src/bin/tester.xml
  
  Index: tester.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.xml,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- tester.xml	2001/06/23 19:27:24	1.51
  +++ tester.xml	2001/06/25 15:40:47	1.52
  @@ -1144,6 +1144,23 @@
            request="${context.path}/WrappedSession06" debug="${debug}"
         outContent="Session06 PASSED"/>
   
  +    <!-- ========== Pass Attributes Across Redirect ======================= -->
  +
  +    <!-- Session maintained across redirect -->
  +    <!-- NOTE:  The following two-step pattern is required because
  +         HttpURLConnection does not forward the session cookie it
  +         receives on to the redirected location (the way that a
  +         browser will do so) -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Session07a.jsp" debug="${debug}"
  +          status="302"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Session07b.jsp" debug="${debug}"
  +     joinSession="true"
  +      outContent="Session07 PASSED"/>
  +
     </target>
   
   
  
  
  
  1.8       +25 -3     jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/TestClient.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestClient.java	2001/04/17 04:22:25	1.7
  +++ TestClient.java	2001/06/25 15:40:52	1.8
  @@ -108,16 +108,19 @@
    *     are expected in the response (order independent).</li>
    * <li><strong>port</strong> - The port number to which this request
will be
    *     sent.  Defaults to <code>8080</code> if not specified.</li>
  + * <li><strong>redirect</strong> - If set to true, follow any redirect
that
  + *     is returned by the server.  (Only works when using HttpURLConnection).
  + *     </li>
    * <li><strong>request</strong> - The request URI to be transmitted for
this
    *     request.  This value should start with a slash character ("/"), and
    *     be the server-relative URI of the requested resource.</li>
    * <li><strong>status</strong> - The HTTP status code that is expected
in the
    *     response from the server.  Defaults to <code>200</code> if not
  - *     specified.</li>
  + *     specified.  Set to zero to disable checking the return value.</li>
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2001/04/17 04:22:25 $
  + * @version $Revision: 1.8 $ $Date: 2001/06/25 15:40:52 $
    */
   
   public class TestClient extends Task {
  @@ -326,6 +329,20 @@
   
   
       /**
  +     * Should we follow redirects returned by the server?
  +     */
  +    protected boolean redirect = false;
  +
  +    public boolean getRedirect() {
  +        return (this.redirect);
  +    }
  +
  +    public void setRedirect(boolean redirect) {
  +        this.redirect = redirect;
  +    }
  +
  +
  +    /**
        * The request URI to be sent to the server.  This value is required.
        */
       protected String request = null;
  @@ -435,7 +452,10 @@
                                          sessionId);
               }
   
  -            conn.setFollowRedirects(false);
  +            if (this.redirect && (debug >= 1))
  +                System.out.println("FLAG: setInstanceFollowRedirects(" +
  +                                   this.redirect + ")");
  +            conn.setInstanceFollowRedirects(this.redirect);
               conn.setRequestMethod(method);
               if (inHeaders != null) {
                   String headers = inHeaders;
  @@ -1053,6 +1073,8 @@
        */
       protected String validateStatus(int status) {
   
  +        if (this.status == 0)
  +            return (null);
           if (this.status == status)
               return (null);
           else
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/Session07a.jsp
  
  Index: Session07a.jsp
  ===================================================================
  <%@ page contentType="text/plain" %><jsp:useBean id="simpleBean"
      scope="session" class="org.apache.tester.SessionBean"/><%
    simpleBean.setStringProperty("From Session07a");
    response.sendRedirect("Session07b.jsp");
  %>
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/Session07b.jsp
  
  Index: Session07b.jsp
  ===================================================================
  <%@ page contentType="text/plain" %><jsp:useBean id="simpleBean"
      scope="session" class="org.apache.tester.SessionBean"/><%
    if ("From Session07a".equals(simpleBean.getStringProperty())) {
      out.println("Session07 PASSED");
    } else {
      out.println("Session07 FAILED - Property = '" +
                  simpleBean.getStringProperty() + "'");
    }
  %>
  
  
  

Mime
View raw message