### Question:
DefaultExtractorInput implements ExtractorInput { @Override public boolean peekFully(byte[] target, int offset, int length, boolean allowEndOfInput) throws IOException, InterruptedException { if (!advancePeekPosition(length, allowEndOfInput)) { return false; } System.arraycopy(peekBuffer, peekBufferPosition - length, target, offset, length); return true; } DefaultExtractorInput(DataSource dataSource, long position, long length); @Override int read(byte[] target, int offset, int length); @Override boolean readFully(byte[] target, int offset, int length, boolean allowEndOfInput); @Override void readFully(byte[] target, int offset, int length); @Override int skip(int length); @Override boolean skipFully(int length, boolean allowEndOfInput); @Override void skipFully(int length); @Override boolean peekFully(byte[] target, int offset, int length, boolean allowEndOfInput); @Override void peekFully(byte[] target, int offset, int length); @Override boolean advancePeekPosition(int length, boolean allowEndOfInput); @Override void advancePeekPosition(int length); @Override void resetPeekPosition(); @Override long getPeekPosition(); @Override long getPosition(); @Override long getLength(); @Override void setRetryPosition(long position, E e);  }### Answer:
@Test public void testPeekFully() throws Exception { DefaultExtractorInput input = createDefaultExtractorInput(); byte[] target = new byte[TEST_DATA.length]; input.peekFully(target, 0, TEST_DATA.length); assertThat(Arrays.equals(TEST_DATA, target)).isTrue(); assertThat(input.getPosition()).isEqualTo(0); assertThat(input.getPeekPosition()).isEqualTo(TEST_DATA.length); byte[] target2 = new byte[TEST_DATA.length]; input.readFully(target2, 0, TEST_DATA.length); assertThat(Arrays.equals(TEST_DATA, target2)).isTrue(); assertThat(input.getPosition()).isEqualTo(TEST_DATA.length); assertThat(input.getPeekPosition()).isEqualTo(TEST_DATA.length); try { input.peekFully(target, 0, 1); fail(); } catch (EOFException e) { } }
@Test public void testPeekFullyAtEndOfStreamWithAllowEndOfInputSucceeds() throws Exception { DefaultExtractorInput input = createDefaultExtractorInput(); byte[] target = new byte[TEST_DATA.length]; assertThat(input.peekFully(target, 0, TEST_DATA.length, true)).isTrue(); assertThat(input.peekFully(target, 0, 1, true)).isFalse(); }
@Test public void testPeekFullyAcrossEndOfInputWithAllowEndOfInputFails() throws Exception { DefaultExtractorInput input = createDefaultExtractorInput(); byte[] target = new byte[TEST_DATA.length]; assertThat(input.peekFully(target, 0, TEST_DATA.length - 1, true)).isTrue(); try { input.peekFully(target, 0, 2, true); fail(); } catch (EOFException e) { } }