Search in sources :

Example 21 with ResponseCache

use of java.net.ResponseCache in project enroscar by stanfy.

the class ResponseCacheSwitcher method saveUrlConnection.

public static void saveUrlConnection(final URLConnection connection) {
    final ResponseCache cache = ResponseCache.getDefault();
    if (!(cache instanceof ResponseCacheSwitcher)) {
        return;
    }
    final ResponseCacheSwitcher hub = (ResponseCacheSwitcher) cache;
    LinkedList<URLConnection> stack = hub.currentUrlConnection.get();
    if (stack == null) {
        stack = new LinkedList<URLConnection>();
        hub.currentUrlConnection.set(stack);
    }
    stack.addFirst(connection);
}
Also used : ResponseCache(java.net.ResponseCache) URLConnection(java.net.URLConnection)

Example 22 with ResponseCache

use of java.net.ResponseCache in project enroscar by stanfy.

the class ImagesManagerAndroidTest method testSetup.

public void testSetup() {
    ResponseCache cache = imagesManager.getImagesResponseCache();
    assertThat(cache).isInstanceOf(ImageFileCache.class);
    ImageFileCache imageFileCache = (ImageFileCache) cache;
    assertThat(imageFileCache.getWorkingDirectory()).isNotNull();
    assertThat(imageFileCache.getWorkingDirectory()).exists();
    assertThat(imageFileCache.getWorkingDirectory()).isDirectory();
    assertThat(imageFileCache.getMaxSize()).isGreaterThan(0);
}
Also used : ImageFileCache(com.stanfy.enroscar.images.cache.ImageFileCache) ResponseCache(java.net.ResponseCache)

Aggregations

ResponseCache (java.net.ResponseCache)22 URI (java.net.URI)11 URLConnection (java.net.URLConnection)11 IOException (java.io.IOException)9 HttpURLConnection (java.net.HttpURLConnection)7 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)7 CacheRequest (java.net.CacheRequest)6 CacheResponse (java.net.CacheResponse)6 List (java.util.List)6 Test (org.junit.Test)6 AndroidShimResponseCache (com.android.okhttp.AndroidShimResponseCache)5 URL (java.net.URL)5 AbstractResponseCache (okhttp3.AbstractResponseCache)5 OkUrlFactory (okhttp3.OkUrlFactory)5 MockResponse (okhttp3.mockwebserver.MockResponse)5 ArrayList (java.util.ArrayList)4 HttpResponseCache (com.android.okhttp.HttpResponseCache)2 MockResponse (com.google.mockwebserver.MockResponse)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2