Source Code Cross Referenced for Reporter.java in  » Testing » testng » org » testng » 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 » Testing » testng » org.testng 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.testng;
002:
003:        import java.util.ArrayList;
004:        import java.util.HashMap;
005:        import java.util.List;
006:        import java.util.Map;
007:        import java.util.Vector;
008:
009:        /**
010:         * This class is used for test methods to log messages that will be
011:         * included in the HTML reports generated by TestNG.
012:         * <br>
013:         * <br>
014:         * <b>Implementation details.</b>
015:         * <br>
016:         * <br>
017:         * The reporter keeps a combined output of strings (in m_output) and also
018:         * a record of which method output which line.  In order to do this, callers
019:         * specify what the current method is with setCurrentMethod() and the
020:         * Reporter maintaing a mapping of each method with a list of integers.
021:         * These integers are indices in the combined output (avoids duplicating
022:         * the output).
023:         *
024:         * Created on Nov 2, 2005
025:         * @author cbeust
026:         */
027:        public class Reporter {
028:            // when tests are run in parallel, each thread may be working with different
029:            // 'current test result'. Also, this value should be inherited if the test code
030:            // spawns its own thread.
031:            private static ThreadLocal<ITestResult> m_currentTestResult = new InheritableThreadLocal<ITestResult>();
032:
033:            /**
034:             * All output logged in a sequential order.
035:             */
036:            private static List<String> m_output = new Vector<String>();
037:
038:            private static Map<ITestResult, List<Integer>> m_methodOutputMap = new HashMap<ITestResult, List<Integer>>();
039:
040:            public static void setCurrentTestResult(ITestResult m) {
041:                m_currentTestResult.set(m);
042:            }
043:
044:            public static List<String> getOutput() {
045:                return m_output;
046:            }
047:
048:            private static synchronized void log(String s, ITestResult m) {
049:                // synchronization needed to ensure the line number and m_output are updated atomically
050:                int n = getOutput().size();
051:                List<Integer> lines = m_methodOutputMap.get(m);
052:                if (lines == null) {
053:                    lines = new ArrayList<Integer>();
054:                    m_methodOutputMap.put(m, lines);
055:                }
056:                lines.add(n);
057:                getOutput().add(s);
058:            }
059:
060:            /**
061:             * Log the passed string to the HTML reports
062:             * @param s The message to log
063:             */
064:            public static void log(String s) {
065:                log(s, getCurrentTestResult());
066:            }
067:
068:            /**
069:             * Log the passed string to the HTML reports if the current verbosity
070:             * is equal or greater than the one passed in parameter. If logToStandardOut
071:             * is true, the string will also be printed on standard out.
072:             *
073:             * @param s The message to log
074:             * @param level The verbosity of this message
075:             * @param logToStandardOut Whether to print this string on standard
076:             * out too
077:             */
078:            public static void log(String s, int level, boolean logToStandardOut) {
079:                if (TestRunner.getVerbose() >= level) {
080:                    log(s, getCurrentTestResult());
081:                    if (logToStandardOut) {
082:                        System.out.println(s);
083:                    }
084:                }
085:            }
086:
087:            /**
088:             * Log the passed string to the HTML reports.  If logToStandardOut
089:             * is true, the string will also be printed on standard out.
090:             *
091:             * @param s The message to log
092:             * @param logToStandardOut Whether to print this string on standard
093:             * out too
094:             */
095:            public static void log(String s, boolean logToStandardOut) {
096:                log(s, getCurrentTestResult());
097:                if (logToStandardOut) {
098:                    System.out.println(s);
099:                }
100:            }
101:
102:            /**
103:             * Log the passed string to the HTML reports if the current verbosity
104:             * is equal or greater than the one passed in parameter
105:             *
106:             * @param s The message to log
107:             * @param level The verbosity of this message
108:             */
109:            public static void log(String s, int level) {
110:                if (TestRunner.getVerbose() >= level) {
111:                    log(s, getCurrentTestResult());
112:                }
113:            }
114:
115:            private static ITestResult getCurrentTestResult() {
116:                return m_currentTestResult.get();
117:            }
118:
119:            private static void ppp(String s) {
120:                System.out.println("[Reporter] " + s);
121:            }
122:
123:            public static List<String> getOutput(ITestResult tr) {
124:                List<String> result = new ArrayList<String>();
125:                List<Integer> lines = m_methodOutputMap.get(tr);
126:                if (lines != null) {
127:                    for (Integer n : lines) {
128:                        result.add(getOutput().get(n));
129:                    }
130:                }
131:
132:                return result;
133:            }
134:
135:            //  public static void setCurrentOutput(List<String> tmr) {
136:            //    m_output = tmr;
137:            ////    m_localResult.set(tmr);
138:            //  }
139:
140:            //  public static List<String> getCurrentOutput() {
141:            //    return m_output;
142:            ////    List<String> result = (List<String>) m_localResult.get();
143:            ////    return result;
144:            //  }
145:
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.