KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > webui > tree > RepositoryTreeModelTest


1 /*
2 Copyright (c) 2003 eInnovation Inc. All rights reserved
3
4 This library is free software; you can redistribute it and/or modify it under the terms
5 of the GNU Lesser General Public License as published by the Free Software Foundation;
6 either version 2.1 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 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 /**
19  * Test for PageTreeModel
20  *
21  * @author Eric Galluzzo
22  */

23 public class RepositoryTreeModelTest extends BaseTestCase
24 {
25     protected RepositoryTreeModel fieldModel;
26     protected RepositoryTreeNode fieldRootNode;
27
28     public RepositoryTreeModelTest(String JavaDoc inName)
29     {
30         super(inName);
31     }
32
33     /**
34          *
35          */

36     public void testFindNode_Blank()
37     {
38         RepositoryTreeNode node = fieldModel.findNode("");
39         assertSame("Should have returned the root", fieldRootNode, node);
40     }
41
42     /**
43          *
44          */

45     public void testFindNode_Nonexistent()
46     {
47         RepositoryTreeNode node = fieldModel.findNode("/openedit/thisdoesnotexist/foo.bar");
48         assertNull(node);
49     }
50
51     /**
52          *
53          */

54     public void testFindNode_Normal()
55     {
56         RepositoryTreeNode node = fieldModel.findNode("/withdefault/index.html");
57         assertNotNull(node);
58         assertTrue(node.getName().equals("index.html"));
59         assertSame(
60             "Should have found the correct node",
61             fieldRootNode.getChild("withdefault").getChild("index.html"), node);
62     }
63
64     /**
65          *
66          */

67     public void testFindNode_Root()
68     {
69         RepositoryTreeNode node = fieldModel.findNode("/");
70         assertSame("Should have returned the root", fieldRootNode, node);
71     }
72
73     /**
74          *
75          */

76     public void testGetRoot()
77     {
78         assertTrue("Root should have some children", fieldRootNode.getChildCount() > 0);
79     }
80
81     /*
82      * @see TestCase#setUp()
83      */

84     protected void setUp() throws Exception JavaDoc
85     {
86         fieldModel = new RepositoryTreeModel(getFixture().getPageManager().getRepository());
87         fieldRootNode = (RepositoryTreeNode) fieldModel.getRoot();
88     }
89 }
90
Popular Tags