本文整理汇总了Java中org.apache.http.cookie.CookieAttributeHandler.validate方法的典型用法代码示例。如果您正苦于以下问题:Java CookieAttributeHandler.validate方法的具体用法?Java CookieAttributeHandler.validate怎么用?Java CookieAttributeHandler.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.cookie.CookieAttributeHandler
的用法示例。
在下文中一共展示了CookieAttributeHandler.validate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasicDomainValidate2
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicDomainValidate2() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
final CookieAttributeHandler h = new BasicDomainHandler();
cookie.setDomain("somehost");
h.validate(cookie, origin);
cookie.setDomain("otherhost");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
示例2: testRFC2109DomainValidate3
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testRFC2109DomainValidate3() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
final CookieAttributeHandler h = new RFC2109DomainHandler();
cookie.setDomain(".a.com");
h.validate(cookie, origin);
cookie.setDomain(".com");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
示例3: testRFC2109VersionValidate
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testRFC2109VersionValidate() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
final CookieAttributeHandler h = new RFC2109VersionHandler();
cookie.setVersion(12);
h.validate(cookie, origin);
cookie.setVersion(-12);
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException must have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
示例4: testNetscapeDomainValidate1
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testNetscapeDomainValidate1() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
final CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain("somehost");
h.validate(cookie, origin);
cookie.setDomain("otherhost");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
示例5: testNetscapeDomainValidate3
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testNetscapeDomainValidate3() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
final CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain(".a.com");
h.validate(cookie, origin);
cookie.setDomain(".com");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
示例6: testNetscapeDomainValidate4
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testNetscapeDomainValidate4() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.a.b.c", 80, "/", false);
final CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain(".a.b.c");
h.validate(cookie, origin);
cookie.setDomain(".b.c");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
示例7: validate
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
for (CookieAttributeHandler handler: getAttribHandlers()) {
handler.validate(cookie, origin);
}
}
示例8: validate
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
for (final CookieAttributeHandler handler: getAttribHandlers()) {
handler.validate(cookie, origin);
}
}
示例9: validate
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Override
public final void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
for (final CookieAttributeHandler handler: this.attribHandlers) {
handler.validate(cookie, origin);
}
}
示例10: validate
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Override
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
for (final CookieAttributeHandler handler: getAttribHandlers()) {
handler.validate(cookie, origin);
}
}
示例11: testBasicDomainValidate3
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicDomainValidate3() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
final CookieAttributeHandler h = new BasicDomainHandler();
cookie.setDomain(".somedomain.com");
h.validate(cookie, origin);
}
示例12: testBasicDomainValidate4
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicDomainValidate4() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
final CookieAttributeHandler h = new BasicDomainHandler();
cookie.setDomain(null);
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
示例13: testBasicPathValidate
import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicPathValidate() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
final CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
h.validate(cookie, origin);
cookie.setPath("/stuffed");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException must have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}