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