01: /*
02: Copyright (c) 2003 eInnovation Inc. All rights reserved
03:
04: This library is free software; you can redistribute it and/or modify it under the terms
05: of the GNU Lesser General Public License as published by the Free Software Foundation;
06: either version 2.1 of the License, or (at your option) any later version.
07:
08: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
09: without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: See the GNU Lesser General Public License for more details.
11: */
12:
13: package com.openedit.webui.tree;
14:
15: import com.openedit.BaseTestCase;
16:
17: /**
18: * Test for PageTreeModel
19: *
20: * @author Eric Galluzzo
21: */
22: public class RepositoryTreeModelTest extends BaseTestCase {
23: protected RepositoryTreeModel fieldModel;
24: protected RepositoryTreeNode fieldRootNode;
25:
26: public RepositoryTreeModelTest(String inName) {
27: super (inName);
28: }
29:
30: /**
31: *
32: */
33: public void testFindNode_Blank() {
34: RepositoryTreeNode node = fieldModel.findNode("");
35: assertSame("Should have returned the root", fieldRootNode, node);
36: }
37:
38: /**
39: *
40: */
41: public void testFindNode_Nonexistent() {
42: RepositoryTreeNode node = fieldModel
43: .findNode("/openedit/thisdoesnotexist/foo.bar");
44: assertNull(node);
45: }
46:
47: public void testFindNode_Normal() {
48: RepositoryTreeNode node = fieldModel
49: .findNode("/withdefault/index.html");
50: assertNotNull(node);
51: assertTrue(node.getName().equals("index.html"));
52: assertSame("Should have found the correct node", fieldRootNode
53: .getChild("withdefault").getChild("index.html"), node);
54: }
55:
56: public void testFindNode_HiddenNormal() {
57: RepositoryTreeNode node = fieldModel
58: .findNode("/hidden/index.html");
59: assertNotNull(node);
60: RepositoryTreeNode hidden = fieldModel
61: .findNode("/hidden/subhidden/index.html");
62: assertNull(hidden);
63:
64: }
65:
66: public void testFindNode_Root() {
67: RepositoryTreeNode node = fieldModel.findNode("/");
68: assertSame("Should have returned the root", fieldRootNode, node);
69: }
70:
71: /**
72: *
73: */
74: public void testGetRoot() {
75: assertTrue("Root should have some children", fieldRootNode
76: .getChildCount() > 0);
77: }
78:
79: /*
80: * @see TestCase#setUp()
81: */
82: protected void setUp() throws Exception {
83: fieldModel = new RepositoryTreeModel(getFixture()
84: .getPageManager().getRepository());
85: fieldModel.setPageManager(getFixture().getPageManager());
86:
87: PagePathViewFilter filter = new PagePathViewFilter();
88: filter.setPageManager(getFixture().getPageManager());
89: filter.setLoadingWebPageRequest(getFixture()
90: .createPageRequest());
91: fieldModel.setFilter(filter);
92: fieldRootNode = (RepositoryTreeNode) fieldModel.getRoot();
93: }
94: }
|