1 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 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 58 public RepositoryTreeNodeTest(String arg0) 59 { 60 super(arg0); 61 } 62 63 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 80 protected void setUp() throws Exception 81 { 82 Repository repository = getRepository(); 84 86 repository.put( createRevision( "/CVS/file" ) ); 87 repository.put( createRevision( "/file1") ); 89 repository.put( createRevision( "/file2") ); 90 91 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 101 protected void tearDown() throws Exception 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 inPath ) throws Exception 112 { 113 return new StringItem( inPath, "content","UTF-8"); 114 } 115 } 116 | Popular Tags |