diff options
| author | Neil Fuller <nfuller@google.com> | 2015-01-09 11:43:42 +0000 |
|---|---|---|
| committer | Neil Fuller <nfuller@google.com> | 2015-01-12 16:05:26 +0000 |
| commit | b7260cbcc45e9dd4ca52a67b5574cc62059fac6b (patch) | |
| tree | 7d23b9228e2b8ee3d404806694c08bd45dc3508c /core/tests | |
| parent | 881f8d1ee3104aad34c14024b2b35aef0ac6f81b (diff) | |
| download | frameworks_base-b7260cbcc45e9dd4ca52a67b5574cc62059fac6b.zip frameworks_base-b7260cbcc45e9dd4ca52a67b5574cc62059fac6b.tar.gz frameworks_base-b7260cbcc45e9dd4ca52a67b5574cc62059fac6b.tar.bz2 | |
Fix HttpResponseCacheTest in anticipation of an OkHttp upgrade.
OkHttp recently changed the behavior of their caching with
commit e74e3f3bf744ef7f4d8ee724a7cf2347e486cfab - it is now
neccessary to close the inputstream (or disconnect the
HttpURLConnection) for a response to be cached.
This change is (effectively) a no-op prior to the upgrade.
The behavior is undefined as to whether closing the
input stream is required for caching. OkHttp's new behavior
is consistent with other HttpURLConnection implementations
tried.
(cherry-picked from commit 62d0677b0f6cc5ae48fd0b816ea5caad82264fd6)
Change-Id: Ibe698a443ec98866787ed9da2698322fab856518
Diffstat (limited to 'core/tests')
| -rw-r--r-- | core/tests/coretests/src/android/net/http/HttpResponseCacheTest.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/tests/coretests/src/android/net/http/HttpResponseCacheTest.java b/core/tests/coretests/src/android/net/http/HttpResponseCacheTest.java index 9015a6f..0421d44 100644 --- a/core/tests/coretests/src/android/net/http/HttpResponseCacheTest.java +++ b/core/tests/coretests/src/android/net/http/HttpResponseCacheTest.java @@ -19,6 +19,7 @@ package android.net.http; import com.google.mockwebserver.MockResponse; import com.google.mockwebserver.MockWebServer; import java.io.File; +import java.io.InputStream; import java.net.CacheRequest; import java.net.CacheResponse; import java.net.ResponseCache; @@ -118,7 +119,10 @@ public final class HttpResponseCacheTest extends TestCase { server.play(); URLConnection c1 = server.getUrl("/").openConnection(); - assertEquals('A', c1.getInputStream().read()); + InputStream inputStream1 = c1.getInputStream(); + assertEquals('A', inputStream1.read()); + inputStream1.close(); + assertEquals(1, cache.getRequestCount()); assertEquals(1, cache.getNetworkCount()); assertEquals(0, cache.getHitCount()); |
