@Test
public void checkBigWrite() throws IOException {

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
    // Resp which should be bigger than 8192, the buffer size of OutputStreamWriter
    JSONArray resp = new JSONArray();
    for (int i = 0; i < 10000; i++) {
        JSONObject data = new JSONObject();
        data.put("value", "hello");
        resp.add(data);
    }
    String respString = resp.toJSONString();
    IoUtil.streamResponseAndClose(writer,resp,null);
    assertEquals(out.size(), respString.length());
    assertEquals(out.toString("UTF-8"), respString);
    assertWriterClosed(writer);
}