Source Code Cross Referenced for TagSuiteWidgetTest.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) 


0001:        package fitnesse.wikitext.widgets;
0002:
0003:        import fitnesse.components.TagManager;
0004:        import fitnesse.wiki.InMemoryPage;
0005:        import fitnesse.wiki.PageCrawler;
0006:        import fitnesse.wiki.PageData;
0007:        import fitnesse.wiki.PathParser;
0008:        import fitnesse.wiki.WikiPage;
0009:
0010:        public class TagSuiteWidgetTest extends AbstractWidget {
0011:
0012:            private static final boolean StiqTests = true;
0013:
0014:            private static final boolean NotStiqTests = false;
0015:
0016:            private static final boolean Tagged = true;
0017:
0018:            private static final boolean NotTagged = false;
0019:
0020:            private static final boolean Present = true;
0021:
0022:            private static final boolean NotPresent = false;
0023:
0024:            private static final String PARENT_THREE = "ParentThree";
0025:
0026:            private static final String CHILD_SIX = "ChildSix";
0027:
0028:            private static final String CHILD_FOUR = "ChildFour";
0029:
0030:            private static final String CHILD_THREE = "ChildThree";
0031:
0032:            private static final String CHILD_TWO = "ChildTwo";
0033:
0034:            private static final String GRANDCHILD_ONE = "GrandchildOne";
0035:
0036:            private static final String ROOT = "Root";
0037:
0038:            private static final String PARENT_TWO = "ParentTwo";
0039:
0040:            private static final String GRANDCHILD_THREE = "GrandchildThree";
0041:
0042:            private static final String GRANDCHILD_TWO = "GrandchildTwo";
0043:
0044:            private static final String CHILD_ONE = "ChildOne";
0045:
0046:            private static final String PARENT_ONE = "ParentOne";
0047:
0048:            private static final String FIRST_BRANCH = "FirstBranch";
0049:
0050:            private static final String SECOND_BRANCH = "SecondBranch";
0051:
0052:            private static final String CHILD_FIVE = "ChildFive";
0053:
0054:            private static final String PARENT_FOUR = "ParentFour";
0055:
0056:            private PageCrawler crawler;
0057:
0058:            private WikiPage root;
0059:
0060:            private WikiPage firstBranch;
0061:
0062:            private WikiPage secondBranch;
0063:
0064:            private WikiPage parentOne;
0065:
0066:            private WikiPage parentTwo;
0067:
0068:            private WikiPage parentThree;
0069:
0070:            private WikiPage parentFour;
0071:
0072:            private WikiPage childFour;
0073:
0074:            public void setUp() throws Exception {
0075:                TagManager.INSTANCE.clearIndex();
0076:                root = InMemoryPage.makeRoot("RooT");
0077:                crawler = root.getPageCrawler();
0078:
0079:                firstBranch = crawler.addPage(root, PathParser
0080:                        .parse(FIRST_BRANCH), "branch");
0081:                parentOne = crawler.addPage(firstBranch, PathParser
0082:                        .parse(PARENT_ONE), "parent");
0083:
0084:                WikiPage childOne = crawler.addPage(parentOne, PathParser
0085:                        .parse(CHILD_ONE), "stuff\n!tag orange");
0086:                setSTIQTestProperty(crawler.addPage(childOne, PathParser
0087:                        .parse(GRANDCHILD_ONE), "stuff\n!tag orange"));
0088:                crawler.addPage(childOne, PathParser.parse(GRANDCHILD_TWO),
0089:                        "!tag orange Red");
0090:
0091:                WikiPage childTwo = setSTIQTestProperty(crawler.addPage(
0092:                        parentOne, PathParser.parse(CHILD_TWO),
0093:                        "!tag Red dog orange Cat\n some text"));
0094:                crawler.addPage(childTwo, PathParser.parse(GRANDCHILD_THREE),
0095:                        "!tag blue orange");
0096:
0097:                setSTIQTestProperty(crawler.addPage(parentOne, PathParser
0098:                        .parse(CHILD_THREE), "stuff\n!tag dog green blue Red"));
0099:
0100:                secondBranch = crawler.addPage(root, PathParser
0101:                        .parse(SECOND_BRANCH), "branch");
0102:                parentTwo = crawler.addPage(secondBranch, PathParser
0103:                        .parse(PARENT_TWO), "!tag green");
0104:                childFour = setSTIQTestProperty(crawler.addPage(parentTwo,
0105:                        PathParser.parse(CHILD_FOUR), "!tag blue Red green"));
0106:
0107:                parentThree = setSTIQTestProperty(crawler.addPage(secondBranch,
0108:                        PathParser.parse(PARENT_THREE), ""));
0109:                crawler.addPage(parentThree, PathParser.parse(CHILD_FIVE), "");
0110:
0111:                parentFour = crawler.addPage(secondBranch, PathParser
0112:                        .parse(PARENT_FOUR), "");
0113:                setSTIQTestProperty(crawler.addPage(parentFour, PathParser
0114:                        .parse(CHILD_SIX), ""));
0115:
0116:                // RooT
0117:                // > FirstBranch
0118:                // > > ParentOne
0119:                // > > > ChildOne [orange]
0120:                // > > > > GrandchildOne [orange] STIQ
0121:                // > > > > GrandchildTwo [orange Red]
0122:                // > > > ChildTwo [Red dog orange Cat] STIQ
0123:                // > > > > GrandchildThree [blue orange]
0124:                // > > > > ChildThree [dog green blue Red] STIQ
0125:                // > SecondBranch
0126:                // > > ParentTwo [green]
0127:                // > > > ChildFour [blue Red green] STIQ
0128:                // > > ParentThree STIQ
0129:                // > > > ChildFive
0130:                // > > ParentFour
0131:                // > > > ChildSix STIQ
0132:            }
0133:
0134:            // 
0135:            // Start Page
0136:            //
0137:
0138:            // Root
0139:            public void testRootOneTagOnePage() throws Exception {
0140:
0141:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0142:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0143:                        + " . Cat\n");
0144:
0145:                String widgetContent = widget.render();
0146:                verifyPages(widgetContent, NotStiqTests, Tagged, NotPresent);
0147:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0148:
0149:                // Tagged and family
0150:                assertPageLink(widgetContent, CHILD_TWO, Present);
0151:
0152:                // NOT Tagged and family
0153:                assertPageLink(widgetContent, CHILD_THREE, NotPresent);
0154:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0155:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0156:            }
0157:
0158:            public void testRootOneTagMultiplePages() throws Exception {
0159:
0160:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0161:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0162:                        + " . orange\n");
0163:
0164:                String widgetContent = widget.render();
0165:                verifyNonStiqTestPagesNotPresent(widgetContent);
0166:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0167:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0168:
0169:                // Tagged and family
0170:                assertPageLink(widgetContent, CHILD_TWO, Present);
0171:                assertPageLink(widgetContent, GRANDCHILD_ONE, Present);
0172:
0173:                // NOT Tagged and family
0174:                assertPageLink(widgetContent, CHILD_THREE, NotPresent);
0175:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0176:            }
0177:
0178:            public void testRootTwoTagsMultiplePages() throws Exception {
0179:
0180:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0181:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0182:                        + " . blue green\n");
0183:
0184:                String widgetContent = widget.render();
0185:                verifyNonStiqTestPagesNotPresent(widgetContent);
0186:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0187:
0188:                // Tagged and family
0189:                assertPageLink(widgetContent, CHILD_THREE, Present);
0190:                assertPageLink(widgetContent, CHILD_FOUR, Present);
0191:
0192:                // NOT Tagged and family
0193:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0194:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0195:            }
0196:
0197:            public void testRootTwoTagsOnePage() throws Exception {
0198:
0199:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0200:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0201:                        + " . Cat Red\n");
0202:
0203:                String widgetContent = widget.render();
0204:                verifyNonStiqTestPagesNotPresent(widgetContent);
0205:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0206:
0207:                // Tagged and family
0208:                assertPageLink(widgetContent, CHILD_TWO, Present);
0209:
0210:                // NOT Tagged and family
0211:                assertPageLink(widgetContent, CHILD_THREE, NotPresent);
0212:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0213:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0214:            }
0215:
0216:            public void testRootManyTagsOnePage() throws Exception {
0217:
0218:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0219:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0220:                        + " . green dog Red blue\n");
0221:
0222:                String widgetContent = widget.render();
0223:                verifyNonStiqTestPagesNotPresent(widgetContent);
0224:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0225:
0226:                // Tagged and family
0227:                assertPageLink(widgetContent, CHILD_THREE, Present);
0228:
0229:                // NOT Tagged and family
0230:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0231:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0232:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0233:            }
0234:
0235:            public void testRootNonexistentOneTag() throws Exception {
0236:
0237:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0238:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0239:                        + " . chair\n");
0240:
0241:                String widgetContent = widget.render();
0242:                verifyNonStiqTestPagesNotPresent(widgetContent);
0243:
0244:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0245:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0246:            }
0247:
0248:            public void testRootNonexistentTwoTags() throws Exception {
0249:
0250:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0251:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0252:                        + " . chair lamp\n");
0253:
0254:                String widgetContent = widget.render();
0255:                verifyNonStiqTestPagesNotPresent(widgetContent);
0256:
0257:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0258:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0259:            }
0260:
0261:            public void testRootNonexistentManyTags() throws Exception {
0262:
0263:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0264:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0265:                        + " . chair lamp vase desk\n");
0266:
0267:                String widgetContent = widget.render();
0268:                verifyNonStiqTestPagesNotPresent(widgetContent);
0269:
0270:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0271:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0272:            }
0273:
0274:            // Branch
0275:            public void testBranchOneTagOnePage() throws Exception {
0276:
0277:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0278:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0279:                        + " SecondBranch.ParentTwo green\n");
0280:
0281:                String widgetContent = widget.render();
0282:                verifyNonStiqTestPagesNotPresent(widgetContent);
0283:
0284:                // Tagged and family
0285:                assertPageLink(widgetContent, CHILD_FOUR, Present);
0286:
0287:                // NOT Tagged and NOT family
0288:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0289:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0290:                assertPageLink(widgetContent, CHILD_THREE, NotPresent);
0291:            }
0292:
0293:            public void testBranchOneTagMultiplePages() throws Exception {
0294:
0295:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0296:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0297:                        + " FirstBranch.ParentOne orange\n");
0298:
0299:                String widgetContent = widget.render();
0300:                verifyNonStiqTestPagesNotPresent(widgetContent);
0301:
0302:                // Tagged and family
0303:                assertPageLink(widgetContent, CHILD_TWO, Present);
0304:                assertPageLink(widgetContent, GRANDCHILD_ONE, Present);
0305:
0306:                // NOT Tagged and family
0307:                assertPageLink(widgetContent, CHILD_THREE, NotPresent);
0308:
0309:                // NOT Tagged and NOT family
0310:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0311:            }
0312:
0313:            public void testBranchTwoTagsOnePage() throws Exception {
0314:
0315:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0316:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0317:                        + " FirstBranch.ParentOne dog blue\n");
0318:
0319:                String widgetContent = widget.render();
0320:                verifyNonStiqTestPagesNotPresent(widgetContent);
0321:
0322:                // Tagged and family
0323:                assertPageLink(widgetContent, CHILD_THREE, Present);
0324:
0325:                // NOT Tagged and family
0326:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0327:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0328:
0329:                // NOT Tagged and NOT family
0330:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0331:            }
0332:
0333:            public void testBranchTwoTagsMultiplePages() throws Exception {
0334:
0335:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0336:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0337:                        + " FirstBranch.ParentOne Red dog\n");
0338:
0339:                String widgetContent = widget.render();
0340:                verifyNonStiqTestPagesNotPresent(widgetContent);
0341:
0342:                // Tagged and family
0343:                assertPageLink(widgetContent, CHILD_TWO, Present);
0344:                assertPageLink(widgetContent, CHILD_THREE, Present);
0345:
0346:                // NOT Tagged and family
0347:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0348:
0349:                // NOT Tagged and NOT family
0350:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0351:            }
0352:
0353:            public void testBranchManyTagsOnePage() throws Exception {
0354:
0355:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0356:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0357:                        + " FirstBranch.ParentOne green dog Red blue\n");
0358:
0359:                String widgetContent = widget.render();
0360:                verifyNonStiqTestPagesNotPresent(widgetContent);
0361:
0362:                // Tagged and family
0363:                assertPageLink(widgetContent, CHILD_THREE, Present);
0364:
0365:                // NOT Tagged and family
0366:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0367:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0368:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0369:            }
0370:
0371:            public void testBranchNonexistentOneTag() throws Exception {
0372:
0373:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0374:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0375:                        + " FirstBranch.ParentOne chair\n");
0376:
0377:                String widgetContent = widget.render();
0378:                verifyNonStiqTestPagesNotPresent(widgetContent);
0379:
0380:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0381:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0382:            }
0383:
0384:            public void testBranchNonexistentTwoTags() throws Exception {
0385:
0386:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0387:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0388:                        + " FirstBranch.ParentOne chair lamp\n");
0389:
0390:                String widgetContent = widget.render();
0391:                verifyNonStiqTestPagesNotPresent(widgetContent);
0392:
0393:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0394:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0395:            }
0396:
0397:            public void testBranchNonexistentManyTags() throws Exception {
0398:
0399:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0400:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0401:                        + " FirstBranch.ParentOne chair lamp vase desk\n");
0402:
0403:                String widgetContent = widget.render();
0404:                verifyNonStiqTestPagesNotPresent(widgetContent);
0405:
0406:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0407:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0408:            }
0409:
0410:            // Leaf
0411:            public void testLeafOneTag() throws Exception {
0412:
0413:                TagSuiteWidget widget = new TagSuiteWidget(
0414:                        new WidgetRoot(parentTwo),
0415:                        "!"
0416:                                + TagSuiteWidget.WIDGET_NAME
0417:                                + " FirstBranch.ParentOne.ChildOne.GrandchildOne orange\n");
0418:
0419:                String widgetContent = widget.render();
0420:                verifyNonStiqTestPagesNotPresent(widgetContent);
0421:
0422:                // Tagged and family
0423:                assertPageLink(widgetContent, GRANDCHILD_ONE, Present);
0424:
0425:                // Tagged and NOT family
0426:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0427:
0428:                // NOT Tagged and NOT family
0429:                assertPageLink(widgetContent, CHILD_THREE, NotPresent);
0430:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0431:            }
0432:
0433:            public void testLeafTwoTags() throws Exception {
0434:
0435:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0436:                        parentTwo), "!" + TagSuiteWidget.WIDGET_NAME
0437:                        + " SecondBranch.ParentTwo.ChildFour green Red\n");
0438:
0439:                String widgetContent = widget.render();
0440:                verifyNonStiqTestPagesNotPresent(widgetContent);
0441:
0442:                // Tagged and family
0443:                assertPageLink(widgetContent, CHILD_FOUR, Present);
0444:
0445:                // Tagged and NOT family
0446:                assertPageLink(widgetContent, CHILD_THREE, NotPresent);
0447:
0448:                // NOT Tagged and NOT family
0449:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0450:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0451:            }
0452:
0453:            public void testLeafManyTags() throws Exception {
0454:
0455:                TagSuiteWidget widget = new TagSuiteWidget(
0456:                        new WidgetRoot(parentTwo),
0457:                        "!"
0458:                                + TagSuiteWidget.WIDGET_NAME
0459:                                + " FirstBranch.ParentOne.ChildThree dog blue green Red\n");
0460:
0461:                String widgetContent = widget.render();
0462:                verifyNonStiqTestPagesNotPresent(widgetContent);
0463:
0464:                // Tagged and family
0465:                assertPageLink(widgetContent, CHILD_THREE, Present);
0466:
0467:                // NOT Tagged and NOT family
0468:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0469:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0470:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0471:            }
0472:
0473:            public void testLeafNonexistentOneTag() throws Exception {
0474:
0475:                TagSuiteWidget widget = new TagSuiteWidget(
0476:                        new WidgetRoot(parentTwo),
0477:                        "!"
0478:                                + TagSuiteWidget.WIDGET_NAME
0479:                                + " FirstBranch.ParentOne.ChildOne.GrandchildOne bear\n");
0480:
0481:                String widgetContent = widget.render();
0482:                verifyNonStiqTestPagesNotPresent(widgetContent);
0483:
0484:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0485:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0486:            }
0487:
0488:            public void testLeafNonexistentTwoTags() throws Exception {
0489:
0490:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0491:                        parentTwo), "!" + TagSuiteWidget.WIDGET_NAME
0492:                        + " FirstBranch.ParentOne.ChildThree bear chair\n");
0493:
0494:                String widgetContent = widget.render();
0495:                verifyNonStiqTestPagesNotPresent(widgetContent);
0496:
0497:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0498:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0499:            }
0500:
0501:            public void testLeafNonexistentManyTags() throws Exception {
0502:
0503:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0504:                        parentTwo), "!" + TagSuiteWidget.WIDGET_NAME
0505:                        + " FirstBranch.ParentOne.ChildThree bear hat chair\n");
0506:
0507:                String widgetContent = widget.render();
0508:                verifyNonStiqTestPagesNotPresent(widgetContent);
0509:
0510:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0511:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0512:            }
0513:
0514:            // Misc.
0515:            public void testStartPageIsNotChildOfRoot() throws Exception {
0516:
0517:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0518:                        parentTwo), "!" + TagSuiteWidget.WIDGET_NAME
0519:                        + " FirstBranch.ParentOne green\n");
0520:
0521:                String widgetContent = widget.render();
0522:                verifyNonStiqTestPagesNotPresent(widgetContent);
0523:
0524:                // Tagged and family
0525:                assertPageLink(widgetContent, CHILD_THREE, Present);
0526:
0527:                // NOT Tagged and family
0528:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0529:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0530:
0531:                // Tagged and not family
0532:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0533:            }
0534:
0535:            public void testStartPageIsChildOfRootUniqueTag() throws Exception {
0536:
0537:                // Make FirstBranch a STIQ test and tag it for this test
0538:                setSTIQTestProperty(firstBranch);
0539:                PageData data = firstBranch.getData();
0540:                data.setContent("!tag duck");
0541:                firstBranch.commit(data);
0542:
0543:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0544:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0545:                        + " FirstBranch duck\n");
0546:
0547:                String widgetContent = widget.render();
0548:                assertPageLink(widgetContent, FIRST_BRANCH, Present);
0549:
0550:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0551:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0552:                verifyPages(widgetContent, NotStiqTests, Tagged, NotPresent);
0553:
0554:                // NOT Tagged and NOT STIQ Tests and family
0555:                assertPageLink(widgetContent, ROOT, NotPresent);
0556:                assertPageLink(widgetContent, PARENT_ONE, NotPresent);
0557:                assertPageLink(widgetContent, SECOND_BRANCH, NotPresent);
0558:                assertPageLink(widgetContent, CHILD_FIVE, NotPresent);
0559:                assertPageLink(widgetContent, PARENT_FOUR, NotPresent);
0560:            }
0561:
0562:            public void testStartPageIsOnDifferentBranch() throws Exception {
0563:
0564:                // Put the widget on SecondBranch.ParentTwo.ChildFour and
0565:                // get pages using FirstBranch.ParentOne start page
0566:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0567:                        childFour), "!" + TagSuiteWidget.WIDGET_NAME
0568:                        + " FirstBranch.ParentOne.ChildThree green\n");
0569:
0570:                String widgetContent = widget.render();
0571:                verifyNonStiqTestPagesNotPresent(widgetContent);
0572:
0573:                // Tagged and family
0574:                assertPageLink(widgetContent, CHILD_THREE, Present);
0575:
0576:                // NOT Tagged and family
0577:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0578:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0579:
0580:                // Tagged and not family
0581:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0582:            }
0583:
0584:            public void testStartPageHasDotPrefix() throws Exception {
0585:
0586:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0587:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0588:                        + " .FirstBranch.ParentOne green\n");
0589:
0590:                String widgetContent = widget.render();
0591:                verifyNonStiqTestPagesNotPresent(widgetContent);
0592:
0593:                // Tagged and family
0594:                assertPageLink(widgetContent, CHILD_THREE, Present);
0595:
0596:                // NOT Tagged and family
0597:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0598:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0599:
0600:                // Tagged and not family
0601:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0602:            }
0603:
0604:            // 
0605:            // Any Tags
0606:            //
0607:            public void testAnyTagsRoot() throws Exception {
0608:
0609:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0610:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME + " . "
0611:                        + TagSuiteWidget.ANY_TAGS);
0612:
0613:                String widgetContent = widget.render();
0614:                verifyNonStiqTestPagesNotPresent(widgetContent);
0615:
0616:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0617:                verifyPages(widgetContent, StiqTests, Tagged, Present);
0618:            }
0619:
0620:            public void testAnyTagsBranch() throws Exception {
0621:
0622:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0623:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0624:                        + " FirstBranch " + TagSuiteWidget.ANY_TAGS);
0625:
0626:                String widgetContent = widget.render();
0627:                verifyNonStiqTestPagesNotPresent(widgetContent);
0628:
0629:                // NOT tagged and everywhere
0630:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0631:
0632:                // Tagged and family
0633:                assertPageLink(widgetContent, CHILD_TWO, Present);
0634:                assertPageLink(widgetContent, GRANDCHILD_ONE, Present);
0635:                assertPageLink(widgetContent, CHILD_THREE, Present);
0636:
0637:                // Tagged and NOT family
0638:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0639:            }
0640:
0641:            public void testAnyTagsLeaf() throws Exception {
0642:
0643:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0644:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0645:                        + " FirstBranch.ParentOne.ChildThree "
0646:                        + TagSuiteWidget.ANY_TAGS);
0647:
0648:                String widgetContent = widget.render();
0649:                verifyNonStiqTestPagesNotPresent(widgetContent);
0650:
0651:                // NOT Tagged and everywhere
0652:                verifyPages(widgetContent, StiqTests, NotTagged, NotPresent);
0653:
0654:                // Tagged and family
0655:                assertPageLink(widgetContent, CHILD_THREE, Present);
0656:
0657:                // Tagged and NOT family
0658:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0659:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0660:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0661:            }
0662:
0663:            //
0664:            // No Tags
0665:            //
0666:            public void testNoTagsRoot() throws Exception {
0667:
0668:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0669:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME + " . "
0670:                        + TagSuiteWidget.NO_TAGS);
0671:
0672:                String widgetContent = widget.render();
0673:                verifyNonStiqTestPagesNotPresent(widgetContent);
0674:
0675:                verifyPages(widgetContent, StiqTests, NotTagged, Present);
0676:                verifyPages(widgetContent, StiqTests, Tagged, NotPresent);
0677:            }
0678:
0679:            public void testNoTagsBranch() throws Exception {
0680:
0681:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0682:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0683:                        + " SecondBranch " + TagSuiteWidget.NO_TAGS);
0684:
0685:                String widgetContent = widget.render();
0686:                verifyNonStiqTestPagesNotPresent(widgetContent);
0687:
0688:                // NOT Tagged and family
0689:                assertPageLink(widgetContent, PARENT_THREE, Present);
0690:                assertPageLink(widgetContent, CHILD_SIX, Present);
0691:
0692:                // Tagged and family
0693:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0694:            }
0695:
0696:            public void testNoTagsLeaf() throws Exception {
0697:
0698:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0699:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0700:                        + " SecondBranch.ParentFour.ChildSix "
0701:                        + TagSuiteWidget.NO_TAGS);
0702:
0703:                String widgetContent = widget.render();
0704:                verifyNonStiqTestPagesNotPresent(widgetContent);
0705:
0706:                // NOT Tagged and family
0707:                assertPageLink(widgetContent, CHILD_SIX, Present);
0708:
0709:                // NOT Tagged and NOT family
0710:                assertPageLink(widgetContent, PARENT_THREE, NotPresent);
0711:
0712:                // Tagged and NOT family
0713:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0714:            }
0715:
0716:            //
0717:
0718:            // All Tests; union of ANY and NONE
0719:            //
0720:            public void testAllStiqTestsRoot() throws Exception {
0721:
0722:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0723:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME + " . "
0724:                        + TagSuiteWidget.ANY_TAGS + TagSuiteWidget.NO_TAGS);
0725:
0726:                String widgetContent = widget.render();
0727:                verifyNonStiqTestPagesNotPresent(widgetContent);
0728:
0729:                verifyPages(widgetContent, StiqTests, Tagged, Present);
0730:                verifyPages(widgetContent, StiqTests, NotTagged, Present);
0731:            }
0732:
0733:            //
0734:            // Display
0735:            //
0736:            public void testTitle() throws Exception {
0737:
0738:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0739:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0740:                        + " FirstBranch.ParentOne Red dog\n");
0741:
0742:                String widgetContent = widget.render();
0743:                assertTrue(widgetContent, widgetContent
0744:                        .indexOf(TagSuiteWidget.WIDGET_TITLE) != -1);
0745:            }
0746:
0747:            public void testPageName() throws Exception {
0748:
0749:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0750:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0751:                        + " FirstBranch.ParentOne Red dog\n");
0752:
0753:                String widgetContent = widget.render();
0754:                assertTrue(widgetContent, widgetContent
0755:                        .indexOf(">FirstBranch.ParentOne</span>") != -1);
0756:            }
0757:
0758:            public void testPageNameWithLeadingDot() throws Exception {
0759:
0760:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0761:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0762:                        + " .FirstBranch.ParentOne Red dog\n");
0763:
0764:                String widgetContent = widget.render();
0765:                assertTrue(widgetContent, widgetContent
0766:                        .indexOf(">.FirstBranch.ParentOne</span>") != -1);
0767:            }
0768:
0769:            public void testPageNameIsDot() throws Exception {
0770:
0771:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0772:                        parentTwo), "!" + TagSuiteWidget.WIDGET_NAME
0773:                        + " . Red dog\n");
0774:
0775:                String widgetContent = widget.render();
0776:                assertTrue(widgetContent,
0777:                        widgetContent.indexOf(">.</span>") != -1);
0778:            }
0779:
0780:            public void testInvalidTagCharacters() throws Exception {
0781:
0782:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0783:                        firstBranch), "!" + TagSuiteWidget.WIDGET_NAME
0784:                        + " . [fred]\n");
0785:                String widgetContent = widget.render();
0786:                assertTrue(widgetContent, widgetContent
0787:                        .indexOf(TagSuiteWidget.ERROR_INVALID_CHARACTERS) != -1);
0788:
0789:                widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
0790:                        + TagSuiteWidget.WIDGET_NAME + " . \\dog/\n");
0791:                widgetContent = widget.render();
0792:                assertTrue(widgetContent, widgetContent
0793:                        .indexOf(TagSuiteWidget.ERROR_INVALID_CHARACTERS) != -1);
0794:
0795:                widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
0796:                        + TagSuiteWidget.WIDGET_NAME + " . $Red%^& dog .\n");
0797:                widgetContent = widget.render();
0798:                assertTrue(widgetContent, widgetContent
0799:                        .indexOf(TagSuiteWidget.ERROR_INVALID_CHARACTERS) != -1);
0800:
0801:                widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
0802:                        + TagSuiteWidget.WIDGET_NAME + " . .\n");
0803:                widgetContent = widget.render();
0804:                assertTrue(widgetContent, widgetContent
0805:                        .indexOf(TagSuiteWidget.ERROR_INVALID_CHARACTERS) != -1);
0806:
0807:                widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
0808:                        + TagSuiteWidget.WIDGET_NAME + " . .");
0809:                widgetContent = widget.render();
0810:                assertTrue(widgetContent, widgetContent
0811:                        .indexOf(TagSuiteWidget.ERROR_INVALID_CHARACTERS) != -1);
0812:            }
0813:
0814:            //
0815:            // Parameter whitespace
0816:            //
0817:            public void testWhitespaceBeforeStartPageSpaces() throws Exception {
0818:
0819:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0820:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0821:                        + "   FirstBranch.ParentOne Red dog\n");
0822:
0823:                String widgetContent = widget.render();
0824:                assertTrue(widgetContent,
0825:                        widgetContent.indexOf(">Red</span>") != -1);
0826:                assertTrue(widgetContent,
0827:                        widgetContent.indexOf(">dog</span>") != -1);
0828:            }
0829:
0830:            public void testWhitespaceBeforeStartPageTab() throws Exception {
0831:
0832:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0833:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0834:                        + "\tFirstBranch.ParentOne Red dog\n");
0835:
0836:                String widgetContent = widget.render();
0837:                assertTrue(widgetContent,
0838:                        widgetContent.indexOf(">Red</span>") != -1);
0839:                assertTrue(widgetContent,
0840:                        widgetContent.indexOf(">dog</span>") != -1);
0841:            }
0842:
0843:            public void testWhitespaceBeforeStartPageTabAndSpaces()
0844:                    throws Exception {
0845:
0846:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0847:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0848:                        + "  \t  FirstBranch.ParentOne Red dog\n");
0849:
0850:                String widgetContent = widget.render();
0851:                assertTrue(widgetContent,
0852:                        widgetContent.indexOf(">Red</span>") != -1);
0853:                assertTrue(widgetContent,
0854:                        widgetContent.indexOf(">dog</span>") != -1);
0855:            }
0856:
0857:            public void testWhitespaceBeforeStartPageTabsAndSpaces()
0858:                    throws Exception {
0859:
0860:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0861:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0862:                        + "  \t \t FirstBranch.ParentOne Red dog\n");
0863:
0864:                String widgetContent = widget.render();
0865:                assertTrue(widgetContent,
0866:                        widgetContent.indexOf(">Red</span>") != -1);
0867:                assertTrue(widgetContent,
0868:                        widgetContent.indexOf(">dog</span>") != -1);
0869:            }
0870:
0871:            public void testWhitespaceTagSpaces() throws Exception {
0872:
0873:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0874:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0875:                        + " FirstBranch.ParentOne Red      dog\n");
0876:
0877:                String widgetContent = widget.render();
0878:                assertTrue(widgetContent,
0879:                        widgetContent.indexOf(">Red</span>") != -1);
0880:                assertTrue(widgetContent,
0881:                        widgetContent.indexOf(">dog</span>") != -1);
0882:            }
0883:
0884:            public void testWhitespaceTagTab() throws Exception {
0885:
0886:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0887:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0888:                        + " FirstBranch.ParentOne Red\tdog\n");
0889:
0890:                String widgetContent = widget.render();
0891:                assertTrue(widgetContent,
0892:                        widgetContent.indexOf(">Red</span>") != -1);
0893:                assertTrue(widgetContent,
0894:                        widgetContent.indexOf(">dog</span>") != -1);
0895:            }
0896:
0897:            public void testWhitespaceTagTabsAndSpaces() throws Exception {
0898:
0899:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0900:                        secondBranch), "!" + TagSuiteWidget.WIDGET_NAME
0901:                        + " FirstBranch.ParentOne green   dog \t Red\tblue\n");
0902:
0903:                String widgetContent = widget.render();
0904:                assertTrue(widgetContent, widgetContent
0905:                        .indexOf(">green</span>") != -1);
0906:                assertTrue(widgetContent,
0907:                        widgetContent.indexOf(">dog</span>") != -1);
0908:                assertTrue(widgetContent,
0909:                        widgetContent.indexOf(">Red</span>") != -1);
0910:                assertTrue(widgetContent,
0911:                        widgetContent.indexOf(">blue</span>") != -1);
0912:            }
0913:
0914:            //
0915:            // Widget name
0916:            //
0917:            public void testLowercaseTagName() throws Exception {
0918:
0919:                TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(
0920:                        secondBranch), "!"
0921:                        + TagSuiteWidget.WIDGET_NAME.toLowerCase()
0922:                        + " FirstBranch.ParentOne green dog Red blue\n");
0923:
0924:                String widgetContent = widget.render();
0925:                verifyNonStiqTestPagesNotPresent(widgetContent);
0926:
0927:                // Tagged and family
0928:                assertPageLink(widgetContent, CHILD_THREE, Present);
0929:
0930:                // NOT Tagged and family
0931:                assertPageLink(widgetContent, GRANDCHILD_ONE, NotPresent);
0932:                assertPageLink(widgetContent, CHILD_TWO, NotPresent);
0933:                assertPageLink(widgetContent, CHILD_FOUR, NotPresent);
0934:            }
0935:
0936:            // 
0937:            // Regex
0938:            //
0939:            public void testRegexMatch() throws Exception {
0940:                // Well formed
0941:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0942:                        + " FirstBranch.ParentOne orange\r");
0943:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0944:                        + " FirstBranch.ParentOne orange\n");
0945:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0946:                        + " FirstBranch.ParentOne orange");
0947:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0948:                        + " .FirstBranch.ParentOne.ChildOne orange");
0949:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0950:                        + " FirstBranch.ParentOne.ChildOne orange");
0951:
0952:                // Can use "." as root
0953:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME + " . orange\r");
0954:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME + " . orange\n");
0955:
0956:                // Multiple tags are separated by whitespace
0957:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0958:                        + " FirstBranch.ParentOne.ChildOne Red green\n");
0959:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0960:                        + " .FirstBranch.ParentOne.ChildOne Red green\r");
0961:
0962:                // Permit extra whitespace
0963:                assertMatches("!"
0964:                        + TagSuiteWidget.WIDGET_NAME
0965:                        + " FirstBranch.ParentOne.ChildOne Red \tgreen   blue\n");
0966:                assertMatches("!" + TagSuiteWidget.WIDGET_NAME
0967:                        + " FirstBranch.ParentOne.ChildOne Red  \t   blue\n");
0968:
0969:                // Missing required parameters
0970:                assertNoMatch("!" + TagSuiteWidget.WIDGET_NAME + "\r");
0971:                assertNoMatch("!" + TagSuiteWidget.WIDGET_NAME + "\n");
0972:                assertNoMatch("!" + TagSuiteWidget.WIDGET_NAME
0973:                        + " FirstBranch.ParentOne\n");
0974:                assertNoMatch("!" + TagSuiteWidget.WIDGET_NAME
0975:                        + " FirstBranch.ParentOne\r");
0976:
0977:                // Don't permit whitespace on the left
0978:                assertNoMatch(" !" + TagSuiteWidget.WIDGET_NAME
0979:                        + " FirstBranch.ParentOne orange\r");
0980:                assertNoMatch(" !" + TagSuiteWidget.WIDGET_NAME
0981:                        + " FirstBranch.ParentOne orange\n");
0982:                assertNoMatch(" !" + TagSuiteWidget.WIDGET_NAME
0983:                        + " FirstBranch.ParentOne.ChildOne orange\r");
0984:                assertNoMatch(" !" + TagSuiteWidget.WIDGET_NAME
0985:                        + " FirstBranch.ParentOne.ChildOne orange apple\n");
0986:            }
0987:
0988:            // 
0989:            // Utility methods
0990:            //
0991:
0992:            private void verifyNonStiqTestPagesNotPresent(String widgetContent) {
0993:                verifyPages(widgetContent, NotStiqTests, Tagged, NotPresent);
0994:                verifyPages(widgetContent, NotStiqTests, NotTagged, NotPresent);
0995:            }
0996:
0997:            private void verifyPages(String widgetContent, boolean pages,
0998:                    boolean tagging, boolean presence) {
0999:
1000:                if (pages == StiqTests) {
1001:                    if (tagging == NotTagged) {
1002:                        assertPageLink(widgetContent, PARENT_THREE, presence);
1003:                        assertPageLink(widgetContent, CHILD_SIX, presence);
1004:                    } else { // Tagged
1005:                        assertPageLink(widgetContent, CHILD_TWO, presence);
1006:                        assertPageLink(widgetContent, CHILD_THREE, presence);
1007:                        assertPageLink(widgetContent, CHILD_FOUR, presence);
1008:                        assertPageLink(widgetContent, GRANDCHILD_ONE, presence);
1009:                    }
1010:                } else { // NOT Stiq Tests
1011:                    if (tagging == NotTagged) {
1012:                        assertPageLink(widgetContent, ROOT, presence);
1013:                        assertPageLink(widgetContent, FIRST_BRANCH, presence);
1014:                        assertPageLink(widgetContent, PARENT_ONE, presence);
1015:                        assertPageLink(widgetContent, SECOND_BRANCH, presence);
1016:                        assertPageLink(widgetContent, CHILD_FIVE, presence);
1017:                        assertPageLink(widgetContent, PARENT_FOUR, presence);
1018:                    } else { // Tagged
1019:                        assertPageLink(widgetContent, CHILD_ONE, presence);
1020:                        assertPageLink(widgetContent, GRANDCHILD_TWO, presence);
1021:                        assertPageLink(widgetContent, GRANDCHILD_THREE,
1022:                                presence);
1023:                        assertPageLink(widgetContent, PARENT_TWO, presence);
1024:                    }
1025:                }
1026:            }
1027:
1028:            private void assertPageLink(String widgetContent, String page,
1029:                    boolean isPresent) {
1030:                assertTrue(
1031:                        widgetContent,
1032:                        ((widgetContent.indexOf(getRenderedPageLink(page)) != -1) == isPresent));
1033:                // should be only be one instance
1034:                if (isPresent) {
1035:                    assertTrue(
1036:                            widgetContent,
1037:                            (widgetContent.indexOf(getRenderedPageLink(page)) == (widgetContent
1038:                                    .lastIndexOf(getRenderedPageLink(page)))));
1039:                }
1040:            }
1041:
1042:            private String getRenderedPageLink(String page) {
1043:                return page + "</a>";
1044:            }
1045:
1046:            private WikiPage setSTIQTestProperty(WikiPage page)
1047:                    throws Exception {
1048:                PageData pageDataToModify = page.getData();
1049:                pageDataToModify.getProperties().set(WikiPage.STIQ_TEST);
1050:                page.commit(pageDataToModify);
1051:                assertTrue(page.isSTIQTest());
1052:                return page;
1053:            }
1054:
1055:            protected String getRegexp() {
1056:                return TagSuiteWidget.REGEXP;
1057:            }
1058:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.