### Question:
LineEncoder implements AutoCloseable { public void addLine(String line) { try { writer.append(line); } catch (IOException ex) { throw new RuntimeException(ex); } addNewLine(); } LineEncoder(FileOutput out, EncoderTask task); void addNewLine(); void addLine(String line); void addText(String text); void nextFile(); void finish(); @Override void close();  }### Answer:
@Test public void testAddLine() throws Exception { try (MockFileOutput output = new MockFileOutput()) { LineEncoder encoder = newEncoder("utf-8", "LF", output); encoder.nextFile(); for (String line : new String[] { "abc", "日本語(Japanese)" }) { encoder.addLine(line); } encoder.finish(); } }