use of android.net.http.HttpResponseCache in project robolectric by robolectric.
the class ShadowHttpResponseCache method install.
@Implementation
public static HttpResponseCache install(File directory, long maxSize) {
HttpResponseCache cache = newInstanceOf(HttpResponseCache.class);
ShadowHttpResponseCache shadowCache = Shadows.shadowOf(cache);
shadowCache.originalObject = cache;
shadowCache.directory = directory;
shadowCache.maxSize = maxSize;
synchronized (LOCK) {
installed = shadowCache;
return cache;
}
}
use of android.net.http.HttpResponseCache in project robolectric by robolectric.
the class ShadowHttpResponseCacheTest method installedCacheIsReturned.
@Test
public void installedCacheIsReturned() throws Exception {
assertThat(HttpResponseCache.getInstalled()).isNull();
HttpResponseCache cache = HttpResponseCache.install(File.createTempFile("foo", "bar"), 42);
HttpResponseCache installed = HttpResponseCache.getInstalled();
assertThat(installed).isSameAs(cache);
assertThat(installed.maxSize()).isEqualTo(42);
}
use of android.net.http.HttpResponseCache in project robolectric by robolectric.
the class ShadowHttpResponseCacheTest method closeRemovesReference.
@Test
public void closeRemovesReference() throws Exception {
HttpResponseCache cache = HttpResponseCache.install(File.createTempFile("foo", "bar"), 42);
cache.close();
assertThat(HttpResponseCache.getInstalled()).isNull();
}
use of android.net.http.HttpResponseCache in project robolectric by robolectric.
the class ShadowHttpResponseCacheTest method countsStartAtZero.
@Test
public void countsStartAtZero() throws Exception {
HttpResponseCache cache = HttpResponseCache.install(File.createTempFile("foo", "bar"), 42);
assertThat(cache.getHitCount()).isZero();
assertThat(cache.getNetworkCount()).isZero();
assertThat(cache.getRequestCount()).isZero();
}
use of android.net.http.HttpResponseCache in project robolectric by robolectric.
the class ShadowHttpResponseCacheTest method deleteRemovesReference.
@Test
public void deleteRemovesReference() throws Exception {
HttpResponseCache cache = HttpResponseCache.install(File.createTempFile("foo", "bar"), 42);
cache.delete();
assertThat(HttpResponseCache.getInstalled()).isNull();
}
Aggregations