Source Code Cross Referenced for CommentAggregatorWidgetTest.java in  » Testing » StoryTestIQ » fitnesse » wikitext » widgets » 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.widgets 
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.widgets;
004:
005:        import fitnesse.wiki.InMemoryPage;
006:        import fitnesse.wiki.PageCrawler;
007:        import fitnesse.wiki.PageData;
008:        import fitnesse.wiki.PathParser;
009:        import fitnesse.wiki.WikiPage;
010:
011:        public class CommentAggregatorWidgetTest extends AbstractWidget {
012:            private static final String commentWithMarkup = "| comment |'''\"Obfuscated Text\" comment'''||\n";
013:
014:            private static final String commentWithMarkupRendered = "<b>\"Obfuscated Text\" comment</b>";
015:
016:            private static final String commentTextOnly = "| comment | Normal stuff ||\n";
017:
018:            private static final String commentTextOnlyRendered = "Normal stuff";
019:
020:            private static final String rowWithoutComment = "| nocomment | not a comment ||\n";
021:
022:            private static final String rowWithoutCommentNotRendered = "not a comment";
023:
024:            private static final String contentWithoutTable = "just some stuff";
025:
026:            private static final String commentVarValue = "comment substituted with variable";
027:
028:            private static final String commentWithVariable = "| comment |${var1}||\n";
029:
030:            private static final String commentWithVariableRendered = commentVarValue;
031:
032:            private static final String titleRowTextRendered = "This is the first row of a test table";
033:
034:            private static final String titleRowText = "| "
035:                    + titleRowTextRendered + " |\n";
036:
037:            private static final String titleRowTextTwoRendered = "Second Title";
038:
039:            private static final String titleRowTextTwo = "| "
040:                    + titleRowTextTwoRendered + " |\n";
041:
042:            private static final String titleRowBlankText = "| |\n";
043:
044:            private WikiPage root;
045:
046:            private WikiPage parent;
047:
048:            private WikiPage parentWithVar;
049:
050:            private PageCrawler crawler;
051:
052:            public void setUp() throws Exception {
053:                root = InMemoryPage.makeRoot("RooT");
054:                crawler = root.getPageCrawler();
055:                // 2 parent pages at the root
056:                parent = crawler.addPage(root, PathParser.parse("ParentOne"),
057:                        "parent 1");
058:                parentWithVar = crawler.addPage(root, PathParser
059:                        .parse("ParentWithVar"), "!define var1 {"
060:                        + commentVarValue + "}");
061:                crawler
062:                        .addPage(root, PathParser.parse("ParentTwo"),
063:                                "parent 2");
064:            }
065:
066:            public void testContainsClassNames() throws Exception {
067:                setSTIQTestProperty(crawler
068:                        .addPage(parentWithVar, PathParser
069:                                .parse("ChildComments"), titleRowText
070:                                + commentTextOnly));
071:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
072:                        new WidgetRoot(parentWithVar), "!STIQcomments\n");
073:                assertTrue(widget.render(), widget.render().indexOf(
074:                        "id=\"" + CommentAggregatorWidget.AGGREGATE_DIV_ID
075:                                + "\"") != -1);
076:                assertTrue(widget.render(), widget.render().indexOf(
077:                        "class=\"" + CommentAggregatorWidget.TEST_COMMENT_CLASS
078:                                + "\"") != -1);
079:                assertTrue(widget.render(), widget.render().indexOf(
080:                        "class=\"" + CommentAggregatorWidget.TEST_LINK_CLASS
081:                                + "\"") != -1);
082:                assertTrue(widget.render(), widget.render().indexOf(
083:                        "class=\"" + CommentAggregatorWidget.TEST_TITLE_CLASS
084:                                + "\"") != -1);
085:                assertTrue(widget.render(), widget.render().indexOf(
086:                        "class=\""
087:                                + CommentAggregatorWidget.TEST_TITLE_CELL_CLASS
088:                                + "\"") != -1);
089:            }
090:
091:            public void testDivIsCollapsable() throws Exception {
092:                setSTIQTestProperty(crawler
093:                        .addPage(parentWithVar, PathParser
094:                                .parse("ChildComments"), titleRowText
095:                                + commentTextOnly));
096:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
097:                        new WidgetRoot(parentWithVar), "!STIQcomments\n");
098:                assertTrue(widget.render(), widget.render().indexOf(
099:                        "class=\"collapse_rim\"") != -1);
100:                assertTrue(widget.render(), widget.render().indexOf(
101:                        "class=\"hidden\"") != -1);
102:            }
103:
104:            public void testContainsTitle() throws Exception {
105:                setSTIQTestProperty(crawler
106:                        .addPage(parentWithVar, PathParser
107:                                .parse("ChildComments"), titleRowText
108:                                + commentTextOnly));
109:                setSTIQTestProperty(crawler.addPage(parentWithVar, PathParser
110:                        .parse("ChildWithOnlyTitle"), titleRowTextTwo));
111:                setSTIQTestProperty(crawler.addPage(parentWithVar, PathParser
112:                        .parse("ChildWithBlankTitle"), titleRowBlankText));
113:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
114:                        new WidgetRoot(parentWithVar), "!STIQcomments\n");
115:                assertTrue(widget.render(), widget.render().indexOf(
116:                        titleRowTextRendered) != -1);
117:                assertTrue(widget.render(), widget.render().indexOf(
118:                        "colspan=\"3\">") == -1);
119:                assertTrue(widget.render(), widget.render().indexOf(
120:                        titleRowTextTwoRendered) != -1);
121:            }
122:
123:            public void testContainsPageLinkRow() throws Exception {
124:                setSTIQTestProperty(crawler.addPage(parentWithVar, PathParser
125:                        .parse("ChildComments"), commentWithVariable));
126:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
127:                        new WidgetRoot(parentWithVar), "!STIQcomments\n");
128:                assertTrue(widget.render(), widget.render().indexOf(
129:                        "href=\"ParentWithVar.ChildComments\"") != -1);
130:            }
131:
132:            public void testContainsPageName() throws Exception {
133:                setSTIQTestProperty(crawler.addPage(parentWithVar, PathParser
134:                        .parse("ChildComments"), commentWithVariable));
135:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
136:                        new WidgetRoot(parentWithVar), "!STIQcomments\n");
137:                assertTrue(widget.render(), widget.render().indexOf(
138:                        "ChildComments") != -1);
139:            }
140:
141:            public void testOneCommentWithVariable() throws Exception {
142:                setSTIQTestProperty(crawler.addPage(parentWithVar, PathParser
143:                        .parse("ChildComments"), commentWithVariable));
144:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
145:                        new WidgetRoot(parentWithVar), "!STIQcomments\n");
146:                assertTrue(widget.render(), widget.render().indexOf(
147:                        commentWithVariableRendered) != -1);
148:            }
149:
150:            public void testOneCommentWithMarkup() throws Exception {
151:                setSTIQTestProperty(crawler.addPage(parent, PathParser
152:                        .parse("ChildComments"), commentWithMarkup));
153:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
154:                        new WidgetRoot(parent), "!STIQcomments\n");
155:                assertTrue(widget.render(), widget.render().indexOf(
156:                        commentWithMarkupRendered) != -1);
157:            }
158:
159:            public void testOneCommentTextOnly() throws Exception {
160:                setSTIQTestProperty(crawler.addPage(parent, PathParser
161:                        .parse("ChildComments"), commentTextOnly));
162:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
163:                        new WidgetRoot(parent), "!STIQcomments\n");
164:                assertTrue(widget.render(), widget.render().indexOf(
165:                        commentTextOnlyRendered) != -1);
166:            }
167:
168:            public void testContentWithoutTable() throws Exception {
169:                setSTIQTestProperty(crawler.addPage(parent, PathParser
170:                        .parse("ChildComments"), contentWithoutTable));
171:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
172:                        new WidgetRoot(parent), "!STIQcomments\n");
173:                assertFalse(widget.render(), widget.render().indexOf(
174:                        contentWithoutTable) != -1);
175:            }
176:
177:            public void testMultipleCommentsOneChild() throws Exception {
178:                setSTIQTestProperty(crawler.addPage(parent, PathParser
179:                        .parse("ChildComments"), commentWithMarkup
180:                        + commentTextOnly));
181:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
182:                        new WidgetRoot(parent), "!STIQcomments\n");
183:                assertTrue(widget.render(), widget.render().indexOf(
184:                        commentWithMarkupRendered) != -1);
185:                assertTrue(widget.render(), widget.render().indexOf(
186:                        commentTextOnlyRendered) != -1);
187:            }
188:
189:            public void testMultipleCommentsMultipleChildren() throws Exception {
190:                setSTIQTestProperty(crawler.addPage(parent, PathParser
191:                        .parse("ChildComments"), commentWithMarkup
192:                        + commentTextOnly));
193:                setSTIQTestProperty(crawler.addPage(parent, PathParser
194:                        .parse("ChildMixed"), commentWithMarkup
195:                        + rowWithoutComment + commentTextOnly));
196:                crawler.addPage(parent, PathParser.parse("ChildNoTable"),
197:                        contentWithoutTable);
198:                CommentAggregatorWidget widget = new CommentAggregatorWidget(
199:                        new WidgetRoot(parent), "!STIQcomments\n");
200:
201:                String renderedStr = widget.render();
202:
203:                // commentWithMarkupRendered must be present twice.
204:                int p1 = renderedStr.indexOf(commentWithMarkupRendered);
205:                assertTrue(renderedStr, p1 != -1);
206:                int p2 = renderedStr.indexOf(commentWithMarkupRendered, p1);
207:                assertTrue(renderedStr, p2 != -1);
208:
209:                // commentTextOnlyRendered must be present twice.
210:                p1 = -1;
211:                p2 = -1;
212:                p1 = renderedStr.indexOf(commentTextOnlyRendered);
213:                assertTrue(renderedStr, p1 != -1);
214:                p2 = renderedStr.indexOf(commentTextOnlyRendered, p1);
215:                assertTrue(renderedStr, p2 != -1);
216:
217:                assertFalse(renderedStr, renderedStr
218:                        .indexOf(rowWithoutCommentNotRendered) != -1);
219:                assertFalse(renderedStr, renderedStr
220:                        .indexOf(contentWithoutTable) != -1);
221:            }
222:
223:            // "Standard" recursive and hierarchical widget tests
224:            public void testMatch() throws Exception {
225:                assertMatchEquals("!STIQcomments\n", "!STIQcomments");
226:                assertMatchEquals("!STIQcomments -R\n", "!STIQcomments -R");
227:                assertMatchEquals("!STIQcomments\r", "!STIQcomments");
228:                assertMatchEquals("!STIQcomments -R\r", "!STIQcomments -R");
229:                assertMatchEquals(" !STIQcomments\n", null);
230:                assertMatchEquals(" !STIQcomments -R\n", null);
231:                assertMatchEquals("!STIQcomments zap\n", null);
232:                assertMatchEquals("!STIQcomments \n", "!STIQcomments ");
233:            }
234:
235:            public void testIsNotHierarchical() throws Exception {
236:                assertFalse(new ContentsWidget(new WidgetRoot(parent),
237:                        "!STIQcomments\n").isRecursive());
238:            }
239:
240:            public void testIsHierarchical() throws Exception {
241:                assertTrue(new ContentsWidget(new WidgetRoot(parent),
242:                        "!STIQcomments -R\n").isRecursive());
243:            }
244:
245:            protected String getRegexp() {
246:                return CommentAggregatorWidget.REGEXP;
247:            }
248:
249:            private WikiPage setSTIQTestProperty(WikiPage page)
250:                    throws Exception {
251:                PageData pageDataToModify = page.getData();
252:                pageDataToModify.getProperties().set(WikiPage.STIQ_TEST);
253:                page.commit(pageDataToModify);
254:                assertTrue(page.isSTIQTest());
255:                return page;
256:            }
257:
258:            public void tearDown() throws Exception {
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.