use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseNoValue.
public void testParseNoValue() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=");
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", "", parsed[0].getValue());
assertTrue("Comment", null == parsed[0].getComment());
assertTrue("ExpiryDate", null == parsed[0].getExpiryDate());
// assertTrue("isToBeDiscarded",parsed[0].isToBeDiscarded());
assertTrue("isPersistent", !parsed[0].isPersistent());
assertEquals("Domain", "127.0.0.1", parsed[0].getDomain());
assertEquals("Path", "/", parsed[0].getPath());
assertTrue("Secure", !parsed[0].getSecure());
assertEquals("Version", 0, parsed[0].getVersion());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testSecondDomainLevelCookieMatch1.
public void testSecondDomainLevelCookieMatch1() throws Exception {
Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false);
cookie.setDomainAttributeSpecified(true);
cookie.setPathAttributeSpecified(true);
CookieSpec cookiespec = new CookieSpecBase();
assertTrue(cookiespec.match("sourceforge.net", 80, "/", false, cookie));
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testMatchInvalidPort.
public void testMatchInvalidPort() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie();
try {
cookiespec.match("host", -80, "/", false, cookie);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException expected) {
}
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testGenericCookieFormatting.
/**
* Tests generic cookie formatting.
*/
public void testGenericCookieFormatting() 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]);
String s = cookiespec.formatCookie(cookies[0]);
assertEquals("name=value", s);
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testMatchNullPath.
public void testMatchNullPath() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie();
try {
cookiespec.match("host", 80, null, false, cookie);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException expected) {
}
}
Aggregations