JSONArrayEventResultProcessor implements ComponentEventResultProcessor<JSONArray> { public void processResultValue(JSONArray value) throws IOException { PrintWriter pw = response.getPrintWriter(contentType.toString()); value.print(pw, compactJSON); pw.close(); } JSONArrayEventResultProcessor(Response response,

                                         @Symbol(SymbolConstants.CHARSET)
                                         String outputEncoding,

                                         @Symbol(SymbolConstants.COMPACT_JSON)
                                         boolean compactJSON); void processResultValue(JSONArray value);  }
@Test public void response_sent() throws IOException { String encoding = "UTF-8"; Response response = mockResponse(); CharArrayWriter writer = new CharArrayWriter(); PrintWriter pw = new PrintWriter(writer); expect(response.getPrintWriter("application/json;charset=UTF-8")).andReturn(pw); replay(); JSONArray array = new JSONArray(" [ \"fred\", \"barney\" \n\n]"); JSONArrayEventResultProcessor p = new JSONArrayEventResultProcessor(response, encoding, false); p.processResultValue(array); verify(); assertEquals(writer.toString(), "[\n \"fred\",\n \"barney\"\n]"); }