@Test
public void testRedirectReaderWriter() throws IOException {

  final Object[][] testParameters = new Object[][] {
      {new ByteArrayInputStream(new byte[] {1, 2, 3}), new ByteArrayOutputStream(), 3},
      {new ByteArrayInputStream(new byte[] {4, 5, 6, 7, 8}), new ByteArrayOutputStream(), 5},
      {new ByteArrayInputStream(new byte[] {9, 10, 11, 12, 13, 14, 15}),
          new ByteArrayOutputStream(), 7}};
  for (final Object[] testParameter : testParameters) {
    int expected = (Integer) testParameter[2];
    InputStream inputStream = (InputStream) testParameter[0];
    OutputStream outputStream = (OutputStream) testParameter[1];
    Reader from = new BufferedReader(new InputStreamReader(inputStream));
    Writer to = new BufferedWriter(new OutputStreamWriter(outputStream));
    assertEquals(expected, IoUtils.redirect(from, to));
  }
}