@Test
public void closeTest() throws IOException {

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  MemStagingHandler handler = new MemStagingHandler( baos, session );
  OutputStream spy = Mockito.spy( handler.getStagingOutputStream() );
  // to be able to spy on inner object
  handler.memoryTrackingStream = (TrackingOutputStream) spy;
  handler.close();
  verify( spy, times(1) ).close();
}