### Question:
IOUtils extends org.apache.commons.io.IOUtils { public static int read(InputStream in, byte[] buf) throws IOException { int num; int off = 0; while (off < buf.length && (num = in.read(buf, off, buf.length-off)) != -1) { off += num; } return off == 0 ? -1 : off; } protected  IOUtils(); static int copy(InputStream in, OutputStream out, byte[] buffer); static long copyLarge(InputStream in, OutputStream out, byte[] buffer); static void copy(InputStream in, OutputStream out,
                          byte[] buffer, long length); static void closeQuietly(Closeable c); static int read(InputStream in, byte[] buf);  }### Answer:
@Test public void testReadNone() throws IOException { final InputStream in = new ByteArrayInputStream(new byte[0]); final byte[] buf = new byte[1]; final int count = IOUtils.read(in, buf); assertEquals(-1, count); assertArrayEquals(new byte[1], buf); }
@Test public void testReadClosed() throws IOException { final InputStream in = new ClosedInputStream(); final byte[] buf = new byte[1]; final int count = IOUtils.read(in, buf); assertEquals(-1, count); assertArrayEquals(new byte[1], buf); }
@Test public void testReadFull() throws IOException { final byte[] expected = new byte[100]; Arrays.fill(expected, (byte) 1); final InputStream in = new ByteArrayInputStream(expected); final byte[] actual = new byte[100]; final int count = IOUtils.read(in, actual); assertEquals(expected.length, count); assertArrayEquals(expected, actual); }
@Test public void testReadShort() throws IOException { final byte[] expected = new byte[50]; Arrays.fill(expected, (byte) 1); final InputStream in = new ByteArrayInputStream(expected); final byte[] actual = new byte[100]; final int count = IOUtils.read(in, actual); assertEquals(50, count); assertArrayEquals(expected, Arrays.copyOfRange(actual, 0, count)); assertArrayEquals(new byte[50], Arrays.copyOfRange(actual, count, 100)); }