public void testRunWithArchiveView() throws Exception { // 1. create document from ORIGINAL_REPORT_DESIGN_RESOURCE first copyResource(ORIGINAL_REPORT_DESIGN_RESOURCE, ORIGINAL_REPORT_DESIGN); IReportRunnable report = engine.openReportDesign(ORIGINAL_REPORT_DESIGN); IRunTask task = engine.createRunTask(report); try { task.run(ORIGINAL_REPORT_DOCUMENT); } finally { task.close(); } // 2. create document from CHANGED_REPORT_DESIGN_RESOURCE copyResource(CHANGED_REPORT_DESIGN_RESOURCE, CHANGED_REPORT_DESIGN); ArchiveView view = new ArchiveView(ARCHIVE_VIEW_DOCUMENT, ORIGINAL_REPORT_DOCUMENT, "rw"); try { report = engine.openReportDesign(CHANGED_REPORT_DESIGN); task = engine.createRunTask(report); try { // 3. new view archive and render ArchiveWriter writer = new ArchiveWriter(view); task.setDataSource(new ArchiveReader(view)); task.run(writer); } finally { task.close(); } // 3. create golden report document report = engine.openReportDesign(CHANGED_REPORT_DESIGN); task = engine.createRunTask(report); try { task.run(CHANGED_REPORT_DOCUMENT); } finally { task.close(); } IReportDocument goldenDocument = engine.openReportDocument(CHANGED_REPORT_DOCUMENT); try { IReportDocument ivDocument = engine.openReportDocument(null, new ArchiveReader(view), new HashMap()); try { // 5. compare two report document compare(goldenDocument, ivDocument); } finally { ivDocument.close(); } } finally { goldenDocument.close(); } } finally { view.close(); } }
protected void ensureWritable() throws IOException { if (!writable) { ArchiveEntry viewEntry = view.createEntry(entry.getName()); try { copyEntry(entry, viewEntry); } finally { entry.close(); } entry = viewEntry; writable = true; } }
public void close() throws IOException { view.closeEntry(this); doClose(); }
ViewEntry(ArchiveView view, String name, ArchiveEntry entry) { super(name, entry); writable = false; this.view = view; view.openEntry(this); }