org.apache.http.client.cache.HttpCacheContext

Here are the examples of the java api class org.apache.http.client.cache.HttpCacheContext taken from open source projects.

1. DocumentLoaderTest#fromURLCache()

Project: jsonld-java
File: DocumentLoaderTest.java
@Test
public void fromURLCache() throws Exception {
    final URL url = new URL("http://json-ld.org/contexts/person.jsonld");
    documentLoader.fromURL(url);
    // Now try to get it again and ensure it is
    // cached
    final HttpClient clientCached = documentLoader.getHttpClient();
    final HttpUriRequest getCached = new HttpGet(url.toURI());
    getCached.setHeader("Accept", DocumentLoader.ACCEPT_HEADER);
    final HttpCacheContext localContextCached = HttpCacheContext.create();
    final HttpResponse respoCached = clientCached.execute(getCached, localContextCached);
    EntityUtils.consume(respoCached.getEntity());
    // Check cache status
    // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/caching.html
    final CacheResponseStatus responseStatusCached = localContextCached.getCacheResponseStatus();
    assertNotEquals(CacheResponseStatus.CACHE_MISS, responseStatusCached);
}