Source Code Cross Referenced for JUnitReportTest.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » junit » 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 » Build » ANT » org.apache.tools.ant.taskdefs.optional.junit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.taskdefs.optional.junit;
020:
021:        import java.io.File;
022:        import java.io.FileReader;
023:        import java.io.InputStream;
024:        import java.net.URL;
025:        import org.apache.tools.ant.BuildFileTest;
026:        import org.apache.tools.ant.util.FileUtils;
027:
028:        /**
029:         * Small testcase for the junitreporttask.
030:         * First test added to reproduce an fault, still a lot to improve
031:         *
032:         */
033:        public class JUnitReportTest extends BuildFileTest {
034:
035:            public JUnitReportTest(String name) {
036:                super (name);
037:            }
038:
039:            protected void setUp() {
040:                configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml");
041:            }
042:
043:            protected void tearDown() {
044:                executeTarget("clean");
045:            }
046:
047:            /**
048:             * Verifies that no empty junit-noframes.html is generated when frames
049:             * output is selected via the default.
050:             * Needs reports1 task from junitreport.xml.
051:             */
052:            public void testNoFileJUnitNoFrames() {
053:                executeTarget("reports1");
054:                if (new File(System.getProperty("root"),
055:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html")
056:                        .exists()) {
057:                    fail("No file junit-noframes.html expected");
058:                }
059:            }
060:
061:            public void assertIndexCreated() {
062:                if (!new File(System.getProperty("root"),
063:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html")
064:                        .exists()) {
065:                    fail("No file index file found");
066:                }
067:
068:            }
069:
070:            /**
071:             * run a target, assert the index file is there, look for text in the log
072:             * @param targetName target
073:             * @param text optional text to look for
074:             */
075:            private void expectReportWithText(String targetName, String text) {
076:                executeTarget(targetName);
077:                assertIndexCreated();
078:                if (text != null) {
079:                    assertLogContaining(text);
080:                }
081:            }
082:
083:            public void testEmptyFile() throws Exception {
084:                expectReportWithText("testEmptyFile",
085:                        XMLResultAggregator.WARNING_EMPTY_FILE);
086:            }
087:
088:            public void testIncompleteFile() throws Exception {
089:                expectReportWithText("testIncompleteFile",
090:                        XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED);
091:            }
092:
093:            public void testWrongElement() throws Exception {
094:                expectReportWithText("testWrongElement",
095:                        XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT);
096:            }
097:
098:            // Bugzilla Report 34963
099:            public void testStackTraceLineBreaks() throws Exception {
100:                expectReportWithText("testStackTraceLineBreaks", null);
101:                FileReader r = null;
102:                try {
103:                    r = new FileReader(
104:                            new File(
105:                                    System.getProperty("root"),
106:                                    "src/etc/testcases/taskdefs/optional/junitreport/test/html/sampleproject/coins/0_CoinTest.html"));
107:                    String report = FileUtils.readFully(r);
108:                    assertTrue(
109:                            "output must contain <br>",
110:                            report
111:                                    .indexOf("junit.framework.AssertionFailedError: DOEG<br/>") > -1);
112:                } finally {
113:                    FileUtils.close(r);
114:                }
115:            }
116:
117:            // Bugzilla Report 38477
118:            public void testSpecialSignsInSrcPath() throws Exception {
119:                executeTarget("testSpecialSignsInSrcPath");
120:                File reportFile = new File(System.getProperty("root"),
121:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html");
122:                // tests one the file object
123:                assertTrue("No index.html present. Not generated?", reportFile
124:                        .exists());
125:                assertTrue("Cant read the report file.", reportFile.canRead());
126:                assertTrue("File shouldnt be empty.", reportFile.length() > 0);
127:                // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
128:                URL reportUrl = new URL(FileUtils.getFileUtils().toURI(
129:                        reportFile.getAbsolutePath()));
130:                InputStream reportStream = reportUrl.openStream();
131:                assertTrue("This shouldnt be an empty stream.", reportStream
132:                        .available() > 0);
133:            }
134:
135:            public void testSpecialSignsInHtmlPath() throws Exception {
136:                executeTarget("testSpecialSignsInHtmlPath");
137:                File reportFile = new File(
138:                        System.getProperty("root"),
139:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html# $%\u00A7&-!report/index.html");
140:                // tests one the file object
141:                assertTrue("No index.html present. Not generated?", reportFile
142:                        .exists());
143:                assertTrue("Cant read the report file.", reportFile.canRead());
144:                assertTrue("File shouldnt be empty.", reportFile.length() > 0);
145:                // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
146:                URL reportUrl = new URL(FileUtils.getFileUtils().toURI(
147:                        reportFile.getAbsolutePath()));
148:                InputStream reportStream = reportUrl.openStream();
149:                assertTrue("This shouldnt be an empty stream.", reportStream
150:                        .available() > 0);
151:            }
152:
153:            //Bugzilla Report 39708
154:            public void testWithStyleFromDir() throws Exception {
155:                executeTarget("testWithStyleFromDir");
156:                File reportFile = new File(System.getProperty("root"),
157:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html");
158:                // tests one the file object
159:                assertTrue("No index.html present. Not generated?", reportFile
160:                        .exists());
161:                assertTrue("Cant read the report file.", reportFile.canRead());
162:                assertTrue("File shouldnt be empty.", reportFile.length() > 0);
163:                // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
164:                URL reportUrl = new URL(FileUtils.getFileUtils().toURI(
165:                        reportFile.getAbsolutePath()));
166:                InputStream reportStream = reportUrl.openStream();
167:                assertTrue("This shouldnt be an empty stream.", reportStream
168:                        .available() > 0);
169:            }
170:
171:            //Bugzilla Report 40021
172:            public void testNoFrames() throws Exception {
173:                executeTarget("testNoFrames");
174:                File reportFile = new File(System.getProperty("root"),
175:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html");
176:                // tests one the file object
177:                assertTrue("No junit-noframes.html present. Not generated?",
178:                        reportFile.exists());
179:                assertTrue("Cant read the report file.", reportFile.canRead());
180:                assertTrue("File shouldnt be empty.", reportFile.length() > 0);
181:                // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
182:                URL reportUrl = new URL(FileUtils.getFileUtils().toURI(
183:                        reportFile.getAbsolutePath()));
184:                InputStream reportStream = reportUrl.openStream();
185:                assertTrue("This shouldnt be an empty stream.", reportStream
186:                        .available() > 0);
187:            }
188:
189:            //Bugzilla Report 39708
190:            public void testWithStyleFromDirAndXslImport() throws Exception {
191:                executeTarget("testWithStyleFromDirAndXslImport");
192:                File reportFile = new File(System.getProperty("root"),
193:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html");
194:                // tests one the file object
195:                assertTrue("No index.html present. Not generated?", reportFile
196:                        .exists());
197:                assertTrue("Cant read the report file.", reportFile.canRead());
198:                assertTrue("File shouldnt be empty.", reportFile.length() > 0);
199:                // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
200:                URL reportUrl = new URL(FileUtils.getFileUtils().toURI(
201:                        reportFile.getAbsolutePath()));
202:                InputStream reportStream = reportUrl.openStream();
203:                assertTrue("This shouldnt be an empty stream.", reportStream
204:                        .available() > 0);
205:            }
206:
207:            public void testWithStyleFromClasspath() throws Exception {
208:                executeTarget("testWithStyleFromClasspath");
209:                File reportFile = new File(System.getProperty("root"),
210:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html");
211:                // tests one the file object
212:                assertTrue("No index.html present. Not generated?", reportFile
213:                        .exists());
214:                assertTrue("Cant read the report file.", reportFile.canRead());
215:                assertTrue("File shouldnt be empty.", reportFile.length() > 0);
216:                // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
217:                URL reportUrl = new URL(FileUtils.getFileUtils().toURI(
218:                        reportFile.getAbsolutePath()));
219:                InputStream reportStream = reportUrl.openStream();
220:                assertTrue("This shouldnt be an empty stream.", reportStream
221:                        .available() > 0);
222:            }
223:
224:            public void testWithParams() throws Exception {
225:                expectLogContaining("testWithParams", "key1=value1,key2=value2");
226:                File reportFile = new File(System.getProperty("root"),
227:                        "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html");
228:                // tests one the file object
229:                assertTrue("No index.html present. Not generated?", reportFile
230:                        .exists());
231:                assertTrue("Cant read the report file.", reportFile.canRead());
232:                assertTrue("File shouldnt be empty.", reportFile.length() > 0);
233:                // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
234:                URL reportUrl = new URL(FileUtils.getFileUtils().toURI(
235:                        reportFile.getAbsolutePath()));
236:                InputStream reportStream = reportUrl.openStream();
237:                assertTrue("This shouldnt be an empty stream.", reportStream
238:                        .available() > 0);
239:            }
240:        }
w___w_w_.j___a___v___a_2_s___._c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.