### Question:
FileOutputConsumer implements OutputConsumer { public void close() { if ( writer != null ) writer.close(); } FileOutputConsumer( File outputFile ); void consume( String line ); void close();  }### Answer:
@Test public void noOutputCreatesEmptyFile() throws IOException { consumer.close(); assertFileEmpty(); }
@Test public void fileExistsAfterClose() throws IOException { String[] lines = { "first", "second", "third" }; writeContent( lines ); consumer.close(); assertFileExists(); assertFileContents( lines ); }
@Test public void newConsumerTruncatesFile() throws IOException { String[] content1 = { "should be overwritten" }; writeContent( content1 ); consumer.close(); assertFileExists(); assertFileContents( content1 ); consumer = new FileOutputConsumer( outputFile ); assertFileExists(); assertFileEmpty(); }