Source Code Cross Referenced for SuiteResponderTest.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.wiki.*;
006:        import fitnesse.http.*;
007:        import fitnesse.testutil.*;
008:        import fitnesse.FitNesseContext;
009:        import java.util.*;
010:
011:        public class SuiteResponderTest extends AbstractRegex {
012:            private MockRequest request;
013:
014:            private SuiteResponder responder;
015:
016:            private WikiPage root;
017:
018:            private WikiPage suite;
019:
020:            private int port = 9123;
021:
022:            private FitNesseContext context;
023:
024:            private FitSocketReceiver receiver;
025:
026:            private WikiPage testPage;
027:
028:            private PageCrawler crawler;
029:
030:            private WikiPage testPage2;
031:
032:            private WikiPage testChildPage;
033:
034:            private String suitePageName;
035:
036:            public void setUp() throws Exception {
037:                suitePageName = "SuitePage";
038:                root = InMemoryPage.makeRoot("RooT");
039:                crawler = root.getPageCrawler();
040:                PageData data = root.getData();
041:                data.setContent(classpathWidgets());
042:                root.commit(data);
043:                suite = crawler.addPage(root, PathParser.parse(suitePageName),
044:                        "This is the test suite\n");
045:                testPage = addTestToSuite("TestOne",
046:                        "|!-fitnesse.testutil.PassFixture-!|\n");
047:
048:                request = new MockRequest();
049:                request.setResource(suitePageName);
050:                responder = new SuiteResponder();
051:                responder.page = suite;
052:                context = new FitNesseContext(root);
053:                context.port = port;
054:
055:                receiver = new FitSocketReceiver(port, context.socketDealer);
056:            }
057:
058:            private WikiPage addTestToSuite(String name, String content)
059:                    throws Exception {
060:                return addTestPage(suite, name, content);
061:            }
062:
063:            private WikiPage addTestPage(WikiPage page, String name,
064:                    String content) throws Exception {
065:                WikiPage testPage = crawler.addPage(page, PathParser
066:                        .parse(name), content);
067:                PageData data = testPage.getData();
068:                data.setAttribute(WikiPage.ACTION_TEST);
069:                testPage.commit(data);
070:                return testPage;
071:            }
072:
073:            public void tearDown() throws Exception {
074:                receiver.close();
075:                receiver = null;
076:            }
077:
078:            private String runSuite() throws Exception {
079:                receiver.receiveSocket();
080:                Response response = responder.makeResponse(context, request);
081:                MockResponseSender sender = new MockResponseSender(response);
082:                String results = sender.sentData();
083:                return results;
084:            }
085:
086:            public void testGatherXRefTestPages() throws Exception {
087:                WikiPage testPage = crawler.addPage(root, PathParser
088:                        .parse("SomePage"), "!xref PageA\n!xref PageB");
089:                WikiPage pageA = crawler.addPage(root, PathParser
090:                        .parse("PageA"));
091:                WikiPage pageB = crawler.addPage(root, PathParser
092:                        .parse("PageB"));
093:                List xrefTestPages = SuiteResponder
094:                        .gatherCrossReferencedTestPages(testPage, root);
095:                assertEquals(2, xrefTestPages.size());
096:                assertTrue(xrefTestPages.contains(pageA));
097:                assertTrue(xrefTestPages.contains(pageB));
098:            }
099:
100:            public void testBuildClassPath() throws Exception {
101:                responder.page = suite;
102:                List testPages = SuiteResponder.getAllTestPagesUnder(suite);
103:                String classpath = SuiteResponder.buildClassPath(testPages,
104:                        responder.page);
105:                assertSubString("classes", classpath);
106:                assertSubString("dummy.jar", classpath);
107:            }
108:
109:            // FIXME
110:            public void XtestWithOneTest() throws Exception {
111:                String results = runSuite();
112:                assertSubString("href=\"#TestOne\"", results);
113:                assertSubString("1 right", results);
114:                assertSubString("id=\"TestOne\"", results);
115:                assertSubString(" href=\"SuitePage.TestOne\"", results);
116:                assertSubString("PassFixture", results);
117:            }
118:
119:            // FIXME
120:            public void XtestPageWithXref() throws Exception {
121:                PageData data = suite.getData();
122:                data
123:                        .setContent("!see XrefOne\r\n!see XrefTwo\n!see XrefThree\n");
124:                suite.commit(data);
125:                addTestPage(root, "XrefOne",
126:                        "|!-fitnesse.testutil.PassFixture-!|\n");
127:                addTestPage(root, "XrefTwo",
128:                        "|!-fitnesse.testutil.PassFixture-!|\n");
129:
130:                String results = runSuite();
131:                assertSubString("href=\"#XrefOne\"", results);
132:                assertSubString("href=\"#XrefTwo\"", results);
133:            }
134:
135:            // FIXME
136:            public void XtestWithTwoTests() throws Exception {
137:                addTestToSuite("TestTwo",
138:                        "|!-fitnesse.testutil.FailFixture-!|\n\n|!-fitnesse.testutil.FailFixture-!|\n");
139:                String results = runSuite();
140:                assertSubString("href=\"#TestOne\"", results);
141:                assertSubString("href=\"#TestTwo\"", results);
142:                assertSubString("1 right", results);
143:                assertSubString("2 wrong", results);
144:                assertSubString("id=\"TestOne\"", results);
145:                assertSubString("id=\"TestTwo\"", results);
146:                assertSubString("PassFixture", results);
147:                assertSubString("FailFixture", results);
148:            }
149:
150:            // FIXME
151:            public void XtestSuiteWithEmptyPage() throws Exception {
152:                suite = crawler.addPage(root, PathParser
153:                        .parse("SuiteWithEmptyPage"),
154:                        "This is the empty page test suite\n");
155:                addTestPage(suite, "TestThatIsEmpty", "");
156:                request.setResource("SuiteWithEmptyPage");
157:                runSuite();
158:
159:                WikiPagePath errorLogPath = PathParser
160:                        .parse("ErrorLogs.SuiteWithEmptyPage");
161:                WikiPage errorLog = crawler.getPage(root, errorLogPath);
162:                PageData data = errorLog.getData();
163:                String errorLogContent = data.getContent();
164:                assertNotSubString("Exception", errorLogContent);
165:            }
166:
167:            // FIXME
168:            public void XtestSuiteWithOneTestWithoutTable() throws Exception {
169:                addTestToSuite("TestWithoutTable", "This test has not table");
170:                addTestToSuite("TestTwo",
171:                        "|!-fitnesse.testutil.PassFixture-!|\n");
172:                addTestToSuite("TestThree",
173:                        "|!-fitnesse.testutil.PassFixture-!|\n");
174:
175:                String results = runSuite();
176:                assertSubString("TestOne", results);
177:                assertSubString("TestTwo", results);
178:                assertSubString("TestThree", results);
179:                assertSubString("TestWithoutTable", results);
180:            }
181:
182:            public void testExitCodeHeader() throws Exception {
183:                String results = runSuite();
184:                assertSubString("Exit-Code: 0", results);
185:            }
186:
187:            public void testGetAllTestPages() throws Exception {
188:                setUpForGetAllTestPages();
189:                List testPages = SuiteResponder.getAllTestPagesUnder(suite);
190:                assertEquals(3, testPages.size());
191:                assertEquals(true, testPages.contains(testPage));
192:                assertEquals(true, testPages.contains(testPage2));
193:                assertEquals(true, testPages.contains(testChildPage));
194:            }
195:
196:            private void setUpForGetAllTestPages() throws Exception {
197:                testPage2 = addTestToSuite("TestPageTwo", "test page two");
198:                testChildPage = testPage2.addChildPage("TestChildPage");
199:                PageData data = testChildPage.getData();
200:                data.setAttribute(WikiPage.ACTION_TEST);
201:                testChildPage.commit(data);
202:            }
203:
204:            public void testGetAllTestPagesSortsByQulifiedNames()
205:                    throws Exception {
206:                setUpForGetAllTestPages();
207:                List testPages = SuiteResponder.getAllTestPagesUnder(suite);
208:                assertEquals(3, testPages.size());
209:                assertEquals(testPage, testPages.get(0));
210:                assertEquals(testPage2, testPages.get(1));
211:                assertEquals(testChildPage, testPages.get(2));
212:            }
213:
214:            public void testSetUpAndTearDown() throws Exception {
215:                WikiPage setUp = crawler.addPage(root, PathParser
216:                        .parse("SuiteSetUp"), "suite set up");
217:                WikiPage tearDown = crawler.addPage(root, PathParser
218:                        .parse("SuiteTearDown"), "suite tear down");
219:
220:                List testPages = responder.makePageList();
221:                assertEquals(3, testPages.size());
222:                assertSame(setUp, testPages.get(0));
223:                assertSame(tearDown, testPages.get(2));
224:            }
225:
226:            public void testExecutionStatusAppears() throws Exception {
227:                String results = runSuite();
228:                assertHasRegexp(divWithIdAndContent("execution-status", ".*?"),
229:                        results);
230:            }
231:
232:            public void testTestSummaryInformationIncludesPageSummary()
233:                    throws Exception {
234:                String results = runSuite();
235:                assertHasRegexp(
236:                        divWithIdAndContent("test-summary",
237:                                ".*?Test Pages:.*?     .*?Assertions:.*?"),
238:                        results);
239:            }
240:
241:            public void testFormatTestSummaryInformation() throws Exception {
242:                String results = runSuite();
243:                assertHasRegexp(
244:                        divWithIdAndContent("test-summary",
245:                                ".*?<strong>Test Pages:</strong>.*?<strong>Assertions:</strong>.*?"),
246:                        results);
247:            }
248:
249:            private String classpathWidgets() {
250:                return "!path classes\n" + "!path lib/dummy.jar\n";
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.