@Test
public void testCacheThrowEOFException() throws Exception {

  FakeDataSet fakeDataSet = new FakeDataSet().setRandomData("test_data", 100);
  FakeDataSource dataSource = new FakeDataSource(fakeDataSet);
  Uri testUri = Uri.parse("test_data");
  DataSpec dataSpec = new DataSpec(testUri, 0, 1000, null);
  try {
    CacheUtil.cache(
        dataSpec,
        cache,
        /* cacheKeyFactory= */ null,
        new CacheDataSource(cache, dataSource),
        new byte[CacheUtil.DEFAULT_BUFFER_SIZE_BYTES],
        /* priorityTaskManager= */ null,
        /* priority= */ 0,
        /* progressListener= */ null,
        /* isCanceled= */ null,
        /* enableEOFException= */ true);
    fail();
  } catch (EOFException e) {
    // Do nothing.
  }
}