Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jbreport/test/ExpandTest.java


1   /*
2    * $Id: ExpandTest.java,v 1.1.1.1 2000/08/31 13:14:38 grantfin Exp $
3    *
4    * jbReport - A reporting library for Java
5    * Copyright (C) 2000 Grant Finnemore <grantfin@users.sourceforge.net>
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2 of the License, or (at your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this library; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   */
21  package jbreport.test;
22  
23  import java.io.InputStream;
24  import java.io.PrintWriter;
25  import junit.framework.TestCase;
26  
27  import jbreport.Constants;
28  import jbreport.ReportException;
29  import jbreport.ReportFacade;
30  import jbreport.ReportSection;
31  import jbreport.util.MemoryTrack;
32  import jbreport.util.XMLOutputReportVisitor;
33  
34  /**
35   * This will test that the report will expand using the given queries.
36   *
37   * @author Grant Finnemore
38   * @version $Revision: 1.1.1.1 $
39   */
40  public 
41  class ExpandTest extends TestCase {
42  
43     public ExpandTest(String name) {
44        super(name);
45     }
46  
47     protected void setUp() throws Exception {
48        InputStream is = getClass().getResourceAsStream("Datasource.xml");
49        ReportFacade.initialize(is);
50        is = getClass().getResourceAsStream("Misc.xml");
51        ReportFacade.initialize(is);
52        is = getClass().getResourceAsStream("Styles.xml");
53        ReportFacade.initialize(is);
54        is = getClass().getResourceAsStream("ParseTest.xml");
55        ReportFacade.initialize(is);
56     }
57     
58     protected void tearDown() {
59        MemoryTrack mt = MemoryTrack.getInstance();
60        System.out.println("ExpandTest> " 
61                           + MemoryTrack.bytesToKB(mt.getMaxUsage()));
62     }
63  
64     /*
65     public void testExpandDocument() throws ReportException {
66        ReportSection doc = ReportFacade.fetchDocument("ParseTest.test-2");
67        assertNotNull(doc);
68        doc.loadData();
69        ReportVisitor visitor = new XMLOutputReportVisitor();
70        ((Traversable)doc).preOrderTraverse(visitor);
71     }
72     */
73  
74     public void testBasicHTMLRenderer() throws ReportException {
75        ReportSection doc = ReportFacade.fetchDocument("ParseTest.test-2");
76        assertNotNull(doc);
77        doc.setBoundParamValue("STOCK_VALUE", "2000");
78        doc.setBoundParamValue("PROVINCES", 
79                               "'Eastern Cape', 'Free State', "
80                               + "'Gauteng', 'KwaZulu-Natal', 'Mpumalanga', "
81                               + "'Northern Province', 'North-West', "
82                               + "'Northern Cape', 'Western Cape'");
83        doc.loadData();
84        PrintWriter writer = new PrintWriter(System.err);
85        doc.addRenderer(Constants.BASIC_HTML, writer);
86        doc.render();
87        writer.flush();
88     }
89  }