Author: jfclere
Date: Mon Mar 17 02:03:05 2008
New Revision: 637793

URL: http://svn.apache.org/viewvc?rev=637793&view=rev
Log:
Arrange the cookie tests.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/test/build.xml
    
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=637793&r1=637792&r2=637793&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Mon Mar 17 02:03:05 2008
@@ -28,11 +28,6 @@
 PATCHES ACCEPTED TO BACKPORT:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-* Add tests for the cookie parsing and use package 
org.apache.catalina.tomcat.util.http
-  http://people.apache.org/~jfclere/patches/test_cookies.patch2
-  +1: jfclere, fhanik, markt
-  -1:
-
 PATCHES PROPOSED TO BACKPORT:
   [ New proposals should be added at the end of the list ]
 

Modified: tomcat/tc6.0.x/trunk/test/build.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/test/build.xml?rev=637793&r1=637792&r2=637793&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/test/build.xml (original)
+++ tomcat/tc6.0.x/trunk/test/build.xml Mon Mar 17 02:03:05 2008
@@ -28,6 +28,7 @@
   <property name="tomcat.build" value="${basedir}/../output/build"/>
 
   <property name="compile.source" value="1.5"/>
+  <property name="compile.debug" value="true"/>
 
   <property name="junit.jar" value="${junit.home}/junit.jar"/>
   <property name="test.runner" value="junit.textui.TestRunner"/>
@@ -61,7 +62,7 @@
 
   <target name="all" depends="compile">
      <java dir="${test.classes}" classname="${test.runner}" fork="yes" 
failonerror="${test.failonerror}">
-            <arg value="TestCookies"/>
+            <arg value="org.apache.catalina.tomcat.util.http.TestCookies"/>
             <classpath refid="tomcat.test.classpath"/>
         </java>
 

Modified: 
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java?rev=637793&r1=637792&r2=637793&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java 
(original)
+++ 
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java 
Mon Mar 17 02:03:05 2008
@@ -15,6 +15,8 @@
  *  limitations under the License.
  */
 
+package org.apache.catalina.tomcat.util.http; 
+
 import org.apache.tomcat.util.http.Cookies;
 import org.apache.tomcat.util.http.ServerCookie;
 
@@ -69,8 +71,8 @@
         test("$Version=1;foo=\"bar\";$Domain=apache.org;$Port=8080;a=b", 
"foo", "bar", "a", "b");
 
         // make sure these never split into two cookies - JVK
-        test("$Version=1;foo=\"b\"ar\";$Domain=apache.org;$Port=8080;a=b",  
"foo", "b", "a", "b");
-        test("$Version=1;foo=\"b\\\"ar\";$Domain=apache.org;$Port=8080;a=b", 
"foo", "b\\\"ar", "a", "b");
+        test("$Version=1;foo=\"b\"ar\";$Domain=apache.org;$Port=8080;a=b",  
"foo", "b", "a", "b"); // Incorrectly escaped.
+        test("$Version=1;foo=\"b\\\"ar\";$Domain=apache.org;$Port=8080;a=b", 
"foo", "b\"ar", "a", "b"); // correctly escaped.
         test("$Version=1;foo=\"b'ar\";$Domain=apache.org;$Port=8080;a=b", 
"foo", "b'ar", "a", "b");
         // JFC: sure it is "b" and not b'ar ?
         test("$Version=1;foo=b'ar;$Domain=apache.org;$Port=8080;a=b", "foo", 
"b", "a", "b");
@@ -113,8 +115,28 @@
 
         
         test("foo;a=b;;\\;bar=rab", "foo", "", "a", "b", "bar", "rab");
+
+        // Try all the separators of version1 in version0 cookie.
+        // Won't work we only parse version1 cookie result 1 cookie.
+        test("a=()<>@:\\\"/[]?={}\t; foo=bar", "foo", "bar");
+
+        // Test the version.
+        test("$Version=1;foo=bar", 1);
+        test("$Version=0;foo=bar", 0);
     }
 
+    public static void test( String s, int val ) throws Exception {
+        System.out.println("Processing [" + s + "]");
+        Cookies cs=new Cookies(null);
+        cs.processCookieHeader( s.getBytes(), 0, s.length());
+        int num = cs.getCookieCount();
+        if (num != 1)
+          throw new Exception("wrong number of cookies " + num);
+        ServerCookie co = cs.getCookie(0);
+        System.out.println("One Cookie: " + co);
+        if (co.getVersion() != val)
+          throw new Exception("wrong version " + co.getVersion() + " != " + 
val);
+    }
     public static void test( String s ) throws Exception {
         System.out.println("Processing [" + s + "]");
         Cookies cs=new Cookies(null);

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=637793&r1=637792&r2=637793&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Mon Mar 17 02:03:05 2008
@@ -91,6 +91,13 @@
       </update>
     </changelog>
   </subsection>
+  <subsection name="Other">
+    <changelog>
+      <add>
+         Improve the Tests for unit tests for the cookie issues. (jfclere)
+      </add>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 6.0.16 (remm)">
   <subsection name="General">



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

Reply via email to