private String prettyPrintContent(InputStream in, AsyncPrettyPrinter asyncPrettyPrinter) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter(out); asyncPrettyPrinter.printTo(writer, in); writer.flush(); return out.toString("UTF-8"); } }
@Test public void testAsyncPrettyPrinterResult() throws IOException { StringWriter out = new StringWriter(); PrintWriter writer = new PrintWriter(out); AsyncPrettyPrinter mAsyncPrettyPrinter = mPrettyPrinterTestFactory.getInstance( TEST_HEADER_NAME, TEST_HEADER_VALUE); mAsyncPrettyPrinter.printTo(writer, mInputStream); assertEquals(PRETTY_PRINT_PREFIX + Arrays.toString(TEST_RESPONSE_BODY), out.toString()); }