@Test public void test() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); concatenatedReport.toCsv(bos); Assert.assertEquals( "concatenated report ", "text1\n1\ntext2\n1\ntext3\n1\n", new String(bos.toByteArray())); concatenatedReport.continuousPageNumbering(); bos = new ByteArrayOutputStream(); concatenatedReport.toCsv(bos); Assert.assertEquals( "concatenated report ", "text1\n1\ntext2\n2\ntext3\n3\n", new String(bos.toByteArray())); concatenatedReport.setContinuousPageNumbering(false); bos = new ByteArrayOutputStream(); concatenatedReport.toCsv(bos); Assert.assertEquals( "concatenated report ", "text1\n1\ntext2\n1\ntext3\n1\n", new String(bos.toByteArray())); } catch (DRException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
@Before public void init() { JasperReportBuilder report1 = report() .columns(col.column("field1", String.class)) .pageFooter(cmp.pageNumber()) .setDataSource(createDataSource("text1")); JasperReportBuilder report2 = report() .columns(col.column("field1", String.class)) .pageFooter(cmp.pageNumber()) .setDataSource(createDataSource("text2")); JasperReportBuilder report3 = report() .columns(col.column("field1", String.class)) .pageFooter(cmp.pageNumber()) .setDataSource(createDataSource("text3")); concatenatedReport = concatenatedReport(); concatenatedReport.concatenate(report1, report2, report3); }