@Test
  public void testUnsuccessfulSkip() throws Exception {
    InputStream inputStream = mock(InputStream.class);
    when(inputStream.skip(anyLong())).thenReturn(3L, 5L, 0L, 6L, 0L);
    when(inputStream.read()).thenReturn(3, -1);
    assertEquals(15, StreamUtil.skip(inputStream, 20));
    InOrder order = inOrder(inputStream);
    order.verify(inputStream).skip(20);
    order.verify(inputStream).skip(17);
    order.verify(inputStream).skip(12);
    order.verify(inputStream).read();
    order.verify(inputStream).skip(11);
    order.verify(inputStream).skip(5);
    order.verify(inputStream).read();
    verifyNoMoreInteractions(inputStream);
  }
Verify getting a byte array from a FileInputStream.
fbcore/src/test/java/com/facebook/common/util/StreamUtilTest.java