Source Code Cross Referenced for PageCrawlerTest.java in  » Testing » StoryTestIQ » fitnesse » wiki » 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.wiki 
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.wiki;
004:
005:        import junit.framework.TestCase;
006:        import fitnesse.components.FitNesseTraversalListener;
007:        import java.util.*;
008:
009:        public class PageCrawlerTest extends TestCase implements 
010:                FitNesseTraversalListener {
011:            private WikiPage root;
012:
013:            private WikiPage page1;
014:
015:            private WikiPage page2;
016:
017:            private WikiPage child1;
018:
019:            private WikiPage grandChild1;
020:
021:            private PageCrawler crawler;
022:
023:            private WikiPagePath page1Path;
024:
025:            private WikiPagePath child1FullPath;
026:
027:            private WikiPagePath page2Path;
028:
029:            private WikiPagePath grandChild1FullPath;
030:
031:            public void setUp() throws Exception {
032:                root = InMemoryPage.makeRoot("RooT");
033:                crawler = new PageCrawlerImpl();
034:
035:                page1Path = PathParser.parse("PageOne");
036:                page2Path = PathParser.parse("PageTwo");
037:                child1FullPath = PathParser.parse("PageOne.ChildOne");
038:                grandChild1FullPath = PathParser
039:                        .parse("PageOne.ChildOne.GrandChildOne");
040:                page1 = crawler.addPage(root, page1Path);
041:                page2 = crawler.addPage(root, page2Path);
042:                child1 = crawler.addPage(page1, PathParser.parse("ChildOne"));
043:                grandChild1 = crawler.addPage(child1, PathParser
044:                        .parse("GrandChildOne"));
045:            }
046:
047:            public void testPageExists() throws Exception {
048:                assertTrue(crawler.pageExists(page1, PathParser
049:                        .parse("ChildOne")));
050:                assertFalse(crawler.pageExists(page1, PathParser
051:                        .parse("BlahBlah")));
052:            }
053:
054:            public void testPageExistsUsingPath() throws Exception {
055:                assertTrue(crawler.pageExists(page1, PathParser
056:                        .parse("ChildOne")));
057:                assertTrue(crawler.pageExists(root, child1FullPath));
058:                assertTrue(crawler.pageExists(root, grandChild1FullPath));
059:                assertTrue(crawler.pageExists(root, PathParser
060:                        .parse(".PageOne")));
061:                assertTrue(crawler.pageExists(root, PathParser
062:                        .parse(".PageOne.ChildOne.GrandChildOne")));
063:
064:                assertFalse(crawler.pageExists(page1, PathParser
065:                        .parse("BlahBlah")));
066:                assertFalse(crawler.pageExists(page1, PathParser
067:                        .parse("PageOne.BlahBlah")));
068:            }
069:
070:            public void testGetPage() throws Exception {
071:                assertEquals(null, crawler.getPage(page1, page1Path));
072:                assertEquals(page1, crawler.getPage(root, page1Path));
073:                assertEquals(page2, crawler.getPage(root, page2Path));
074:                assertEquals(page1, crawler.getPage(page1, PathParser
075:                        .parse(".PageOne")));
076:                assertEquals(page1, crawler.getPage(grandChild1, PathParser
077:                        .parse(".PageOne")));
078:                assertEquals(grandChild1, crawler.getPage(page1, PathParser
079:                        .parse("ChildOne.GrandChildOne")));
080:                assertEquals(root, crawler.getPage(root, PathParser
081:                        .parse("root")));
082:                assertEquals(root, crawler.getPage(root, PathParser.parse(".")));
083:                assertEquals(root, crawler.getPage(root, PathParser.parse("")));
084:            }
085:
086:            public void testGetFullPath() throws Exception {
087:                assertEquals(page1Path, crawler.getFullPath(page1));
088:                assertEquals(page2Path, crawler.getFullPath(page2));
089:                assertEquals(child1FullPath, crawler.getFullPath(child1));
090:                assertEquals(grandChild1FullPath, crawler
091:                        .getFullPath(grandChild1));
092:                assertEquals(PathParser.parse(""), crawler.getFullPath(root));
093:            }
094:
095:            public void testGetAbsolutePathForChild() throws Exception {
096:                WikiPagePath somePagePath = PathParser.parse("SomePage");
097:                WikiPagePath somePageFullPath = crawler.getFullPathOfChild(
098:                        root, somePagePath);
099:                assertEquals("SomePage", PathParser.render(somePageFullPath));
100:
101:                WikiPagePath pageOnePath = page1Path;
102:                WikiPagePath pageOneFullPath = crawler.getFullPathOfChild(root,
103:                        pageOnePath);
104:                assertEquals("PageOne", PathParser.render(pageOneFullPath));
105:
106:                WikiPagePath SomePageChildFullPath = crawler
107:                        .getFullPathOfChild(child1, somePagePath);
108:                assertEquals("PageOne.ChildOne.SomePage", PathParser
109:                        .render(SomePageChildFullPath));
110:
111:                WikiPagePath otherPagePath = PathParser
112:                        .parse("SomePage.OtherPage");
113:                WikiPagePath otherPageFullPath = crawler.getFullPathOfChild(
114:                        root, otherPagePath);
115:                assertEquals("SomePage.OtherPage", PathParser
116:                        .render(otherPageFullPath));
117:
118:                WikiPagePath somePageAbsolutePath = PathParser
119:                        .parse(".SomePage");
120:                WikiPagePath somePageAbsoluteFullPath = crawler
121:                        .getFullPathOfChild(child1, somePageAbsolutePath);
122:                assertEquals("SomePage", PathParser
123:                        .render(somePageAbsoluteFullPath));
124:            }
125:
126:            public void testAddPage() throws Exception {
127:                WikiPage page = crawler.addPage(page1, PathParser
128:                        .parse("SomePage"));
129:                assertEquals(PathParser.parse("PageOne.SomePage"), crawler
130:                        .getFullPath(page));
131:                assertEquals(page1, page.getParent());
132:            }
133:
134:            public void testRecursiveAddbyName() throws Exception {
135:                crawler.addPage(root, PathParser.parse("AaAa"), "its content");
136:                assertTrue(root.hasChildPage("AaAa"));
137:
138:                crawler.addPage(root, PathParser.parse("AaAa.BbBb"), "floop");
139:                assertTrue(crawler.pageExists(root, PathParser
140:                        .parse("AaAa.BbBb")));
141:                assertEquals("floop", crawler.getPage(root,
142:                        PathParser.parse("AaAa.BbBb")).getData().getContent());
143:            }
144:
145:            public void testAddChildPageWithMissingParent() throws Exception {
146:                WikiPage page = crawler.addPage(root, PathParser
147:                        .parse("WikiMail.BadSubject0123"), "");
148:                assertNotNull(page);
149:                assertEquals("BadSubject0123", page.getName());
150:                assertEquals(PathParser.parse("WikiMail.BadSubject0123"),
151:                        crawler.getFullPath(page));
152:            }
153:
154:            public void testGetRelativePageName() throws Exception {
155:                assertEquals("PageOne", crawler.getRelativeName(root, page1));
156:                assertEquals("PageOne.ChildOne", crawler.getRelativeName(root,
157:                        child1));
158:                assertEquals("ChildOne", crawler.getRelativeName(page1, child1));
159:                assertEquals("GrandChildOne", crawler.getRelativeName(child1,
160:                        grandChild1));
161:                assertEquals("ChildOne.GrandChildOne", crawler.getRelativeName(
162:                        page1, grandChild1));
163:            }
164:
165:            public void testIsRoot() throws Exception {
166:                assertTrue(crawler.isRoot(root));
167:                WikiPage page = crawler.addPage(root, page1Path);
168:                assertFalse(crawler.isRoot(page));
169:            }
170:
171:            Set traversedPages = new HashSet();
172:
173:            public void testTraversal() throws Exception {
174:                crawler.traverse(root, this );
175:                assertEquals(5, traversedPages.size());
176:                assertTrue(traversedPages.contains("PageOne"));
177:                assertTrue(traversedPages.contains("ChildOne"));
178:            }
179:
180:            public void processPage(WikiPage page) throws Exception {
181:                traversedPages.add(page.getName());
182:            }
183:
184:            public String getSearchPattern() throws Exception {
185:                return "blah";
186:            }
187:
188:            public void testdoesntTraverseSymbolicPages() throws Exception {
189:                PageData data = page1.getData();
190:                data.getProperties().addSymbolicLink("SymLink",
191:                        PathParser.parse("PageTwo"));
192:                page1.commit(data);
193:
194:                crawler.traverse(root, this );
195:                assertEquals(5, traversedPages.size());
196:
197:                assertFalse(traversedPages.contains("SymLink"));
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.