# CacheAsserts

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/CacheAsserts.java+class:androidx.media3.test.utils.CacheAsserts)

*** ** * ** ***


```
@UnstableApi
public final class CacheAsserts
```

<br />

*** ** * ** ***

Assertion methods for `https://developer.android.com/reference/androidx/media3/datasource/cache/Cache`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/CacheAsserts.RequestSet` Defines a set of data requests. |

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/CacheAsserts#assertCacheEmpty(androidx.media3.datasource.cache.Cache)(https://developer.android.com/reference/androidx/media3/datasource/cache/Cache cache)` Asserts that the cache is empty. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/CacheAsserts#assertCachedData(androidx.media3.datasource.cache.Cache,androidx.media3.test.utils.FakeDataSet)(https://developer.android.com/reference/androidx/media3/datasource/cache/Cache cache, https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet fakeDataSet)` Asserts that the cache content is equal to the data in the `fakeDataSet`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/CacheAsserts#assertCachedData(androidx.media3.datasource.cache.Cache,androidx.media3.test.utils.CacheAsserts.RequestSet)(https://developer.android.com/reference/androidx/media3/datasource/cache/Cache cache, https://developer.android.com/reference/androidx/media3/test/utils/CacheAsserts.RequestSet requestSet)` Asserts that the cache contains necessary data for the `requestSet`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/CacheAsserts#assertDataCached(androidx.media3.datasource.cache.Cache,androidx.media3.datasource.DataSpec,byte[])(https://developer.android.com/reference/androidx/media3/datasource/cache/Cache cache, https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec, byte[] expected)` Asserts that the cache contains the given data for `dataSpec`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/CacheAsserts#assertReadData(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,byte[])( https://developer.android.com/reference/androidx/media3/datasource/DataSource dataSource, https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec, byte[] expected )` Asserts that the read data from `dataSource` specified by `dataSpec` is equal to `expected` or not. |

## Public methods

### assertCacheEmpty

```
public static void assertCacheEmpty(Cache cache)
```

Asserts that the cache is empty.

### assertCachedData

```
public static void assertCachedData(Cache cache, FakeDataSet fakeDataSet)
```

Asserts that the cache content is equal to the data in the `fakeDataSet`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the Cache. |

### assertCachedData

```
public static void assertCachedData(Cache cache, CacheAsserts.RequestSet requestSet)
```

Asserts that the cache contains necessary data for the `requestSet`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the Cache. |

### assertDataCached

```
public static void assertDataCached(Cache cache, DataSpec dataSpec, byte[] expected)
```

Asserts that the cache contains the given data for `dataSpec`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the Cache. |

### assertReadData

```
public static void assertReadData(
    DataSource dataSource,
    DataSpec dataSpec,
    byte[] expected
)
```

Asserts that the read data from `dataSource` specified by `dataSpec` is equal to `expected` or not.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the Cache. |