Package org.apache.http.client.cache

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


    }

    @Test
    public void testCachePut() throws IOException {
        final String url = "foo";
        final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
        mockSerializer.writeTo(EasyMock.isA(HttpCacheEntry.class), EasyMock
                .isA(OutputStream.class));
        EasyMock.expect(
                mockMemcachedClient.set(EasyMock.eq(url), EasyMock.eq(0),
                        EasyMock.aryEq(new byte[0]))).andReturn(null);
View Full Code Here


    @Test
    public void testCacheGet() throws UnsupportedEncodingException,
            IOException {
        final String url = "foo";
        final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry();
        EasyMock.expect(mockMemcachedClient.get(url)).andReturn(new byte[] {});
        EasyMock.expect(
                mockSerializer.readFrom(EasyMock.isA(InputStream.class)))
                .andReturn(cacheEntry);
        replayMocks();
        HttpCacheEntry resultingEntry = impl.getEntry(url);
        verifyMocks();
        assertSame(cacheEntry, resultingEntry);
    }
View Full Code Here

        final String url = "foo";

        EasyMock.expect(mockMemcachedClient.get(url)).andReturn(null);

        replayMocks();
        HttpCacheEntry resultingEntry = impl.getEntry(url);
        verifyMocks();

        assertNull(resultingEntry);
    }
View Full Code Here

    @Test
    public void testCacheUpdateNullEntry() throws IOException,
            HttpCacheUpdateException {
        final String url = "foo";
        final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();

        HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
            public HttpCacheEntry update(HttpCacheEntry old) {
                assertNull(old);
                return updatedValue;
View Full Code Here

    }

    @Test
    public void testCacheUpdate() throws IOException, HttpCacheUpdateException {
        final String url = "foo";
        final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry();
        final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();

        CASValue<Object> v = new CASValue<Object>(1234, new byte[] {});

        HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
            public HttpCacheEntry update(HttpCacheEntry old) {
View Full Code Here

    }

    @Test
    public void testCacheUpdateThrowsTimeoutException() throws IOException, HttpCacheUpdateException {
        final String url = "foo";
        final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry();
        final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();

        CASValue<Object> v = new CASValue<Object>(1234, new byte[] {});

        HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
            public HttpCacheEntry update(HttpCacheEntry old) {
View Full Code Here

    @Test
    public void testSingleCacheUpdateRetry() throws IOException,
            HttpCacheUpdateException {
        final String url = "foo";
        final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry();
        final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
        CASValue<Object> v = new CASValue<Object>(1234, new byte[] {});

        HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
            public HttpCacheEntry update(HttpCacheEntry old) {
                assertEquals(existingValue, old);
View Full Code Here

    }

    @Test
    public void testCacheUpdateFail() throws IOException {
        final String url = "foo";
        final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry();
        final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
        CASValue<Object> v = new CASValue<Object>(1234, new byte[] {});

        HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
            public HttpCacheEntry update(HttpCacheEntry old) {
                assertEquals(existingValue, old);
View Full Code Here

    }

    @Test
    public void testCachePutThrowsIOExceptionOnTimeout() throws Exception {
        final String url = "foo";
        final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
        impl = new MemcachedHttpCacheStorage(mockMemcachedClient);
       
        EasyMock.expect(mockMemcachedClient.set(EasyMock.eq(url), EasyMock.anyInt(), EasyMock.anyObject()))
            .andThrow(new OperationTimeoutException(url));
       
View Full Code Here

        if (!cacheableRequestPolicy.isServableFromCache(request)) {
            return callBackend(target, request, context);
        }

        HttpCacheEntry entry = satisfyFromCache(target, request);
        if (entry == null) {
            return handleCacheMiss(target, request, context);
        }

        return handleCacheHit(target, request, context, 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.