KickJava   Java API By Example, From Geeks To Geeks.

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


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 junit.framework.TestCase;
16
17 import org.openedit.repository.ContentItem;
18 import org.openedit.repository.Repository;
19 import org.openedit.repository.filesystem.DirectoryTool;
20 import org.openedit.repository.filesystem.StringItem;
21 import org.openedit.repository.filesystem.XmlVersionRepository;
22
23
24
25 /**
26  * DOCUMENT ME!
27  *
28  * @author cburkey date Jan 7, 2003
29  */

30 public class RepositoryTreeNodeTest extends TestCase
31 {
32     RepositoryTreeNode fieldRootNode;
33     DirectoryTool fieldDirectoryTool;
34     Repository fieldRepository;
35
36     public DirectoryTool getDirectoryTool()
37     {
38         if (fieldDirectoryTool == null)
39         {
40             fieldDirectoryTool = new DirectoryTool( );
41         }
42         return fieldDirectoryTool;
43     }
44     
45     public Repository getRepository()
46     {
47         if ( fieldRepository == null )
48         {
49             fieldRepository = new XmlVersionRepository(getDirectoryTool().getRootDirectory() );
50         }
51         return fieldRepository;
52     }
53     /**
54      * Constructor for PageTreeNodeTest.
55      *
56      * @param arg0
57      */

58     public RepositoryTreeNodeTest(String JavaDoc arg0)
59     {
60         super(arg0);
61     }
62
63     /**
64          *
65          */

66     public void testReloadChildren()
67     {
68         fieldRootNode.reloadChildren();
69         assertEquals(".versions", ((RepositoryTreeNode) fieldRootNode.getChild(0)).getName());
70         assertEquals("CVS", ((RepositoryTreeNode) fieldRootNode.getChild(1)).getName());
71         assertEquals("dir1", ((RepositoryTreeNode) fieldRootNode.getChild(2)).getName());
72         assertEquals("dir2", ((RepositoryTreeNode) fieldRootNode.getChild(3)).getName());
73         assertEquals("file1", ((RepositoryTreeNode) fieldRootNode.getChild(4)).getName());
74         assertEquals("file2", ((RepositoryTreeNode) fieldRootNode.getChild(5)).getName());
75     }
76
77     /**
78      * @see TestCase#setUp()
79      */

80     protected void setUp() throws Exception JavaDoc
81     {
82         //BasicConfigurator.configure();
83
Repository repository = getRepository();
84         // This is the one that should be ignored
85

86         repository.put( createRevision( "/CVS/file" ) );
87         // Create a couple of files
88
repository.put( createRevision( "/file1") );
89         repository.put( createRevision( "/file2") );
90
91         // Create a couple of directories
92
repository.put( createRevision("/dir1/file") );
93         repository.put( createRevision("/dir2/file") );
94         ContentItem root = repository.get( "/");
95         fieldRootNode = new RepositoryTreeNode(repository, root);
96     }
97
98     /**
99      * @see TestCase#tearDown()
100      */

101     protected void tearDown() throws Exception JavaDoc
102     {
103         Repository repository = getRepository();
104         repository.remove( createRevision( "/CVS/file" ) );
105         repository.remove( createRevision( "/file1") );
106         repository.remove( createRevision( "/file2") );
107         repository.remove( createRevision("/dir1/file") );
108         repository.remove( createRevision("/dir2/file") );
109     }
110     
111     protected ContentItem createRevision( String JavaDoc inPath ) throws Exception JavaDoc
112     {
113         return new StringItem( inPath, "content","UTF-8");
114     }
115 }
116
Popular Tags