FileLineConsumer implements LineConsumer { @Override public void writeLine(String line) throws IOException { if (isOpen) { try { if (line != null) { writer.write(line); } writer.write('\n'); writer.flush(); } catch (IOException e) { if ("Stream closed".equals(e.getMessage())) { throw new ConsumerAlreadyClosedException(e.getMessage()); } throw e; } } } FileLineConsumer(File file); File getFile(); @Override void writeLine(String line); @Override void close();  }
@Test public void shouldBeAbleToWriteIntoFile() throws Exception { final String message = "Test line"; fileLineConsumer.writeLine(message); verify(writer).write(eq(message)); }