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.TestCase;
06: import java.util.List;
07:
08: public class BaseWikiPageTest extends TestCase {
09: private BaseWikiPage root;
10:
11: private WikiPage linkingPage;
12:
13: public void setUp() throws Exception {
14: root = (BaseWikiPage) InMemoryPage.makeRoot("RooT");
15: root.addChildPage("LinkedPage");
16: linkingPage = root.addChildPage("LinkingPage");
17: linkingPage.addChildPage("ChildPage");
18: }
19:
20: public void testGetChildrenUsesSymbolicPages() throws Exception {
21: createLink();
22:
23: List children = linkingPage.getChildren();
24: assertEquals(2, children.size());
25: assertEquals("ChildPage", ((WikiPage) children.get(0))
26: .getName());
27:
28: checkSymbolicPage(children.get(1));
29: }
30:
31: public void testgetChildUsesSymbolicPages() throws Exception {
32: createLink();
33: checkSymbolicPage(linkingPage.getChildPage("SymLink"));
34: }
35:
36: private void createLink() throws Exception {
37: PageData data = linkingPage.getData();
38: WikiPageProperties properties = data.getProperties();
39: properties.addSymbolicLink("SymLink", PathParser
40: .parse("LinkedPage"));
41: linkingPage.commit(data);
42: }
43:
44: private void checkSymbolicPage(Object page) throws Exception {
45: assertEquals(SymbolicPage.class, page.getClass());
46: SymbolicPage symPage = (SymbolicPage) page;
47: assertEquals("SymLink", symPage.getName());
48: assertEquals("LinkedPage", symPage.getRealPage().getName());
49: }
50:
51: }
|