XLSXOutput implements ReportOutputHandler { public int generate( final MasterReport report, final int acceptedPage, final OutputStream outputStream, final int yieldRate ) throws ReportProcessingException, IOException { final FlowReportProcessor reportProcessor = createProcessor( report, yieldRate ); final IAsyncReportListener listener = ReportListenerThreadHolder.getListener(); if ( listener != null ) { reportProcessor.addReportProgressListener( listener ); } try { proxyOutputStream.setParent( outputStream ); if ( templateData != null ) { final FlowExcelOutputProcessor target = (FlowExcelOutputProcessor) reportProcessor.getOutputProcessor(); target.setTemplateInputStream( new ByteArrayInputStream( templateData ) ); } reportProcessor.processReport(); if ( listener != null ) { listener.setIsQueryLimitReached( reportProcessor.isQueryLimitReached() ); } outputStream.flush(); return 0; } finally { if ( listener != null ) { reportProcessor.removeReportProgressListener( listener ); } reportProcessor.close(); proxyOutputStream.setParent( null ); final FlowExcelOutputProcessor target = (FlowExcelOutputProcessor) reportProcessor.getOutputProcessor(); target.setTemplateInputStream( null ); } } XLSXOutput(); void setTemplateDataFromStream( final InputStream templateInputStream ); byte[] getTemplateData(); void setTemplateData( final byte[] templateData ); Object getReportLock(); int paginate( MasterReport report, int yieldRate ); int generate( final MasterReport report, final int acceptedPage, final OutputStream outputStream,
                       final int yieldRate ); boolean supportsPagination(); void close();  }
@Test public void testGenerateListener() throws Exception { ClassicEngineBoot.getInstance().start(); xlsxOutput.generate( new MasterReport(), 1, new ByteArrayOutputStream(), 1 ); verify( listener, times( 1 ) ).reportProcessingStarted( any( ReportProgressEvent.class ) ); verify( listener, times( 1 ) ).reportProcessingFinished( any( ReportProgressEvent.class ) ); verify( listener, atLeastOnce() ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); }
@Test public void testGenerate() throws Exception { ClassicEngineBoot.getInstance().start(); ReportListenerThreadHolder.clear(); xlsxOutput.generate( new MasterReport(), 1, new ByteArrayOutputStream(), 1 ); verify( listener, times( 0 ) ).reportProcessingStarted( any( ReportProgressEvent.class ) ); verify( listener, times( 0 ) ).reportProcessingFinished( any( ReportProgressEvent.class ) ); verify( listener, times( 0 ) ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); }