ConcurrentFileLineConsumer implements LineConsumer { public boolean isOpen() { return isOpen; } ConcurrentFileLineConsumer(File file); File getFile(); boolean isOpen(); @Override void writeLine(String line); @Override void close();  }
@Test public void closeOperationShouldWaitUntilAllCurrentWriteOperationsWillBeFinished() throws Exception { final String message1 = "Message 1"; final String message2 = "Message 2"; WaitingAnswer<Void> waitingAnswer1 = waitOnWrite(message1); WaitingAnswer<Void> waitingAnswer2 = waitOnWrite(message2); executor.execute(this::closeConsumer); waitingAnswer1.completeAnswer(); waitingAnswer2.completeAnswer(); awaitFinalization(); assertFalse(concurrentFileLineConsumer.isOpen()); verify(writer).write(eq(message1)); verify(writer).write(eq(message2)); }