use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseWithAll.
public void testParseWithAll() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value;Version=1;Path=/commons;Domain=.apache.org;" + "Comment=This is a comment.;secure;Expires=Thu, 01-Jan-1970 00:00:10 GMT");
CookieSpec cookiespec = new CookieSpecBase();
Cookie[] parsed = cookieParse(cookiespec, ".apache.org", 80, "/commons/httpclient", true, header);
assertEquals("Found 1 cookie.", 1, parsed.length);
assertEquals("Name", "cookie-name", parsed[0].getName());
assertEquals("Value", "cookie-value", parsed[0].getValue());
assertEquals("Domain", ".apache.org", parsed[0].getDomain());
assertEquals("Path", "/commons", parsed[0].getPath());
assertTrue("Secure", parsed[0].getSecure());
assertEquals(new Date(10000L), parsed[0].getExpiryDate());
assertEquals("Comment", "This is a comment.", parsed[0].getComment());
assertEquals("Version", 0, parsed[0].getVersion());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseWithQuotes.
public void testParseWithQuotes() throws Exception {
Header header = new Header("Set-Cookie", " cookie-name = \" cookie-value \" ;path=/");
CookieSpec cookiespec = new CookieSpecBase();
Cookie[] parsed = cookieParse(cookiespec, "127.0.0.1", 80, "/", false, header);
assertEquals("Found 1 cookie.", 1, parsed.length);
assertEquals("Name", "cookie-name", parsed[0].getName());
assertEquals("Value", " cookie-value ", parsed[0].getValue());
assertEquals("Domain", "127.0.0.1", parsed[0].getDomain());
assertEquals("Path", "/", parsed[0].getPath());
assertTrue("Secure", !parsed[0].getSecure());
assertTrue("ExpiryDate", null == parsed[0].getExpiryDate());
assertTrue("Comment", null == parsed[0].getComment());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testGenericCookieFormattingAsHeader.
public void testGenericCookieFormattingAsHeader() throws Exception {
Header header = new Header("Set-Cookie", "name=value; path=/; domain=.mydomain.com");
CookieSpec cookiespec = new CookieSpecBase();
Cookie[] cookies = cookiespec.parse("myhost.mydomain.com", 80, "/", false, header);
cookiespec.validate("myhost.mydomain.com", 80, "/", false, cookies[0]);
Header cookieheader = cookiespec.formatCookieHeader(cookies[0]);
assertEquals("name=value", cookieheader.getValue());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseAttributeBlankPath.
public void testParseAttributeBlankPath() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie();
cookiespec.parseAttribute(new NameValuePair("path", " "), cookie);
assertEquals("/", cookie.getPath());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseWithSecure.
public void testParseWithSecure() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value; secure");
CookieSpec cookiespec = new CookieSpecBase();
Cookie[] parsed = cookieParse(cookiespec, "127.0.0.1", 80, "/", true, header);
assertEquals("Found 1 cookie.", 1, parsed.length);
assertEquals("Name", "cookie-name", parsed[0].getName());
assertEquals("Value", "cookie-value", parsed[0].getValue());
assertEquals("Domain", "127.0.0.1", parsed[0].getDomain());
assertEquals("Path", "/", parsed[0].getPath());
assertTrue("Secure", parsed[0].getSecure());
assertTrue("ExpiryDate", null == parsed[0].getExpiryDate());
assertTrue("Comment", null == parsed[0].getComment());
}
Aggregations