Source Code Cross Referenced for MovePageResponderTest.java in  » Testing » StoryTestIQ » fitnesse » responders » refactoring » 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.refactoring 
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.refactoring;
004:
005:        import fitnesse.wiki.*;
006:        import fitnesse.*;
007:        import fitnesse.http.*;
008:        import fitnesse.responders.AbstractResponderRegex;
009:        import java.util.List;
010:
011:        public class MovePageResponderTest extends AbstractResponderRegex {
012:            private WikiPage pageOne;
013:
014:            private WikiPage pageA;
015:
016:            private WikiPage pageTwo;
017:
018:            private MovePageResponder moveResponder;
019:
020:            protected Responder responderInstance() {
021:                return new MovePageResponder();
022:            }
023:
024:            public void setUp() throws Exception {
025:                super .setUp();
026:                moveResponder = (MovePageResponder) responder;
027:                pageOne = crawler.addPage(root, PathParser.parse("PageOne"),
028:                        "^PageA");
029:                pageA = crawler.addPage(pageOne, PathParser.parse("PageA"),
030:                        "content");
031:                pageTwo = crawler.addPage(root, PathParser.parse("PageTwo"));
032:            }
033:
034:            public void testIsChildOf() throws Exception {
035:                WikiPage parent = crawler.addPage(root, PathParser
036:                        .parse("TheParent"));
037:                WikiPage child = crawler.addPage(parent, PathParser
038:                        .parse("TheChild"));
039:                WikiPage grandChild = crawler.addPage(child, PathParser
040:                        .parse("TheGrandChild"));
041:                assertTrue(moveResponder.pageIsAncestorOfNewParent(crawler
042:                        .getFullPath(parent), crawler.getFullPath(child)));
043:                assertTrue(moveResponder.pageIsAncestorOfNewParent(crawler
044:                        .getFullPath(parent), crawler.getFullPath(grandChild)));
045:                assertFalse(moveResponder.pageIsAncestorOfNewParent(crawler
046:                        .getFullPath(child), crawler.getFullPath(parent)));
047:                assertFalse(moveResponder.pageIsAncestorOfNewParent(crawler
048:                        .getFullPath(grandChild), crawler.getFullPath(parent)));
049:                assertTrue(moveResponder.pageIsAncestorOfNewParent(crawler
050:                        .getFullPath(parent), crawler.getFullPath(parent)));
051:            }
052:
053:            public void testMovePage() throws Exception {
054:                PageData data = pageA.getData();
055:                data.setAttribute("someAttribute", "someValue");
056:                pageA.commit(data);
057:
058:                final String sourcePage = "PageOne.PageA";
059:                final String destinationPage = "PageTwo.PageA";
060:                final String destinationParent = "PageTwo";
061:
062:                assertTrue(crawler.pageExists(root, PathParser
063:                        .parse(sourcePage)));
064:                assertFalse(crawler.pageExists(root, PathParser
065:                        .parse(destinationPage)));
066:
067:                movePage(sourcePage, destinationParent);
068:                assertTrue(crawler.pageExists(root, PathParser
069:                        .parse(destinationPage)));
070:                assertFalse(crawler.pageExists(root, PathParser
071:                        .parse(sourcePage)));
072:
073:                WikiPagePath destinationPath = PathParser
074:                        .parse(destinationPage);
075:                WikiPage movedPage = crawler.getPage(root, destinationPath);
076:                data = movedPage.getData();
077:                assertEquals("content", data.getContent());
078:                assertEquals("someValue", data.getAttribute("someAttribute"));
079:            }
080:
081:            private SimpleResponse movePage(String pageToMove, String newParent)
082:                    throws Exception // todo
083:            // RCM
084:            // 2/8/05
085:            // Change
086:            // all
087:            // callers
088:            // to
089:            // use
090:            // wikiPagePath
091:            // version
092:            // below.
093:            {
094:                request.addInput("newLocation", newParent);
095:                request.setResource(pageToMove);
096:                return (SimpleResponse) responder.makeResponse(
097:                        new FitNesseContext(root), request);
098:            }
099:
100:            private SimpleResponse movePage(WikiPagePath pageToMove,
101:                    WikiPagePath newParent) throws Exception {
102:                return movePage(PathParser.render(pageToMove), PathParser
103:                        .render(newParent));
104:            }
105:
106:            public void testReferencesChanged() throws Exception {
107:                movePage("PageOne.PageA", "PageTwo");
108:                pageOne = root.getChildPage("PageOne");
109:                assertEquals(".PageTwo.PageA", pageOne.getData().getContent());
110:            }
111:
112:            public void testReferenceToSubPageChanged() throws Exception {
113:                crawler.addPage(root, PathParser.parse("ReferingPage"),
114:                        "PageOne.PageA");
115:                movePage("PageOne", "PageTwo");
116:                WikiPage referingPage = root.getChildPage("ReferingPage");
117:                assertEquals(".PageTwo.PageOne.PageA", referingPage.getData()
118:                        .getContent());
119:            }
120:
121:            public void testCantMoveToSelf() throws Exception {
122:                pageA.getData().setAttribute("someAttribute", "someValue");
123:                assertTrue(crawler.pageExists(root, PathParser
124:                        .parse("PageOne.PageA")));
125:                SimpleResponse response = (SimpleResponse) movePage(
126:                        "PageOne.PageA", "PageOne");
127:                assertSubString("Cannot move", response.getContent());
128:                assertTrue(crawler.pageExists(root, PathParser
129:                        .parse("PageOne.PageA")));
130:            }
131:
132:            public void testCantReplaceExistingPage() throws Exception {
133:                crawler.addPage(pageTwo, PathParser.parse("PageA"),
134:                        "someContent");
135:                pageA.getData().setAttribute("someAttribute", "someValue");
136:                assertTrue(crawler.pageExists(root, PathParser
137:                        .parse("PageTwo.PageA")));
138:                assertTrue(crawler.pageExists(root, PathParser
139:                        .parse("PageOne.PageA")));
140:
141:                SimpleResponse response = (SimpleResponse) movePage(
142:                        "PageOne.PageA", "PageTwo");
143:                assertSubString("Cannot move", response.getContent());
144:                assertEquals("someContent", pageTwo.getChildPage("PageA")
145:                        .getData().getContent());
146:                assertEquals("content", pageA.getData().getContent());
147:                assertTrue(crawler.pageExists(root, PathParser
148:                        .parse("PageTwo.PageA")));
149:                assertTrue(crawler.pageExists(root, PathParser
150:                        .parse("PageOne.PageA")));
151:            }
152:
153:            public void testChildrenGetMovedIfParentMoves() throws Exception {
154:                final String sourceChildOne = "PageOne.PageA.ChildOne";
155:                final String sourceChildTwo = "PageOne.PageA.ChildTwo";
156:                final String sourceGrandChild = "PageOne.PageA.ChildTwo.ChildTwoDotOne";
157:                final String parentToMove = "PageOne.PageA";
158:                final String destinationParent = "PageTwo";
159:                final String destinationPage = "PageTwo.PageA";
160:                final String destinationChildOne = "PageTwo.PageA.ChildOne";
161:                final String destinationChildTwo = "PageTwo.PageA.ChildTwo";
162:                final String destinationGrandChild = "PageTwo.PageA.ChildTwo.ChildTwoDotOne";
163:
164:                WikiPagePath sourceChildOnePath = PathParser
165:                        .parse(sourceChildOne);
166:                WikiPagePath sourceChildTwoPath = PathParser
167:                        .parse(sourceChildTwo);
168:                WikiPagePath sourceGrandChildPath = PathParser
169:                        .parse(sourceGrandChild);
170:                WikiPagePath destinationPagePath = PathParser
171:                        .parse(destinationPage);
172:                WikiPagePath destinationChildOnePath = PathParser
173:                        .parse(destinationChildOne);
174:                WikiPagePath destinationChildTwoPath = PathParser
175:                        .parse(destinationChildTwo);
176:                WikiPagePath destinationGrandChildPath = PathParser
177:                        .parse(destinationGrandChild);
178:
179:                crawler.addPage(root, sourceChildOnePath, "child1Content");
180:                crawler.addPage(root, sourceChildTwoPath, "child2Content");
181:                crawler.addPage(root, sourceGrandChildPath);
182:
183:                movePage(parentToMove, destinationParent);
184:                WikiPage movedPage = crawler.getPage(root, destinationPagePath);
185:                assertFalse(crawler.pageExists(root, sourceChildOnePath));
186:                assertFalse(crawler.pageExists(root, sourceChildTwoPath));
187:                List children = movedPage.getChildren();
188:                assertEquals(2, children.size());
189:                assertTrue(crawler.pageExists(root, destinationChildOnePath));
190:                assertTrue(crawler.pageExists(root, destinationChildTwoPath));
191:                assertTrue(crawler.pageExists(root, destinationGrandChildPath));
192:            }
193:
194:            public void testCantMovePageBelowChild() throws Exception {
195:                SimpleResponse response = (SimpleResponse) movePage("PageOne",
196:                        "PageOne.PageA");
197:                assertSubString("Cannot move", response.getContent());
198:                assertTrue(crawler.pageExists(root, PathParser
199:                        .parse("PageOne.PageA")));
200:
201:            }
202:
203:            public void testMoveToRoot() throws Exception {
204:                WikiPagePath originalPath = PathParser.parse("PageOne.PageA");
205:                assertTrue(crawler.pageExists(root, originalPath));
206:                movePage(originalPath, PathParser.parse(""));
207:                WikiPage movedPage = root.getChildPage(pageA.getName());
208:                assertFalse(crawler.pageExists(root, originalPath));
209:                assertEquals("content", movedPage.getData().getContent());
210:                assertEquals(PathParser.parse("PageA"), crawler
211:                        .getFullPath(movedPage));
212:                pageOne = root.getChildPage(pageOne.getName());
213:                assertEquals(".PageA", pageOne.getData().getContent());
214:            }
215:
216:            public void testMoveFromRoot() throws Exception {
217:                assertTrue(crawler
218:                        .pageExists(root, PathParser.parse("PageOne")));
219:                movePage("PageOne", "PageTwo");
220:                WikiPage movedPage = pageTwo.getChildPage("PageOne");
221:                assertFalse(crawler.pageExists(root, PathParser
222:                        .parse("PageOne")));
223:                assertEquals(".PageTwo.PageOne.PageA", movedPage.getData()
224:                        .getContent());
225:                assertEquals("PageTwo.PageOne", PathParser.render(crawler
226:                        .getFullPath(movedPage)));
227:            }
228:
229:            public void testRedirection() throws Exception {
230:                String url = moveResponder.createRedirectionUrl(pageOne, pageA);
231:                assertEquals("PageOne.PageA", url);
232:
233:                url = moveResponder.createRedirectionUrl(root, pageA);
234:                assertEquals("PageA", url);
235:            }
236:
237:            public void testBadMoveLocationName() throws Exception {
238:                assertTrue(crawler.pageExists(root, PathParser
239:                        .parse("PageOne.PageA")));
240:                SimpleResponse response = (SimpleResponse) movePage(
241:                        "PageOne.PageA", "NoSuchPage");
242:                assertSubString("Cannot move", response.getContent());
243:                assertTrue(crawler.pageExists(root, PathParser
244:                        .parse("PageOne.PageA")));
245:            }
246:
247:            public void testMovePageIntoItselfIsNotAllowed() throws Exception {
248:                crawler.addPage(root, PathParser.parse("TestPage"));
249:                SimpleResponse response = movePage("TestPage", "TestPage");
250:
251:                assertFalse(crawler.pageExists(root, PathParser
252:                        .parse("TestPage.TestPage")));
253:                assertEquals(400, response.getStatus());
254:                assertSubString("Cannot move", response.getContent());
255:            }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.