You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/09/02 14:58:24 UTC
svn commit: r1621972 -
/tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java
Author: markt
Date: Tue Sep 2 12:58:24 2014
New Revision: 1621972
URL: http://svn.apache.org/r1621972
Log:
Refactor test to make it easier to test multiple cookie parsers
Modified:
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java
Modified: tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java?rev=1621972&r1=1621971&r2=1621972&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java Tue Sep 2 12:58:24 2014
@@ -24,6 +24,8 @@ import javax.servlet.http.Cookie;
import org.junit.Assert;
import org.junit.Test;
+import org.apache.tomcat.util.buf.MessageBytes;
+
public class TestCookies {
private Cookie FOO = new Cookie("foo", "bar");
private Cookie BAR = new Cookie("bar", "rab");
@@ -195,9 +197,12 @@ public class TestCookies {
}
private void test(String header, Cookie... expected) {
- Cookies cookies = new Cookies(null);
+ MimeHeaders mimeHeaders = new MimeHeaders();
+ Cookies cookies = new Cookies(mimeHeaders);
+ MessageBytes cookieHeaderValue = mimeHeaders.addValue("Cookie");
byte[] bytes = header.getBytes(StandardCharsets.UTF_8);
- cookies.processCookieHeader(bytes, 0, bytes.length);
+ cookieHeaderValue.setBytes(bytes, 0, bytes.length);
+ // Calling getCookieCount() triggers parsing
Assert.assertEquals(expected.length, cookies.getCookieCount());
for (int i = 0; i < expected.length; i++) {
Cookie cookie = expected[i];
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org