ChunkedPrintWriter extends ServletPrintWriter { @Override public void println() { synchronized (lock) { print(NEW_LINE); } } ChunkedPrintWriter(final OutputStream out); @Override void println(); @Override void write(final String str); @Override void writeEnd();  }
@Test public void shouldAppendNewLineProperly() { ByteArrayOutputStream out = new ByteArrayOutputStream(ONE_KILO); ChunkedPrintWriter printWriter = new ChunkedPrintWriter(out); printWriter.print("Wiki"); printWriter.println(); printWriter.flush(); assertThat(new String(out.toByteArray()), is("4\r\nWiki\r\n2\r\n\r\n\r\n")); }