Package org.apache.http.client.cache

Examples of org.apache.http.client.cache.HttpCacheEntry


    }

    @Test
    public void testMustRevalidateIsTrueWhenDirectiveIsPresent() {
        Header[] headers = new Header[] { new BasicHeader("Cache-Control","public, must-revalidate") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertTrue(impl.mustRevalidate(entry));
    }
View Full Code Here


    }

    @Test
    public void testProxyRevalidateIsFalseIfDirectiveNotPresent() {
        Header[] headers = new Header[] { new BasicHeader("Cache-Control","public") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertFalse(impl.proxyRevalidate(entry));
    }
View Full Code Here

    }

    @Test
    public void testProxyRevalidateIsTrueWhenDirectiveIsPresent() {
        Header[] headers = new Header[] { new BasicHeader("Cache-Control","public, proxy-revalidate") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertTrue(impl.proxyRevalidate(entry));
    }
View Full Code Here

    public void testMayReturnStaleIfErrorInResponseIsTrueWithinStaleness(){
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),
                new BasicHeader("Cache-Control", "max-age=5, stale-if-error=15")
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
        HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
        assertTrue(impl.mayReturnStaleIfError(req, entry, now));
    }
View Full Code Here

    public void testMayReturnStaleIfErrorInRequestIsTrueWithinStaleness(){
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),
                new BasicHeader("Cache-Control", "max-age=5")
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
        HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
        req.setHeader("Cache-Control","stale-if-error=15");
        assertTrue(impl.mayReturnStaleIfError(req, entry, now));
    }
View Full Code Here

    public void testMayNotReturnStaleIfErrorInResponseAndAfterResponseWindow(){
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),
                new BasicHeader("Cache-Control", "max-age=5, stale-if-error=1")
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
        HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
        assertFalse(impl.mayReturnStaleIfError(req, entry, now));
    }
View Full Code Here

    public void testMayNotReturnStaleIfErrorInResponseAndAfterRequestWindow(){
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),
                new BasicHeader("Cache-Control", "max-age=5")
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
        HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
        req.setHeader("Cache-Control","stale-if-error=1");
        assertFalse(impl.mayReturnStaleIfError(req, entry, now));
    }
View Full Code Here

    @Test
    public void testMayReturnStaleWhileRevalidatingIsFalseWhenDirectiveIsAbsent() {
        Date now = new Date();
       
        Header[] headers = new Header[] { new BasicHeader("Cache-control", "public") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
       
        CacheValidityPolicy impl = new CacheValidityPolicy();
       
        assertFalse(impl.mayReturnStaleWhileRevalidating(entry, now));
    }
View Full Code Here

        Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),
                new BasicHeader("Cache-Control", "max-age=5, stale-while-revalidate=15")
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
       
        CacheValidityPolicy impl = new CacheValidityPolicy();
       
        assertTrue(impl.mayReturnStaleWhileRevalidating(entry, now));
    }
View Full Code Here

        Date twentyFiveSecondsAgo = new Date(now.getTime() - 25 * 1000L);
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(twentyFiveSecondsAgo)),
                new BasicHeader("Cache-Control", "max-age=5, stale-while-revalidate=15")
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
       
        CacheValidityPolicy impl = new CacheValidityPolicy();
       
        assertFalse(impl.mayReturnStaleWhileRevalidating(entry, now));
    }
View Full Code Here

TOP

Related Classes of org.apache.http.client.cache.HttpCacheEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.