Package org.apache.http.client.cache

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


   
    @Test
    public void testMissingContentLengthDoesntInvalidateEntry() {
        final int contentLength = 128;
        Header[] headers = {}; // no Content-Length header
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers, HttpTestUtils.getRandomBytes(contentLength));
        assertTrue(impl.contentLengthHeaderMatchesActualLength(entry));
    }
View Full Code Here


   
    @Test
    public void testCorrectContentLengthDoesntInvalidateEntry() {
        final int contentLength = 128;
        Header[] headers = { new BasicHeader(HTTP.CONTENT_LEN, Integer.toString(contentLength)) };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers, HttpTestUtils.getRandomBytes(contentLength));
        assertTrue(impl.contentLengthHeaderMatchesActualLength(entry));
    }
View Full Code Here

   
    @Test
    public void testWrongContentLengthInvalidatesEntry() {
        final int contentLength = 128;
        Header[] headers = {new BasicHeader(HTTP.CONTENT_LEN, Integer.toString(contentLength+1))};
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers, HttpTestUtils.getRandomBytes(contentLength));
        assertFalse(impl.contentLengthHeaderMatchesActualLength(entry));
    }
View Full Code Here

    }

    @Test
    public void testMalformedDateHeaderIsIgnored() {
        Header[] headers = new Header[] { new BasicHeader("Date", "asdf") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertNull(impl.getDateValue(entry));
    }
View Full Code Here

    }

    @Test
    public void testMalformedContentLengthReturnsNegativeOne() {
        Header[] headers = new Header[] { new BasicHeader("Content-Length", "asdf") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertEquals(-1, impl.getContentLengthValue(entry));
    }
View Full Code Here

    }

    @Test
    public void testNegativeAgeHeaderValueReturnsMaxAge() {
        Header[] headers = new Header[] { new BasicHeader("Age", "-100") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertEquals(CacheValidityPolicy.MAX_AGE, impl.getAgeValue(entry));
    }
View Full Code Here

    }

    @Test
    public void testMalformedAgeHeaderValueReturnsMaxAge() {
        Header[] headers = new Header[] { new BasicHeader("Age", "asdf") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertEquals(CacheValidityPolicy.MAX_AGE, impl.getAgeValue(entry));
    }
View Full Code Here

    }

    @Test
    public void testMalformedCacheControlMaxAgeHeaderReturnsZero() {
        Header[] headers = new Header[] { new BasicHeader("Cache-Control", "max-age=asdf") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertEquals(0, impl.getMaxAge(entry));
    }
View Full Code Here

    }

    @Test
    public void testMalformedExpirationDateReturnsNull() {
        Header[] headers = new Header[] { new BasicHeader("Expires", "asdf") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertNull(impl.getExpirationDate(entry));
    }
View Full Code Here

    }

    @Test
    public void testMustRevalidateIsFalseIfDirectiveNotPresent() {
        Header[] headers = new Header[] { new BasicHeader("Cache-Control","public") };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertFalse(impl.mustRevalidate(entry));
    }
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.