mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-09 03:25:28 +00:00
Renamed CacheEntryGenerator to MemCacheEntryFactory
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@981668 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
911350a0c2
commit
7c8a1fdf5b
@ -58,7 +58,7 @@ class CacheEntryUpdater {
|
|||||||
private final HttpCacheEntryFactory cacheEntryFactory;
|
private final HttpCacheEntryFactory cacheEntryFactory;
|
||||||
|
|
||||||
CacheEntryUpdater() {
|
CacheEntryUpdater() {
|
||||||
this(new CacheEntryGenerator());
|
this(new MemCacheEntryFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheEntryUpdater(final HttpCacheEntryFactory cacheEntryFactory) {
|
CacheEntryUpdater(final HttpCacheEntryFactory cacheEntryFactory) {
|
||||||
|
@ -138,28 +138,28 @@ public CachingHttpClient(
|
|||||||
public CachingHttpClient() {
|
public CachingHttpClient() {
|
||||||
this(new DefaultHttpClient(),
|
this(new DefaultHttpClient(),
|
||||||
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
||||||
new CacheEntryGenerator(),
|
new MemCacheEntryFactory(),
|
||||||
new CacheConfig());
|
new CacheConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CachingHttpClient(CacheConfig config) {
|
public CachingHttpClient(CacheConfig config) {
|
||||||
this(new DefaultHttpClient(),
|
this(new DefaultHttpClient(),
|
||||||
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
||||||
new CacheEntryGenerator(),
|
new MemCacheEntryFactory(),
|
||||||
config);
|
config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CachingHttpClient(HttpClient client) {
|
public CachingHttpClient(HttpClient client) {
|
||||||
this(client,
|
this(client,
|
||||||
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
||||||
new CacheEntryGenerator(),
|
new MemCacheEntryFactory(),
|
||||||
new CacheConfig());
|
new CacheConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CachingHttpClient(HttpClient client, CacheConfig config) {
|
public CachingHttpClient(HttpClient client, CacheConfig config) {
|
||||||
this(client,
|
this(client,
|
||||||
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
new BasicHttpCache(MAX_CACHE_ENTRIES),
|
||||||
new CacheEntryGenerator(),
|
new MemCacheEntryFactory(),
|
||||||
config);
|
config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
class CacheEntryGenerator implements HttpCacheEntryFactory {
|
class MemCacheEntryFactory implements HttpCacheEntryFactory {
|
||||||
|
|
||||||
public HttpCacheEntry generateEntry(
|
public HttpCacheEntry generateEntry(
|
||||||
Date requestDate,
|
Date requestDate,
|
@ -52,7 +52,7 @@ public void setUp() {
|
|||||||
originResponse = make200Response();
|
originResponse = make200Response();
|
||||||
|
|
||||||
cache = new BasicHttpCache(MAX_ENTRIES);
|
cache = new BasicHttpCache(MAX_ENTRIES);
|
||||||
cacheEntryFactory = new CacheEntryGenerator();
|
cacheEntryFactory = new MemCacheEntryFactory();
|
||||||
mockBackend = EasyMock.createMock(HttpClient.class);
|
mockBackend = EasyMock.createMock(HttpClient.class);
|
||||||
mockEntity = EasyMock.createMock(HttpEntity.class);
|
mockEntity = EasyMock.createMock(HttpEntity.class);
|
||||||
mockCache = EasyMock.createMock(HttpCache.class);
|
mockCache = EasyMock.createMock(HttpCache.class);
|
||||||
|
@ -82,7 +82,7 @@ public void setUp() {
|
|||||||
mockCache = EasyMock.createMock(HttpCache.class);
|
mockCache = EasyMock.createMock(HttpCache.class);
|
||||||
CacheConfig params = new CacheConfig();
|
CacheConfig params = new CacheConfig();
|
||||||
params.setMaxObjectSizeBytes(MAX_BYTES);
|
params.setMaxObjectSizeBytes(MAX_BYTES);
|
||||||
impl = new CachingHttpClient(mockBackend, cache, new CacheEntryGenerator(), params);
|
impl = new CachingHttpClient(mockBackend, cache, new MemCacheEntryFactory(), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpResponse make200Response() {
|
private HttpResponse make200Response() {
|
||||||
|
@ -108,7 +108,7 @@ public void testCacheEntryCanStoreMultipleVariantUris() throws Exception {
|
|||||||
Header[] headers = new Header[]{};
|
Header[] headers = new Header[]{};
|
||||||
CacheEntry entry = new CacheEntry(headers);
|
CacheEntry entry = new CacheEntry(headers);
|
||||||
|
|
||||||
CacheEntryGenerator entryGenerator = new CacheEntryGenerator();
|
MemCacheEntryFactory entryGenerator = new MemCacheEntryFactory();
|
||||||
|
|
||||||
HttpCacheEntry addedOne = entryGenerator.copyVariant(entry, "foo");
|
HttpCacheEntry addedOne = entryGenerator.copyVariant(entry, "foo");
|
||||||
HttpCacheEntry addedTwo = entryGenerator.copyVariant(addedOne, "bar");
|
HttpCacheEntry addedTwo = entryGenerator.copyVariant(addedOne, "bar");
|
||||||
|
@ -43,7 +43,7 @@ public class TestCacheEntryGenerator {
|
|||||||
@Test
|
@Test
|
||||||
public void testEntryMatchesInputs() {
|
public void testEntryMatchesInputs() {
|
||||||
|
|
||||||
CacheEntryGenerator gen = new CacheEntryGenerator();
|
MemCacheEntryFactory gen = new MemCacheEntryFactory();
|
||||||
|
|
||||||
HttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1),
|
HttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1),
|
||||||
HttpStatus.SC_OK, "Success");
|
HttpStatus.SC_OK, "Success");
|
||||||
|
@ -100,7 +100,7 @@ public void setUp() {
|
|||||||
|
|
||||||
CacheConfig params = new CacheConfig();
|
CacheConfig params = new CacheConfig();
|
||||||
params.setMaxObjectSizeBytes(MAX_BYTES);
|
params.setMaxObjectSizeBytes(MAX_BYTES);
|
||||||
impl = new CachingHttpClient(mockBackend, cache, new CacheEntryGenerator(), params);
|
impl = new CachingHttpClient(mockBackend, cache, new MemCacheEntryFactory(), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpResponse make200Response() {
|
private HttpResponse make200Response() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user