Source Code Cross Referenced for SummaryFormatter.java in  » Test-Coverage » Quilt » org » quilt » reports » 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 » Test Coverage » Quilt » org.quilt.reports 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* SummaryFormatter.java */
002:
003:        // //////////////////////////////////////////////////////////////////
004:        // MODIFY TO EXTEND BaseFormatter ? /////////////////////////////////
005:        // //////////////////////////////////////////////////////////////////
006:        package org.quilt.reports;
007:
008:        import java.text.NumberFormat;
009:        import java.io.IOException;
010:        import java.io.OutputStream;
011:
012:        import junit.framework.AssertionFailedError;
013:        import junit.framework.Test;
014:
015:        import org.apache.tools.ant.BuildException;
016:
017:        import org.quilt.framework.*;
018:        import org.quilt.runner.Runner;
019:
020:        public class SummaryFormatter implements  Formatter {
021:
022:            private boolean filtertrace = false;
023:            private Runner runner = null;
024:
025:            private NumberFormat nf = NumberFormat.getInstance();
026:            private OutputStream out;
027:
028:            private boolean withOutAndErr = false;
029:            private String systemOutput = null;
030:            private String systemError = null;
031:
032:            public SummaryFormatter() {
033:            }
034:
035:            // FORMATTER INTERFACE //////////////////////////////////////////
036:
037:            /** Called at the end of the Ant/Quilt test run. */
038:            public void endTestSuite(QuiltTest qt) throws BuildException {
039:                StringBuffer sb = new StringBuffer("Tests run: "
040:                        + qt.runCount() + ", Failures: " + qt.failureCount()
041:                        + ", Errors: " + qt.errorCount() + ", Time elapsed: "
042:                        + nf.format(qt.getRunTime() / 1000.0) + " sec\n");
043:
044:                if (withOutAndErr) {
045:                    if (systemOutput != null && systemOutput.length() > 0) {
046:                        sb.append("Output:\n" + systemOutput + "\n");
047:                    }
048:                    if (systemError != null && systemError.length() > 0) {
049:                        sb.append("Error:\n " + systemError + "\n");
050:                    }
051:                }
052:
053:                try {
054:                    out.write(sb.toString().getBytes());
055:                    out.flush();
056:                } catch (IOException e) {
057:                    throw new BuildException("Unable to write summary output",
058:                            e);
059:                } finally {
060:                    if (out != System.out && out != System.err) {
061:                        try {
062:                            out.close();
063:                        } catch (IOException e) {
064:                        }
065:                    }
066:                }
067:            }
068:
069:            /** Enable filtering of Ant/Quilt/JUnit lines from stack traces. */
070:            public void setFiltertrace(boolean b) {
071:                filtertrace = b; // NEVER USED 
072:            }
073:
074:            /** Where to direct output. */
075:            public void setOutput(OutputStream out) {
076:                this .out = out;
077:            }
078:
079:            /** Select the runner to be used. */
080:            public void setRunner(Runner testrunner) {
081:                runner = testrunner;
082:            }
083:
084:            /** Where to send system error output. */
085:            public void setSystemError(String err) {
086:                systemError = err;
087:            }
088:
089:            /** Where to send standard output. */
090:            public void setSystemOutput(String out) {
091:                systemOutput = out;
092:            }
093:
094:            /** Called at start of Ant/Quilt test run. */
095:            public void startTestSuite(QuiltTest suite) {
096:            }
097:
098:            // INTERFACE TESTLISTENER ///////////////////////////////////////
099:            /** An unexpected error occurred. */
100:            public void addError(Test test, Throwable t) {
101:            }
102:
103:            /** A failure occurred. */
104:            public void addFailure(Test test, Throwable t) {
105:            }
106:
107:            /** A failure occurred. */
108:            public void addFailure(Test test, AssertionFailedError t) {
109:                addFailure(test, (Throwable) t);
110:            }
111:
112:            /** Called at end of JUnit test. */
113:            public void endTest(Test test) {
114:            }
115:
116:            /** Called at beginning of JUnit test. */
117:            public void startTest(Test t) {
118:            }
119:
120:            // OTHER METHODS ////////////////////////////////////////////////
121:            /**
122:             * Ant-compatible method determining whether System.out and 
123:             * System.err should be echoed to the summary report. 
124:             */
125:            public void setWithOutAndErr(boolean value) {
126:                withOutAndErr = value;
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.