aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/android/volley/CacheDispatcherTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/android/volley/CacheDispatcherTest.java')
-rw-r--r--src/test/java/com/android/volley/CacheDispatcherTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/java/com/android/volley/CacheDispatcherTest.java b/src/test/java/com/android/volley/CacheDispatcherTest.java
index 2592a0b..aef6785 100644
--- a/src/test/java/com/android/volley/CacheDispatcherTest.java
+++ b/src/test/java/com/android/volley/CacheDispatcherTest.java
@@ -140,6 +140,25 @@ public class CacheDispatcherTest {
assertSame(entry, mRequest.getCacheEntry());
}
+ // An fresh cache hit with parse error, does not post a response and queues to the network.
+ @Test
+ public void freshCacheHit_parseError() throws Exception {
+ Request request = mock(Request.class);
+ when(request.parseNetworkResponse(any(NetworkResponse.class)))
+ .thenReturn(Response.error(new ParseError()));
+ when(request.getCacheKey()).thenReturn("cache/key");
+ Cache.Entry entry = CacheTestUtils.makeRandomCacheEntry(null, false, false);
+ when(mCache.get(anyString())).thenReturn(entry);
+
+ mDispatcher.processRequest(request);
+
+ verifyNoResponse(mDelivery);
+ verify(mNetworkQueue).put(request);
+ assertNull(request.getCacheEntry());
+ verify(mCache).invalidate("cache/key", true);
+ verify(request).addMarker("cache-parsing-failed");
+ }
+
@Test
public void duplicateCacheMiss() throws Exception {
StringRequest secondRequest =