assertEquals("table toc doesn't contain 6 nodes",6,tableNode.getChildren().size()); headerNode=(TOCNode)tableNode.getChildren().get(0); groupNode=(TOCNode)((TOCNode)tableNode.getChildren().get(1)).getChildren().get(0); footerNode=(TOCNode)tableNode.getChildren().get(5); assertNotNull("table header toc doesn't exist",headerNode); assertNotNull("table group toc doesn't exist",groupNode); assertNotNull("table footer toc doesn't exist",footerNode); assertEquals("header toc expression isn't HeaderSection","HeaderSection",headerNode.getDisplayString() ); assertEquals("group toc expression isn't GroupSection","GroupSection",groupNode.getDisplayString() ); assertEquals("footer toc expression isn't FooterSection","FooterSection",footerNode.getDisplayString() );  assertNotNull("table group toc doesn't contain nodes",groupNode.getChildren()); detailNode=(TOCNode)((TOCNode)tableNode.getChildren().get(1)).getChildren().get(1); assertEquals("detail toc expression isn't DetailSection","DetailSection",detailNode.getDisplayString() );    IDocArchiveReader arch=reportDoc.getArchive(); assertNotNull("get null document archive",arch); assertEquals("get incorrect document archive",archive.getName(),arch.getName());    ArrayList bookmarks=(ArrayList)reportDoc.getBookmarks(); String hMark="TableHeaderMark",gMark="TableGroupMark",dMark="TableDetailMark"; String fMark="TableFooterMark",pMark="ParameterMark"; assertNotNull("get no bookmarks",bookmarks);  assertTrue("bookmarks doesn't contain "+hMark,bookmarks.contains(hMark)); assertTrue("bookmarks doesn't contain "+gMark,bookmarks.contains(gMark)); assertTrue("bookmarks doesn't contain "+dMark,bookmarks.contains(dMark)); assertTrue("bookmarks doesn't contain "+fMark,bookmarks.contains(fMark)); assertTrue("bookmarks doesn't contain "+pMark,bookmarks.contains(pMark));    List root_children=reportDoc.getChildren("/"); assertNotNull("cannot get root toc's children",root_children); assertNotNull("cannot get table toc",root_children.get(0)); TOCNode table_toc=(TOCNode)root_children.get(0); List table_children=reportDoc.getChildren(table_toc.getNodeID() ); assertNotNull("table toc's children is null",table_children); assertEquals("table toc contains 6 children",6,table_children.size());    InputStream designStream=reportDoc.getDesignStream(); FileInputStream designFile=new FileInputStream(report_design); assertNotNull("return null design stream",designStream);  int length=designStream.available(); byte[] fBytes=new byte[length]; designStream.read(fBytes,0,length);   String tempFile=path+OUTPUT_FOLDER+"report_document_tmp.rptdesign"; File tmp=new File(tempFile); FileOutputStream fos=new FileOutputStream(tmp); fos.write(fBytes); fos.close(); designStream.close(); designFile.close(); assertEquals("return wrong design stream",-6,new File(report_design).compareTo(tmp));  removeFile(tempFile);
TOCNode root, tableNode, headerNode, groupNode, detailNode, footerNode; root = reportDoc.findTOC( "/" ); assertNotNull( "get root toc", root ); assertNotNull( "root contain no children toc", root.getChildren( ) ); tableNode = (TOCNode) root.getChildren( ).get( 0 ); assertNotNull( "table toc doesn't exist.", tableNode ); assertEquals( "table toc expression isn't TableSection", "TableSection", tableNode.getDisplayString( ) ); assertNotNull( "table toc doesn't contain nodes", tableNode .getChildren( ) );
	public void testReportDocument(){		String report_design=path+INPUT_FOLDER+System.getProperty("file.separator")+"report_document.rptdesign";		String report_document=path+OUTPUT_FOLDER+System.getProperty("file.separator")+"report_document";		try{			createReportDocument_param(report_design,report_document);			IDocArchiveReader archive=new FileArchiveReader(report_document);			IReportDocument reportDoc=engine.openReportDocument(report_document);						//checkTOC(done)			TOCNode root,tableNode,headerNode,groupNode,detailNode,footerNode;			root=reportDoc.findTOC("/");			assertNotNull("get root toc",root);			assertNotNull("root contain no children toc",root.getChildren());			tableNode=(TOCNode)root.getChildren().get(0);			assertNotNull("table toc doesn't exist.",tableNode);			assertEquals("table toc expression isn't TableSection","TableSection",tableNode.getDisplayString() );			assertNotNull("table toc doesn't contain nodes",tableNode.getChildren());			assertEquals("table toc doesn't contain 6 nodes",6,tableNode.getChildren().size());			headerNode=(TOCNode)tableNode.getChildren().get(0);			groupNode=(TOCNode)((TOCNode)tableNode.getChildren().get(1)).getChildren().get(0);			footerNode=(TOCNode)tableNode.getChildren().get(5);			assertNotNull("table header toc doesn't exist",headerNode);			assertNotNull("table group toc doesn't exist",groupNode);			assertNotNull("table footer toc doesn't exist",footerNode);			assertEquals("header toc expression isn't HeaderSection","HeaderSection",headerNode.getDisplayString() );			assertEquals("group toc expression isn't GroupSection","GroupSection",groupNode.getDisplayString() );			assertEquals("footer toc expression isn't FooterSection","FooterSection",footerNode.getDisplayString() );						assertNotNull("table group toc doesn't contain nodes",groupNode.getChildren());			detailNode=(TOCNode)((TOCNode)tableNode.getChildren().get(1)).getChildren().get(1);			assertEquals("detail toc expression isn't DetailSection","DetailSection",detailNode.getDisplayString() );									//check Archive(done)			IDocArchiveReader arch=reportDoc.getArchive();			assertNotNull("get null document archive",arch);			assertEquals("get incorrect document archive",archive.getName(),arch.getName());									//check bookmarks			ArrayList bookmarks=(ArrayList)reportDoc.getBookmarks();			String hMark="TableHeaderMark",gMark="TableGroupMark",dMark="TableDetailMark";			String fMark="TableFooterMark",pMark="ParameterMark";			assertNotNull("get no bookmarks",bookmarks);  			//assertEquals("bookmarks doesn't contain 19 nodes",19,bookmarks.size());  			assertTrue("bookmarks doesn't contain "+hMark,bookmarks.contains(hMark));  			assertTrue("bookmarks doesn't contain "+gMark,bookmarks.contains(gMark));  			assertTrue("bookmarks doesn't contain "+dMark,bookmarks.contains(dMark));  			assertTrue("bookmarks doesn't contain "+fMark,bookmarks.contains(fMark));  			assertTrue("bookmarks doesn't contain "+pMark,bookmarks.contains(pMark));									//check children(done)			List root_children=reportDoc.getChildren("/");			assertNotNull("cannot get root toc's children",root_children);			assertNotNull("cannot get table toc",root_children.get(0));			TOCNode table_toc=(TOCNode)root_children.get(0);			List table_children=reportDoc.getChildren(table_toc.getNodeID() );			assertNotNull("table toc's children is null",table_children);			assertEquals("table toc contains 6 children",6,table_children.size());								//check designStream			InputStream designStream=reportDoc.getDesignStream();			FileInputStream designFile=new FileInputStream(report_design);			assertNotNull("return null design stream",designStream);			//generate design file through designStream.			int length=designStream.available();			byte[] fBytes=new byte[length];			designStream.read(fBytes,0,length);						//String tempFile="D:/TEMP/workspace3.1/org.eclipse.birt.report.tests.engine/output/report_document_tmp.rptdesign";			String tempFile=path+OUTPUT_FOLDER+"report_document_tmp.rptdesign";			File tmp=new File(tempFile);			FileOutputStream fos=new FileOutputStream(tmp);			fos.write(fBytes);			fos.close();			designStream.close();			designFile.close();			assertEquals("return wrong design stream",-6,new File(report_design).compareTo(tmp));			//remove tmp file.			removeFile(tempFile);						//check page count(done)			assertEquals("return wrong page count",2,reportDoc.getPageCount());						//check getPageNumber(InstanceID)			//TODO:						//check getPageNumber(bookmark)			assertEquals("return wrong page number which contains bookmark",2,reportDoc.getPageNumber(pMark));			//check parameters(done)			HashMap params=(HashMap)reportDoc.getParameterValues();			assertNotNull("return no parameters",params);						assertEquals("parameter amount isn't 2",2,params.size() );			assertNotNull("p1 parameter returned null",params.get(new String("p1")));			assertNotNull("p2 parameter returned null",params.get(new String("p2")));			assertEquals("p1 parameter returned wrong value","p1string",params.get(new String("p1")));			assertEquals("p1 parameter returned wrong value",new Integer(2),params.get(new String("p2")));												//check report document name			String name=report_document;			name=name.replace('/','\\');  			assertEquals("return wrong report document name",name,reportDoc.getName());						//check reportrunnable			IReportRunnable report=reportDoc.getReportRunnable();						assertNotNull("return null reportRunnable",report);			assertEquals("return wrong reportRunnable",reportRunnable.getReportEngine(), report.getReportEngine());		}catch(Exception e){			e.printStackTrace();		}	}