MemStagingHandler extends AbstractStagingHandler { @Override public void close() { if ( memoryTrackingStream != null ) { try { memoryTrackingStream.close(); } catch ( final IOException e ) { logger.debug( "Unable to close memory stream? (never happens)" ); } } } MemStagingHandler( final OutputStream outputStream, final IPentahoSession userSession ); @Override void complete(); @Override void close(); @Override int getWrittenByteCount(); @Override boolean canSendHeaders(); @Override OutputStream getStagingOutputStream(); @Override boolean isFullyBuffered(); @Override StagingMode getStagingMode();  }
@Test public void closeTest() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MemStagingHandler handler = new MemStagingHandler( baos, session ); OutputStream spy = Mockito.spy( handler.getStagingOutputStream() ); handler.memoryTrackingStream = (TrackingOutputStream) spy; handler.close(); verify( spy, times(1) ).close(); }