Source Code Cross Referenced for WikiPagePathTest.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:
007:        public class WikiPagePathTest extends TestCase {
008:            public WikiPagePath path;
009:
010:            protected void setUp() throws Exception {
011:                path = new WikiPagePath();
012:            }
013:
014:            public void testEmptyPath() throws Exception {
015:                assertTrue(path.isEmpty());
016:                assertNull(path.getFirst());
017:                assertTrue(path.getRest().isEmpty());
018:            }
019:
020:            public void testAddOneName() throws Exception {
021:                path.addName("bob");
022:                assertEquals("bob", path.getFirst());
023:                assertFalse(path.isEmpty());
024:                assertTrue(path.getRest().isEmpty());
025:            }
026:
027:            public void testAddTwoNames() throws Exception {
028:                path.addName("bob");
029:                path.addName("martin");
030:                assertFalse(path.isEmpty());
031:                assertEquals("bob", path.getFirst());
032:                WikiPagePath rest = path.getRest();
033:                assertNotNull(rest);
034:                assertEquals("martin", rest.getFirst());
035:                assertTrue(rest.getRest().isEmpty());
036:            }
037:
038:            public void testRenderEmptyPath() throws Exception {
039:                String renderedPath = PathParser.render(path);
040:                assertEquals("", renderedPath);
041:            }
042:
043:            public void testRenderSimplePath() throws Exception {
044:                path.addName("Bob");
045:                String renderedPath = PathParser.render(path);
046:                assertEquals("Bob", renderedPath);
047:            }
048:
049:            public void testRenderComplexPaths() throws Exception {
050:                path.addName("Bob");
051:                path.addName("Martin");
052:                String renderedPath = PathParser.render(path);
053:                assertEquals("Bob.Martin", renderedPath);
054:            }
055:
056:            public void testPop() throws Exception {
057:                path.addName("Micah");
058:                path.pop();
059:                assertEquals("", PathParser.render(path));
060:
061:                path.addName("Micah");
062:                path.addName("Martin");
063:                path.pop();
064:                assertEquals("Micah", PathParser.render(path));
065:
066:                path.pop();
067:                assertEquals("", PathParser.render(path));
068:            }
069:
070:            public void testConstructorWithPage() throws Exception {
071:                WikiPage root = InMemoryPage.makeRoot("RooT");
072:                PageCrawler crawler = root.getPageCrawler();
073:                WikiPagePath abcdPath = PathParser.parse("AaA.BbB.CcC.DdD");
074:                WikiPagePath grandchildPath = PathParser
075:                        .parse("PageOne.ChildOne.GrandChildOne");
076:
077:                WikiPage page1 = crawler.addPage(root, abcdPath);
078:                WikiPage page2 = crawler.addPage(root, grandchildPath);
079:
080:                WikiPagePath page1Path = new WikiPagePath(page1);
081:                assertEquals(abcdPath, page1Path);
082:                WikiPagePath page2Path = new WikiPagePath(page2);
083:                assertEquals(grandchildPath, page2Path);
084:            }
085:
086:            public void testAppend() throws Exception {
087:                WikiPagePath path = new WikiPagePath();
088:                WikiPagePath a = PathParser.parse("PageA");
089:                WikiPagePath pageAPath = path.append(a);
090:                assertEquals("PageA", PathParser.render(pageAPath));
091:
092:                WikiPagePath pageBPath = PathParser.parse("PageB");
093:                WikiPagePath pageABPath = pageAPath.append(pageBPath);
094:                assertEquals("PageA.PageB", PathParser.render(pageABPath));
095:            }
096:
097:            public void testIsAbsolute() throws Exception {
098:                assertTrue(PathParser.parse(".AbsolutePage").isAbsolute());
099:                assertFalse(PathParser.parse("RelativePage").isAbsolute());
100:            }
101:
102:            public void testGetRelativePath() throws Exception {
103:                WikiPagePath somePageAbsolutePath = PathParser
104:                        .parse(".SomePage");
105:                assertEquals("SomePage", PathParser.render(somePageAbsolutePath
106:                        .relativePath()));
107:
108:                WikiPagePath somePagePath = PathParser.parse("SomePage");
109:                assertEquals("SomePage", PathParser.render(somePagePath
110:                        .relativePath()));
111:            }
112:
113:            public void testEquals() throws Exception {
114:                assertEquals(PathParser.parse("PageOne"), PathParser
115:                        .parse("PageOne"));
116:                assertFalse(PathParser.parse("PageOne").equals(
117:                        PathParser.parse("PageTwo")));
118:                assertFalse(PathParser.parse("PageOne").equals("a string"));
119:                assertEquals(PathParser.parse("PageOne.PageTwo"), PathParser
120:                        .parse("PageOne.PageTwo"));
121:                assertFalse(PathParser.parse("PageOne.PageTwo").equals(
122:                        PathParser.parse("PageOne.PageThree")));
123:                assertFalse(PathParser.parse("PageOne").equals(
124:                        PathParser.parse(".PageOne")));
125:            }
126:
127:            public void testCompareTo() throws Exception {
128:                WikiPagePath a = PathParser.parse("PageA");
129:                WikiPagePath ab = PathParser.parse("PageA.PageB");
130:                WikiPagePath b = PathParser.parse("PageB");
131:                WikiPagePath aa = PathParser.parse("PageA.PageA");
132:                WikiPagePath bb = PathParser.parse("PageB.PageB");
133:                WikiPagePath ba = PathParser.parse("PageB.PageA");
134:
135:                assertTrue(a.compareTo(a) == 0); // a == a
136:                assertTrue(a.compareTo(b) != 0); // a != b
137:                assertTrue(ab.compareTo(ab) == 0); // ab == ab
138:                assertTrue(a.compareTo(b) == -1); // a < b
139:                assertTrue(aa.compareTo(ab) == -1); // aa < ab
140:                assertTrue(ba.compareTo(bb) == -1); // ba < bb
141:                assertTrue(b.compareTo(a) == 1); // b > a
142:                assertTrue(ab.compareTo(aa) == 1); // ab > aa
143:                assertTrue(bb.compareTo(ba) == 1); // bb > ba
144:            }
145:
146:            public void testMakeAbsolute() throws Exception {
147:                WikiPagePath p = PathParser.parse("PathOne");
148:                p.makeAbsolute();
149:                assertTrue(p.isAbsolute());
150:
151:                WikiPagePath empty = new WikiPagePath();
152:                empty.makeAbsolute();
153:                assertFalse(empty.isEmpty());
154:                assertTrue(empty.isAbsolute());
155:            }
156:
157:            public void testParentPath() throws Exception {
158:                WikiPagePath path2 = new WikiPagePath();
159:                assertEquals(path2, path.parentPath());
160:
161:                path.addName("AbC");
162:                assertEquals(path2, path.parentPath());
163:
164:                path.addName("XyZ");
165:                path2.addName("AbC");
166:                assertEquals(path2, path.parentPath());
167:            }
168:
169:            public void testEquality() throws Exception {
170:                WikiPagePath path1 = new WikiPagePath();
171:                WikiPagePath path2 = new WikiPagePath();
172:
173:                assertEquals(path1, path2);
174:                assertEquals(path2, path1);
175:
176:                path1.addName("AbC");
177:                assertFalse(path1.equals(path2));
178:                assertFalse(path2.equals(path1));
179:
180:                path2.addName("AbC");
181:                assertEquals(path1, path2);
182:
183:                path1.addName("XyZ");
184:                path2.addName("XyZ");
185:                assertEquals(path1, path2);
186:
187:                path1.pop();
188:                assertFalse(path1.equals(path2));
189:                path2.pop();
190:                assertEquals(path1, path2);
191:            }
192:
193:            public void testStartsWith() throws Exception {
194:                WikiPagePath path2 = new WikiPagePath();
195:                assertTrue(path2.startsWith(path));
196:
197:                path.addName("AbC");
198:                assertTrue(path.startsWith(path2));
199:
200:                path2.addName("AbC");
201:                assertTrue(path.startsWith(path2));
202:
203:                path.addName("DeF");
204:                assertTrue(path.startsWith(path2));
205:
206:                path2.addName("XyZ");
207:                assertFalse(path.startsWith(path2));
208:
209:                path2.pop();
210:                path2.addName("DeF");
211:                assertTrue(path.startsWith(path2));
212:
213:                path2.addName("XyZ");
214:                assertFalse(path.startsWith(path2));
215:            }
216:
217:            public void testWithNameAdded() throws Exception {
218:                WikiPagePath path2 = new WikiPagePath();
219:                path2.addName("AbC");
220:                WikiPagePath path3 = path.withNameAdded("AbC");
221:                assertEquals(path2, path3);
222:                assertNotSame(path3, path2);
223:                assertNotSame(path3, path);
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.