Source Code Cross Referenced for FileSystemPageTest.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:
004:        package fitnesse.wiki;
005:
006:        import junit.framework.TestCase;
007:        import java.io.File;
008:        import java.util.*;
009:        import fitnesse.util.FileUtil;
010:
011:        public class FileSystemPageTest extends TestCase {
012:            private static final String defaultPath = "./teststorage";
013:
014:            private static final File base = new File(defaultPath);
015:
016:            private FileSystemPage root;
017:
018:            private PageCrawler crawler;
019:
020:            public void setUp() throws Exception {
021:                FileUtil.deleteFileSystemDirectory(base);
022:                createFileSystemDirectory(base);
023:                root = (FileSystemPage) FileSystemPage.makeRoot(defaultPath,
024:                        "RooT");
025:                crawler = root.getPageCrawler();
026:            }
027:
028:            public void tearDown() throws Exception {
029:                FileUtil.deleteFileSystemDirectory(base);
030:                FileUtil.deleteFileSystemDirectory("RooT");
031:            }
032:
033:            public static void createFileSystemDirectory(File current) {
034:                current.mkdir();
035:            }
036:
037:            public void testCreateBase() throws Exception {
038:                FileSystemPage levelA = (FileSystemPage) crawler.addPage(root,
039:                        PathParser.parse("PageA"), "");
040:                assertEquals("./teststorage/RooT/PageA", levelA
041:                        .getFileSystemPath());
042:                assertTrue(new File(defaultPath + "/RooT/PageA").exists());
043:            }
044:
045:            public void testTwoLevel() throws Exception {
046:                WikiPage levelA = crawler.addPage(root, PathParser
047:                        .parse("PageA"));
048:                crawler.addPage(levelA, PathParser.parse("PageB"));
049:                assertTrue(new File(defaultPath + "/RooT/PageA/PageB").exists());
050:            }
051:
052:            public void testContent() throws Exception {
053:                WikiPagePath rootPath = PathParser.parse("root");
054:                assertEquals("", crawler.getPage(root, rootPath).getData()
055:                        .getContent());
056:                crawler.addPage(root, PathParser.parse("AaAa"), "A content");
057:                assertEquals("A content", root.getChildPage("AaAa").getData()
058:                        .getContent());
059:                WikiPagePath bPath = PathParser.parse("AaAa.BbBb");
060:                crawler.addPage(root, bPath, "B content");
061:                assertEquals("B content", crawler.getPage(root, bPath)
062:                        .getData().getContent());
063:            }
064:
065:            public void testBigContent() throws Exception {
066:                StringBuffer buffer = new StringBuffer();
067:                for (int i = 0; i < 1000; i++)
068:                    buffer.append("abcdefghijklmnopqrstuvwxyz");
069:                crawler.addPage(root, PathParser.parse("BigPage"), buffer
070:                        .toString());
071:                String content = root.getChildPage("BigPage").getData()
072:                        .getContent();
073:                assertTrue(buffer.toString().equals(content));
074:            }
075:
076:            public void testPageExists() throws Exception {
077:                crawler.addPage(root, PathParser.parse("AaAa"), "A content");
078:                assertTrue(root.hasChildPage("AaAa"));
079:            }
080:
081:            public void testGetChidren() throws Exception {
082:                crawler.addPage(root, PathParser.parse("AaAa"), "A content");
083:                crawler.addPage(root, PathParser.parse("BbBb"), "B content");
084:                crawler.addPage(root, PathParser.parse("CcCc"), "C content");
085:                new File(defaultPath + "/root/someOtherDir").mkdir();
086:                List children = root.getChildren();
087:                assertEquals(3, children.size());
088:                for (Iterator iterator = children.iterator(); iterator
089:                        .hasNext();) {
090:                    WikiPage child = (WikiPage) iterator.next();
091:                    String name = child.getName();
092:                    boolean isOk = "AaAa".equals(name) || "BbBb".equals(name)
093:                            || "CcCc".equals(name);
094:                    assertTrue("WikiPAge is not a valid one: " + name, isOk);
095:                }
096:            }
097:
098:            public void testRemovePage() throws Exception {
099:                WikiPage levelOne = crawler.addPage(root, PathParser
100:                        .parse("LevelOne"));
101:                crawler.addPage(levelOne, PathParser.parse("LevelTwo"));
102:                levelOne.removeChildPage("LevelTwo");
103:                File fileOne = new File(defaultPath + "/RooT/LevelOne");
104:                File fileTwo = new File(defaultPath + "/RooT/LevelOne/LevelTwo");
105:                assertTrue(fileOne.exists());
106:                assertFalse(fileTwo.exists());
107:            }
108:
109:            public void testDelTree() throws Exception {
110:                FileSystemPage fsRoot = (FileSystemPage) FileSystemPage
111:                        .makeRoot(".", "RooT");
112:                WikiPage levelOne = crawler.addPage(fsRoot, PathParser
113:                        .parse("LevelOne"));
114:                crawler.addPage(levelOne, PathParser.parse("LevelTwo"));
115:                File childOne = new File("RooT/LevelOne");
116:                File childTwo = new File("RooT/LevelOne/LevelTwo");
117:                assertTrue(childOne.exists());
118:                FileUtil.deleteFileSystemDirectory(childOne);
119:                assertFalse(childTwo.exists());
120:                assertFalse(childOne.exists());
121:            }
122:
123:            public void testDefaultAttributes() throws Exception {
124:                WikiPage page = crawler.addPage(root, PathParser
125:                        .parse("PageOne"), "something");
126:                assertTrue(page.getData().hasAttribute(WikiPage.ACTION_EDIT));
127:            }
128:
129:            public void testPersistentAttributes() throws Exception {
130:                crawler.addPage(root, PathParser.parse("FrontPage"));
131:                WikiPage createdPage = root.getChildPage("FrontPage");
132:                PageData data = createdPage.getData();
133:                data.setAttribute(WikiPage.ACTION_TEST, "true");
134:                data.setAttribute(WikiPage.ACTION_SEARCH, "true");
135:                createdPage.commit(data);
136:                assertTrue(data.hasAttribute(WikiPage.ACTION_TEST));
137:                assertTrue(data.hasAttribute(WikiPage.ACTION_SEARCH));
138:                WikiPage page = root.getChildPage("FrontPage");
139:                assertTrue(page.getData().hasAttribute(WikiPage.ACTION_TEST));
140:                assertTrue(page.getData().hasAttribute(WikiPage.ACTION_SEARCH));
141:            }
142:
143:            public void testCachedInfo() throws Exception {
144:                WikiPage page1 = crawler.addPage(root, PathParser
145:                        .parse("PageOne"), "page one");
146:                WikiPage child1 = crawler.addPage(page1, PathParser
147:                        .parse("ChildOne"), "child one");
148:                WikiPage child = page1.getChildPage("ChildOne");
149:                assertSame(child1, child);
150:            }
151:
152:            public void testCanFindExistingPages() throws Exception {
153:                crawler.addPage(root, PathParser.parse("FrontPage"),
154:                        "front page");
155:                WikiPage newRoot = FileSystemPage.makeRoot(defaultPath, "RooT");
156:                assertNotNull(newRoot.getChildPage("FrontPage"));
157:            }
158:
159:            public void testGetPath() throws Exception {
160:                assertEquals(defaultPath + "/RooT", root.getFileSystemPath());
161:            }
162:
163:            public void testLastModifiedTime() throws Exception {
164:                WikiPage page = crawler.addPage(root, PathParser
165:                        .parse("SomePage"), "some text");
166:                page.commit(page.getData());
167:                Date now = new Date();
168:                Date lastModified = page.getData().getLastModificationTime();
169:                assertTrue(now.getTime() - lastModified.getTime() <= 1000);
170:            }
171:
172:            public void testUnicodeCharacters() throws Exception {
173:                WikiPage page = crawler.addPage(root, PathParser
174:                        .parse("SomePage"), "\uba80\uba81\uba82\uba83");
175:                PageData data = page.getData();
176:                assertEquals("\uba80\uba81\uba82\uba83", data.getContent());
177:            }
178:
179:            public void XtestUnicodeInVersions() throws Exception {
180:                // FIXME
181:                WikiPage page = crawler.addPage(root, PathParser
182:                        .parse("SomePage"), "\uba80\uba81\uba82\uba83");
183:                PageData data = page.getData();
184:                data.setContent("blah");
185:                VersionInfo info = page.commit(data);
186:
187:                data = page.getDataVersion(info.getName());
188:                String expected = "\uba80\uba81\uba82\uba83";
189:                String actual = data.getContent();
190:
191:                assertEquals(expected, actual);
192:            }
193:
194:            public void testLoadChildrenWhenPageIsDeletedManualy()
195:                    throws Exception {
196:                WikiPage page = crawler.addPage(root, PathParser
197:                        .parse("TestPage"));
198:                page.getChildren();
199:                FileUtil.deleteFileSystemDirectory(((FileSystemPage) page)
200:                        .getFileSystemPath());
201:                try {
202:                    page.getChildren();
203:                } catch (Exception e) {
204:                    fail("No Exception should be thrown");
205:                }
206:            }
207:
208:            public void XtestVersionedPropertiedLoadedProperly()
209:                    throws Exception {
210:                // FIXME
211:                WikiPage page = crawler.addPage(root, PathParser
212:                        .parse("TestPage"));
213:                PageData data = page.getData();
214:                WikiPageProperties oldProps = data.getProperties();
215:                WikiPageProperties props = new WikiPageProperties();
216:                props.set("MyProp", "my value");
217:                data.setProperties(props);
218:                page.commit(data);
219:
220:                data.setProperties(oldProps);
221:                VersionInfo version = page.commit(data);
222:
223:                PageData versionedData = page.getDataVersion(version.getName());
224:                WikiPageProperties versionedProps = versionedData
225:                        .getProperties();
226:
227:                assertTrue(versionedProps.has("MyProp"));
228:                assertEquals("my value", versionedProps.get("MyProp"));
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.