public void createReport() throws Exception { report = new MasterReport();
public MasterReport createReport() { final MasterReport report = new MasterReport(); report.setRootGroup( create() ); return report; }
public void testSerializeEmptyReport() throws Exception { final MasterReport report = new MasterReport(); final ByteArrayOutputStream bo = new ByteArrayOutputStream(); final ObjectOutputStream out = new ObjectOutputStream( bo ); out.writeObject( report ); final ObjectInputStream oin = new ObjectInputStream( new ByteArrayInputStream( bo.toByteArray() ) ); final MasterReport e2 = (MasterReport) oin.readObject(); assertNotNull( e2 ); // cannot assert equals, as this is not implemented. // will crash if the serialization fails .. e2.getStyle().toArray(); }
@Test public void addReportProgressListener() throws Exception { final AbstractReportProcessor reportProcessor = new DummyReportProcessor( new MasterReport() ); boolean thrown1 = false; try { reportProcessor.addReportProgressListener( null ); } catch ( final NullPointerException e ) { thrown1 = true; } assertEquals( true, thrown1 ); }
@Test public void testConstructionAndClose() throws ReportProcessingException { final AbstractReportProcessor reportProcessor = new DummyReportProcessor( new MasterReport() ); assertEquals( reportProcessor, ReportProcessorThreadHolder.getProcessor() ); reportProcessor.close(); assertNull( ReportProcessorThreadHolder.getProcessor() ); }
@Test public void testUnconfiguredDoesNotCrash() throws ReportProcessingException { BSFReportPreProcessor p = new BSFReportPreProcessor(); MasterReport preData = materializePreData( new MasterReport(), p ); MasterReport postData = materialize( new MasterReport(), p ); Assert.assertNull( preData.getAttribute( "test", "test" ) ); Assert.assertNull( postData.getAttribute( "test", "test" ) ); }
@Test public void testReportIsConfigured() throws ReportProcessingException { ReportPreProcessor p = create(); MasterReport preData = materializePreData( new MasterReport(), p ); MasterReport postData = materialize( new MasterReport(), p ); Assert.assertEquals( "pre-data-script", preData.getAttribute( "test", "test" ) ); Assert.assertEquals( "script", postData.getAttribute( "test", "test" ) ); } }
protected static MasterReport createDummyReport( final Band band ) { ReportDefinition masterReport = band.getMasterReport(); MasterReport dummy = new MasterReport(); dummy.copyAttributes( masterReport.getAttributes() ); dummy.setPageDefinition( masterReport.getPageDefinition() ); SimpleStyleResolver simpleStyleResolver = new SimpleStyleResolver( true ); ResolverStyleSheet resolveStyleSheet = new ResolverStyleSheet(); simpleStyleResolver.resolve( dummy, resolveStyleSheet ); dummy.setComputedStyle( new SimpleStyleSheet( resolveStyleSheet ) ); return dummy; } }
public void testRegistrationComplete() { final ReportProcessTaskRegistry registry = ReportProcessTaskRegistry.getInstance(); assertTrue( registry.getExportTypes().length > 0 ); assertTrue( registry.isExportTypeRegistered( "pageable/X-AWT-Graphics" ) ); final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final ReportProcessTask processTask = registry.createProcessTask( "pageable/X-AWT-Graphics" ); ReportProcessTaskUtil.configureBodyStream( processTask, byteArrayOutputStream, "image", null ); processTask.setReport( new MasterReport() ); processTask.run(); assertTrue( String.valueOf( processTask.getError() ), processTask.isTaskSuccessful() ); assertTrue( byteArrayOutputStream.toByteArray().length > 0 ); } }
public void testDerive() throws CloneNotSupportedException { final MasterReport report = new MasterReport(); report.setQueryLimit( 10 ); report.setQueryTimeout( 10 ); final MasterReport element = (MasterReport) report.derive(); assertEquals( 10, element.getQueryLimit() ); assertEquals( 10, element.getQueryTimeout() ); }
@Test public void testIsQueryLimitNotReachedForUnsetQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitNotReachedForNumberOfRowsEqualQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 500 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitNotReachedForUnlimitedQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( -1 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitNotReachedForZeroQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 500, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 0 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testIsQueryLimitNotReachedForNumberOfRowsLessQueryLimit() throws Exception { final MasterReport report = new MasterReport(); final DefaultTableModel model = new DefaultTableModel( 499, 10 ); report.setDataFactory( new TableDataFactory( "default", model ) ); report.setQueryLimit( 500 ); final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report ); reportProcessor.prepareReportProcessing(); assertEquals( reportProcessor.isQueryLimitReached(), false ); }
@Test public void testShallowInlineSubReportDetection() { SubReport srInner = new SubReport(); SubReport sr = new SubReport(); sr.getReportHeader().addElement( srInner ); MasterReport report = new MasterReport(); report.getReportHeader().addElement( sr ); ReportStructureValidator v = new ReportStructureValidator(); Assert.assertFalse( v.isValidForFastProcessing( report ) ); }
public void testDataFactoryInspection() { CompoundDataFactory cdf = new CompoundDataFactory(); cdf.add( new TableDataFactory( "query1", new DefaultTableModel() ) ); cdf.add( new TableDataFactory( "query2", new DefaultTableModel() ) ); MasterReport report = new MasterReport(); report.setDataFactory( cdf ); final int[] callCount = new int[1]; final TestStructureVisitor v = new TestStructureVisitor( callCount ); v.inspect( report ); assertEquals( 2, callCount[0] ); } }
public void testAddToReport() { MasterReport report = new MasterReport(); report.getItemBand().setName( "ItemBand!" ); report.addGroup( new RelationalGroup() ); report.addGroup( createGroup( "second", new String[] { "field" } ) ); report.addGroup( createGroup( "third", new String[] { "field", "field2" } ) ); assertEquals( 4, report.getGroupCount() ); assertEquals( "ItemBand!", report.getItemBand().getName() ); } }
public void testRunWithInvalidQuery() throws ReportDataFactoryException { final CompoundDataFactory cdf = new CompoundDataFactory(); cdf.add( new TableDataFactory( "query", new DefaultTableModel() ) ); cdf.add( new TableDataFactory( "query", new DefaultTableModel() ) ); final DataFactory tableDataFactory1 = cdf.getReference( 0 ); final DataFactory tableDataFactory2 = cdf.getReference( 1 ); final MasterReport report = new MasterReport(); report.setDataFactory( cdf ); report.setQuery( "default" ); assertFalse( DesignTimeUtil.isSelectedDataSource( report, tableDataFactory2, "query" ) ); assertFalse( DesignTimeUtil.isSelectedDataSource( report, tableDataFactory1, "query" ) ); }
public void testRunWithValidQuery() throws ReportDataFactoryException { final CompoundDataFactory cdf = new CompoundDataFactory(); cdf.add( new TableDataFactory( "query", new DefaultTableModel() ) ); cdf.add( new TableDataFactory( "query", new DefaultTableModel() ) ); final DataFactory tableDataFactory1 = cdf.getReference( 0 ); final DataFactory tableDataFactory2 = cdf.getReference( 1 ); final MasterReport report = new MasterReport(); report.setDataFactory( cdf ); report.setQuery( "query" ); assertFalse( DesignTimeUtil.isSelectedDataSource( report, tableDataFactory2, "query" ) ); assertTrue( DesignTimeUtil.isSelectedDataSource( report, tableDataFactory1, "query" ) ); } }