Source Code Cross Referenced for SubreportRunTest.java in  » Report » datavision-1.1.0 » jimm » datavision » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » datavision 1.1.0 » jimm.datavision.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.test;
002:
003:        import jimm.datavision.*;
004:        import jimm.datavision.layout.CharSepLE;
005:        import jimm.datavision.source.Join;
006:        import java.io.*;
007:        import java.util.Iterator;
008:        import junit.framework.TestCase;
009:        import junit.framework.TestSuite;
010:        import junit.framework.Test;
011:
012:        /**
013:         * Reads a report from an XML file, runs it, and verifies the output. Uses
014:         * the {@link CharSepLE} layout engine to produce a tab-delimited output file.
015:         * <p>
016:         * These tests are tightly coupled with the contents of the file
017:         * <code>test_sub.xml</code> and the contents of the test database generated
018:         * by the files in <code>jimm/datavision/testdata</code>.
019:         *
020:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
021:         */
022:        public class SubreportRunTest extends TestCase {
023:
024:            protected static final File EXAMPLE_REPORT = new File(AllTests
025:                    .testDataFile("test_sub.xml"));
026:            protected static final File OUT_FILE = new File(System
027:                    .getProperty("java.io.tmpdir"),
028:                    "datavision_subreport_run_test_out.txt");
029:            // This must match the format string for the report.date field in
030:            // EXAMPLE_REPORT.
031:            protected static final String REPORT_DATE_FORMAT = "yyyy-MM-dd";
032:            // This must be an alphabetically sorted list of office names from the
033:            // offices table.
034:            protected static final String OFFICES[] = { "Chicago",
035:                    "New Jersey", "New York" };
036:            // The value of parameter one, which is at the beginning of the
037:            // report header.
038:            protected static final String STRING_PARAM_VALUE = "Chicago";
039:            // The value of the report.title special field, which appears
040:            // in the report header.
041:            protected static final String REPORT_TITLE = "Example Report";
042:
043:            protected Report report;
044:
045:            public static Test suite() {
046:                return new TestSuite(SubreportRunTest.class);
047:            }
048:
049:            public SubreportRunTest(String name) {
050:                super (name);
051:            }
052:
053:            public void setUp() throws Exception {
054:                report = new Report();
055:                report.setDatabasePassword("");
056:                report.read(EXAMPLE_REPORT); // Must come after setting password
057:
058:                if (OUT_FILE.exists())
059:                    OUT_FILE.delete(); // Delete previous output
060:                OUT_FILE.deleteOnExit();
061:                PrintWriter out = new PrintWriter(new FileWriter(OUT_FILE));
062:                report.setLayoutEngine(new CharSepLE(out, '\t'));
063:            }
064:
065:            public void tearDown() {
066:                if (OUT_FILE.exists())
067:                    OUT_FILE.delete();
068:            }
069:
070:            // Make sure a simple subreport runs
071:            public void testReportRun() throws IOException,
072:                    FileNotFoundException {
073:                // Run report in this thread, not a separate one. Running the
074:                // report closes the output stream.
075:                report.runReport();
076:
077:                BufferedReader in = new BufferedReader(new FileReader(OUT_FILE));
078:                String line;
079:                int cityIndex = -1;
080:                String expectedOffice;
081:                while ((line = in.readLine()) != null) {
082:                    int tabPos = line.indexOf("\t");
083:
084:                    if (tabPos == -1) // New group
085:                        ++cityIndex;
086:                    expectedOffice = ReportRunTest.OFFICES[cityIndex];
087:
088:                    if (tabPos == -1)
089:                        assertEquals(expectedOffice, line);
090:                    else {
091:                        // Line is "NN<tab>name<tab>name"
092:                        line = line.substring(tabPos + 1);
093:                        tabPos = line.indexOf("\t");
094:                        assertEquals(expectedOffice, line.substring(tabPos + 1));
095:                    }
096:                }
097:                in.close();
098:            }
099:
100:            public void testMultipleJoins() throws IOException,
101:                    FileNotFoundException {
102:                for (Iterator iter = report.subreports(); iter.hasNext();) {
103:                    Subreport s = (Subreport) iter.next();
104:                    s.addJoin(new Join(report.findColumn("office.name"), "=",
105:                            report.findColumn("office.name")));
106:                }
107:
108:                // Run report in this thread, not a separate one. Running the
109:                // report closes the output stream.
110:                report.runReport();
111:
112:                BufferedReader in = new BufferedReader(new FileReader(OUT_FILE));
113:                String line;
114:                int cityIndex = -1;
115:                String expectedOffice;
116:                while ((line = in.readLine()) != null) {
117:                    int tabPos = line.indexOf("\t");
118:
119:                    if (tabPos == -1) // New group
120:                        ++cityIndex;
121:                    expectedOffice = ReportRunTest.OFFICES[cityIndex];
122:
123:                    if (tabPos == -1)
124:                        assertEquals(expectedOffice, line);
125:                    else {
126:                        // Line is "NN<tab>name<tab>name"
127:                        line = line.substring(tabPos + 1);
128:                        tabPos = line.indexOf("\t");
129:                        assertEquals(expectedOffice, line.substring(tabPos + 1));
130:                    }
131:                }
132:                in.close();
133:            }
134:
135:            public static void main(String[] args) {
136:                junit.textui.TestRunner.run(suite());
137:                System.exit(0);
138:            }
139:
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.