use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseWithExpires.
public void testParseWithExpires() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value;Expires=Thu, 01-Jan-1970 00:00:10 GMT");
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());
assertEquals(new Date(10000L), 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 testMatchNullHost.
public void testMatchNullHost() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie();
try {
cookiespec.match(null, 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 testCookieMatch3.
public void testCookieMatch3() throws Exception {
CookieSpec cookiespec = new CookieSpecBase();
Cookie cookie = new Cookie(".whatever.com", "name", "value", "/", null, false);
assertTrue(cookiespec.match(".really.whatever.com", 80, "/", false, cookie));
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieCompatibilitySpec method testParseSimple.
public void testParseSimple() 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, "/path/path", false, header);
assertEquals("Found 1 cookie.", 1, parsed.length);
assertEquals("Name", "cookie-name", parsed[0].getName());
assertEquals("Value", "cookie-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", "/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 testParseWithBlankHost.
public void testParseWithBlankHost() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value; domain=127.0.0.1; path=/; secure");
CookieSpec cookiespec = new CookieSpecBase();
try {
Cookie[] parsed = cookieParse(cookiespec, " ", 80, "/", false, header);
fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations