@Test
public void testReadSetupHeadersWithIOExceptions() throws IOException, InterruptedException {

  // initial two pages of bytes which by spec contain the three Vorbis header packets:
  // identification, comment and setup header.
  byte[] data =
      TestUtil.getByteArray(
          ApplicationProvider.getApplicationContext(), "binary/ogg/vorbis_header_pages");
  ExtractorInput input = new FakeExtractorInput.Builder().setData(data).setSimulateIOErrors(true)
      .setSimulateUnknownLength(true).setSimulatePartialReads(true).build();
  VorbisReader reader = new VorbisReader();
  VorbisReader.VorbisSetup vorbisSetup = readSetupHeaders(reader, input);
  assertThat(vorbisSetup.idHeader).isNotNull();
  assertThat(vorbisSetup.commentHeader).isNotNull();
  assertThat(vorbisSetup.setupHeaderData).isNotNull();
  assertThat(vorbisSetup.modes).isNotNull();
  assertThat(vorbisSetup.commentHeader.length).isEqualTo(45);
  assertThat(vorbisSetup.idHeader.data).hasLength(30);
  assertThat(vorbisSetup.setupHeaderData).hasLength(3597);
  assertThat(vorbisSetup.idHeader.bitrateMax).isEqualTo(-1);
  assertThat(vorbisSetup.idHeader.bitrateMin).isEqualTo(-1);
  assertThat(vorbisSetup.idHeader.bitrateNominal).isEqualTo(66666);
  assertThat(vorbisSetup.idHeader.blockSize0).isEqualTo(512);
  assertThat(vorbisSetup.idHeader.blockSize1).isEqualTo(1024);
  assertThat(vorbisSetup.idHeader.channels).isEqualTo(2);
  assertThat(vorbisSetup.idHeader.framingFlag).isTrue();
  assertThat(vorbisSetup.idHeader.sampleRate).isEqualTo(22050);
  assertThat(vorbisSetup.idHeader.version).isEqualTo(0);
  assertThat(vorbisSetup.commentHeader.vendor).isEqualTo("Xiph.Org libVorbis I 20030909");
  assertThat(vorbisSetup.iLogModes).isEqualTo(1);
  assertThat(vorbisSetup.setupHeaderData[vorbisSetup.setupHeaderData.length - 1])
      .isEqualTo(data[data.length - 1]);
  assertThat(vorbisSetup.modes[0].blockFlag).isFalse();
  assertThat(vorbisSetup.modes[1].blockFlag).isTrue();
}