Source Code Cross Referenced for TagManagerTest.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:        package fitnesse.wikitext;
002:
003:        import java.util.Set;
004:
005:        import fitnesse.components.TagManager;
006:        import fitnesse.wiki.InMemoryPage;
007:        import fitnesse.wiki.PageCrawler;
008:        import fitnesse.wiki.PageData;
009:        import fitnesse.wiki.PathParser;
010:        import fitnesse.wiki.WikiPage;
011:        import fitnesse.wikitext.widgets.AbstractWidget;
012:        import fitnesse.wikitext.widgets.TagSuiteWidget;
013:
014:        public abstract class TagManagerTest extends AbstractWidget {
015:            protected static final boolean StiqTests = true;
016:
017:            protected static final boolean NotStiqTests = false;
018:
019:            protected static final boolean Tagged = true;
020:
021:            protected static final boolean NotTagged = false;
022:
023:            protected static final boolean Present = true;
024:
025:            protected static final boolean NotPresent = false;
026:
027:            private static final String PARENT_THREE = "ParentThree";
028:
029:            private static final String CHILD_SIX = "ChildSix";
030:
031:            private static final String CHILD_FOUR = "ChildFour";
032:
033:            private static final String CHILD_THREE = "ChildThree";
034:
035:            private static final String CHILD_TWO = "ChildTwo";
036:
037:            private static final String GRANDCHILD_ONE = "GrandchildOne";
038:
039:            private static final String ROOT = "RooT";
040:
041:            private static final String PARENT_TWO = "ParentTwo";
042:
043:            private static final String GRANDCHILD_THREE = "GrandchildThree";
044:
045:            private static final String GRANDCHILD_TWO = "GrandchildTwo";
046:
047:            private static final String CHILD_ONE = "ChildOne";
048:
049:            private static final String PARENT_ONE = "ParentOne";
050:
051:            private static final String FIRST_BRANCH = "FirstBranch";
052:
053:            private static final String SECOND_BRANCH = "SecondBranch";
054:
055:            private static final String CHILD_FIVE = "ChildFive";
056:
057:            private static final String PARENT_FOUR = "ParentFour";
058:
059:            private PageCrawler crawler;
060:
061:            protected WikiPage root;
062:
063:            protected WikiPage firstBranch;
064:
065:            protected WikiPage secondBranch;
066:
067:            protected WikiPage parentOne;
068:
069:            protected WikiPage parentTwo;
070:
071:            protected WikiPage parentThree;
072:
073:            protected WikiPage parentFour;
074:
075:            protected WikiPage childFour;
076:
077:            protected WikiPage childTwo;
078:
079:            protected WikiPage childOne;
080:
081:            protected WikiPage grandChildOne;
082:
083:            protected WikiPage grandChildTwo;
084:
085:            protected WikiPage childThree;
086:
087:            protected WikiPage childSix;
088:
089:            protected WikiPage childFive;
090:
091:            protected WikiPage grandChildThree;
092:
093:            protected TagManager tagManager;
094:
095:            abstract protected TagManager createTagManager();
096:
097:            public void setUp() throws Exception {
098:                tagManager = createTagManager();
099:                tagManager.clearIndex();
100:                root = InMemoryPage.makeRoot(ROOT);
101:                crawler = root.getPageCrawler();
102:
103:                firstBranch = crawler.addPage(root, PathParser
104:                        .parse(FIRST_BRANCH), "branch");
105:                parentOne = crawler.addPage(firstBranch, PathParser
106:                        .parse(PARENT_ONE), "parent");
107:
108:                childOne = crawler.addPage(parentOne, PathParser
109:                        .parse(CHILD_ONE), "stuff\n!tag orange");
110:                grandChildOne = crawler.addPage(childOne, PathParser
111:                        .parse(GRANDCHILD_ONE), "stuff\n!tag orange");
112:                setSTIQTestProperty(grandChildOne);
113:                grandChildTwo = crawler.addPage(childOne, PathParser
114:                        .parse(GRANDCHILD_TWO), "!tag orange Red");
115:
116:                childTwo = setSTIQTestProperty(crawler.addPage(parentOne,
117:                        PathParser.parse(CHILD_TWO),
118:                        "!tag Red dog orange Cat\n some text"));
119:                grandChildThree = crawler.addPage(childTwo, PathParser
120:                        .parse(GRANDCHILD_THREE), "!tag blue orange");
121:
122:                childThree = setSTIQTestProperty(crawler.addPage(parentOne,
123:                        PathParser.parse(CHILD_THREE),
124:                        "stuff\n!tag dog green blue Red"));
125:
126:                secondBranch = crawler.addPage(root, PathParser
127:                        .parse(SECOND_BRANCH), "branch");
128:                parentTwo = crawler.addPage(secondBranch, PathParser
129:                        .parse(PARENT_TWO), "!tag green");
130:                childFour = setSTIQTestProperty(crawler.addPage(parentTwo,
131:                        PathParser.parse(CHILD_FOUR), "!tag blue Red green"));
132:
133:                parentThree = setSTIQTestProperty(crawler.addPage(secondBranch,
134:                        PathParser.parse(PARENT_THREE), ""));
135:                childFive = crawler.addPage(parentThree, PathParser
136:                        .parse(CHILD_FIVE), "");
137:                parentFour = crawler.addPage(secondBranch, PathParser
138:                        .parse(PARENT_FOUR), "");
139:                childSix = setSTIQTestProperty(crawler.addPage(parentFour,
140:                        PathParser.parse(CHILD_SIX), ""));
141:
142:                // RooT
143:                // > FirstBranch
144:                // > > ParentOne
145:                // > > > ChildOne [orange]
146:                // > > > > GrandchildOne [orange] STIQ
147:                // > > > > GrandchildTwo [orange Red]
148:                // > > > ChildTwo [Red dog orange Cat] STIQ
149:                // > > > > GrandchildThree [blue orange]
150:                // > > > > ChildThree [dog green blue Red] STIQ
151:                // > SecondBranch
152:                // > > ParentTwo [green]
153:                // > > > ChildFour [blue Red green] STIQ
154:                // > > ParentThree STIQ
155:                // > > > ChildFive
156:                // > > ParentFour
157:                // > > > ChildSix STIQ
158:            }
159:
160:            // 
161:            // Start Page
162:            //
163:
164:            // Root
165:            public void testRootOneTagOnePage() throws Exception {
166:
167:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
168:                // + TagSuiteWidget.WIDGET_NAME + " . Cat\n");
169:                Set pageSet = tagManager.pagesForTags(root,
170:                        new String[] { "Cat" }, false, false);
171:
172:                verifyPages(pageSet, NotStiqTests, Tagged, NotPresent);
173:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
174:
175:                // Tagged and family
176:                assertPageLink(pageSet, childTwo, Present);
177:
178:                // NOT Tagged and family
179:                assertPageLink(pageSet, childThree, NotPresent);
180:                assertPageLink(pageSet, childFour, NotPresent);
181:                assertPageLink(pageSet, grandChildOne, NotPresent);
182:            }
183:
184:            public void testRootOneTagMultiplePages() throws Exception {
185:
186:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
187:                // + TagSuiteWidget.WIDGET_NAME + " . orange\n");
188:                Set pageSet = tagManager.pagesForTags(root,
189:                        new String[] { "orange" }, false, false);
190:                verifyNonStiqTestPagesNotPresent(pageSet);
191:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
192:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
193:
194:                // Tagged and family
195:                assertPageLink(pageSet, childTwo, Present);
196:                assertPageLink(pageSet, grandChildOne, Present);
197:
198:                // NOT Tagged and family
199:                assertPageLink(pageSet, childThree, NotPresent);
200:                assertPageLink(pageSet, childFour, NotPresent);
201:            }
202:
203:            public void testRootTwoTagsMultiplePages() throws Exception {
204:
205:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
206:                // + TagSuiteWidget.WIDGET_NAME + " . blue green\n");
207:                Set pageSet = tagManager.pagesForTags(root, new String[] {
208:                        "blue", "green" }, false, false);
209:                verifyNonStiqTestPagesNotPresent(pageSet);
210:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
211:
212:                // Tagged and family
213:                assertPageLink(pageSet, childThree, Present);
214:                assertPageLink(pageSet, childFour, Present);
215:
216:                // NOT Tagged and family
217:                assertPageLink(pageSet, childTwo, NotPresent);
218:                assertPageLink(pageSet, grandChildOne, NotPresent);
219:            }
220:
221:            public void testRootTwoTagsOnePage() throws Exception {
222:
223:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
224:                // + TagSuiteWidget.WIDGET_NAME + " . Cat Red\n");
225:                Set pageSet = tagManager.pagesForTags(root, new String[] {
226:                        "Cat", "Red" }, false, false);
227:                verifyNonStiqTestPagesNotPresent(pageSet);
228:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
229:
230:                // Tagged and family
231:                assertPageLink(pageSet, childTwo, Present);
232:
233:                // NOT Tagged and family
234:                assertPageLink(pageSet, childThree, NotPresent);
235:                assertPageLink(pageSet, grandChildOne, NotPresent);
236:                assertPageLink(pageSet, childFour, NotPresent);
237:            }
238:
239:            public void testRootManyTagsOnePage() throws Exception {
240:
241:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
242:                // + TagSuiteWidget.WIDGET_NAME + " . green dog Red blue\n");
243:                Set pageSet = tagManager.pagesForTags(root, new String[] {
244:                        "green", "dog", "Red", "blue" }, false, false);
245:                verifyNonStiqTestPagesNotPresent(pageSet);
246:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
247:
248:                // Tagged and family
249:                assertPageLink(pageSet, childThree, Present);
250:
251:                // NOT Tagged and family
252:                assertPageLink(pageSet, childTwo, NotPresent);
253:                assertPageLink(pageSet, grandChildOne, NotPresent);
254:                assertPageLink(pageSet, childFour, NotPresent);
255:            }
256:
257:            public void testRootNonexistentOneTag() throws Exception {
258:
259:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
260:                // + TagSuiteWidget.WIDGET_NAME + " . chair\n");
261:                Set pageSet = tagManager.pagesForTags(root,
262:                        new String[] { "chair" }, false, false);
263:
264:                verifyNonStiqTestPagesNotPresent(pageSet);
265:
266:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
267:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
268:            }
269:
270:            public void testRootNonexistentTwoTags() throws Exception {
271:
272:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
273:                // + TagSuiteWidget.WIDGET_NAME + " . chair lamp\n");
274:                Set pageSet = tagManager.pagesForTags(root, new String[] {
275:                        "chair", "lamp" }, false, false);
276:
277:                verifyNonStiqTestPagesNotPresent(pageSet);
278:
279:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
280:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
281:            }
282:
283:            public void testRootNonexistentManyTags() throws Exception {
284:
285:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
286:                // + TagSuiteWidget.WIDGET_NAME + " . chair lamp vase desk\n");
287:                Set pageSet = tagManager.pagesForTags(root, new String[] {
288:                        "chair", "lamp", "vase", "desk" }, false, false);
289:
290:                verifyNonStiqTestPagesNotPresent(pageSet);
291:
292:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
293:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
294:            }
295:
296:            // Branch
297:            public void testBranchOneTagOnePage() throws Exception {
298:
299:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
300:                // + TagSuiteWidget.WIDGET_NAME + " SecondBranch.ParentTwo green\n");
301:
302:                Set pageSet = tagManager.pagesForTags(parentTwo,
303:                        new String[] { "green" }, false, false);
304:                verifyNonStiqTestPagesNotPresent(pageSet);
305:
306:                // Tagged and family
307:                assertPageLink(pageSet, childFour, Present);
308:
309:                // NOT Tagged and NOT family
310:                assertPageLink(pageSet, childTwo, NotPresent);
311:                assertPageLink(pageSet, grandChildOne, NotPresent);
312:                assertPageLink(pageSet, childThree, NotPresent);
313:            }
314:
315:            public void testBranchOneTagMultiplePages() throws Exception {
316:
317:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
318:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne orange\n");
319:                Set pageSet = tagManager.pagesForTags(parentOne,
320:                        new String[] { "orange" }, false, false);
321:
322:                verifyNonStiqTestPagesNotPresent(pageSet);
323:
324:                // Tagged and family
325:                assertPageLink(pageSet, childTwo, Present);
326:                assertPageLink(pageSet, grandChildOne, Present);
327:
328:                // NOT Tagged and family
329:                assertPageLink(pageSet, childThree, NotPresent);
330:
331:                // NOT Tagged and NOT family
332:                assertPageLink(pageSet, childFour, NotPresent);
333:            }
334:
335:            public void testBranchTwoTagsOnePage() throws Exception {
336:
337:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
338:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne dog blue\n");
339:                Set pageSet = tagManager.pagesForTags(parentOne, new String[] {
340:                        "dog", "blue" }, false, false);
341:
342:                verifyNonStiqTestPagesNotPresent(pageSet);
343:
344:                // Tagged and family
345:                assertPageLink(pageSet, childThree, Present);
346:
347:                // NOT Tagged and family
348:                assertPageLink(pageSet, childTwo, NotPresent);
349:                assertPageLink(pageSet, grandChildOne, NotPresent);
350:
351:                // NOT Tagged and NOT family
352:                assertPageLink(pageSet, childFour, NotPresent);
353:            }
354:
355:            public void testBranchTwoTagsMultiplePages() throws Exception {
356:
357:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
358:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne Red dog\n");
359:                Set pageSet = tagManager.pagesForTags(parentOne, new String[] {
360:                        "Red", "dog" }, false, false);
361:
362:                verifyNonStiqTestPagesNotPresent(pageSet);
363:
364:                // Tagged and family
365:                assertPageLink(pageSet, childTwo, Present);
366:                assertPageLink(pageSet, childThree, Present);
367:
368:                // NOT Tagged and family
369:                assertPageLink(pageSet, grandChildOne, NotPresent);
370:
371:                // NOT Tagged and NOT family
372:                assertPageLink(pageSet, childFour, NotPresent);
373:            }
374:
375:            public void testBranchManyTagsOnePage() throws Exception {
376:
377:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
378:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne green dog Red blue\n");
379:
380:                Set pageSet = tagManager.pagesForTags(parentOne, new String[] {
381:                        "green", "dog", "Red", "blue" }, false, false);
382:                verifyNonStiqTestPagesNotPresent(pageSet);
383:
384:                // Tagged and family
385:                assertPageLink(pageSet, childThree, Present);
386:
387:                // NOT Tagged and family
388:                assertPageLink(pageSet, grandChildOne, NotPresent);
389:                assertPageLink(pageSet, childTwo, NotPresent);
390:                assertPageLink(pageSet, childFour, NotPresent);
391:            }
392:
393:            public void testBranchNonexistentOneTag() throws Exception {
394:
395:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
396:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne chair\n");
397:
398:                Set pageSet = tagManager.pagesForTags(parentOne,
399:                        new String[] { "chair" }, false, false);
400:                verifyNonStiqTestPagesNotPresent(pageSet);
401:
402:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
403:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
404:            }
405:
406:            public void testBranchNonexistentTwoTags() throws Exception {
407:
408:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
409:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne chair lamp\n");
410:
411:                Set pageSet = tagManager.pagesForTags(parentOne, new String[] {
412:                        "chair", "lamp" }, false, false);
413:                verifyNonStiqTestPagesNotPresent(pageSet);
414:
415:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
416:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
417:            }
418:
419:            public void testBranchNonexistentManyTags() throws Exception {
420:
421:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
422:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne chair lamp vase desk\n");
423:
424:                Set pageSet = tagManager.pagesForTags(parentOne, new String[] {
425:                        "chair", "lamp", "vase", "desk" }, false, false);
426:                verifyNonStiqTestPagesNotPresent(pageSet);
427:
428:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
429:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
430:            }
431:
432:            // Leaf
433:            public void testLeafOneTag() throws Exception {
434:
435:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(parentTwo), "!"
436:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne.ChildOne.GrandchildOne orange\n");
437:
438:                Set pageSet = tagManager.pagesForTags(grandChildOne,
439:                        new String[] { "orange" }, false, false);
440:
441:                verifyNonStiqTestPagesNotPresent(pageSet);
442:
443:                // Tagged and family
444:                assertPageLink(pageSet, grandChildOne, Present);
445:
446:                // Tagged and NOT family
447:                assertPageLink(pageSet, childTwo, NotPresent);
448:
449:                // NOT Tagged and NOT family
450:                assertPageLink(pageSet, childThree, NotPresent);
451:                assertPageLink(pageSet, childFour, NotPresent);
452:            }
453:
454:            public void testLeafTwoTags() throws Exception {
455:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(parentTwo), "!"
456:                // + TagSuiteWidget.WIDGET_NAME + " SecondBranch.ParentTwo.ChildFour green Red\n");
457:                Set pageSet = tagManager.pagesForTags(childFour, new String[] {
458:                        "green", "Red" }, false, false);
459:
460:                verifyNonStiqTestPagesNotPresent(pageSet);
461:
462:                // Tagged and family
463:                assertPageLink(pageSet, childFour, Present);
464:
465:                // Tagged and NOT family
466:                assertPageLink(pageSet, childThree, NotPresent);
467:
468:                // NOT Tagged and NOT family
469:                assertPageLink(pageSet, childTwo, NotPresent);
470:                assertPageLink(pageSet, grandChildOne, NotPresent);
471:            }
472:
473:            public void testLeafManyTags() throws Exception {
474:
475:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(parentTwo), "!"
476:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne.ChildThree dog blue green Red\n");
477:                Set pageSet = tagManager.pagesForTags(childThree, new String[] {
478:                        "dog", "blue", "green", "Red" }, false, false);
479:                verifyNonStiqTestPagesNotPresent(pageSet);
480:
481:                // Tagged and family
482:                assertPageLink(pageSet, childThree, Present);
483:
484:                // NOT Tagged and NOT family
485:                assertPageLink(pageSet, childTwo, NotPresent);
486:                assertPageLink(pageSet, grandChildOne, NotPresent);
487:                assertPageLink(pageSet, childFour, NotPresent);
488:            }
489:
490:            public void testLeafNonexistentOneTag() throws Exception {
491:
492:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(parentTwo), "!"
493:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne.ChildOne.GrandchildOne bear\n");
494:                Set pageSet = tagManager.pagesForTags(grandChildOne,
495:                        new String[] { "bear" }, false, false);
496:                verifyNonStiqTestPagesNotPresent(pageSet);
497:
498:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
499:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
500:            }
501:
502:            public void testLeafNonexistentTwoTags() throws Exception {
503:
504:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(parentTwo), "!"
505:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne.ChildThree bear chair\n");
506:                Set pageSet = tagManager.pagesForTags(childThree, new String[] {
507:                        "bear", "chair" }, false, false);
508:
509:                verifyNonStiqTestPagesNotPresent(pageSet);
510:
511:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
512:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
513:            }
514:
515:            public void testLeafNonexistentManyTags() throws Exception {
516:
517:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(parentTwo), "!"
518:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne.ChildThree bear hat chair\n");
519:                Set pageSet = tagManager.pagesForTags(childThree, new String[] {
520:                        "bear", "hat", "chair" }, false, false);
521:                verifyNonStiqTestPagesNotPresent(pageSet);
522:
523:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
524:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
525:            }
526:
527:            // Misc.
528:            public void testStartPageIsNotChildOfRoot() throws Exception {
529:
530:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(parentTwo), "!"
531:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne green\n");
532:                Set pageSet = tagManager.pagesForTags(parentOne,
533:                        new String[] { "green" }, false, false);
534:                verifyNonStiqTestPagesNotPresent(pageSet);
535:
536:                // Tagged and family
537:                assertPageLink(pageSet, childThree, Present);
538:
539:                // NOT Tagged and family
540:                assertPageLink(pageSet, childTwo, NotPresent);
541:                assertPageLink(pageSet, grandChildOne, NotPresent);
542:
543:                // Tagged and not family
544:                assertPageLink(pageSet, childFour, NotPresent);
545:            }
546:
547:            public void testStartPageIsChildOfRootUniqueTag() throws Exception {
548:
549:                // Make FirstBranch a STIQ test and tag it for this test
550:                setSTIQTestProperty(firstBranch);
551:                PageData data = firstBranch.getData();
552:                data.setContent("!tag duck");
553:                firstBranch.commit(data);
554:
555:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
556:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch duck\n");
557:                Set pageSet = tagManager.pagesForTags(firstBranch,
558:                        new String[] { "duck" }, false, false);
559:                assertPageLink(pageSet, firstBranch, Present);
560:
561:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
562:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
563:                verifyPages(pageSet, NotStiqTests, Tagged, NotPresent);
564:
565:                // NOT Tagged and NOT STIQ Tests and family
566:                assertPageLink(pageSet, root, NotPresent);
567:                assertPageLink(pageSet, parentOne, NotPresent);
568:                assertPageLink(pageSet, secondBranch, NotPresent);
569:                assertPageLink(pageSet, childFive, NotPresent);
570:                assertPageLink(pageSet, parentFour, NotPresent);
571:            }
572:
573:            public void testStartPageIsOnDifferentBranch() throws Exception {
574:
575:                // Put the widget on SecondBranch.ParentTwo.ChildFour and
576:                // get pages using FirstBranch.ParentOne start page
577:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(childFour), "!"
578:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne.ChildThree green\n");
579:                Set pageSet = tagManager.pagesForTags(childThree,
580:                        new String[] { "green" }, false, false);
581:                verifyNonStiqTestPagesNotPresent(pageSet);
582:
583:                // Tagged and family
584:                assertPageLink(pageSet, childThree, Present);
585:
586:                // NOT Tagged and family
587:                assertPageLink(pageSet, childTwo, NotPresent);
588:                assertPageLink(pageSet, grandChildOne, NotPresent);
589:
590:                // Tagged and not family
591:                assertPageLink(pageSet, childFour, NotPresent);
592:            }
593:
594:            public void testStartPageHasDotPrefix() throws Exception {
595:
596:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
597:                // + TagSuiteWidget.WIDGET_NAME + " .FirstBranch.ParentOne green\n");
598:                Set pageSet = tagManager.pagesForTags(parentOne,
599:                        new String[] { "green" }, false, false);
600:
601:                verifyNonStiqTestPagesNotPresent(pageSet);
602:
603:                // Tagged and family
604:                assertPageLink(pageSet, childThree, Present);
605:
606:                // NOT Tagged and family
607:                assertPageLink(pageSet, childTwo, NotPresent);
608:                assertPageLink(pageSet, grandChildOne, NotPresent);
609:
610:                // Tagged and not family
611:                assertPageLink(pageSet, childFour, NotPresent);
612:            }
613:
614:            //
615:            // Any Tags
616:            //
617:            public void testAnyTagsRoot() throws Exception {
618:
619:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
620:                // + TagSuiteWidget.WIDGET_NAME + " . " + TagSuiteWidget.ANY_TAGS);
621:                Set pageSet = tagManager.pagesForTags(root,
622:                        new String[] { TagSuiteWidget.ANY_TAGS }, true, false);
623:                verifyNonStiqTestPagesNotPresent(pageSet);
624:
625:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
626:                verifyPages(pageSet, StiqTests, Tagged, Present);
627:            }
628:
629:            public void testAnyTagsBranch() throws Exception {
630:
631:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
632:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch " + TagSuiteWidget.ANY_TAGS);
633:                Set pageSet = tagManager.pagesForTags(firstBranch,
634:                        new String[] { TagSuiteWidget.ANY_TAGS }, true, false);
635:                verifyNonStiqTestPagesNotPresent(pageSet);
636:
637:                // NOT tagged and everywhere
638:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
639:
640:                // Tagged and family
641:                assertPageLink(pageSet, childTwo, Present);
642:                assertPageLink(pageSet, grandChildOne, Present);
643:                assertPageLink(pageSet, childThree, Present);
644:
645:                // Tagged and NOT family
646:                assertPageLink(pageSet, childFour, NotPresent);
647:            }
648:
649:            public void testAnyTagsLeaf() throws Exception {
650:
651:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(secondBranch), "!"
652:                // + TagSuiteWidget.WIDGET_NAME + " FirstBranch.ParentOne.ChildThree " + TagSuiteWidget.ANY_TAGS);
653:                Set pageSet = tagManager.pagesForTags(childThree,
654:                        new String[] { TagSuiteWidget.ANY_TAGS }, true, false);
655:                verifyNonStiqTestPagesNotPresent(pageSet);
656:
657:                // NOT Tagged and everywhere
658:                verifyPages(pageSet, StiqTests, NotTagged, NotPresent);
659:
660:                // Tagged and family
661:                assertPageLink(pageSet, childThree, Present);
662:
663:                // Tagged and NOT family
664:                assertPageLink(pageSet, childTwo, NotPresent);
665:                assertPageLink(pageSet, grandChildOne, NotPresent);
666:                assertPageLink(pageSet, childFour, NotPresent);
667:            }
668:
669:            //
670:            // No Tags
671:            //
672:            public void testNoTagsRoot() throws Exception {
673:
674:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
675:                // + TagSuiteWidget.WIDGET_NAME + " . " + TagSuiteWidget.NO_TAGS);
676:                Set pageSet = tagManager.pagesForTags(root,
677:                        new String[] { TagSuiteWidget.NO_TAGS }, false, true);
678:                verifyNonStiqTestPagesNotPresent(pageSet);
679:
680:                verifyPages(pageSet, StiqTests, NotTagged, Present);
681:                verifyPages(pageSet, StiqTests, Tagged, NotPresent);
682:            }
683:
684:            public void testNoTagsBranch() throws Exception {
685:
686:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
687:                // + TagSuiteWidget.WIDGET_NAME + " SecondBranch " + TagSuiteWidget.NO_TAGS);
688:                Set pageSet = tagManager.pagesForTags(secondBranch,
689:                        new String[] { TagSuiteWidget.NO_TAGS }, false, true);
690:                verifyNonStiqTestPagesNotPresent(pageSet);
691:
692:                // NOT Tagged and family
693:                assertPageLink(pageSet, parentThree, Present);
694:                assertPageLink(pageSet, childSix, Present);
695:
696:                // Tagged and family
697:                assertPageLink(pageSet, childFour, NotPresent);
698:            }
699:
700:            public void testNoTagsLeaf() throws Exception {
701:
702:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
703:                // + TagSuiteWidget.WIDGET_NAME + " SecondBranch.ParentFour.ChildSix " + TagSuiteWidget.NO_TAGS);
704:                Set pageSet = tagManager.pagesForTags(childSix,
705:                        new String[] { TagSuiteWidget.NO_TAGS }, false, true);
706:                verifyNonStiqTestPagesNotPresent(pageSet);
707:
708:                // NOT Tagged and family
709:                assertPageLink(pageSet, childSix, Present);
710:
711:                // NOT Tagged and NOT family
712:                assertPageLink(pageSet, parentThree, NotPresent);
713:
714:                // Tagged and NOT family
715:                assertPageLink(pageSet, childFour, NotPresent);
716:            }
717:
718:            // All Tests; union of ANY and NONE
719:            //
720:            public void testAllStiqTestsRoot() throws Exception {
721:
722:                // TagSuiteWidget widget = new TagSuiteWidget(new WidgetRoot(firstBranch), "!"
723:                // + TagSuiteWidget.WIDGET_NAME + " . " + TagSuiteWidget.ANY_TAGS + TagSuiteWidget.NO_TAGS);
724:                Set pageSet = tagManager.pagesForTags(root,
725:                        new String[] { TagSuiteWidget.NO_TAGS }, true, true);
726:
727:                verifyNonStiqTestPagesNotPresent(pageSet);
728:
729:                verifyPages(pageSet, StiqTests, Tagged, Present);
730:                verifyPages(pageSet, StiqTests, NotTagged, Present);
731:            }
732:
733:            // 
734:            // Utility methods
735:            //
736:
737:            private void verifyNonStiqTestPagesNotPresent(Set pages)
738:                    throws Exception {
739:                verifyPages(pages, NotStiqTests, Tagged, NotPresent);
740:                verifyPages(pages, NotStiqTests, NotTagged, NotPresent);
741:            }
742:
743:            protected void verifyPages(Set pageSet, boolean pages,
744:                    boolean tagging, boolean presence) throws Exception {
745:
746:                if (pages == StiqTests) {
747:                    if (tagging == NotTagged) {
748:                        assertPageLink(pageSet, parentThree, presence);
749:                        assertPageLink(pageSet, childSix, presence);
750:                    } else { // Tagged
751:                        assertPageLink(pageSet, childTwo, presence);
752:                        assertPageLink(pageSet, childThree, presence);
753:                        assertPageLink(pageSet, childFour, presence);
754:                        assertPageLink(pageSet, grandChildOne, presence);
755:                    }
756:                } else { // NOT Stiq Tests
757:                    if (tagging == NotTagged) {
758:                        assertPageLink(pageSet, root, presence);
759:                        assertPageLink(pageSet, firstBranch, presence);
760:                        assertPageLink(pageSet, parentOne, presence);
761:                        assertPageLink(pageSet, secondBranch, presence);
762:                        assertPageLink(pageSet, childFive, presence);
763:                        assertPageLink(pageSet, parentFour, presence);
764:                    } else { // Tagged
765:                        assertPageLink(pageSet, childOne, presence);
766:                        assertPageLink(pageSet, grandChildTwo, presence);
767:                        assertPageLink(pageSet, grandChildThree, presence);
768:                        assertPageLink(pageSet, parentTwo, presence);
769:                    }
770:                }
771:            }
772:
773:            protected void assertPageLink(Set pages, WikiPage page,
774:                    boolean isPresent) throws Exception {
775:                if (isPresent) {
776:                    assertPagePresent(pages, page);
777:                } else {
778:                    assertPageNotPresent(pages, page);
779:                }
780:            }
781:
782:            private void assertPageNotPresent(Set pages, WikiPage page)
783:                    throws Exception {
784:                assertTrue("Page " + page.getName() + " Not Present", !pages
785:                        .contains(page));
786:            }
787:
788:            private void assertPagePresent(Set pages, WikiPage page)
789:                    throws Exception {
790:                assertTrue("Page " + page.getName() + " Present", pages
791:                        .contains(page));
792:            }
793:
794:            private WikiPage setSTIQTestProperty(WikiPage page)
795:                    throws Exception {
796:                PageData pageDataToModify = page.getData();
797:                pageDataToModify.getProperties().set(WikiPage.STIQ_TEST);
798:                page.commit(pageDataToModify);
799:                assertTrue(page.isSTIQTest());
800:                return page;
801:            }
802:
803:            protected String getRegexp() {
804:                return TagSuiteWidget.REGEXP;
805:            }
806:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.