Source Code Cross Referenced for WikiImportPropertyTest.java in  » Wiki-Engine » fitnesse » fitnesse » responders » 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.responders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package fitnesse.responders;
002:
003:        import fitnesse.wiki.*;
004:        import fitnesse.testutil.*;
005:        import fitnesse.http.*;
006:        import fitnesse.*;
007:        import fitnesse.html.*;
008:        import java.util.Date;
009:        import java.text.SimpleDateFormat;
010:
011:        public class WikiImportPropertyTest extends RegexTest {
012:            private WikiImportProperty property;
013:            private WikiPage page;
014:
015:            public void setUp() {
016:                property = new WikiImportProperty("");
017:            }
018:
019:            public void testSource() throws Exception {
020:                property = new WikiImportProperty("import source");
021:                assertEquals("import source", property.getSourceUrl());
022:                assertEquals("import source", property.get("Source"));
023:            }
024:
025:            public void testIsRoot() throws Exception {
026:                assertFalse(property.isRoot());
027:                assertFalse(property.has("IsRoot"));
028:
029:                property.setRoot(true);
030:
031:                assertTrue(property.isRoot());
032:                assertTrue(property.has("IsRoot"));
033:            }
034:
035:            public void testAutoUpdate() throws Exception {
036:                assertFalse(property.isAutoUpdate());
037:                assertFalse(property.has("AutoUpdate"));
038:
039:                property.setAutoUpdate(true);
040:
041:                assertTrue(property.isAutoUpdate());
042:                assertTrue(property.has("AutoUpdate"));
043:            }
044:
045:            public void testLastUpdated() throws Exception {
046:                SimpleDateFormat format = WikiPageProperty.getTimeFormat();
047:                Date date = new Date();
048:                property.setLastRemoteModificationTime(date);
049:
050:                assertEquals(format.format(date), format.format(property
051:                        .getLastRemoteModificationTime()));
052:
053:                assertEquals(format.format(date), property
054:                        .get("LastRemoteModification"));
055:            }
056:
057:            public void testFailedCreateFromProperty() throws Exception {
058:                assertNull(WikiImportProperty
059:                        .createFrom(new WikiPageProperty()));
060:            }
061:
062:            public void testCreateFromProperty() throws Exception {
063:                WikiPageProperty rawImportProperty = property
064:                        .set(WikiImportProperty.PROPERTY_NAME);
065:                rawImportProperty.set("IsRoot");
066:                rawImportProperty.set("AutoUpdate");
067:                rawImportProperty.set("Source", "some source");
068:                Date date = new Date();
069:                rawImportProperty.set("LastRemoteModification",
070:                        WikiPageProperty.getTimeFormat().format(date));
071:
072:                WikiImportProperty importProperty = WikiImportProperty
073:                        .createFrom(property);
074:                assertEquals("some source", importProperty.getSourceUrl());
075:                assertTrue(importProperty.isRoot());
076:                assertTrue(importProperty.isAutoUpdate());
077:                SimpleDateFormat format = WikiPageProperty.getTimeFormat();
078:                assertEquals(format.format(date), format.format(importProperty
079:                        .getLastRemoteModificationTime()));
080:            }
081:
082:            public void testAddtoProperty() throws Exception {
083:                WikiImportProperty importProperty = new WikiImportProperty(
084:                        "some source");
085:                importProperty.setRoot(true);
086:                importProperty.setAutoUpdate(true);
087:                importProperty.addTo(property);
088:
089:                WikiImportProperty importProperty2 = WikiImportProperty
090:                        .createFrom(property);
091:                assertEquals("some source", importProperty2.getSourceUrl());
092:                assertTrue(importProperty2.isRoot());
093:                assertTrue(importProperty2.isAutoUpdate());
094:            }
095:
096:            // Tests for the rendering of import specific page details
097:            private WikiPage root;
098:            private PageCrawler crawler;
099:
100:            public void pageRenderingSetUp() throws Exception {
101:                root = InMemoryPage.makeRoot("root");
102:                crawler = root.getPageCrawler();
103:            }
104:
105:            private SimpleResponse requestPage(String name) throws Exception {
106:                MockRequest request = new MockRequest();
107:                request.setResource(name);
108:                Responder responder = new WikiPageResponder();
109:                return (SimpleResponse) responder.makeResponse(
110:                        new FitNesseContext(root), request);
111:            }
112:
113:            public void testVirtualPageIndication() throws Exception {
114:                pageRenderingSetUp();
115:
116:                WikiPage targetPage = crawler.addPage(root, PathParser
117:                        .parse("TargetPage"));
118:                crawler.addPage(targetPage, PathParser.parse("ChildPage"));
119:                WikiPage linkPage = (BaseWikiPage) crawler.addPage(root,
120:                        PathParser.parse("LinkPage"));
121:                VirtualCouplingExtensionTest
122:                        .setVirtualWiki(linkPage, "http://localhost:"
123:                                + FitNesseUtil.port + "/TargetPage");
124:
125:                FitNesseUtil.startFitnesse(root);
126:                SimpleResponse response = null;
127:                try {
128:                    response = requestPage("LinkPage.ChildPage");
129:                } finally {
130:                    FitNesseUtil.stopFitnesse();
131:                }
132:
133:                assertSubString("<body class=\"virtual\">", response
134:                        .getContent());
135:            }
136:
137:            public void testImportedPageIndication() throws Exception {
138:                pageRenderingSetUp();
139:
140:                page = crawler.addPage(root, PathParser.parse("SamplePage"));
141:                PageData data = page.getData();
142:                WikiImportProperty importProperty = new WikiImportProperty(
143:                        "blah");
144:                importProperty.addTo(data.getProperties());
145:                page.commit(data);
146:
147:                String content = getContentAfterSpecialImportHandling();
148:
149:                assertSubString("<body class=\"imported\">", content);
150:            }
151:
152:            public void testEditActions() throws Exception {
153:                pageRenderingSetUp();
154:
155:                page = crawler.addPage(root, PathParser.parse("SamplePage"));
156:                PageData data = page.getData();
157:                page.commit(data);
158:                String content = getContentAfterSpecialImportHandling();
159:
160:                assertNotSubString("Edit Locally", content);
161:                assertNotSubString("Edit Remotely", content);
162:
163:                WikiImportProperty importProperty = new WikiImportProperty(
164:                        "blah");
165:                importProperty.addTo(data.getProperties());
166:                page.commit(data);
167:                content = getContentAfterSpecialImportHandling();
168:
169:                assertSubString(
170:                        "<a href=\"SamplePage?edit\" accesskey=\"e\">Edit Locally</a>",
171:                        content);
172:                assertSubString(
173:                        "<a href=\"blah?responder=edit&redirectToReferer=true&redirectAction=importAndView\" accesskey=\"e\">Edit Remotely</a>",
174:                        content);
175:            }
176:
177:            private String getContentAfterSpecialImportHandling()
178:                    throws Exception {
179:                HtmlPage html = new HtmlPageFactory().newPage();
180:                WikiImportProperty.handleImportProperties(html, page, page
181:                        .getData());
182:                return html.html();
183:            }
184:
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.