vmassol     01/06/27 13:45:10

  Modified:    cactus/src/sample/share/org/apache/commons/cactus/sample/unit
                        TestServletTestCase2.java
  Log:
  added test to cookie encoding bug so that it doesn't happen again ... :)
  
  Revision  Changes    Path
  1.4       +30 -0     
jakarta-commons/cactus/src/sample/share/org/apache/commons/cactus/sample/unit/TestServletTestCase2.java
  
  Index: TestServletTestCase2.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/sample/share/org/apache/commons/cactus/sample/unit/TestServletTestCase2.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestServletTestCase2.java 2001/05/05 14:37:18     1.3
  +++ TestServletTestCase2.java 2001/06/27 20:45:08     1.4
  @@ -362,4 +362,34 @@
           assertEquals("</html>", results[2]);
       }
   
  +    //-------------------------------------------------------------------------
  +
  +    /**
  +     * Verify that special characters in cookies are not URL encoded
  +     *
  +     * @param theRequest the request object that serves to initialize the
  +     *                   HTTP connection to the server redirector.
  +     */
  +    public void beginCookieEncoding(ServletTestRequest theRequest)
  +    {
  +        // Note: the pipe ('&') character is a special character regarding
  +        // URL encoding
  +        theRequest.addCookie("testcookie", "user&pwd");
  +    }
  +
  +    /**
  +     * Verify that special characters in cookies are not encoded
  +     */
  +    public void testCookieEncoding()
  +    {
  +        Cookie[] cookies = request.getCookies();
  +        for (int i = 0; i < cookies.length; i++) {
  +            if (cookies[i].getName().equals("testcookie")) {
  +                assertEquals("user&pwd", cookies[i].getValue());
  +                return;
  +            }
  +        }
  +        fail("No cookie named 'testcookie' found");
  +    }
  +
   }
  
  
  

Reply via email to