### Question:
VorbisReader extends StreamReader { @VisibleForTesting VorbisSetup readSetupHeaders(ParsableByteArray scratch) throws IOException { if (vorbisIdHeader == null) { vorbisIdHeader = VorbisUtil.readVorbisIdentificationHeader(scratch); return null; } if (commentHeader == null) { commentHeader = VorbisUtil.readVorbisCommentHeader(scratch); return null; } byte[] setupHeaderData = new byte[scratch.limit()]; System.arraycopy(scratch.data, 0, setupHeaderData, 0, scratch.limit()); Mode[] modes = VorbisUtil.readVorbisModes(scratch, vorbisIdHeader.channels); int iLogModes = VorbisUtil.iLog(modes.length - 1); return new VorbisSetup(vorbisIdHeader, commentHeader, setupHeaderData, modes, iLogModes); }  static boolean verifyBitstreamType(ParsableByteArray data);  }### Answer:
@Test public void testReadSetupHeadersWithIOExceptions() throws IOException, InterruptedException { byte[] data = OggTestData.getVorbisHeaderPages(); 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(); }