java - Analyse JasperReports export output -


again - jasperreports...

so, we've got reports charts , tables similar this:

jan | feb | mar | ... | dec | sum ----+-----+-----+-----+-----+----  5  |  1  |  9  | 120 | 20  | 155 (numbers represent amounts of vehicles) 

beneath these tables there multiple tables consist of data above table in deeper detail (in drill down manner).

we export these reports pdf , serve them in web application downloadable documents. needed data calculated in specialized java factories. per report there 1 factory serves list dumb data objects. these objects contain aggregated numbers displayed in charts , tables.

additionally numbers hyperlinks. forward servlet offers xls export contains detailed data each vehicle. of course, each hyperlink has bunch of parameters servlet.

what want have:

a full automated test following:

  • check data integrity of each table (is number in sum column sum of each column before)
  • check data integrity of detailed tables in respect superior table (sum of jan columns = number in jan column of superior table)
  • get hyperlink of each number , feed xls export check if number of vehicles in xls equal displayed number in table

so test should work similar this:

test -> generate pdf report -> check table integrity -> parse links -> check xls -> asserteverythinglooksfine() 

what have tried:

currently pdf report written bytearrayoutputstream forward data pdfreader parses simpletextextractionstrategy. way it's possible check table integrity although it's quite cumbersome. additionally not possible hyperlinks. idea exporting report html instead of pdf hyperlinks. checking table integrity more cumbersome because jasperreports doesn't generate html tables bunch of divs.

additional notes:

  • yes, table integrity checked on basis of factory's output - idea came me while writing question. important point test xls export , parameters export generated in jasperreports
    • yes, generating export parameters done in factory don't think belongs there (tier architecture , on)
  • i know, analyzing binary-format output in unit-test bad idea, jasperreports quite black box , lot of work in jrxml-stuff
  • i thought of sort of formatter/customizer accesses elements while generating
  • i have read http://whathaveyoutried.com , tried best ;)

my questions:

  • what think of approach? reasonable?
  • is there point have missed done better?
  • has jasperreports sort of api or interface accessed access generated output more easily? maybe formatter/customizer approach?
  • are there better apis reading pdf?
  • have forgot reasonable questions? ;)

which versions use:

  • java 1.6
  • poi 3.8
  • itext 5.1.3
  • jasperreports 4.7.1

i hope question not messed , don't beat me death verbally ;)

as @vash said, no place topic can answered / discussed.

nevertheless post our solution in case of having similar problem , finding site.

getting needed - jasperreports generated - output

neither generating html instead of pdf nor parsing final pdf document kind of api satisfying solution. did writing scriptlet linked report. in report scriplet called number of vehicles displayed. number of vehicles , generated link passed scriplet parameters , method returns number again.

now scriplet has static map<string, double> collects links , numbers. after generating report can grab map , analyse corresponding xls export. way can compare amounts of vehicles in pdf , xls.

the drawback of method is, pdf report generated empty outputstream.

checking table data integrity

fortunately data displayed generated in java factory. have instantiate , check output delivered in special data classes , collections. way can implicitly verify data in report correct.

running full unit test setup consisting of 3 reports , circa 240 xls documents lasts 5 minutes. byproduct have bunch full of xls sheets (which written empty outputstreams) not nice on other hand, it's unit test doesn't have hyper efficient.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -