Introduction: Consider following simplified unit test:\[code\]@Testpublic void testClosingStreamFunc() throws Exception { boolean closeCalled = false; InputStream stream = new InputStream() { @Override public int read() throws IOException { return -1; } @Override public void close() throws IOException { closeCalled = true; super.close(); } }; MyClassUnderTest.closingStreamFunc(stream); assertTrue(closeCalled);}\[/code\]Obviously it does not work, complains about \[code\]closed\[/code\] not being \[code\]final\[/code\].Question: What is the best or most idiomatic way to verify that the function under test does call some method, like \[code\]close()\[/code\] here, in context of Java unit tests?