Source Code Cross Referenced for WidgetBuilderTest.java in  » Testing » StoryTestIQ » fitnesse » wikitext » 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.wikitext 
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.wikitext;
004:
005:        import fitnesse.wiki.MockWikiPage;
006:        import fitnesse.wiki.WikiPage;
007:        import fitnesse.wikitext.widgets.*;
008:        import junit.framework.TestCase;
009:
010:        public class WidgetBuilderTest extends TestCase {
011:            private WikiPage mockSource;
012:
013:            public void setUp() throws Exception {
014:                mockSource = new MockWikiPage();
015:            }
016:
017:            public void tearDown() throws Exception {
018:            }
019:
020:            public void testEmptyPage() throws Exception {
021:                ParentWidget widget = new WidgetRoot(null, mockSource);
022:                assertNotNull(widget);
023:                assertEquals(0, widget.numberOfChildren());
024:            }
025:
026:            public void testSimpleText() throws Exception {
027:                ParentWidget page = new WidgetRoot("Hello, World!", mockSource);
028:                assertNotNull(page);
029:                assertEquals(1, page.numberOfChildren());
030:                WikiWidget widget = page.nextChild();
031:                testWidgetClassAndText(widget, TextWidget.class,
032:                        "Hello, World!");
033:            }
034:
035:            public void testSimpleWikiWord() throws Exception {
036:                ParentWidget page = new WidgetRoot("WikiWord", mockSource);
037:                WikiWidget widget = page.nextChild();
038:                testWidgetClassAndText(widget, WikiWordWidget.class, "WikiWord");
039:            }
040:
041:            public void testTextThenWikiWord() throws Exception {
042:                ParentWidget page = new WidgetRoot("text WikiWord more Text",
043:                        mockSource);
044:                assertEquals(3, page.numberOfChildren());
045:                WikiWidget widget1 = page.nextChild();
046:                WikiWidget widget2 = page.nextChild();
047:                WikiWidget widget3 = page.nextChild();
048:                testWidgetClassAndText(widget1, TextWidget.class, "text ");
049:                testWidgetClassAndText(widget2, WikiWordWidget.class,
050:                        "WikiWord");
051:                testWidgetClassAndText(widget3, TextWidget.class, " more Text");
052:            }
053:
054:            public void testWikiWord_Text_WikiWord() throws Exception {
055:                ParentWidget page = new WidgetRoot("WikiWord more WordWiki",
056:                        mockSource);
057:                assertEquals(3, page.numberOfChildren());
058:                WikiWidget widget1 = page.nextChild();
059:                WikiWidget widget2 = page.nextChild();
060:                WikiWidget widget3 = page.nextChild();
061:                testWidgetClassAndText(widget1, WikiWordWidget.class,
062:                        "WikiWord");
063:                testWidgetClassAndText(widget2, TextWidget.class, " more ");
064:                testWidgetClassAndText(widget3, WikiWordWidget.class,
065:                        "WordWiki");
066:            }
067:
068:            public void testItalic_text_WikiWord() throws Exception {
069:                ParentWidget page = new WidgetRoot("''italic'' text WikiWord",
070:                        mockSource);
071:                assertEquals(3, page.numberOfChildren());
072:                WikiWidget widget1 = page.nextChild();
073:                WikiWidget widget2 = page.nextChild();
074:                WikiWidget widget3 = page.nextChild();
075:                assertEquals(ItalicWidget.class, widget1.getClass());
076:                testWidgetClassAndText(widget2, TextWidget.class, " text ");
077:                testWidgetClassAndText(widget3, WikiWordWidget.class,
078:                        "WikiWord");
079:            }
080:
081:            public void testWikiWordInsideItalic() throws Exception {
082:                testWikiWordInParentWidget("''WikiWord''", ItalicWidget.class,
083:                        "WikiWord", 1);
084:            }
085:
086:            public void testWikiWordInsideBold() throws Exception {
087:                testWikiWordInParentWidget("'''WikiWord'''", BoldWidget.class,
088:                        "WikiWord", 1);
089:            }
090:
091:            public void testMultiLineWidget() throws Exception {
092:                ParentWidget page = new WidgetRoot("{{{\npreformatted\n}}}",
093:                        mockSource);
094:                assertEquals(1, page.numberOfChildren());
095:                assertEquals(PreformattedWidget.class, page.nextChild()
096:                        .getClass());
097:            }
098:
099:            public void testEmailWidget() throws Exception {
100:                ParentWidget page = new WidgetRoot("someone@somewhere.com",
101:                        mockSource);
102:                assertEquals(1, page.numberOfChildren());
103:                assertEquals(EmailWidget.class, page.nextChild().getClass());
104:            }
105:
106:            public void testHrule() throws Exception {
107:                ParentWidget page = new WidgetRoot("-----", mockSource);
108:                WikiWidget widget = page.nextChild();
109:                assertEquals(HruleWidget.class, widget.getClass());
110:            }
111:
112:            public void testAnchorsMarker() throws Exception {
113:                ParentWidget page = new WidgetRoot(".#name ", mockSource);
114:                WikiWidget widget = page.nextChild();
115:                assertEquals(AnchorMarkerWidget.class, widget.getClass());
116:            }
117:
118:            public void testAnchorsDeclaration() throws Exception {
119:                ParentWidget page = new WidgetRoot("!anchor name ", mockSource);
120:                WikiWidget widget = page.nextChild();
121:                assertEquals(AnchorDeclarationWidget.class, widget.getClass());
122:
123:            }
124:
125:            public void testWikiWordInsideHeader() throws Exception {
126:                testWikiWordInParentWidget("!1 WikiWord\n", HeaderWidget.class,
127:                        "WikiWord", 1);
128:            }
129:
130:            public void testWikiWordInsideCenter() throws Exception {
131:                testWikiWordInParentWidget("!c WikiWord\n", CenterWidget.class,
132:                        "WikiWord", 1);
133:            }
134:
135:            public void testTable() throws Exception {
136:                ParentWidget page = new WidgetRoot("|a|b|\n|c|d|\n", mockSource);
137:                assertEquals(1, page.numberOfChildren());
138:                WikiWidget widget = page.nextChild();
139:                assertEquals(TableWidget.class, widget.getClass());
140:            }
141:
142:            public void testLineBreak() throws Exception {
143:                ParentWidget page = new WidgetRoot("\n\r\n\r", mockSource);
144:                assertEquals(3, page.numberOfChildren());
145:                while (page.hasNextChild())
146:                    assertEquals(LineBreakWidget.class, page.nextChild()
147:                            .getClass());
148:            }
149:
150:            public void testList() throws Exception {
151:                ParentWidget page = new WidgetRoot(" *Item1\n", mockSource);
152:                assertEquals(1, page.numberOfChildren());
153:                assertEquals(ListWidget.class, page.nextChild().getClass());
154:            }
155:
156:            public void testClasspath() throws Exception {
157:                ParentWidget page = new WidgetRoot("!path something",
158:                        mockSource);
159:                assertEquals(1, page.numberOfChildren());
160:                assertEquals(ClasspathWidget.class, page.nextChild().getClass());
161:            }
162:
163:            public void testStrike() throws Exception {
164:                testWikiWordInParentWidget("--WikiWord--", StrikeWidget.class,
165:                        "WikiWord", 1);
166:            }
167:
168:            public void testNoteWidget() throws Exception {
169:                ParentWidget page = new WidgetRoot("!note something",
170:                        mockSource);
171:                assertEquals(1, page.numberOfChildren());
172:                assertEquals(NoteWidget.class, page.nextChild().getClass());
173:            }
174:
175:            public void testCollapsableWidget() throws Exception {
176:                ParentWidget page = new WidgetRoot("!* title\ncontent\n*!\n",
177:                        mockSource);
178:                assertEquals(1, page.numberOfChildren());
179:                assertEquals(CollapsableWidget.class, page.nextChild()
180:                        .getClass());
181:            }
182:
183:            public void testNullPointerError() throws Exception {
184:                String wikiText = "''\nsome text that should be in italics\n''";
185:                WidgetRoot root = new WidgetRoot(wikiText, new MockWikiPage());
186:
187:                try {
188:                    root.render();
189:                } catch (Exception e) {
190:                    fail("should be no exception\n" + e);
191:                }
192:            }
193:
194:            public void testVirtualWikiWidget() throws Exception {
195:                ParentWidget page = new WidgetRoot(
196:                        "!virtualwiki http://localhost/FrontPage", mockSource);
197:                assertEquals(1, page.numberOfChildren());
198:                assertEquals(VirtualWikiWidget.class, page.nextChild()
199:                        .getClass());
200:            }
201:
202:            private void testWikiWordInParentWidget(String input,
203:                    Class expectedClass, String wikiWordText, int subChildren)
204:                    throws Exception {
205:                ParentWidget page = new WidgetRoot(input, mockSource);
206:                assertEquals(1, page.numberOfChildren());
207:                WikiWidget widget = page.nextChild();
208:                assertEquals(expectedClass, widget.getClass());
209:
210:                ParentWidget iWidget = (ParentWidget) widget;
211:                assertEquals(subChildren, iWidget.numberOfChildren());
212:                WikiWidget childWidget = iWidget.nextChild();
213:                testWidgetClassAndText(childWidget, WikiWordWidget.class,
214:                        wikiWordText);
215:            }
216:
217:            private void testWidgetClassAndText(WikiWidget widget,
218:                    Class expectedClass, String expectedText) {
219:                assertEquals(expectedClass, widget.getClass());
220:                if (widget instanceof  TextWidget)
221:                    assertEquals(expectedText, ((TextWidget) widget).getText());
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.