Examples of HttpCacheEntry


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

    public void testFreshnessLifetimeIsFromExpiresHeaderIfNoMaxAge() {
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),
                new BasicHeader("Expires", DateUtils.formatDate(sixSecondsAgo)) };

        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertEquals(4, impl.getFreshnessLifetimeSecs(entry));
    }
View Full Code Here

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

    public void testHeuristicFreshnessLifetime() {
        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(oneSecondAgo)),
                new BasicHeader("Last-Modified", DateUtils.formatDate(elevenSecondsAgo))
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertEquals(1, impl.getHeuristicFreshnessLifetimeSecs(entry, 0.1f, 0));
    }
View Full Code Here

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

    }

    @Test
    public void testHeuristicFreshnessLifetimeDefaultsProperly() {
        long defaultFreshness = 10;
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
        assertEquals(defaultFreshness, impl.getHeuristicFreshnessLifetimeSecs(entry, 0.1f, defaultFreshness));
    }
View Full Code Here

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

        Header[] headers = new Header[] {
                new BasicHeader("Date", DateUtils.formatDate(elevenSecondsAgo)),
                new BasicHeader("Last-Modified", DateUtils.formatDate(oneSecondAgo))
        };

        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertTrue(impl.getHeuristicFreshnessLifetimeSecs(entry, 0.1f, 10) >= 0);
    }
View Full Code Here

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

        assertTrue(impl.getHeuristicFreshnessLifetimeSecs(entry, 0.1f, 10) >= 0);
    }

    @Test
    public void testResponseIsFreshIfFreshnessLifetimeExceedsCurrentAge() {
        final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
        impl = new CacheValidityPolicy() {
            @Override
            public long getCurrentAgeSecs(HttpCacheEntry e, Date d) {
                assertSame(entry, e);
                assertEquals(now, d);
View Full Code Here

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

        assertTrue(impl.isResponseFresh(entry, now));
    }

    @Test
    public void testResponseIsNotFreshIfFreshnessLifetimeEqualsCurrentAge() {
        final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
        impl = new CacheValidityPolicy() {
            @Override
            public long getCurrentAgeSecs(HttpCacheEntry e, Date d) {
                assertEquals(now, d);
                assertSame(entry, e);
View Full Code Here

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

        assertFalse(impl.isResponseFresh(entry, now));
    }

    @Test
    public void testResponseIsNotFreshIfCurrentAgeExceedsFreshnessLifetime() {
        final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
        impl = new CacheValidityPolicy() {
            @Override
            public long getCurrentAgeSecs(HttpCacheEntry e, Date d) {
                assertEquals(now, d);
                assertSame(entry, e);
View Full Code Here

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

    @Test
    public void testCacheEntryIsRevalidatableIfHeadersIncludeETag() {
        Header[] headers = {
                new BasicHeader("Expires", DateUtils.formatDate(new Date())),
                new BasicHeader("ETag", "somevalue")};
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertTrue(impl.isRevalidatable(entry));
    }
View Full Code Here

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

    @Test
    public void testCacheEntryIsRevalidatableIfHeadersIncludeLastModifiedDate() {
        Header[] headers = {
                new BasicHeader("Expires", DateUtils.formatDate(new Date())),
                new BasicHeader("Last-Modified", DateUtils.formatDate(new Date())) };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertTrue(impl.isRevalidatable(entry));
    }
View Full Code Here

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

    @Test
    public void testCacheEntryIsNotRevalidatableIfNoAppropriateHeaders() {
        Header[] headers =  {
                new BasicHeader("Expires", DateUtils.formatDate(new Date())),
                new BasicHeader("Cache-Control", "public") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertFalse(impl.isRevalidatable(entry));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.