use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseWithComment.
public void testParseWithComment() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value; comment=\"This is a comment.\"");
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());
assertEquals("Comment", "This is a comment.", parsed[0].getComment());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseWithWhiteSpace.
public void testParseWithWhiteSpace() throws Exception {
Header header = new Header("Set-Cookie", " cookie-name = cookie-value ");
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 testMatchNullCookieDomain.
public void testMatchNullCookieDomain() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie(null, "name", "value", "/", null, false);
assertFalse(cookiespec.match("host", 80, "/", false, cookie));
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testValidateInvalidPort.
public void testValidateInvalidPort() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie();
try {
cookiespec.validate("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 testParseMultipleSamePaths.
public void testParseMultipleSamePaths() throws Exception {
Header header = new Header("Set-Cookie", "name1=value1;Version=1;Path=/commons,name1=value2;Version=1;Path=/commons");
CookieSpec cookiespec = new CookieSpecBase();
Cookie[] parsed = cookieParse(cookiespec, ".apache.org", 80, "/commons/httpclient", true, header);
HttpState state = new HttpState();
state.addCookies(parsed);
Cookie[] cookies = state.getCookies();
assertEquals("Found 1 cookies.", 1, cookies.length);
assertEquals("Name", "name1", cookies[0].getName());
assertEquals("Value", "value2", cookies[0].getValue());
}
Aggregations