UnsyncBufferedWriter extends Writer { public void newLine() throws IOException { write(_LINE_SEPARATOR); } UnsyncBufferedWriter(Writer writer);  UnsyncBufferedWriter(Writer writer, int size); @Override void close(); @Override void flush(); void newLine(); @Override void write(char[] chars, int offset, int length); @Override void write(int c); @Override void write(String string, int offset, int length);  }
@Test public void testNewLine() throws Exception { StringWriter stringWriter = new StringWriter(); UnsyncBufferedWriter unsyncBufferedWriter = new UnsyncBufferedWriter( stringWriter, 10); unsyncBufferedWriter.newLine(); String lineSeparator = System.getProperty("line.separator"); Assert.assertEquals( lineSeparator.length(), _countField.getInt(unsyncBufferedWriter)); unsyncBufferedWriter.write('a'); Assert.assertEquals( lineSeparator.length() + 1, _countField.getInt(unsyncBufferedWriter)); unsyncBufferedWriter.newLine(); Assert.assertEquals( (lineSeparator.length() * 2) + 1, _countField.getInt(unsyncBufferedWriter)); unsyncBufferedWriter.flush(); Assert.assertEquals( lineSeparator + "a" + lineSeparator, stringWriter.toString()); }