protected void implementEncodingTest(
      final String srcStr, final String encoding, final int bufferSize) throws Exception {
    FastByteArrayOutputStream bout = new FastByteArrayOutputStream(bufferSize);

    byte[] bytes = srcStr.getBytes(encoding);
    bout.write(bytes);

    JspWriter writer = new StringCapturingJspWriter();
    bout.writeTo(writer, encoding);

    String actualStr = writer.toString();
    String expectedStr = new String(bytes, encoding);
    assertTheyAreEqual(expectedStr, actualStr, encoding);
  }