@Test
public void testCacheUnknownLength() throws Exception {

  FakeDataSet fakeDataSet = new FakeDataSet().newData("test_data")
      .setSimulateUnknownLength(true)
      .appendReadData(TestUtil.buildTestData(100)).endData();
  FakeDataSource dataSource = new FakeDataSource(fakeDataSet);
  DataSpec dataSpec = new DataSpec(Uri.parse("test_data"));
  CachingCounters counters = new CachingCounters();
  CacheUtil.cache(
      dataSpec, cache, /* cacheKeyFactory= */ null, dataSource, counters, /* isCanceled= */ null);
  counters.assertValues(0, 100, 100);
  assertCachedData(cache, fakeDataSet);
}