Commit 4419a26b by tonihei Committed by Oliver Woodman

Use assertThrows in CacheWriterTest.

PiperOrigin-RevId: 313556143
parent a01fd007
...@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.upstream.cache; ...@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.upstream.cache;
import static com.google.android.exoplayer2.testutil.CacheAsserts.assertCachedData; import static com.google.android.exoplayer2.testutil.CacheAsserts.assertCachedData;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.assertThrows;
import android.net.Uri; import android.net.Uri;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
...@@ -254,20 +254,19 @@ public final class CacheWriterTest { ...@@ -254,20 +254,19 @@ public final class CacheWriterTest {
Uri testUri = Uri.parse("test_data"); Uri testUri = Uri.parse("test_data");
DataSpec dataSpec = new DataSpec(testUri, /* position= */ 0, /* length= */ 1000); DataSpec dataSpec = new DataSpec(testUri, /* position= */ 0, /* length= */ 1000);
try { IOException exception =
CacheWriter cacheWriter = assertThrows(
new CacheWriter( IOException.class,
new CacheDataSource(cache, dataSource), () ->
dataSpec, new CacheWriter(
/* allowShortContent= */ false, new CacheDataSource(cache, dataSource),
/* isCanceled= */ null, dataSpec,
/* temporaryBuffer= */ null, /* allowShortContent= */ false,
/* progressListener= */ null); /* isCanceled= */ null,
cacheWriter.cache(); /* temporaryBuffer= */ null,
fail(); /* progressListener= */ null)
} catch (IOException e) { .cache());
assertThat(DataSourceException.isCausedByPositionOutOfRange(e)).isTrue(); assertThat(DataSourceException.isCausedByPositionOutOfRange(exception)).isTrue();
}
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment