@Test
public void testRemove() throws Exception {

  FakeDataSet fakeDataSet = new FakeDataSet().setRandomData("test_data", 100);
  FakeDataSource dataSource = new FakeDataSource(fakeDataSet);
  Uri uri = Uri.parse("test_data");
  DataSpec dataSpec = new DataSpec(uri, DataSpec.FLAG_ALLOW_CACHE_FRAGMENTATION);
  CacheUtil.cache(
      dataSpec,
      cache,
      /* cacheKeyFactory= */ null,
      // Set fragmentSize to 10 to make sure there are multiple spans.
      new CacheDataSource(
          cache,
          dataSource,
          new FileDataSource(),
          new CacheDataSink(cache, /* fragmentSize= */ 10),
          /* flags= */ 0,
          /* eventListener= */ null),
      new byte[CacheUtil.DEFAULT_BUFFER_SIZE_BYTES],
      /* priorityTaskManager= */ null,
      /* priority= */ 0,
      /* progressListener= */ null,
      /* isCanceled= */ null,
      true);
  CacheUtil.remove(dataSpec, cache, /* cacheKeyFactory= */ null);
  assertCacheEmpty(cache);
}