PlainTextOutput implements ReportOutputHandler { public int generate( final MasterReport report, final int acceptedPage, final OutputStream outputStream, final int yieldRate ) throws ReportProcessingException, IOException, ContentIOException { final PageableReportProcessor proc = create( report, yieldRate ); proxyOutputStream.setParent( outputStream ); final IAsyncReportListener listener = ReportListenerThreadHolder.getListener(); if ( listener != null ) { proc.addReportProgressListener( listener ); } try { if ( proc.isPaginated() == false ) { proc.paginate(); } proc.processReport(); if ( listener != null ) { listener.setIsQueryLimitReached( proc.isQueryLimitReached() ); } return 0; } finally { if ( listener != null ) { proc.removeReportProgressListener( listener ); } proc.close(); proxyOutputStream.setParent( null ); } } PlainTextOutput(); 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(); plainTextOutput.generate( new MasterReport(), 1, new ByteArrayOutputStream(), 1 ); verify( listener, times( 2 ) ).reportProcessingStarted( any( ReportProgressEvent.class ) ); verify( listener, times( 2 ) ).reportProcessingFinished( any( ReportProgressEvent.class ) ); verify( listener, atLeastOnce() ).reportProcessingUpdate( any( ReportProgressEvent.class ) ); }
@Test public void testGenerate() throws Exception { ClassicEngineBoot.getInstance().start(); ReportListenerThreadHolder.clear(); plainTextOutput.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 ) ); }