Source Code Cross Referenced for SuiteResponder.java in  » Testing » StoryTestIQ » fitnesse » responders » run » 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 » StoryTestIQ » fitnesse.responders.run 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002:        // Released under the terms of the GNU General Public License version 2 or later.
003:        package fitnesse.responders.run;
004:
005:        import fitnesse.html.*;
006:        import fitnesse.wiki.*;
007:        import fitnesse.components.*;
008:        import fit.*;
009:        import java.util.*;
010:
011:        public class SuiteResponder extends TestResponder implements 
012:                FitClientListener {
013:            public static final String SUITE_SETUP_NAME = "SuiteSetUp";
014:
015:            public static final String SUITE_TEARDOWN_NAME = "SuiteTearDown";
016:
017:            private LinkedList processingQueue = new LinkedList();
018:
019:            private WikiPage currentTest = null;
020:
021:            private SuiteHtmlFormatter suiteFormatter;
022:
023:            protected HtmlTag addSummaryPlaceHolder() {
024:                HtmlTag testSummaryDiv = new HtmlTag("div", "Running Tests ...");
025:                testSummaryDiv.addAttribute("id", "test-summary");
026:
027:                return testSummaryDiv;
028:            }
029:
030:            protected void doSending() throws Exception {
031:                data = page.getData();
032:                buildHtml();
033:                addToResponse(formatter.head());
034:
035:                List testPages = makePageList();
036:
037:                String classPath = buildClassPath(testPages, page);
038:                command = buildCommand(data, getClassName(data, request),
039:                        classPath);
040:                client = new CommandRunningFitClient(this , command,
041:                        context.port, context.socketDealer);
042:                log = new ExecutionLog(page, client.commandRunner);
043:                client.start();
044:                if (client.isSuccessfullyStarted()) {
045:                    processTestPages(testPages);
046:
047:                    client.done();
048:                    client.join();
049:
050:                    completeResponse();
051:                }
052:            }
053:
054:            private void processTestPages(List testPages) throws Exception {
055:                for (Iterator iterator = testPages.iterator(); iterator
056:                        .hasNext();) {
057:                    WikiPage testPage = (WikiPage) iterator.next();
058:                    processingQueue.addLast(testPage);
059:                    String testableHtml = HtmlUtil.testableHtml(testPage
060:                            .getData());
061:                    if (testableHtml.length() > 0)
062:                        client.send(testableHtml);
063:                    else
064:                        client.send(emptyPageContent);
065:                }
066:            }
067:
068:            protected void close() throws Exception {
069:                response.add(suiteFormatter.testOutput());
070:                response.add(suiteFormatter.tail());
071:                response.closeChunks();
072:                response.addTrailingHeader("Exit-Code", String
073:                        .valueOf(exitCode()));
074:                response.closeTrailer();
075:                response.close();
076:            }
077:
078:            public void acceptOutput(String output) throws Exception {
079:                WikiPage firstInLine = processingQueue.isEmpty() ? null
080:                        : (WikiPage) processingQueue.getFirst();
081:                if (firstInLine != null && firstInLine != currentTest) {
082:                    PageCrawler pageCrawler = page.getPageCrawler();
083:                    String relativeName = pageCrawler.getRelativeName(page,
084:                            firstInLine);
085:                    WikiPagePath fullPath = pageCrawler
086:                            .getFullPath(firstInLine);
087:                    String fullPathName = PathParser.render(fullPath);
088:                    suiteFormatter.startOutputForNewTest(relativeName,
089:                            fullPathName);
090:                    currentTest = firstInLine;
091:                }
092:                suiteFormatter.acceptOutput(output);
093:            }
094:
095:            public void acceptResults(Counts counts) throws Exception {
096:                super .acceptResults(counts);
097:
098:                PageCrawler pageCrawler = page.getPageCrawler();
099:                WikiPage testPage = (WikiPage) processingQueue.removeFirst();
100:                String relativeName = pageCrawler.getRelativeName(page,
101:                        testPage);
102:                addToResponse(suiteFormatter
103:                        .acceptResults(relativeName, counts));
104:            }
105:
106:            protected void makeFormatter() throws Exception {
107:                suiteFormatter = new SuiteHtmlFormatter(html);
108:                formatter = suiteFormatter;
109:            }
110:
111:            protected String pageType() {
112:                return "Suite Results";
113:            }
114:
115:            public static String buildClassPath(List testPages, WikiPage page)
116:                    throws Exception {
117:                final ClassPathBuilder classPathBuilder = new ClassPathBuilder();
118:                final String pathSeparator = classPathBuilder
119:                        .getPathSeparator(page);
120:                List classPathElements = new ArrayList();
121:                Set visitedPages = new HashSet();
122:
123:                for (Iterator iterator = testPages.iterator(); iterator
124:                        .hasNext();) {
125:                    WikiPage testPage = (WikiPage) iterator.next();
126:                    addClassPathElements(testPage, classPathElements,
127:                            visitedPages);
128:                }
129:                final String classPathString = classPathBuilder
130:                        .createClassPathString(classPathElements, pathSeparator);
131:                return classPathString;
132:            }
133:
134:            private static void addClassPathElements(WikiPage page,
135:                    List classPathElements, Set visitedPages) throws Exception {
136:                List pathElements = new ClassPathBuilder()
137:                        .getInheritedPathElements(page, visitedPages);
138:                classPathElements.addAll(pathElements);
139:            }
140:
141:            public List makePageList() throws Exception {
142:                return makePageList(page, root);
143:            }
144:
145:            public static List makePageList(WikiPage page, WikiPage root)
146:                    throws Exception {
147:                LinkedList pages = getAllTestPagesUnder(page);
148:                List referencedPages = gatherCrossReferencedTestPages(page,
149:                        root);
150:                pages.addAll(referencedPages);
151:
152:                WikiPage suiteSetUp = PageCrawlerImpl.getInheritedPage(
153:                        SUITE_SETUP_NAME, page);
154:                if (suiteSetUp != null) {
155:                    if (pages.contains(suiteSetUp))
156:                        pages.remove(suiteSetUp);
157:                    pages.addFirst(suiteSetUp);
158:                }
159:                WikiPage suiteTearDown = PageCrawlerImpl.getInheritedPage(
160:                        SUITE_TEARDOWN_NAME, page);
161:                if (suiteTearDown != null) {
162:                    if (pages.contains(suiteTearDown))
163:                        pages.remove(suiteTearDown);
164:                    pages.addLast(suiteTearDown);
165:                }
166:
167:                return pages;
168:            }
169:
170:            public static LinkedList getAllTestPagesUnder(WikiPage suiteRoot)
171:                    throws Exception {
172:                LinkedList testPages = new LinkedList();
173:                addTestPagesToList(testPages, suiteRoot);
174:
175:                Collections.sort(testPages, new Comparator() {
176:                    public int compare(Object o, Object o1) {
177:                        try {
178:                            PageCrawler crawler = ((WikiPage) o)
179:                                    .getPageCrawler();
180:                            WikiPagePath path1 = crawler
181:                                    .getFullPath((WikiPage) o);
182:                            WikiPagePath path2 = crawler
183:                                    .getFullPath((WikiPage) o1);
184:
185:                            return path1.compareTo(path2);
186:                        } catch (Exception e) {
187:                            e.printStackTrace();
188:                            return 0;
189:                        }
190:                    }
191:                });
192:
193:                return testPages;
194:            }
195:
196:            private static void addTestPagesToList(List testPages,
197:                    WikiPage context) throws Exception {
198:                if (context.getData().hasAttribute(WikiPage.ACTION_TEST)) {
199:                    testPages.add(context);
200:                }
201:
202:                ArrayList children = new ArrayList();
203:                children.addAll(context.getChildren());
204:                if (context.hasExtension(VirtualCouplingExtension.NAME)) {
205:                    VirtualCouplingExtension extension = (VirtualCouplingExtension) context
206:                            .getExtension(VirtualCouplingExtension.NAME);
207:                    children.addAll(extension.getVirtualCoupling()
208:                            .getChildren());
209:                }
210:                for (Iterator iterator = children.iterator(); iterator
211:                        .hasNext();) {
212:                    WikiPage page = (WikiPage) iterator.next();
213:                    addTestPagesToList(testPages, page);
214:                }
215:            }
216:
217:            public static List gatherCrossReferencedTestPages(
218:                    WikiPage testPage, WikiPage root) throws Exception {
219:                LinkedList pages = new LinkedList();
220:                PageData data = testPage.getData();
221:                List pageReferences = data.getXrefPages();
222:                PageCrawler crawler = testPage.getPageCrawler();
223:                WikiPagePath testPagePath = crawler.getFullPath(testPage);
224:                WikiPage parent = crawler.getPage(root, testPagePath
225:                        .parentPath());
226:                for (Iterator i = pageReferences.iterator(); i.hasNext();) {
227:                    WikiPagePath path = PathParser.parse((String) i.next());
228:                    WikiPage referencedPage = crawler.getPage(parent, path);
229:                    if (referencedPage != null)
230:                        pages.add(referencedPage);
231:                }
232:                return pages;
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.