@Test
public void testSkipFully() throws IOException {

  byte inArray[] = new byte[] {0, 1, 2, 3, 4};
  ByteArrayInputStream in = new ByteArrayInputStream(inArray);
  try {
    in.mark(inArray.length);
    IOUtils.skipFully(in, 2);
    IOUtils.skipFully(in, 2);
    try {
      IOUtils.skipFully(in, 2);
      fail("expected to get a PrematureEOFException");
    } catch (EOFException e) {
      assertEquals("Premature EOF from inputStream " +
              "after skipping 1 byte(s).",e.getMessage());
    }
    in.reset();
    try {
      IOUtils.skipFully(in, 20);
      fail("expected to get a PrematureEOFException");
    } catch (EOFException e) {
      assertEquals("Premature EOF from inputStream " +
              "after skipping 5 byte(s).",e.getMessage());
    }
    in.reset();
    IOUtils.skipFully(in, 5);
    try {
      IOUtils.skipFully(in, 10);
      fail("expected to get a PrematureEOFException");
    } catch (EOFException e) {
      assertEquals("Premature EOF from inputStream " +
              "after skipping 0 byte(s).",e.getMessage());
    }
  } finally {
    in.close();
  }
}