Source Code Cross Referenced for PlainFormatter.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:        /* PlainFormatter */
002:
003:        package org.quilt.reports;
004:
005:        import org.apache.tools.ant.taskdefs.optional.junit.*;
006:        import org.apache.tools.ant.BuildException;
007:
008:        import java.io.OutputStream;
009:        import java.io.StringWriter;
010:        import java.io.PrintWriter;
011:        import java.io.IOException;
012:        import java.text.NumberFormat;
013:        import java.util.Hashtable;
014:
015:        import junit.framework.AssertionFailedError;
016:        import junit.framework.Test;
017:
018:        import org.quilt.runner.Runner;
019:        import org.quilt.framework.*;
020:
021:        /** Plain text output of JUnit test results. */
022:
023:        public class PlainFormatter extends BaseFormatter {
024:
025:            private Hashtable testStarts = new Hashtable();
026:            private Hashtable failed = new Hashtable();
027:
028:            /** No-arg constructor. */
029:            public PlainFormatter() {
030:                results = new StringWriter();
031:                resultWriter = new PrintWriter(results);
032:            }
033:
034:            // INTERFACE FORMATTER //////////////////////////////////////////
035:
036:            public void endTestSuite(QuiltTest qt) throws BuildException {
037:                StringBuffer sb = new StringBuffer("Testsuite: " + qt.getName()
038:                        + "\nTests run: " + qt.runCount() + ", Failures: "
039:                        + qt.failureCount() + ", Errors: " + qt.errorCount()
040:                        + ", Time elapsed: "
041:                        + numberFormat.format(qt.getRunTime() / 1000.0)
042:                        + " sec\n");
043:
044:                if (systemOutput != null && systemOutput.length() > 0) {
045:                    sb
046:                            .append("------------- Standard Output ----------------\n"
047:                                    + systemOutput
048:                                    + "------------- ---------------- ---------------\n");
049:                }
050:
051:                if (systemError != null && systemError.length() > 0) {
052:                    sb
053:                            .append("------------- Standard Error -----------------\n"
054:                                    + systemError
055:                                    + "------------- ---------------- ---------------\n");
056:                }
057:
058:                sb.append("\n");
059:
060:                if (out != null) {
061:                    try {
062:                        out.write(sb.toString().getBytes());
063:                        resultWriter.close();
064:                        out.write(results.toString().getBytes());
065:                        out.flush();
066:                    } catch (IOException ioex) {
067:                        throw new BuildException("Unable to write output", ioex);
068:                    } finally {
069:                        if (out != System.out && out != System.err) {
070:                            try {
071:                                out.close();
072:                            } catch (IOException e) {
073:                            }
074:                        }
075:                    }
076:                }
077:            }
078:
079:            // INTERFACE TESTLISTENER ///////////////////////////////////////
080:            public void startTest(Test t) {
081:                testStarts.put(t, new Long(System.currentTimeMillis()));
082:                failed.put(t, Boolean.FALSE);
083:            }
084:
085:            public void endTest(Test test) {
086:                synchronized (resultWriter) {
087:                    // requires JUnit 3.7 or later
088:                    resultWriter.print("Testcase: " + getTestName(test));
089:
090:                    // remember that the hash holds objects, not primitives
091:                    if (Boolean.TRUE.equals(failed.get(test))) {
092:                        return;
093:                    }
094:                    Long t0 = (Long) testStarts.get(test);
095:                    double seconds = 0;
096:                    // can be null if an error occured in setUp
097:                    if (t0 != null) {
098:                        seconds = (System.currentTimeMillis() - t0.longValue()) / 1000.0;
099:                    }
100:
101:                    resultWriter.println(" took "
102:                            + numberFormat.format(seconds) + " sec");
103:                }
104:            }
105:
106:            public void addFailure(Test test, Throwable t) {
107:                formatError("\tFAILED", test, t);
108:            }
109:
110:            public void addFailure(Test test, AssertionFailedError t) {
111:                addFailure(test, (Throwable) t);
112:            }
113:
114:            public void addError(Test test, Throwable t) {
115:                formatError("\tCaused an ERROR", test, t);
116:            }
117:
118:            // OTHER METHODS ////////////////////////////////////////////////
119:            private void formatError(String type, Test test, Throwable t) {
120:                synchronized (resultWriter) {
121:                    if (test != null) {
122:                        endTest(test);
123:                        failed.put(test, Boolean.TRUE);
124:                    }
125:
126:                    resultWriter.println(type);
127:                    resultWriter.println(t.getMessage());
128:                    String strace = runner.getFilteredTrace(t, filtertrace);
129:                    resultWriter.print(strace);
130:                    resultWriter.println("");
131:                }
132:            }
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.