01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.wiki;
04:
05: import junit.framework.*;
06:
07: import fitnesse.testutil.FitNesseUtil;
08:
09: public class VirtualEnabledPageCrawlerTest extends TestCase {
10: private WikiPage root;
11:
12: private WikiPage target;
13:
14: private WikiPage vlink;
15:
16: private WikiPage child1;
17:
18: private PageCrawler crawler;
19:
20: private WikiPagePath child1Path = PathParser.parse("ChildOne");
21:
22: public void setUp() throws Exception {
23: root = InMemoryPage.makeRoot("RooT");
24: crawler = root.getPageCrawler();
25: crawler.setDeadEndStrategy(new VirtualEnabledPageCrawler());
26: target = crawler.addPage(root, PathParser.parse("TargetPage"));
27: vlink = crawler.addPage(root, PathParser.parse("VirtualLink"));
28: child1 = crawler.addPage(target, child1Path);
29: crawler.addPage(child1, PathParser.parse("GrandChildOne"));
30: FitNesseUtil.bindVirtualLinkToPage(vlink, target);
31: }
32:
33: public void tearDown() throws Exception {
34: }
35:
36: public void testCanCrossVirtualLink() throws Exception {
37: WikiPage virtualChild = crawler.getPage(vlink, child1Path);
38: assertNotNull(virtualChild);
39: assertEquals("ChildOne", virtualChild.getName());
40: assertNotNull(crawler.getPage(vlink, PathParser
41: .parse("ChildOne.GrandChildOne")));
42: }
43:
44: public void testCanCrossMultipleVirtualLinks() throws Exception {
45: WikiPage secondTarget = crawler.addPage(root, PathParser
46: .parse("SecondTarget"));
47: crawler.addPage(secondTarget, PathParser
48: .parse("ChildOfSecondTarget"));
49: FitNesseUtil.bindVirtualLinkToPage(child1, secondTarget);
50: WikiPage virtualChild = crawler.getPage(vlink, PathParser
51: .parse("ChildOne.ChildOfSecondTarget"));
52: assertNotNull(virtualChild);
53: assertEquals("ChildOfSecondTarget", virtualChild.getName());
54: }
55:
56: public void testThatVirtualCylcesTerminate() throws Exception {
57: FitNesseUtil.bindVirtualLinkToPage(child1, target); // Cycle.
58: WikiPage virtualChild = crawler.getPage(vlink, PathParser
59: .parse("ChildOne.ChildOne.ChildOne.ChildOne.ChildOne"));
60: assertNotNull(virtualChild);
61: }
62:
63: public void testFullyQualifiedNameUsesVirtualParent()
64: throws Exception {
65: WikiPage virtualChildPage = crawler.getPage(vlink, child1Path);
66: WikiPagePath virtualChildFullPath = PathParser
67: .parse("VirtualLink.ChildOne");
68: assertEquals(virtualChildFullPath, crawler
69: .getFullPath(virtualChildPage));
70: }
71: }
|