You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2012/12/03 17:34:38 UTC

svn commit: r1416582 - in /httpcomponents/httpclient/trunk/httpclient-cache/src: main/java/org/apache/http/impl/client/cache/ main/java/org/apache/http/impl/client/cache/ehcache/ main/java/org/apache/http/impl/client/cache/memcached/ test/java/org/apac...

Author: olegk
Date: Mon Dec  3 16:34:27 2012
New Revision: 1416582

URL: http://svn.apache.org/viewvc?rev=1416582&view=rev
Log:
Made CacheConfig consistent with the new config API

Modified:
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java Mon Dec  3 16:34:27 2012
@@ -77,7 +77,7 @@ class BasicHttpCache implements HttpCach
     }
 
     public BasicHttpCache() {
-        this(new CacheConfig());
+        this(CacheConfig.DEFAULT);
     }
 
     public void flushCacheEntriesFor(HttpHost host, HttpRequest request)

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java Mon Dec  3 16:34:27 2012
@@ -42,8 +42,8 @@ package org.apache.http.impl.client.cach
  * <p>Cache configuration can be grouped into the following categories:</p>
  *
  * <p><b>Cache size.</b> If the backend storage supports these limits, you
- * can specify the {@link CacheConfig#setMaxCacheEntries maximum number of
- * cache entries} as well as the {@link CacheConfig#setMaxObjectSizeBytes
+ * can specify the {@link CacheConfig#getMaxCacheEntries maximum number of
+ * cache entries} as well as the {@link CacheConfig#getMaxObjectSizeBytes
  * maximum cacheable response body size}.</p>
  *
  * <p><b>Public/private caching.</b> By default, the caching module considers
@@ -60,7 +60,7 @@ package org.apache.http.impl.client.cach
  * are working with an origin that doesn't set proper headers but where you
  * still want to cache the responses. You will want to {@link
  * CacheConfig#setHeuristicCachingEnabled(boolean) enable heuristic caching},
- * then specify either a {@link CacheConfig#setHeuristicDefaultLifetime(long)
+ * then specify either a {@link CacheConfig#getHeuristicDefaultLifetime()
  * default freshness lifetime} and/or a {@link
  * CacheConfig#setHeuristicCoefficient(float) fraction of the time since
  * the resource was last modified}. See Sections
@@ -73,15 +73,15 @@ package org.apache.http.impl.client.cach
  * <a href="http://tools.ietf.org/html/rfc5861">RFC5861</a>, which allows
  * certain cache entry revalidations to happen in the background. You may
  * want to tweak the settings for the {@link
- * CacheConfig#setAsynchronousWorkersCore(int) minimum} and {@link
- * CacheConfig#setAsynchronousWorkersMax(int) maximum} number of background
+ * CacheConfig#setAsynchronousWorkersCore() minimum} and {@link
+ * CacheConfig#setAsynchronousWorkersMax() maximum} number of background
  * worker threads, as well as the {@link
- * CacheConfig#setAsynchronousWorkerIdleLifetimeSecs(int) maximum time they
+ * CacheConfig#setAsynchronousWorkerIdleLifetimeSecs() maximum time they
  * can be idle before being reclaimed}. You can also control the {@link
- * CacheConfig#setRevalidationQueueSize(int) size of the queue} used for
+ * CacheConfig#setRevalidationQueueSize() size of the queue} used for
  * revalidations when there aren't enough workers to keep up with demand.</b>
  */
-public class CacheConfig {
+public class CacheConfig implements Cloneable {
 
     /** Default setting for the maximum object size that will be
      * cached, in bytes.
@@ -131,17 +131,65 @@ public class CacheConfig {
      */
     public static final int DEFAULT_REVALIDATION_QUEUE_SIZE = 100;
 
-    private long maxObjectSize = DEFAULT_MAX_OBJECT_SIZE_BYTES;
-    private int maxCacheEntries = DEFAULT_MAX_CACHE_ENTRIES;
-    private int maxUpdateRetries = DEFAULT_MAX_UPDATE_RETRIES;
-    private boolean heuristicCachingEnabled = false;
-    private float heuristicCoefficient = DEFAULT_HEURISTIC_COEFFICIENT;
-    private long heuristicDefaultLifetime = DEFAULT_HEURISTIC_LIFETIME;
-    private boolean isSharedCache = true;
-    private int asynchronousWorkersMax = DEFAULT_ASYNCHRONOUS_WORKERS_MAX;
-    private int asynchronousWorkersCore = DEFAULT_ASYNCHRONOUS_WORKERS_CORE;
-    private int asynchronousWorkerIdleLifetimeSecs = DEFAULT_ASYNCHRONOUS_WORKER_IDLE_LIFETIME_SECS;
-    private int revalidationQueueSize = DEFAULT_REVALIDATION_QUEUE_SIZE;
+    public static final CacheConfig DEFAULT = new Builder().build();
+
+    // TODO: make final
+    private long maxObjectSize;
+    private int maxCacheEntries;
+    private int maxUpdateRetries;
+    private boolean heuristicCachingEnabled;
+    private float heuristicCoefficient;
+    private long heuristicDefaultLifetime;
+    private boolean isSharedCache;
+    private int asynchronousWorkersMax;
+    private int asynchronousWorkersCore;
+    private int asynchronousWorkerIdleLifetimeSecs;
+    private int revalidationQueueSize;
+
+    /**
+     * @deprecated (4.3) use {@link Builder}.
+     */
+    @Deprecated
+    public CacheConfig() {
+        super();
+        this.maxObjectSize = DEFAULT_MAX_OBJECT_SIZE_BYTES;
+        this.maxCacheEntries = DEFAULT_MAX_CACHE_ENTRIES;
+        this.maxUpdateRetries = DEFAULT_MAX_UPDATE_RETRIES;
+        this.heuristicCachingEnabled = false;
+        this.heuristicCoefficient = DEFAULT_HEURISTIC_COEFFICIENT;
+        this.heuristicDefaultLifetime = DEFAULT_HEURISTIC_LIFETIME;
+        this.isSharedCache = true;
+        this.asynchronousWorkersMax = DEFAULT_ASYNCHRONOUS_WORKERS_MAX;
+        this.asynchronousWorkersCore = DEFAULT_ASYNCHRONOUS_WORKERS_CORE;
+        this.asynchronousWorkerIdleLifetimeSecs = DEFAULT_ASYNCHRONOUS_WORKER_IDLE_LIFETIME_SECS;
+        this.revalidationQueueSize = DEFAULT_REVALIDATION_QUEUE_SIZE;
+    }
+
+    CacheConfig(
+            long maxObjectSize,
+            int maxCacheEntries,
+            int maxUpdateRetries,
+            boolean heuristicCachingEnabled,
+            float heuristicCoefficient,
+            long heuristicDefaultLifetime,
+            boolean isSharedCache,
+            int asynchronousWorkersMax,
+            int asynchronousWorkersCore,
+            int asynchronousWorkerIdleLifetimeSecs,
+            int revalidationQueueSize) {
+        super();
+        this.maxObjectSize = maxObjectSize;
+        this.maxCacheEntries = maxCacheEntries;
+        this.maxUpdateRetries = maxUpdateRetries;
+        this.heuristicCachingEnabled = heuristicCachingEnabled;
+        this.heuristicCoefficient = heuristicCoefficient;
+        this.heuristicDefaultLifetime = heuristicDefaultLifetime;
+        this.isSharedCache = isSharedCache;
+        this.asynchronousWorkersMax = asynchronousWorkersMax;
+        this.asynchronousWorkersCore = asynchronousWorkersCore;
+        this.asynchronousWorkerIdleLifetimeSecs = asynchronousWorkerIdleLifetimeSecs;
+        this.revalidationQueueSize = revalidationQueueSize;
+    }
 
     /**
      * Returns the current maximum response body size that will be cached.
@@ -149,7 +197,7 @@ public class CacheConfig {
      *
      * @deprecated (4.2)  use {@link #getMaxObjectSize()}
      */
-    @Deprecated 
+    @Deprecated
     public int getMaxObjectSizeBytes() {
         return maxObjectSize > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) maxObjectSize;
     }
@@ -158,9 +206,9 @@ public class CacheConfig {
      * Specifies the maximum response body size that will be eligible for caching.
      * @param maxObjectSizeBytes size in bytes
      *
-     * @deprecated (4.2)  use {@link #setMaxObjectSize(long)}
+     * @deprecated (4.2)  use {@link Builder}.
      */
-    @Deprecated 
+    @Deprecated
     public void setMaxObjectSizeBytes(int maxObjectSizeBytes) {
         if (maxObjectSizeBytes > Integer.MAX_VALUE) {
             this.maxObjectSize = Integer.MAX_VALUE;
@@ -184,31 +232,15 @@ public class CacheConfig {
      * @param maxObjectSize size in bytes
      *
      * @since 4.2
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setMaxObjectSize(long maxObjectSize) {
         this.maxObjectSize = maxObjectSize;
     }
 
     /**
-     * Returns whether the cache will behave as a shared cache or not.
-     * @return {@code true} for a shared cache, {@code false} for a non-
-     * shared (private) cache
-     */
-    public boolean isSharedCache() {
-        return isSharedCache;
-    }
-
-    /**
-     * Sets whether the cache should behave as a shared cache or not.
-     * @param isSharedCache true to behave as a shared cache, false to
-     * behave as a non-shared (private) cache. To have the cache
-     * behave like a browser cache, you want to set this to {@code false}.
-     */
-    public void setSharedCache(boolean isSharedCache) {
-        this.isSharedCache = isSharedCache;
-    }
-
-    /**
      * Returns the maximum number of cache entries the cache will retain.
      */
     public int getMaxCacheEntries() {
@@ -217,7 +249,10 @@ public class CacheConfig {
 
     /**
      * Sets the maximum number of cache entries the cache will retain.
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setMaxCacheEntries(int maxCacheEntries) {
         this.maxCacheEntries = maxCacheEntries;
     }
@@ -231,7 +266,10 @@ public class CacheConfig {
 
     /**
      * Sets the number of times to retry a cache update on failure
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setMaxUpdateRetries(int maxUpdateRetries){
         this.maxUpdateRetries = maxUpdateRetries;
     }
@@ -248,7 +286,10 @@ public class CacheConfig {
      * Enables or disables heuristic caching.
      * @param heuristicCachingEnabled should be {@code true} to
      *   permit heuristic caching, {@code false} to enable it.
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setHeuristicCachingEnabled(boolean heuristicCachingEnabled) {
         this.heuristicCachingEnabled = heuristicCachingEnabled;
     }
@@ -267,7 +308,10 @@ public class CacheConfig {
      * response will be considered heuristically fresh.
      * @param heuristicCoefficient should be between {@code 0.0} and
      *   {@code 1.0}.
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setHeuristicCoefficient(float heuristicCoefficient) {
         this.heuristicCoefficient = heuristicCoefficient;
     }
@@ -290,12 +334,37 @@ public class CacheConfig {
      *   consider a cache-eligible response fresh in the absence of other
      *   information. Set this to {@code 0} to disable this style of
      *   heuristic caching.
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setHeuristicDefaultLifetime(long heuristicDefaultLifetimeSecs) {
         this.heuristicDefaultLifetime = heuristicDefaultLifetimeSecs;
     }
 
     /**
+     * Returns whether the cache will behave as a shared cache or not.
+     * @return {@code true} for a shared cache, {@code false} for a non-
+     * shared (private) cache
+     */
+    public boolean isSharedCache() {
+        return isSharedCache;
+    }
+
+    /**
+     * Sets whether the cache should behave as a shared cache or not.
+     * @param isSharedCache true to behave as a shared cache, false to
+     * behave as a non-shared (private) cache. To have the cache
+     * behave like a browser cache, you want to set this to {@code false}.
+     *
+     * @deprecated (4.3) use {@link Builder}.
+     */
+    @Deprecated
+    public void setSharedCache(boolean isSharedCache) {
+        this.isSharedCache = isSharedCache;
+    }
+
+    /**
      * Returns the maximum number of threads to allow for background
      * revalidations due to the {@code stale-while-revalidate} directive. A
      * value of 0 means background revalidations are disabled.
@@ -309,7 +378,10 @@ public class CacheConfig {
      * revalidations due to the {@code stale-while-revalidate} directive.
      * @param max number of threads; a value of 0 disables background
      * revalidations.
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setAsynchronousWorkersMax(int max) {
         this.asynchronousWorkersMax = max;
     }
@@ -327,7 +399,10 @@ public class CacheConfig {
      * revalidations due to the {@code stale-while-revalidate} directive.
      * @param min should be greater than zero and less than or equal
      *   to <code>getAsynchronousWorkersMax()</code>
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setAsynchronousWorkersCore(int min) {
         this.asynchronousWorkersCore = min;
     }
@@ -348,7 +423,10 @@ public class CacheConfig {
      * for this long, and there are more than the core number of worker
      * threads alive, the worker will be reclaimed.
      * @param secs idle lifetime in seconds
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setAsynchronousWorkerIdleLifetimeSecs(int secs) {
         this.asynchronousWorkerIdleLifetimeSecs = secs;
     }
@@ -362,10 +440,200 @@ public class CacheConfig {
 
     /**
      * Sets the current maximum queue size for background revalidations.
+     *
+     * @deprecated (4.3) use {@link Builder}.
      */
+    @Deprecated
     public void setRevalidationQueueSize(int size) {
         this.revalidationQueueSize = size;
     }
 
+    @Override
+    protected CacheConfig clone() throws CloneNotSupportedException {
+        return (CacheConfig) super.clone();
+    }
+
+    public static Builder custom() {
+        return new Builder();
+    }
+
+    public static class Builder {
+
+        private long maxObjectSize;
+        private int maxCacheEntries;
+        private int maxUpdateRetries;
+        private boolean heuristicCachingEnabled;
+        private float heuristicCoefficient;
+        private long heuristicDefaultLifetime;
+        private boolean isSharedCache;
+        private int asynchronousWorkersMax;
+        private int asynchronousWorkersCore;
+        private int asynchronousWorkerIdleLifetimeSecs;
+        private int revalidationQueueSize;
+
+        Builder() {
+            this.maxObjectSize = DEFAULT_MAX_OBJECT_SIZE_BYTES;
+            this.maxCacheEntries = DEFAULT_MAX_CACHE_ENTRIES;
+            this.maxUpdateRetries = DEFAULT_MAX_UPDATE_RETRIES;
+            this.heuristicCachingEnabled = false;
+            this.heuristicCoefficient = DEFAULT_HEURISTIC_COEFFICIENT;
+            this.heuristicDefaultLifetime = DEFAULT_HEURISTIC_LIFETIME;
+            this.isSharedCache = true;
+            this.asynchronousWorkersMax = DEFAULT_ASYNCHRONOUS_WORKERS_MAX;
+            this.asynchronousWorkersCore = DEFAULT_ASYNCHRONOUS_WORKERS_CORE;
+            this.asynchronousWorkerIdleLifetimeSecs = DEFAULT_ASYNCHRONOUS_WORKER_IDLE_LIFETIME_SECS;
+            this.revalidationQueueSize = DEFAULT_REVALIDATION_QUEUE_SIZE;
+        }
+
+        /**
+         * Specifies the maximum response body size that will be eligible for caching.
+         * @param maxObjectSize size in bytes
+         */
+        public Builder setMaxObjectSize(long maxObjectSize) {
+            this.maxObjectSize = maxObjectSize;
+            return this;
+        }
+
+        /**
+         * Sets the maximum number of cache entries the cache will retain.
+         */
+        public Builder setMaxCacheEntries(int maxCacheEntries) {
+            this.maxCacheEntries = maxCacheEntries;
+            return this;
+        }
+
+        /**
+         * Sets the number of times to retry a cache update on failure
+         */
+        public Builder setMaxUpdateRetries(int maxUpdateRetries) {
+            this.maxUpdateRetries = maxUpdateRetries;
+            return this;
+        }
+
+        /**
+         * Enables or disables heuristic caching.
+         * @param heuristicCachingEnabled should be {@code true} to
+         *   permit heuristic caching, {@code false} to enable it.
+         */
+        public Builder setHeuristicCachingEnabled(boolean heuristicCachingEnabled) {
+            this.heuristicCachingEnabled = heuristicCachingEnabled;
+            return this;
+        }
+
+        /**
+         * Sets coefficient to be used in heuristic freshness caching. This is
+         * interpreted as the fraction of the time between the {@code Last-Modified}
+         * and {@code Date} headers of a cached response during which the cached
+         * response will be considered heuristically fresh.
+         * @param heuristicCoefficient should be between {@code 0.0} and
+         *   {@code 1.0}.
+         */
+        public Builder setHeuristicCoefficient(float heuristicCoefficient) {
+            this.heuristicCoefficient = heuristicCoefficient;
+            return this;
+        }
+
+        /**
+         * Sets default lifetime in seconds to be used if heuristic freshness
+         * calculation is not possible. Explicit cache control directives on
+         * either the request or origin response will override this, as will
+         * the heuristic {@code Last-Modified} freshness calculation if it is
+         * available.
+         * @param heuristicDefaultLifetimeSecs is the number of seconds to
+         *   consider a cache-eligible response fresh in the absence of other
+         *   information. Set this to {@code 0} to disable this style of
+         *   heuristic caching.
+         */
+        public Builder setHeuristicDefaultLifetime(long heuristicDefaultLifetime) {
+            this.heuristicDefaultLifetime = heuristicDefaultLifetime;
+            return this;
+        }
+
+        /**
+         * Sets whether the cache should behave as a shared cache or not.
+         * @param isSharedCache true to behave as a shared cache, false to
+         * behave as a non-shared (private) cache. To have the cache
+         * behave like a browser cache, you want to set this to {@code false}.
+         */
+        public Builder setSharedCache(boolean isSharedCache) {
+            this.isSharedCache = isSharedCache;
+            return this;
+        }
+
+        /**
+         * Sets the maximum number of threads to allow for background
+         * revalidations due to the {@code stale-while-revalidate} directive.
+         * @param max number of threads; a value of 0 disables background
+         * revalidations.
+         */
+        public Builder setAsynchronousWorkersMax(int asynchronousWorkersMax) {
+            this.asynchronousWorkersMax = asynchronousWorkersMax;
+            return this;
+        }
+
+        /**
+         * Sets the minimum number of threads to keep alive for background
+         * revalidations due to the {@code stale-while-revalidate} directive.
+         * @param min should be greater than zero and less than or equal
+         *   to <code>getAsynchronousWorkersMax()</code>
+         */
+        public Builder setAsynchronousWorkersCore(int asynchronousWorkersCore) {
+            this.asynchronousWorkersCore = asynchronousWorkersCore;
+            return this;
+        }
+
+        /**
+         * Sets the current maximum idle lifetime in seconds for a
+         * background revalidation worker thread. If a worker thread is idle
+         * for this long, and there are more than the core number of worker
+         * threads alive, the worker will be reclaimed.
+         * @param secs idle lifetime in seconds
+         */
+        public Builder setAsynchronousWorkerIdleLifetimeSecs(int asynchronousWorkerIdleLifetimeSecs) {
+            this.asynchronousWorkerIdleLifetimeSecs = asynchronousWorkerIdleLifetimeSecs;
+            return this;
+        }
+
+        /**
+         * Sets the current maximum queue size for background revalidations.
+         */
+        public Builder setRevalidationQueueSize(int revalidationQueueSize) {
+            this.revalidationQueueSize = revalidationQueueSize;
+            return this;
+        }
+
+        public CacheConfig build() {
+            return new CacheConfig(
+                    maxObjectSize,
+                    maxCacheEntries,
+                    maxUpdateRetries,
+                    heuristicCachingEnabled,
+                    heuristicCoefficient,
+                    heuristicDefaultLifetime,
+                    isSharedCache,
+                    asynchronousWorkersMax,
+                    asynchronousWorkersCore,
+                    asynchronousWorkerIdleLifetimeSecs,
+                    revalidationQueueSize);
+        }
+
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("[maxObjectSize=").append(this.maxObjectSize)
+                .append(", maxCacheEntries=").append(this.maxCacheEntries)
+                .append(", maxUpdateRetries=").append(this.heuristicCachingEnabled)
+                .append(", heuristicCoefficient=").append(this.heuristicCoefficient)
+                .append(", heuristicDefaultLifetime=").append(this.heuristicDefaultLifetime)
+                .append(", isSharedCache=").append(this.isSharedCache)
+                .append(", asynchronousWorkersMax=").append(this.asynchronousWorkersMax)
+                .append(", asynchronousWorkersCore=").append(this.asynchronousWorkersCore)
+                .append(", asynchronousWorkerIdleLifetimeSecs=").append(this.asynchronousWorkerIdleLifetimeSecs)
+                .append(", revalidationQueueSize=").append(this.revalidationQueueSize)
+                .append("]");
+        return builder.toString();
+    }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java Mon Dec  3 16:34:27 2012
@@ -70,7 +70,7 @@ public class EhcacheHttpCacheStorage imp
      * @param cache where to store cached origin responses
      */
     public EhcacheHttpCacheStorage(Ehcache cache) {
-        this(cache, new CacheConfig(), new DefaultHttpCacheEntrySerializer());
+        this(cache, CacheConfig.DEFAULT, new DefaultHttpCacheEntrySerializer());
     }
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java Mon Dec  3 16:34:27 2012
@@ -111,7 +111,7 @@ public class MemcachedHttpCacheStorage i
      * @param cache client to use for communicating with <i>memcached</i>
      */
     public MemcachedHttpCacheStorage(MemcachedClientIF cache) {
-        this(cache, new CacheConfig(), new MemcachedCacheEntryFactoryImpl(),
+        this(cache, CacheConfig.DEFAULT, new MemcachedCacheEntryFactoryImpl(),
                 new SHA256KeyHashingScheme());
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java Mon Dec  3 16:34:27 2012
@@ -50,7 +50,7 @@ public abstract class AbstractProtocolTe
     protected HttpCache mockCache;
     protected HttpRequest request;
     protected HttpResponse originResponse;
-    protected CacheConfig params;
+    protected CacheConfig config;
     protected CachingHttpClient impl;
     protected HttpCache cache;
 
@@ -69,13 +69,14 @@ public abstract class AbstractProtocolTe
 
         originResponse = HttpTestUtils.make200Response();
 
-        params = new CacheConfig();
-        params.setMaxCacheEntries(MAX_ENTRIES);
-        params.setMaxObjectSize(MAX_BYTES);
-        cache = new BasicHttpCache(params);
+        config = CacheConfig.custom()
+            .setMaxCacheEntries(MAX_ENTRIES)
+            .setMaxObjectSize(MAX_BYTES)
+            .build();
+        cache = new BasicHttpCache(config);
         mockBackend = EasyMock.createNiceMock(HttpClient.class);
         mockCache = EasyMock.createNiceMock(HttpCache.class);
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        impl = new CachingHttpClient(mockBackend, cache, config);
     }
 
     protected void replayMocks() {
@@ -98,7 +99,7 @@ public abstract class AbstractProtocolTe
         mockBackend = EasyMock.createNiceMock(HttpClient.class);
         mockCache = EasyMock.createNiceMock(HttpCache.class);
 
-        impl = new CachingHttpClient(mockBackend, mockCache, params);
+        impl = new CachingHttpClient(mockBackend, mockCache, config);
 
         EasyMock.expect(mockCache.getCacheEntry(EasyMock.isA(HttpHost.class), EasyMock.isA(HttpRequest.class)))
             .andReturn(null).anyTimes();
@@ -119,8 +120,12 @@ public abstract class AbstractProtocolTe
     }
 
     protected void behaveAsNonSharedCache() {
-        params.setSharedCache(false);
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        config = CacheConfig.custom()
+                .setMaxCacheEntries(MAX_ENTRIES)
+                .setMaxObjectSize(MAX_BYTES)
+                .setSharedCache(false)
+                .build();
+        impl = new CachingHttpClient(mockBackend, cache, config);
     }
 
     public AbstractProtocolTest() {

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java Mon Dec  3 16:34:27 2012
@@ -74,9 +74,9 @@ public class DoNotTestProtocolRequiremen
         request = new BasicHttpRequest("GET", "/foo", HTTP_1_1);
 
         originResponse = make200Response();
-        CacheConfig params = new CacheConfig();
-        params.setMaxObjectSize(MAX_BYTES);
-        params.setMaxCacheEntries(MAX_ENTRIES);
+        CacheConfig params = CacheConfig.custom()
+            .setMaxObjectSize(MAX_BYTES)
+            .setMaxCacheEntries(MAX_ENTRIES).build();
 
         HttpCache cache = new BasicHttpCache(params);
         mockBackend = EasyMock.createNiceMock(HttpClient.class);

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java Mon Dec  3 16:34:27 2012
@@ -166,9 +166,10 @@ public class TestAsynchronousValidator {
 
     @Test
     public void testRevalidateCacheEntryEndToEnd() throws ProtocolException, IOException {
-        CacheConfig config = new CacheConfig();
-        config.setAsynchronousWorkersMax(1);
-        config.setAsynchronousWorkersCore(1);
+        CacheConfig config = CacheConfig.custom()
+            .setAsynchronousWorkersMax(1)
+            .setAsynchronousWorkersCore(1)
+            .build();
         impl = new AsynchronousValidator(mockClient, config);
 
         EasyMock.expect(mockCacheEntry.hasVariants()).andReturn(false);

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java Mon Dec  3 16:34:27 2012
@@ -66,7 +66,7 @@ public class TestBasicHttpCache {
     @Before
     public void setUp() throws Exception {
         backing = new SimpleHttpCacheStorage();
-        impl = new BasicHttpCache(new HeapResourceFactory(), backing, new CacheConfig());
+        impl = new BasicHttpCache(new HeapResourceFactory(), backing, CacheConfig.DEFAULT);
     }
 
     @Test

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java Mon Dec  3 16:34:27 2012
@@ -66,7 +66,7 @@ public class TestCachedResponseSuitabili
         mockValidityPolicy = EasyMock.createNiceMock(CacheValidityPolicy.class);
         entry = HttpTestUtils.makeCacheEntry();
 
-        impl = new CachedResponseSuitabilityChecker(new CacheConfig());
+        impl = new CachedResponseSuitabilityChecker(CacheConfig.DEFAULT);
     }
 
     private HttpCacheEntry getEntry(Header[] headers) {
@@ -236,9 +236,9 @@ public class TestCachedResponseSuitabili
 
         entry = HttpTestUtils.makeCacheEntry(oneSecondAgo, oneSecondAgo, headers);
 
-        CacheConfig config = new CacheConfig();
-        config.setHeuristicCachingEnabled(true);
-        config.setHeuristicCoefficient(0.1f);
+        CacheConfig config = CacheConfig.custom()
+            .setHeuristicCachingEnabled(true)
+            .setHeuristicCoefficient(0.1f).build();
         impl = new CachedResponseSuitabilityChecker(config);
 
         Assert.assertTrue(impl.canCachedResponseBeUsed(host, request, entry, now));
@@ -253,9 +253,10 @@ public class TestCachedResponseSuitabili
 
         entry = getEntry(headers);
 
-        CacheConfig config = new CacheConfig();
-        config.setHeuristicCachingEnabled(true);
-        config.setHeuristicDefaultLifetime(20);
+        CacheConfig config = CacheConfig.custom()
+            .setHeuristicCachingEnabled(true)
+            .setHeuristicDefaultLifetime(20)
+            .build();
         impl = new CachedResponseSuitabilityChecker(config);
 
         Assert.assertTrue(impl.canCachedResponseBeUsed(host, request, entry, now));

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java Mon Dec  3 16:34:27 2012
@@ -487,7 +487,7 @@ public class TestCachingHttpClient {
 
     @Test
     public void testNonCacheableResponseIsNotCachedAndIsReturnedAsIs() throws Exception {
-        CacheConfig config = new CacheConfig();
+        CacheConfig config = CacheConfig.DEFAULT;
         impl = new CachingHttpClient(mockBackend,
                 new BasicHttpCache(new HeapResourceFactory(), mockStorage, config),
                 config);
@@ -1793,7 +1793,7 @@ public class TestCachingHttpClient {
     public void testTreatsCacheIOExceptionsAsCacheMiss()
         throws Exception {
 
-        impl = new CachingHttpClient(mockBackend, mockCache, new CacheConfig());
+        impl = new CachingHttpClient(mockBackend, mockCache, CacheConfig.DEFAULT);
         HttpResponse resp = HttpTestUtils.make200Response();
 
         mockCache.flushInvalidatedCacheEntriesFor(host, request);

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java Mon Dec  3 16:34:27 2012
@@ -84,9 +84,10 @@ public class TestHttpCacheJiraNumber1147
     
     @Test
     public void testIssue1147() throws Exception {
-        CacheConfig cacheConfig = new CacheConfig();
-        cacheConfig.setSharedCache(true);
-        cacheConfig.setMaxObjectSize(262144); //256kb
+        CacheConfig cacheConfig = CacheConfig.custom()
+            .setSharedCache(true)
+            .setMaxObjectSize(262144) //256kb
+            .build();
 
         ResourceFactory resourceFactory = new FileResourceFactory(cacheDir);
         HttpCacheStorage httpCacheStorage = new ManagedHttpCacheStorage(cacheConfig);

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java Mon Dec  3 16:34:27 2012
@@ -93,16 +93,17 @@ public class TestProtocolDeviations {
 
         originResponse = make200Response();
 
-        CacheConfig params = new CacheConfig();
-        params.setMaxObjectSize(MAX_BYTES);
-        params.setMaxCacheEntries(MAX_ENTRIES);
+        CacheConfig config = CacheConfig.custom()
+                .setMaxCacheEntries(MAX_ENTRIES)
+                .setMaxObjectSize(MAX_BYTES)
+                .build();
 
-        HttpCache cache = new BasicHttpCache(params);
+        HttpCache cache = new BasicHttpCache(config);
         mockBackend = EasyMock.createNiceMock(HttpClient.class);
         mockEntity = EasyMock.createNiceMock(HttpEntity.class);
         mockCache = EasyMock.createNiceMock(HttpCache.class);
 
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        impl = new CachingHttpClient(mockBackend, cache, config);
     }
 
     private HttpResponse make200Response() {

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java Mon Dec  3 16:34:27 2012
@@ -2222,7 +2222,7 @@ public class TestProtocolRequirements ex
 
         HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, hdrs, bytes);
 
-        impl = new CachingHttpClient(mockBackend, mockCache, params);
+        impl = new CachingHttpClient(mockBackend, mockCache, config);
 
         request = new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1);
 
@@ -2268,7 +2268,7 @@ public class TestProtocolRequirements ex
 
         HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, hdrs, bytes);
 
-        impl = new CachingHttpClient(mockBackend, mockCache, params);
+        impl = new CachingHttpClient(mockBackend, mockCache, config);
         request = new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1);
 
         mockCache.flushInvalidatedCacheEntriesFor(host, request);
@@ -2316,7 +2316,7 @@ public class TestProtocolRequirements ex
 
         HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, hdrs, bytes);
 
-        impl = new CachingHttpClient(mockBackend, mockCache, params);
+        impl = new CachingHttpClient(mockBackend, mockCache, config);
         request = new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1);
 
         mockCache.flushInvalidatedCacheEntriesFor(host, request);
@@ -2518,7 +2518,7 @@ public class TestProtocolRequirements ex
 
         HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, hdrs, bytes);
 
-        impl = new CachingHttpClient(mockBackend, mockCache, params);
+        impl = new CachingHttpClient(mockBackend, mockCache, config);
         request = new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1);
 
         mockCache.flushInvalidatedCacheEntriesFor(host, request);
@@ -2569,7 +2569,7 @@ public class TestProtocolRequirements ex
 
         HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(requestTime, responseTime, hdrs, bytes);
 
-        impl = new CachingHttpClient(mockBackend, mockCache, params);
+        impl = new CachingHttpClient(mockBackend, mockCache, config);
 
         request = new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1);
 

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java Mon Dec  3 16:34:27 2012
@@ -165,8 +165,8 @@ public class TestRFC5861Compliance exten
     @Test
     public void testStaleIfErrorInResponseNeedNotYieldToProxyRevalidateForPrivateCache()
             throws Exception{
-        CacheConfig config = new CacheConfig();
-        config.setSharedCache(false);
+        CacheConfig config = CacheConfig.custom()
+                .setSharedCache(false).build();
         impl = new CachingHttpClient(mockBackend, config);
 
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
@@ -299,9 +299,13 @@ public class TestRFC5861Compliance exten
     @Test
     public void testStaleWhileRevalidateReturnsStaleEntryWithWarning()
         throws Exception {
+        config = CacheConfig.custom()
+                .setMaxCacheEntries(MAX_ENTRIES)
+                .setMaxObjectSize(MAX_BYTES)
+                .setAsynchronousWorkersMax(1)
+                .build();
 
-        params.setAsynchronousWorkersMax(1);
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        impl = new CachingHttpClient(mockBackend, cache, config);
 
         HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -337,9 +341,13 @@ public class TestRFC5861Compliance exten
     public void testCanAlsoServeStale304sWhileRevalidating()
         throws Exception {
 
-        params.setAsynchronousWorkersMax(1);
-        params.setSharedCache(false);
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        config = CacheConfig.custom()
+                .setMaxCacheEntries(MAX_ENTRIES)
+                .setMaxObjectSize(MAX_BYTES)
+                .setAsynchronousWorkersMax(1)
+                .setSharedCache(false)
+                .build();
+        impl = new CachingHttpClient(mockBackend, cache, config);
 
         HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -380,8 +388,12 @@ public class TestRFC5861Compliance exten
         Date now = new Date();
         Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
 
-        params.setAsynchronousWorkersMax(1);
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        config = CacheConfig.custom()
+                .setMaxCacheEntries(MAX_ENTRIES)
+                .setMaxObjectSize(MAX_BYTES)
+                .setAsynchronousWorkersMax(1)
+                .build();
+        impl = new CachingHttpClient(mockBackend, cache, config);
 
         HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -424,9 +436,13 @@ public class TestRFC5861Compliance exten
         Date now = new Date();
         Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
 
-        params.setAsynchronousWorkersMax(1);
-        params.setSharedCache(true);
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        config = CacheConfig.custom()
+                .setMaxCacheEntries(MAX_ENTRIES)
+                .setMaxObjectSize(MAX_BYTES)
+                .setAsynchronousWorkersMax(1)
+                .setSharedCache(true)
+                .build();
+        impl = new CachingHttpClient(mockBackend, cache, config);
 
         HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -469,9 +485,13 @@ public class TestRFC5861Compliance exten
         Date now = new Date();
         Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
 
-        params.setAsynchronousWorkersMax(1);
-        params.setSharedCache(true);
-        impl = new CachingHttpClient(mockBackend, cache, params);
+        config = CacheConfig.custom()
+                .setMaxCacheEntries(MAX_ENTRIES)
+                .setMaxObjectSize(MAX_BYTES)
+                .setAsynchronousWorkersMax(1)
+                .setSharedCache(true)
+                .build();
+        impl = new CachingHttpClient(mockBackend, cache, config);
 
         HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
         HttpResponse resp1 = HttpTestUtils.make200Response();

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java Mon Dec  3 16:34:27 2012
@@ -52,8 +52,7 @@ public class TestEhcacheHttpCacheStorage
     @Override
     public void setUp() {
         mockCache = EasyMock.createNiceMock(Ehcache.class);
-        CacheConfig config = new CacheConfig();
-        config.setMaxUpdateRetries(1);
+        CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(1).build();
         mockSerializer = EasyMock.createNiceMock(HttpCacheEntrySerializer.class);
         impl = new EhcacheHttpCacheStorage(mockCache, config, mockSerializer);
     }

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java Mon Dec  3 16:34:27 2012
@@ -63,8 +63,7 @@ public class TestEhcacheProtocolRequirem
     @Before
     public void setUp() {
         super.setUp();
-        params = new CacheConfig();
-        params.setMaxObjectSize(MAX_BYTES);
+        config = CacheConfig.custom().setMaxObjectSize(MAX_BYTES).build();
 
         if (CACHE_MANAGER.cacheExists(TEST_EHCACHE_NAME)){
             CACHE_MANAGER.removeCache(TEST_EHCACHE_NAME);
@@ -73,7 +72,7 @@ public class TestEhcacheProtocolRequirem
         HttpCacheStorage storage = new EhcacheHttpCacheStorage(CACHE_MANAGER.getCache(TEST_EHCACHE_NAME));
         mockBackend = EasyMock.createNiceMock(HttpClient.class);
 
-        impl = new CachingHttpClient(mockBackend, new HeapResourceFactory(), storage, params);
+        impl = new CachingHttpClient(mockBackend, new HeapResourceFactory(), storage, config);
     }
 
     @After

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java?rev=1416582&r1=1416581&r2=1416582&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java (original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java Mon Dec  3 16:34:27 2012
@@ -64,8 +64,7 @@ public class TestMemcachedHttpCacheStora
         mockMemcachedCacheEntry2 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
         mockMemcachedCacheEntry3 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
         mockMemcachedCacheEntry4 = EasyMock.createNiceMock(MemcachedCacheEntry.class);
-        CacheConfig config = new CacheConfig();
-        config.setMaxUpdateRetries(1);
+        CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(1).build();
         impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                 mockMemcachedCacheEntryFactory, mockKeyHashingScheme);
     }
@@ -431,8 +430,7 @@ public class TestMemcachedHttpCacheStora
         CASValue<Object> casValue = new CASValue<Object>(1, oldBytes);
         final byte[] newBytes = HttpTestUtils.getRandomBytes(128);
         
-        CacheConfig config = new CacheConfig();
-        config.setMaxUpdateRetries(0);
+        CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(0).build();
         impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                 mockMemcachedCacheEntryFactory, mockKeyHashingScheme);