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


001:        package org.testng.remote;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.List;
006:        import java.util.Properties;
007:
008:        import org.testng.ISuite;
009:        import org.testng.ISuiteResult;
010:        import org.testng.ITestListener;
011:        import org.testng.ITestResult;
012:        import org.testng.SuiteRunner;
013:        import org.testng.TestNGException;
014:        import org.testng.internal.Invoker;
015:        import org.testng.internal.PropertiesFile;
016:        import org.testng.internal.annotations.IAnnotationFinder;
017:        import org.testng.remote.adapter.DefaultMastertAdapter;
018:        import org.testng.remote.adapter.IMasterAdapter;
019:        import org.testng.remote.adapter.RemoteResultListener;
020:        import org.testng.xml.XmlSuite;
021:        import org.testng.xml.XmlTest;
022:
023:        /**
024:         * Dispatches test suits according to the strategy defined.
025:         * 
026:         *  
027:         * @author	Guy Korland
028:         * @date 	April 20, 2007
029:         */
030:        public class SuiteDispatcher {
031:            /**
032:             * Properties allowed in remote.properties
033:             */
034:            public static final String MASTER_STRATEGY = "testng.master.strategy";
035:            public static final String VERBOSE = "testng.verbose";
036:            public static final String MASTER_ADPATER = "testng.master.adpter";
037:
038:            /**
039:             * Values allowed for STRATEGY
040:             */
041:            public static final String STRATEGY_TEST = "test";
042:            public static final String STRATEGY_SUITE = "suite";
043:
044:            final private int m_verbose;
045:            final private boolean m_isStrategyTest;
046:
047:            final private IMasterAdapter m_masterAdpter;
048:
049:            /**
050:             * Creates a new suite dispatcher.
051:             * 
052:             * @param propertiesFile
053:             * @throws Exception
054:             */
055:            public SuiteDispatcher(String propertiesFile)
056:                    throws TestNGException {
057:                try {
058:                    PropertiesFile file = new PropertiesFile(propertiesFile);
059:                    Properties properties = file.getProperties();
060:
061:                    m_verbose = Integer.parseInt(properties.getProperty(
062:                            VERBOSE, "1"));
063:
064:                    String strategy = properties.getProperty(MASTER_STRATEGY,
065:                            STRATEGY_SUITE);
066:                    m_isStrategyTest = STRATEGY_TEST.equalsIgnoreCase(strategy);
067:
068:                    String adapter = properties.getProperty(MASTER_ADPATER);
069:                    if (adapter == null) {
070:                        m_masterAdpter = new DefaultMastertAdapter();
071:                    } else {
072:                        Class clazz = Class.forName(adapter);
073:                        m_masterAdpter = (IMasterAdapter) clazz.newInstance();
074:                    }
075:                    m_masterAdpter.init(properties);
076:                } catch (Exception e) {
077:                    throw new TestNGException("Fail to initialize master mode",
078:                            e);
079:                }
080:            }
081:
082:            /**
083:             * Dispatch test suites 
084:             * @param suites
085:             * @param outputDir
086:             * @param javadocAnnotationFinder
087:             * @param jdkAnnotationFinder
088:             * @param testListeners
089:             * @return suites result
090:             */
091:            public List<ISuite> dispatch(List<XmlSuite> suites,
092:                    String outputDir,
093:                    IAnnotationFinder javadocAnnotationFinder,
094:                    IAnnotationFinder jdkAnnotationFinder,
095:                    List<ITestListener> testListeners) {
096:                List<ISuite> result = new ArrayList<ISuite>();
097:                try {
098:                    //
099:                    // Dispatch the suites/tests
100:                    //
101:
102:                    for (XmlSuite suite : suites) {
103:                        suite.setVerbose(m_verbose);
104:                        SuiteRunner suiteRunner = new SuiteRunner(suite,
105:                                outputDir, new IAnnotationFinder[] {
106:                                        javadocAnnotationFinder,
107:                                        jdkAnnotationFinder });
108:                        RemoteResultListener listener = new RemoteResultListener(
109:                                suiteRunner);
110:                        if (m_isStrategyTest) {
111:                            for (XmlTest test : suite.getTests()) {
112:                                XmlSuite tmpSuite = new XmlSuite();
113:                                tmpSuite.setXmlPackages(suite.getXmlPackages());
114:                                tmpSuite.setAnnotations(suite.getAnnotations());
115:                                tmpSuite.setJUnit(suite.isJUnit());
116:                                tmpSuite.setSkipFailedInvocationCounts(suite
117:                                        .skipFailedInvocationCounts());
118:                                tmpSuite.setName("Temporary suite for "
119:                                        + test.getName());
120:                                tmpSuite.setParallel(suite.getParallel());
121:                                tmpSuite.setParameters(suite.getParameters());
122:                                tmpSuite.setThreadCount(suite.getThreadCount());
123:                                tmpSuite.setVerbose(suite.getVerbose());
124:                                tmpSuite.setObjectFactory(suite
125:                                        .getObjectFactory());
126:                                XmlTest tmpTest = new XmlTest(tmpSuite);
127:                                tmpTest.setAnnotations(test.getAnnotations());
128:                                tmpTest.setBeanShellExpression(test
129:                                        .getExpression());
130:                                tmpTest.setXmlClasses(test.getXmlClasses());
131:                                tmpTest.setExcludedGroups(test
132:                                        .getExcludedGroups());
133:                                tmpTest.setIncludedGroups(test
134:                                        .getIncludedGroups());
135:                                tmpTest.setJUnit(test.isJUnit());
136:                                tmpTest.setMethodSelectors(test
137:                                        .getMethodSelectors());
138:                                tmpTest.setName(test.getName());
139:                                tmpTest.setParallel(test.getParallel());
140:                                tmpTest.setParameters(test.getParameters());
141:                                tmpTest.setVerbose(test.getVerbose());
142:                                tmpTest.setXmlClasses(test.getXmlClasses());
143:                                tmpTest.setXmlPackages(test.getXmlPackages());
144:
145:                                m_masterAdpter.runSuitesRemotely(tmpSuite,
146:                                        listener);
147:                            }
148:                        } else {
149:                            m_masterAdpter.runSuitesRemotely(suite, listener);
150:                        }
151:                        result.add(suiteRunner);
152:                    }
153:
154:                    m_masterAdpter.awaitTermination(100000);
155:
156:                    //
157:                    // Run test listeners
158:                    //
159:                    for (ISuite suite : result) {
160:                        for (ISuiteResult suiteResult : suite.getResults()
161:                                .values()) {
162:                            Collection<ITestResult> allTests[] = new Collection[] {
163:                                    suiteResult.getTestContext()
164:                                            .getPassedTests().getAllResults(),
165:                                    suiteResult.getTestContext()
166:                                            .getFailedTests().getAllResults(),
167:                                    suiteResult.getTestContext()
168:                                            .getSkippedTests().getAllResults(),
169:                                    suiteResult
170:                                            .getTestContext()
171:                                            .getFailedButWithinSuccessPercentageTests()
172:                                            .getAllResults(), };
173:                            for (Collection<ITestResult> all : allTests) {
174:                                for (ITestResult tr : all) {
175:                                    Invoker.runTestListeners(tr, testListeners);
176:                                }
177:                            }
178:                        }
179:                    }
180:                } catch (Exception ex) {
181:                    //TODO add to logs
182:                    ex.printStackTrace();
183:                }
184:                return result;
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.