use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieNetscapeDraft method testParseWithNegativePort.
public void testParseWithNegativePort() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value; domain=127.0.0.1; path=/; secure");
CookieSpec cookiespec = new NetscapeDraftSpec();
try {
Cookie[] parsed = cookieParse(cookiespec, "127.0.0.1", -80, null, false, header);
fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException e) {
// expected
}
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieNetscapeDraft method testParseWithNullHost.
public void testParseWithNullHost() throws Exception {
Header header = new Header("Set-Cookie", "cookie-name=cookie-value; domain=127.0.0.1; path=/; secure");
CookieSpec cookiespec = new NetscapeDraftSpec();
try {
Cookie[] parsed = cookieParse(cookiespec, null, 80, "/", false, header);
fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException e) {
// expected
}
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieNetscapeDraft method testNetscapeCookieFormatting.
/**
* Tests Netscape specific cookie formatting.
*/
public void testNetscapeCookieFormatting() throws Exception {
Header header = new Header("Set-Cookie", "name=value; path=/; domain=.mydomain.com");
CookieSpec cookiespec = new NetscapeDraftSpec();
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 TestCookieNetscapeDraft method testParseRelativePath.
public void testParseRelativePath() throws Exception {
Header header = new Header("Set-Cookie", "name1=value1;Path=whatever");
CookieSpec cookiespec = new NetscapeDraftSpec();
Cookie[] parsed = cookieParse(cookiespec, "host", 80, "whatever", true, header);
assertEquals("Found 1 cookies.", 1, parsed.length);
assertEquals("Name", "name1", parsed[0].getName());
assertEquals("Value", "value1", parsed[0].getValue());
assertEquals("Domain", "host", parsed[0].getDomain());
assertEquals("Path", "whatever", parsed[0].getPath());
}
use of org.apache.commons.httpclient.Cookie in project ecf by eclipse.
the class TestCookieNetscapeDraft method testNetscapeCookieExpireAttribute.
/**
* Tests Netscape specific expire attribute parsing.
*/
public void testNetscapeCookieExpireAttribute() throws Exception {
CookieSpec cookiespec = new NetscapeDraftSpec();
Header header = new Header("Set-Cookie", "name=value; path=/; domain=.mydomain.com; expires=Thu, 01-Jan-2070 00:00:10 GMT; comment=no_comment");
Cookie[] cookies = cookiespec.parse("myhost.mydomain.com", 80, "/", false, header);
cookiespec.validate("myhost.mydomain.com", 80, "/", false, cookies[0]);
header = new Header("Set-Cookie", "name=value; path=/; domain=.mydomain.com; expires=Thu 01-Jan-2070 00:00:10 GMT; comment=no_comment");
try {
cookies = cookiespec.parse("myhost.mydomain.com", 80, "/", false, header);
cookiespec.validate("myhost.mydomain.com", 80, "/", false, cookies[0]);
fail("MalformedCookieException must have been thrown");
} catch (MalformedCookieException expected) {
}
}
Aggregations