use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieRFC2109Spec method testParseDomainEqualsHost.
/**
* Test domain equals host
*/
public void testParseDomainEqualsHost() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value; domain=www.b.com; version=1");
CookieSpec cookiespec = new RFC2109Spec();
Cookie[] parsed = cookieParse(cookiespec, "www.b.com", 80, "/", false, header);
assertNotNull(parsed);
assertEquals(1, parsed.length);
assertEquals("www.b.com", parsed[0].getDomain());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieRFC2109Spec method testParseAttributeNullPath.
public void testParseAttributeNullPath() throws Exception {
CookieSpec cookiespec = new RFC2109Spec();
try {
Cookie cookie = new Cookie();
cookiespec.parseAttribute(new NameValuePair("path", null), cookie);
fail("MalformedCookieException must have been thrown");
} catch (MalformedCookieException expected) {
}
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieRFC2109Spec method testSecondDomainLevelCookieMatch.
public void testSecondDomainLevelCookieMatch() throws Exception {
Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false);
cookie.setDomainAttributeSpecified(true);
cookie.setPathAttributeSpecified(true);
CookieSpec cookiespec = new RFC2109Spec();
assertFalse(cookiespec.match("sourceforge.net", 80, "/", false, cookie));
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieRFC2109Spec method testNullCookieValueFormatting.
/**
* Tests if null cookie values are handled correctly.
*/
public void testNullCookieValueFormatting() {
Cookie cookie = new Cookie(".whatever.com", "name", null, "/", null, false);
cookie.setDomainAttributeSpecified(true);
cookie.setPathAttributeSpecified(true);
CookieSpec cookiespec = new RFC2109Spec();
String s = cookiespec.formatCookie(cookie);
assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com", s);
cookie.setVersion(1);
s = cookiespec.formatCookie(cookie);
assertEquals("$Version=\"1\"; name=\"\"; $Path=\"/\"; $Domain=\".whatever.com\"", s);
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieRFC2109Spec method testParseWithIllegalDomain1.
/**
* Domain does not start with a dot
*/
public void testParseWithIllegalDomain1() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value; domain=a.b.com; version=1");
CookieSpec cookiespec = new RFC2109Spec();
try {
Cookie[] parsed = cookieParse(cookiespec, "www.a.b.com", 80, "/", false, header);
fail("MalformedCookieException should have been thrown");
} catch (MalformedCookieException e) {
// expected
}
}
Aggregations