mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-16 15:07:27 +00:00
Avoid duplicate redundant objects and use Singleton instead.
This commit is contained in:
parent
dca9108352
commit
18fa09f6a2
@ -56,7 +56,7 @@ public class BasicCookieStore implements CookieStore, Serializable {
|
||||
|
||||
public BasicCookieStore() {
|
||||
super();
|
||||
this.cookies = new TreeSet<>(new CookieIdentityComparator());
|
||||
this.cookies = new TreeSet<>(CookieIdentityComparator.INSTANCE);
|
||||
this.lock = new ReentrantReadWriteLock();
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class CookieIdentityComparator implements Serializable, Comparator<Cookie> {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final CookieIdentityComparator INSTANCE = new CookieIdentityComparator();
|
||||
|
||||
private static final long serialVersionUID = 4466565437490631532L;
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +100,7 @@ public AsyncConnectExec(
|
||||
this.proxyAuthStrategy = proxyAuthStrategy;
|
||||
this.authenticator = new HttpAuthenticator();
|
||||
this.authCacheKeeper = authCachingDisabled ? null : new AuthCacheKeeper(schemePortResolver);
|
||||
this.routeDirector = new BasicRouteDirector();
|
||||
this.routeDirector = BasicRouteDirector.INSTANCE;
|
||||
}
|
||||
|
||||
static class State {
|
||||
|
@ -690,10 +690,10 @@ public CloseableHttpAsyncClient build() {
|
||||
new RequestUserAgent(userAgentCopy),
|
||||
new RequestExpectContinue());
|
||||
if (!cookieManagementDisabled) {
|
||||
b.add(new RequestAddCookies());
|
||||
b.add(RequestAddCookies.INSTANCE);
|
||||
}
|
||||
if (!cookieManagementDisabled) {
|
||||
b.add(new ResponseProcessCookies());
|
||||
b.add(ResponseProcessCookies.INSTANCE);
|
||||
}
|
||||
if (requestInterceptors != null) {
|
||||
for (final RequestInterceptorEntry entry: requestInterceptors) {
|
||||
|
@ -822,10 +822,10 @@ public CloseableHttpAsyncClient build() {
|
||||
new RequestUserAgent(userAgentCopy),
|
||||
new RequestExpectContinue());
|
||||
if (!cookieManagementDisabled) {
|
||||
b.add(new RequestAddCookies());
|
||||
b.add(RequestAddCookies.INSTANCE);
|
||||
}
|
||||
if (!cookieManagementDisabled) {
|
||||
b.add(new ResponseProcessCookies());
|
||||
b.add(ResponseProcessCookies.INSTANCE);
|
||||
}
|
||||
if (requestInterceptors != null) {
|
||||
for (final RequestInterceptorEntry entry: requestInterceptors) {
|
||||
|
@ -101,7 +101,7 @@ public ConnectExec(
|
||||
this.proxyAuthStrategy = proxyAuthStrategy;
|
||||
this.authenticator = new HttpAuthenticator();
|
||||
this.authCacheKeeper = authCachingDisabled ? null : new AuthCacheKeeper(schemePortResolver);
|
||||
this.routeDirector = new BasicRouteDirector();
|
||||
this.routeDirector = BasicRouteDirector.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -805,10 +805,10 @@ public CloseableHttpClient build() {
|
||||
new RequestUserAgent(userAgentCopy),
|
||||
new RequestExpectContinue());
|
||||
if (!cookieManagementDisabled) {
|
||||
b.add(new RequestAddCookies());
|
||||
b.add(RequestAddCookies.INSTANCE);
|
||||
}
|
||||
if (!cookieManagementDisabled) {
|
||||
b.add(new ResponseProcessCookies());
|
||||
b.add(ResponseProcessCookies.INSTANCE);
|
||||
}
|
||||
if (requestInterceptors != null) {
|
||||
for (final RequestInterceptorEntry entry: requestInterceptors) {
|
||||
|
@ -48,6 +48,14 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class BasicDomainHandler implements CommonCookieAttributeHandler {
|
||||
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final BasicDomainHandler INSTANCE = new BasicDomainHandler();
|
||||
|
||||
public BasicDomainHandler() {
|
||||
super();
|
||||
}
|
||||
|
@ -43,6 +43,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class BasicHttpOnlyHandler implements CommonCookieAttributeHandler {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final BasicHttpOnlyHandler INSTANCE = new BasicHttpOnlyHandler();
|
||||
|
||||
public BasicHttpOnlyHandler() {
|
||||
super();
|
||||
}
|
||||
|
@ -44,6 +44,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final BasicMaxAgeHandler INSTANCE = new BasicMaxAgeHandler();
|
||||
|
||||
public BasicMaxAgeHandler() {
|
||||
super();
|
||||
}
|
||||
|
@ -44,6 +44,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class BasicPathHandler implements CommonCookieAttributeHandler {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final BasicPathHandler INSTANCE = new BasicPathHandler();
|
||||
|
||||
public BasicPathHandler() {
|
||||
super();
|
||||
}
|
||||
|
@ -43,6 +43,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class BasicSecureHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final BasicSecureHandler INSTANCE = new BasicSecureHandler();
|
||||
|
||||
public BasicSecureHandler() {
|
||||
super();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public CookieSpec create(final HttpContext context) {
|
||||
if (cookieSpec == null) {
|
||||
synchronized (this) {
|
||||
if (cookieSpec == null) {
|
||||
this.cookieSpec = new IgnoreSpecSpec();
|
||||
this.cookieSpec = IgnoreSpecSpec.INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class IgnoreSpecSpec extends CookieSpecBase {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final IgnoreSpecSpec INSTANCE = new IgnoreSpecSpec();
|
||||
|
||||
@Override
|
||||
public List<Cookie> parse(final Header header, final CookieOrigin origin)
|
||||
throws MalformedCookieException {
|
||||
|
@ -56,6 +56,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final LaxExpiresHandler INSTANCE = new LaxExpiresHandler();
|
||||
|
||||
private static final BitSet DELIMS;
|
||||
static {
|
||||
final BitSet bitSet = new BitSet();
|
||||
|
@ -48,6 +48,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class LaxMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final LaxMaxAgeHandler INSTANCE = new LaxMaxAgeHandler();
|
||||
|
||||
private final static Pattern MAX_AGE_PATTERN = Pattern.compile("^\\-?[0-9]+$");
|
||||
|
||||
public LaxMaxAgeHandler() {
|
||||
|
@ -83,12 +83,12 @@ public CookieSpec create(final HttpContext context) {
|
||||
switch (this.compatibilityLevel) {
|
||||
case STRICT:
|
||||
this.cookieSpec = new RFC6265StrictSpec(
|
||||
new BasicPathHandler(),
|
||||
BasicPathHandler.INSTANCE,
|
||||
PublicSuffixDomainFilter.decorate(
|
||||
new BasicDomainHandler(), this.publicSuffixMatcher),
|
||||
new BasicMaxAgeHandler(),
|
||||
new BasicSecureHandler(),
|
||||
new BasicHttpOnlyHandler(),
|
||||
BasicDomainHandler.INSTANCE, this.publicSuffixMatcher),
|
||||
BasicMaxAgeHandler.INSTANCE,
|
||||
BasicSecureHandler.INSTANCE,
|
||||
BasicHttpOnlyHandler.INSTANCE,
|
||||
new BasicExpiresHandler(DateUtils.STANDARD_PATTERNS));
|
||||
break;
|
||||
case IE_MEDIUM_SECURITY:
|
||||
@ -102,20 +102,20 @@ public void validate(
|
||||
}
|
||||
},
|
||||
PublicSuffixDomainFilter.decorate(
|
||||
new BasicDomainHandler(), this.publicSuffixMatcher),
|
||||
new BasicMaxAgeHandler(),
|
||||
new BasicSecureHandler(),
|
||||
new BasicHttpOnlyHandler(),
|
||||
BasicDomainHandler.INSTANCE, this.publicSuffixMatcher),
|
||||
BasicMaxAgeHandler.INSTANCE,
|
||||
BasicSecureHandler.INSTANCE,
|
||||
BasicHttpOnlyHandler.INSTANCE,
|
||||
new BasicExpiresHandler(DateUtils.STANDARD_PATTERNS));
|
||||
break;
|
||||
default:
|
||||
this.cookieSpec = new RFC6265LaxSpec(
|
||||
new BasicPathHandler(),
|
||||
BasicPathHandler.INSTANCE,
|
||||
PublicSuffixDomainFilter.decorate(
|
||||
new BasicDomainHandler(), this.publicSuffixMatcher),
|
||||
new LaxMaxAgeHandler(),
|
||||
new BasicSecureHandler(),
|
||||
new LaxExpiresHandler());
|
||||
BasicDomainHandler.INSTANCE, this.publicSuffixMatcher),
|
||||
LaxMaxAgeHandler.INSTANCE,
|
||||
BasicSecureHandler.INSTANCE,
|
||||
LaxExpiresHandler.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,12 +43,12 @@
|
||||
public class RFC6265LaxSpec extends RFC6265CookieSpecBase {
|
||||
|
||||
public RFC6265LaxSpec() {
|
||||
super(new BasicPathHandler(),
|
||||
new BasicDomainHandler(),
|
||||
new LaxMaxAgeHandler(),
|
||||
new BasicSecureHandler(),
|
||||
new BasicHttpOnlyHandler(),
|
||||
new LaxExpiresHandler());
|
||||
super(BasicPathHandler.INSTANCE,
|
||||
BasicDomainHandler.INSTANCE,
|
||||
LaxMaxAgeHandler.INSTANCE,
|
||||
BasicSecureHandler.INSTANCE,
|
||||
BasicHttpOnlyHandler.INSTANCE,
|
||||
LaxExpiresHandler.INSTANCE);
|
||||
}
|
||||
|
||||
RFC6265LaxSpec(final CommonCookieAttributeHandler... handlers) {
|
||||
|
@ -43,11 +43,11 @@
|
||||
public class RFC6265StrictSpec extends RFC6265CookieSpecBase {
|
||||
|
||||
public RFC6265StrictSpec() {
|
||||
super(new BasicPathHandler(),
|
||||
new BasicDomainHandler(),
|
||||
new BasicMaxAgeHandler(),
|
||||
new BasicSecureHandler(),
|
||||
new BasicHttpOnlyHandler(),
|
||||
super(BasicPathHandler.INSTANCE,
|
||||
BasicDomainHandler.INSTANCE,
|
||||
BasicMaxAgeHandler.INSTANCE,
|
||||
BasicSecureHandler.INSTANCE,
|
||||
BasicHttpOnlyHandler.INSTANCE,
|
||||
new BasicExpiresHandler(DateUtils.STANDARD_PATTERNS));
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class BasicRouteDirector implements HttpRouteDirector {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final BasicRouteDirector INSTANCE = new BasicRouteDirector();
|
||||
|
||||
/**
|
||||
* Provides the next step.
|
||||
*
|
||||
|
@ -66,6 +66,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class RequestAddCookies implements HttpRequestInterceptor {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final RequestAddCookies INSTANCE = new RequestAddCookies();
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RequestAddCookies.class);
|
||||
|
||||
public RequestAddCookies() {
|
||||
|
@ -49,6 +49,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class RequestDefaultHeaders implements HttpRequestInterceptor {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final RequestDefaultHeaders INSTANCE = new RequestDefaultHeaders();
|
||||
|
||||
private final Collection<? extends Header> defaultHeaders;
|
||||
|
||||
/**
|
||||
|
@ -58,6 +58,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public class ResponseProcessCookies implements HttpResponseInterceptor {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final ResponseProcessCookies INSTANCE = new ResponseProcessCookies();
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ResponseProcessCookies.class);
|
||||
|
||||
public ResponseProcessCookies() {
|
||||
|
@ -44,6 +44,13 @@
|
||||
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||
public final class PublicSuffixListParser {
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public static final PublicSuffixListParser INSTANCE = new PublicSuffixListParser();
|
||||
|
||||
public PublicSuffixListParser() {
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public final class PublicSuffixMatcherLoader {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PublicSuffixMatcherLoader.class);
|
||||
|
||||
private static PublicSuffixMatcher load(final InputStream in) throws IOException {
|
||||
final List<PublicSuffixList> lists = new PublicSuffixListParser().parseByType(
|
||||
final List<PublicSuffixList> lists = PublicSuffixListParser.INSTANCE.parseByType(
|
||||
new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
return new PublicSuffixMatcher(lists);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class TestCookieIdentityComparator {
|
||||
|
||||
@Test
|
||||
public void testCookieIdentityComparasionByName() {
|
||||
final CookieIdentityComparator comparator = new CookieIdentityComparator();
|
||||
final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE;
|
||||
final BasicClientCookie c1 = new BasicClientCookie("name", "value1");
|
||||
final BasicClientCookie c2 = new BasicClientCookie("name", "value2");
|
||||
Assertions.assertEquals(0, comparator.compare(c1, c2));
|
||||
@ -50,7 +50,7 @@ public void testCookieIdentityComparasionByName() {
|
||||
|
||||
@Test
|
||||
public void testCookieIdentityComparasionByNameAndDomain() {
|
||||
final CookieIdentityComparator comparator = new CookieIdentityComparator();
|
||||
final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE;
|
||||
final BasicClientCookie c1 = new BasicClientCookie("name", "value1");
|
||||
c1.setDomain("www.domain.com");
|
||||
final BasicClientCookie c2 = new BasicClientCookie("name", "value2");
|
||||
@ -66,7 +66,7 @@ public void testCookieIdentityComparasionByNameAndDomain() {
|
||||
|
||||
@Test
|
||||
public void testCookieIdentityComparasionByNameAndNullDomain() {
|
||||
final CookieIdentityComparator comparator = new CookieIdentityComparator();
|
||||
final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE;
|
||||
final BasicClientCookie c1 = new BasicClientCookie("name", "value1");
|
||||
c1.setDomain(null);
|
||||
final BasicClientCookie c2 = new BasicClientCookie("name", "value2");
|
||||
@ -82,7 +82,7 @@ public void testCookieIdentityComparasionByNameAndNullDomain() {
|
||||
|
||||
@Test
|
||||
public void testCookieIdentityComparasionByNameDomainAndPath() {
|
||||
final CookieIdentityComparator comparator = new CookieIdentityComparator();
|
||||
final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE;
|
||||
final BasicClientCookie c1 = new BasicClientCookie("name", "value1");
|
||||
c1.setDomain("www.domain.com");
|
||||
c1.setPath("/whatever");
|
||||
@ -102,7 +102,7 @@ public void testCookieIdentityComparasionByNameDomainAndPath() {
|
||||
|
||||
@Test
|
||||
public void testCookieIdentityComparasionByNameDomainAndNullPath() {
|
||||
final CookieIdentityComparator comparator = new CookieIdentityComparator();
|
||||
final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE;
|
||||
final BasicClientCookie c1 = new BasicClientCookie("name", "value1");
|
||||
c1.setDomain("www.domain.com");
|
||||
c1.setPath("/");
|
||||
|
@ -45,7 +45,7 @@ public class TestBasicCookieAttribHandlers {
|
||||
@Test
|
||||
public void testBasicDomainParse() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
h.parse(cookie, "www.somedomain.com");
|
||||
Assertions.assertEquals("www.somedomain.com", cookie.getDomain());
|
||||
}
|
||||
@ -53,7 +53,7 @@ public void testBasicDomainParse() throws Exception {
|
||||
@Test
|
||||
public void testBasicDomainParseInvalid1() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, ""));
|
||||
}
|
||||
@ -61,7 +61,7 @@ public void testBasicDomainParseInvalid1() throws Exception {
|
||||
@Test
|
||||
public void testBasicDomainParseInvalid2() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, null));
|
||||
}
|
||||
@ -70,7 +70,7 @@ public void testBasicDomainParseInvalid2() throws Exception {
|
||||
public void testBasicDomainValidate1() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain(".somedomain.com");
|
||||
h.validate(cookie, origin);
|
||||
@ -85,7 +85,7 @@ public void testBasicDomainValidate1() throws Exception {
|
||||
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();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain("somehost");
|
||||
h.validate(cookie, origin);
|
||||
@ -98,7 +98,7 @@ public void testBasicDomainValidate2() throws Exception {
|
||||
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();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain(".somedomain.com");
|
||||
h.validate(cookie, origin);
|
||||
@ -108,7 +108,7 @@ public void testBasicDomainValidate3() throws Exception {
|
||||
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();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain(null);
|
||||
Assertions.assertThrows(MalformedCookieException.class, () -> h.validate(cookie, origin));
|
||||
@ -118,7 +118,7 @@ public void testBasicDomainValidate4() throws Exception {
|
||||
public void testBasicDomainMatch1() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain("somedomain.com");
|
||||
cookie.setAttribute(Cookie.DOMAIN_ATTR, "somedomain.com");
|
||||
@ -132,7 +132,7 @@ public void testBasicDomainMatch1() throws Exception {
|
||||
public void testBasicDomainMatch2() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain("somedomain.com");
|
||||
cookie.setAttribute(Cookie.DOMAIN_ATTR, "somedomain.com");
|
||||
@ -149,7 +149,7 @@ public void testBasicDomainMatch2() throws Exception {
|
||||
public void testBasicDomainMatchOneLetterPrefix() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("a.somedomain.com", 80, "/", false);
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain("somedomain.com");
|
||||
cookie.setAttribute(Cookie.DOMAIN_ATTR, "somedomain.com");
|
||||
@ -160,7 +160,7 @@ public void testBasicDomainMatchOneLetterPrefix() throws Exception {
|
||||
public void testBasicDomainMatchMixedCase() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("a.SomeDomain.com", 80, "/", false);
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
|
||||
cookie.setDomain("somedoMain.Com");
|
||||
cookie.setAttribute(Cookie.DOMAIN_ATTR, "somedoMain.Com");
|
||||
@ -169,7 +169,7 @@ public void testBasicDomainMatchMixedCase() throws Exception {
|
||||
|
||||
@Test
|
||||
public void testBasicDomainInvalidInput() throws Exception {
|
||||
final CookieAttributeHandler h = new BasicDomainHandler();
|
||||
final CookieAttributeHandler h = BasicDomainHandler.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null));
|
||||
Assertions.assertThrows(NullPointerException.class, () -> h.validate(null, null));
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
@ -182,7 +182,7 @@ public void testBasicDomainInvalidInput() throws Exception {
|
||||
@Test
|
||||
public void testBasicPathParse() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
h.parse(cookie, "stuff");
|
||||
Assertions.assertEquals("stuff", cookie.getPath());
|
||||
h.parse(cookie, "");
|
||||
@ -195,7 +195,7 @@ public void testBasicPathParse() throws Exception {
|
||||
public void testBasicPathMatch1() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
cookie.setPath("/stuff");
|
||||
Assertions.assertTrue(h.match(cookie, origin));
|
||||
}
|
||||
@ -204,7 +204,7 @@ public void testBasicPathMatch1() throws Exception {
|
||||
public void testBasicPathMatch2() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/", false);
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
cookie.setPath("/stuff");
|
||||
Assertions.assertTrue(h.match(cookie, origin));
|
||||
}
|
||||
@ -213,7 +213,7 @@ public void testBasicPathMatch2() throws Exception {
|
||||
public void testBasicPathMatch3() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/more-stuff", false);
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
cookie.setPath("/stuff");
|
||||
Assertions.assertTrue(h.match(cookie, origin));
|
||||
}
|
||||
@ -222,7 +222,7 @@ public void testBasicPathMatch3() throws Exception {
|
||||
public void testBasicPathMatch4() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuffed", false);
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
cookie.setPath("/stuff");
|
||||
Assertions.assertFalse(h.match(cookie, origin));
|
||||
}
|
||||
@ -231,7 +231,7 @@ public void testBasicPathMatch4() throws Exception {
|
||||
public void testBasicPathMatch5() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/otherstuff", false);
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
cookie.setPath("/stuff");
|
||||
Assertions.assertFalse(h.match(cookie, origin));
|
||||
}
|
||||
@ -240,7 +240,7 @@ public void testBasicPathMatch5() throws Exception {
|
||||
public void testBasicPathMatch6() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
cookie.setPath("/stuff/");
|
||||
Assertions.assertTrue(h.match(cookie, origin));
|
||||
}
|
||||
@ -249,13 +249,13 @@ public void testBasicPathMatch6() throws Exception {
|
||||
public void testBasicPathMatch7() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
Assertions.assertTrue(h.match(cookie, origin));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicPathInvalidInput() throws Exception {
|
||||
final CookieAttributeHandler h = new BasicPathHandler();
|
||||
final CookieAttributeHandler h = BasicPathHandler.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null));
|
||||
Assertions.assertThrows(NullPointerException.class, () -> h.match(null, null));
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
@ -265,7 +265,7 @@ public void testBasicPathInvalidInput() throws Exception {
|
||||
@Test
|
||||
public void testBasicMaxAgeParse() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicMaxAgeHandler();
|
||||
final CookieAttributeHandler h = BasicMaxAgeHandler.INSTANCE;
|
||||
h.parse(cookie, "2000");
|
||||
Assertions.assertNotNull(cookie.getExpiryInstant());
|
||||
}
|
||||
@ -273,21 +273,21 @@ public void testBasicMaxAgeParse() throws Exception {
|
||||
@Test
|
||||
public void testBasicMaxAgeParseInvalid() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicMaxAgeHandler();
|
||||
final CookieAttributeHandler h = BasicMaxAgeHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () -> h.parse(cookie, "garbage"));
|
||||
Assertions.assertThrows(MalformedCookieException.class, () -> h.parse(cookie, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicMaxAgeInvalidInput() throws Exception {
|
||||
final CookieAttributeHandler h = new BasicMaxAgeHandler();
|
||||
final CookieAttributeHandler h = BasicMaxAgeHandler.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicSecureParse() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicSecureHandler();
|
||||
final CookieAttributeHandler h = BasicSecureHandler.INSTANCE;
|
||||
h.parse(cookie, "whatever");
|
||||
Assertions.assertTrue(cookie.isSecure());
|
||||
h.parse(cookie, null);
|
||||
@ -297,7 +297,7 @@ public void testBasicSecureParse() throws Exception {
|
||||
@Test
|
||||
public void testBasicSecureMatch() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new BasicSecureHandler();
|
||||
final CookieAttributeHandler h = BasicSecureHandler.INSTANCE;
|
||||
|
||||
final CookieOrigin origin1 = new CookieOrigin("somehost", 80, "/stuff", false);
|
||||
cookie.setSecure(false);
|
||||
@ -352,7 +352,7 @@ public void testPublicSuffixFilter() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
|
||||
final PublicSuffixMatcher matcher = new PublicSuffixMatcher(DomainType.ICANN, Arrays.asList("co.uk", "com"), null);
|
||||
final PublicSuffixDomainFilter h = new PublicSuffixDomainFilter(new BasicDomainHandler(), matcher);
|
||||
final PublicSuffixDomainFilter h = new PublicSuffixDomainFilter(BasicDomainHandler.INSTANCE, matcher);
|
||||
|
||||
cookie.setDomain(".co.uk");
|
||||
cookie.setAttribute(Cookie.DOMAIN_ATTR, ".co.uk");
|
||||
|
@ -41,7 +41,7 @@ public class TestLaxCookieAttribHandlers {
|
||||
@Test
|
||||
public void testParseMaxAge() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxMaxAgeHandler();
|
||||
final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE;
|
||||
h.parse(cookie, "2000");
|
||||
Assertions.assertNotNull(cookie.getExpiryInstant());
|
||||
}
|
||||
@ -49,7 +49,7 @@ public void testParseMaxAge() throws Exception {
|
||||
@Test
|
||||
public void testParseMaxNegative() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxMaxAgeHandler();
|
||||
final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE;
|
||||
h.parse(cookie, "-2000");
|
||||
Assertions.assertNotNull(cookie.getExpiryInstant());
|
||||
}
|
||||
@ -57,7 +57,7 @@ public void testParseMaxNegative() throws Exception {
|
||||
@Test
|
||||
public void testParseMaxZero() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxMaxAgeHandler();
|
||||
final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE;
|
||||
h.parse(cookie, "0000");
|
||||
Assertions.assertNotNull(cookie.getExpiryInstant());
|
||||
}
|
||||
@ -65,7 +65,7 @@ public void testParseMaxZero() throws Exception {
|
||||
@Test
|
||||
public void testBasicMaxAgeParseEmpty() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxMaxAgeHandler();
|
||||
final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE;
|
||||
h.parse(cookie, " ");
|
||||
Assertions.assertNull(cookie.getExpiryInstant());
|
||||
}
|
||||
@ -73,21 +73,21 @@ public void testBasicMaxAgeParseEmpty() throws Exception {
|
||||
@Test
|
||||
public void testBasicMaxAgeParseInvalid() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxMaxAgeHandler();
|
||||
final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE;
|
||||
h.parse(cookie, "garbage");
|
||||
Assertions.assertNull(cookie.getExpiryInstant());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicMaxAgeInvalidInput() throws Exception {
|
||||
final CookieAttributeHandler h = new LaxMaxAgeHandler();
|
||||
final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, "stuff"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpiryGarbage() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, ";;blah,blah;yada "));
|
||||
}
|
||||
@ -95,7 +95,7 @@ public void testExpiryGarbage() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiry() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "1:0:12 8-jan-2012");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -113,7 +113,7 @@ public void testParseExpiry() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInstant() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "1:0:12 8-jan-2012");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -131,7 +131,7 @@ public void testParseExpiryInstant() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidTime0() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, null);
|
||||
Assertions.assertNull(cookie.getExpiryInstant());
|
||||
}
|
||||
@ -139,7 +139,7 @@ public void testParseExpiryInvalidTime0() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidTime1() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "1:0:122 8 dec 1980"));
|
||||
}
|
||||
@ -147,7 +147,7 @@ public void testParseExpiryInvalidTime1() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidTime2() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "24:00:00 8 dec 1980"));
|
||||
}
|
||||
@ -155,7 +155,7 @@ public void testParseExpiryInvalidTime2() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidTime3() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "23:60:00 8 dec 1980"));
|
||||
}
|
||||
@ -163,7 +163,7 @@ public void testParseExpiryInvalidTime3() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidTime4() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "23:00:60 8 dec 1980"));
|
||||
}
|
||||
@ -171,7 +171,7 @@ public void testParseExpiryInvalidTime4() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyTime() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "1:59:00blah; 8-feb-2000");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -189,7 +189,7 @@ public void testParseExpiryFunnyTime() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyTimeInstant() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "1:59:00blah; 8-feb-2000");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -207,7 +207,7 @@ public void testParseExpiryFunnyTimeInstant() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidDayOfMonth1() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "12:00:00 888 mar 1880"));
|
||||
}
|
||||
@ -215,7 +215,7 @@ public void testParseExpiryInvalidDayOfMonth1() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidDayOfMonth2() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "12:00:00 0 mar 1880"));
|
||||
}
|
||||
@ -223,7 +223,7 @@ public void testParseExpiryInvalidDayOfMonth2() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidDayOfMonth3() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "12:00:00 32 mar 1880"));
|
||||
}
|
||||
@ -231,7 +231,7 @@ public void testParseExpiryInvalidDayOfMonth3() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyDayOfMonth() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "12:00:00 8blah;mar;1880");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -249,7 +249,7 @@ public void testParseExpiryFunnyDayOfMonth() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyDayOfMonthInstant() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "12:00:00 8blah;mar;1880");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -267,7 +267,7 @@ public void testParseExpiryFunnyDayOfMonthInstant() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidMonth() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "1:00:00 8 dek 80"));
|
||||
}
|
||||
@ -275,7 +275,7 @@ public void testParseExpiryInvalidMonth() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyMonth() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "23:59:59; 1-ApriLLLLL-2008");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -293,7 +293,7 @@ public void testParseExpiryFunnyMonth() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyMonthInstant() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "23:59:59; 1-ApriLLLLL-2008");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -311,7 +311,7 @@ public void testParseExpiryFunnyMonthInstant() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidYearTooShort() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "1:00:00 8 dec 8"));
|
||||
}
|
||||
@ -319,7 +319,7 @@ public void testParseExpiryInvalidYearTooShort() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidYearTooLong() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "1:00:00 8 dec 88888"));
|
||||
}
|
||||
@ -327,7 +327,7 @@ public void testParseExpiryInvalidYearTooLong() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryInvalidYearTooLongAgo() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
Assertions.assertThrows(MalformedCookieException.class, () ->
|
||||
h.parse(cookie, "1:00:00 8 dec 1600"));
|
||||
}
|
||||
@ -335,7 +335,7 @@ public void testParseExpiryInvalidYearTooLongAgo() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyYear() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "23:59:59; 1-Apr-2008blah");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -353,7 +353,7 @@ public void testParseExpiryFunnyYear() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryFunnyYearInstant() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "23:59:59; 1-Apr-2008blah");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -371,7 +371,7 @@ public void testParseExpiryFunnyYearInstant() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryYearTwoDigit1() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "23:59:59; 1-Apr-70");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -383,7 +383,7 @@ public void testParseExpiryYearTwoDigit1() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryYearTwoDigit2() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "23:59:59; 1-Apr-99");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
@ -395,7 +395,7 @@ public void testParseExpiryYearTwoDigit2() throws Exception {
|
||||
@Test
|
||||
public void testParseExpiryYearTwoDigit3() throws Exception {
|
||||
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
|
||||
final CookieAttributeHandler h = new LaxExpiresHandler();
|
||||
final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE;
|
||||
h.parse(cookie, "23:59:59; 1-Apr-00");
|
||||
|
||||
final LocalDateTime expiryDate = DateUtils.toUTC(cookie.getExpiryInstant());
|
||||
|
@ -53,13 +53,13 @@ public void setUp() throws Exception {
|
||||
Assertions.assertNotNull(in);
|
||||
final PublicSuffixList suffixList;
|
||||
try {
|
||||
final PublicSuffixListParser parser = new PublicSuffixListParser();
|
||||
final PublicSuffixListParser parser = PublicSuffixListParser.INSTANCE;
|
||||
suffixList = parser.parse(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
final PublicSuffixMatcher matcher = new PublicSuffixMatcher(suffixList.getRules(), suffixList.getExceptions());
|
||||
this.filter = new PublicSuffixDomainFilter(new BasicDomainHandler(), matcher);
|
||||
this.filter = new PublicSuffixDomainFilter(BasicDomainHandler.INSTANCE, matcher);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -83,7 +83,7 @@ public class TestRouteDirector {
|
||||
|
||||
@Test
|
||||
public void testIllegal() {
|
||||
final HttpRouteDirector rowdy = new BasicRouteDirector();
|
||||
final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE;
|
||||
final HttpRoute route = new HttpRoute(TARGET1);
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
rowdy.nextStep(null, route));
|
||||
@ -92,7 +92,7 @@ public void testIllegal() {
|
||||
@Test
|
||||
public void testDirect() {
|
||||
|
||||
final HttpRouteDirector rowdy = new BasicRouteDirector();
|
||||
final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE;
|
||||
final HttpRoute route1 = new HttpRoute(TARGET1);
|
||||
final HttpRoute route2 = new HttpRoute(TARGET2);
|
||||
final HttpRoute route1p1 = new HttpRoute(TARGET1, null, PROXY1, false);
|
||||
@ -119,7 +119,7 @@ public void testDirect() {
|
||||
@Test
|
||||
public void testProxy() {
|
||||
|
||||
final HttpRouteDirector rowdy = new BasicRouteDirector();
|
||||
final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE;
|
||||
final HttpRoute route1p1 = new HttpRoute(TARGET1, null, PROXY1, false);
|
||||
final HttpRoute route1p2 = new HttpRoute(TARGET1, null, PROXY2, false);
|
||||
final HttpRoute route2p1 = new HttpRoute(TARGET2, null, PROXY1, false);
|
||||
@ -160,7 +160,7 @@ public void testProxyChain() {
|
||||
final HttpHost[] chainB = { PROXY1, PROXY2 };
|
||||
final HttpHost[] chainC = { PROXY2, PROXY1 };
|
||||
|
||||
final HttpRouteDirector rowdy = new BasicRouteDirector();
|
||||
final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE;
|
||||
final HttpRoute route1cA = new HttpRoute(TARGET1, null, chainA, false,
|
||||
TunnelType.PLAIN, LayerType.PLAIN);
|
||||
final HttpRoute route1cB = new HttpRoute(TARGET1, null, chainB, false,
|
||||
@ -203,7 +203,7 @@ public void testProxyChain() {
|
||||
@Test
|
||||
public void testLocalDirect() {
|
||||
|
||||
final HttpRouteDirector rowdy = new BasicRouteDirector();
|
||||
final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE;
|
||||
final HttpRoute route1l41 = new HttpRoute(TARGET1, LOCAL41, false);
|
||||
final HttpRoute route1l42 = new HttpRoute(TARGET1, LOCAL42, false);
|
||||
final HttpRoute route1l61 = new HttpRoute(TARGET1, LOCAL61, false);
|
||||
@ -257,7 +257,7 @@ public void testLocalDirect() {
|
||||
@Test
|
||||
public void testDirectSecure() {
|
||||
|
||||
final HttpRouteDirector rowdy = new BasicRouteDirector();
|
||||
final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE;
|
||||
final HttpRoute route1u = new HttpRoute(TARGET1, null, false);
|
||||
final HttpRoute route1s = new HttpRoute(TARGET1, null, true);
|
||||
final HttpRoute route1p1u = new HttpRoute(TARGET1, null, PROXY1, false);
|
||||
@ -289,7 +289,7 @@ public void testDirectSecure() {
|
||||
@Test
|
||||
public void testProxyTLS() {
|
||||
|
||||
final HttpRouteDirector rowdy = new BasicRouteDirector();
|
||||
final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE;
|
||||
final HttpRoute route1 = new HttpRoute
|
||||
(TARGET1, null, PROXY1, false,
|
||||
TunnelType.PLAIN, LayerType.PLAIN);
|
||||
|
@ -181,7 +181,7 @@ public void testIllegalStates() {
|
||||
@Test
|
||||
public void testDirectRoutes() {
|
||||
|
||||
final HttpRouteDirector rd = new BasicRouteDirector();
|
||||
final HttpRouteDirector rd = BasicRouteDirector.INSTANCE;
|
||||
HttpRoute r = new HttpRoute(TARGET1, LOCAL41, false);
|
||||
RouteTracker rt = new RouteTracker(r);
|
||||
boolean complete = checkVia(rt, r, rd, 2);
|
||||
@ -196,7 +196,7 @@ public void testDirectRoutes() {
|
||||
@Test
|
||||
public void testProxyRoutes() {
|
||||
|
||||
final HttpRouteDirector rd = new BasicRouteDirector();
|
||||
final HttpRouteDirector rd = BasicRouteDirector.INSTANCE;
|
||||
HttpRoute r = new HttpRoute(TARGET2, null, PROXY1, false);
|
||||
RouteTracker rt = new RouteTracker(r);
|
||||
boolean complete = checkVia(rt, r, rd, 2);
|
||||
@ -226,7 +226,7 @@ public void testProxyRoutes() {
|
||||
@Test
|
||||
public void testProxyChainRoutes() {
|
||||
|
||||
final HttpRouteDirector rd = new BasicRouteDirector();
|
||||
final HttpRouteDirector rd = BasicRouteDirector.INSTANCE;
|
||||
HttpHost[] proxies = { PROXY1, PROXY2 };
|
||||
HttpRoute r = new HttpRoute(TARGET2, LOCAL42, proxies, false,
|
||||
TunnelType.PLAIN, LayerType.PLAIN);
|
||||
|
@ -87,7 +87,7 @@ public void setUp() {
|
||||
@Test
|
||||
public void testRequestParameterCheck() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
interceptor.process(null, null, context));
|
||||
}
|
||||
@ -95,7 +95,7 @@ public void testRequestParameterCheck() throws Exception {
|
||||
@Test
|
||||
public void testContextParameterCheck() throws Exception {
|
||||
final HttpRequest request = new BasicHttpRequest("GET", "/");
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
interceptor.process(request, null, null));
|
||||
}
|
||||
@ -111,7 +111,7 @@ public void testAddCookies() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers = request.getHeaders("Cookie");
|
||||
@ -138,7 +138,7 @@ public void testCookiesForConnectRequest() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers = request.getHeaders("Cookie");
|
||||
@ -157,7 +157,7 @@ public void testNoCookieStore() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, null);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers = request.getHeaders("Cookie");
|
||||
@ -176,7 +176,7 @@ public void testNoCookieSpecRegistry() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, null);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers = request.getHeaders("Cookie");
|
||||
@ -193,7 +193,7 @@ public void testNoHttpConnection() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers = request.getHeaders("Cookie");
|
||||
@ -215,7 +215,7 @@ public void testAddCookiesUsingExplicitCookieSpec() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final CookieSpec cookieSpec = context.getCookieSpec();
|
||||
@ -238,7 +238,7 @@ public void testAuthScopeInvalidRequestURI() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ public void testAuthScopeRemotePortWhenDirect() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final CookieOrigin cookieOrigin = context.getCookieOrigin();
|
||||
@ -278,7 +278,7 @@ public void testAuthDefaultHttpPortWhenProxy() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final CookieOrigin cookieOrigin = context.getCookieOrigin();
|
||||
@ -303,7 +303,7 @@ public void testAuthDefaultHttpsPortWhenProxy() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final CookieOrigin cookieOrigin = context.getCookieOrigin();
|
||||
@ -338,7 +338,7 @@ public void testExcludeExpiredCookies() throws Exception {
|
||||
// Make sure the third cookie expires
|
||||
Thread.sleep(200);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers = request.getHeaders("Cookie");
|
||||
@ -366,7 +366,7 @@ public void testNoMatchingCookies() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers = request.getHeaders("Cookie");
|
||||
@ -401,7 +401,7 @@ public void testCookieOrder() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
|
||||
|
||||
final HttpRequestInterceptor interceptor = new RequestAddCookies();
|
||||
final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE;
|
||||
interceptor.process(request, null, context);
|
||||
|
||||
final Header[] headers1 = request.getHeaders("Cookie");
|
||||
|
@ -44,7 +44,7 @@ public class TestRequestDefaultHeaders {
|
||||
@Test
|
||||
public void testRequestParameterCheck() throws Exception {
|
||||
final HttpContext context = new BasicHttpContext();
|
||||
final HttpRequestInterceptor interceptor = new RequestDefaultHeaders();
|
||||
final HttpRequestInterceptor interceptor = RequestDefaultHeaders.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
interceptor.process(null, null, context));
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public void setUp() throws Exception {
|
||||
@Test
|
||||
public void testResponseParameterCheck() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
|
||||
final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
interceptor.process(null, null, context));
|
||||
}
|
||||
@ -65,7 +65,7 @@ public void testResponseParameterCheck() throws Exception {
|
||||
@Test
|
||||
public void testContextParameterCheck() throws Exception {
|
||||
final HttpResponse response = new BasicHttpResponse(200, "OK");
|
||||
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
|
||||
final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE;
|
||||
Assertions.assertThrows(NullPointerException.class, () ->
|
||||
interceptor.process(response, null, null));
|
||||
}
|
||||
@ -80,7 +80,7 @@ public void testParseCookies() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
|
||||
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
|
||||
final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE;
|
||||
interceptor.process(response, null, context);
|
||||
|
||||
final List<Cookie> cookies = this.cookieStore.getCookies();
|
||||
@ -103,7 +103,7 @@ public void testNoCookieOrigin() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
|
||||
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
|
||||
final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE;
|
||||
interceptor.process(response, null, context);
|
||||
|
||||
final List<Cookie> cookies = this.cookieStore.getCookies();
|
||||
@ -121,7 +121,7 @@ public void testNoCookieSpec() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
|
||||
|
||||
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
|
||||
final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE;
|
||||
interceptor.process(response, null, context);
|
||||
|
||||
final List<Cookie> cookies = this.cookieStore.getCookies();
|
||||
@ -139,7 +139,7 @@ public void testNoCookieStore() throws Exception {
|
||||
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
|
||||
context.setAttribute(HttpClientContext.COOKIE_STORE, null);
|
||||
|
||||
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
|
||||
final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE;
|
||||
interceptor.process(response, null, context);
|
||||
|
||||
final List<Cookie> cookies = this.cookieStore.getCookies();
|
||||
|
@ -46,7 +46,7 @@ public void testParse() throws Exception {
|
||||
Assertions.assertNotNull(in);
|
||||
final PublicSuffixList suffixList;
|
||||
try {
|
||||
final PublicSuffixListParser parser = new PublicSuffixListParser();
|
||||
final PublicSuffixListParser parser = PublicSuffixListParser.INSTANCE;
|
||||
suffixList = parser.parse(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
} finally {
|
||||
in.close();
|
||||
@ -63,7 +63,7 @@ public void testParseByType() throws Exception {
|
||||
Assertions.assertNotNull(in);
|
||||
final List<PublicSuffixList> suffixLists;
|
||||
try {
|
||||
final PublicSuffixListParser parser = new PublicSuffixListParser();
|
||||
final PublicSuffixListParser parser = PublicSuffixListParser.INSTANCE;
|
||||
suffixLists = parser.parseByType(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
} finally {
|
||||
in.close();
|
||||
|
@ -47,7 +47,7 @@ public void setUp() throws Exception {
|
||||
final ClassLoader classLoader = getClass().getClassLoader();
|
||||
final InputStream in = classLoader.getResourceAsStream(SOURCE_FILE);
|
||||
Assertions.assertNotNull(in);
|
||||
final List<PublicSuffixList> lists = new PublicSuffixListParser().parseByType(
|
||||
final List<PublicSuffixList> lists = PublicSuffixListParser.INSTANCE.parseByType(
|
||||
new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
matcher = new PublicSuffixMatcher(lists);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public void setup() throws IOException {
|
||||
final ClassLoader classLoader = getClass().getClassLoader();
|
||||
final InputStream in = classLoader.getResourceAsStream(PUBLIC_SUFFIX_MATCHER_SOURCE_FILE);
|
||||
Assertions.assertNotNull(in);
|
||||
final List<PublicSuffixList> lists = new PublicSuffixListParser().parseByType(
|
||||
final List<PublicSuffixList> lists = PublicSuffixListParser.INSTANCE.parseByType(
|
||||
new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
publicSuffixMatcher = new PublicSuffixMatcher(lists);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user