XmlPageableOutput implements ReportOutputHandler { public int generate( final MasterReport report, final int acceptedPage, final OutputStream outputStream, final int yieldRate ) throws ReportProcessingException, IOException { if ( proc == null ) { proc = createProcessor( report, yieldRate ); } final IAsyncReportListener listener = ReportListenerThreadHolder.getListener(); if ( listener != null ) { proc.addReportProgressListener( listener ); } try { if ( acceptedPage >= 0 ) { final XmlPageOutputProcessor outputProcessor = (XmlPageOutputProcessor) proc.getOutputProcessor(); outputProcessor.setFlowSelector( new SinglePageFlowSelector( acceptedPage, false ) ); } proxyOutputStream.setParent( outputStream ); proc.processReport(); if ( listener != null ) { listener.setIsQueryLimitReached( proc.isQueryLimitReached() ); } return proc.getPhysicalPageCount(); } finally { if ( listener != null ) { proc.removeReportProgressListener( listener ); } if ( acceptedPage >= 0 ) { final XmlPageOutputProcessor outputProcessor = (XmlPageOutputProcessor) proc.getOutputProcessor(); outputProcessor.setFlowSelector( new AllPageFlowSelector() ); } if ( proxyOutputStream != null ) { proxyOutputStream.setParent( null ); } } } XmlPageableOutput(); Object getReportLock(); int paginate( final MasterReport report, final 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(); xmlPageableOutput.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(); xmlPageableOutput.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 ) ); }