001: /*
002: Copyright (c) 2003 eInnovation Inc. All rights reserved
003:
004: This library is free software; you can redistribute it and/or modify it under the terms
005: of the GNU Lesser General Public License as published by the Free Software Foundation;
006: either version 2.1 of the License, or (at your option) any later version.
007:
008: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
009: without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: See the GNU Lesser General Public License for more details.
011: */
012:
013: package com.openedit.webui.tree;
014:
015: import junit.framework.TestCase;
016:
017: import org.openedit.repository.ContentItem;
018: import org.openedit.repository.Repository;
019: import org.openedit.repository.filesystem.DirectoryTool;
020: import org.openedit.repository.filesystem.StringItem;
021: import org.openedit.repository.filesystem.XmlVersionRepository;
022:
023: import com.openedit.BaseTestCase;
024:
025: /**
026: * DOCUMENT ME!
027: *
028: * @author cburkey date Jan 7, 2003
029: */
030: public class RepositoryTreeNodeTest extends BaseTestCase {
031: RepositoryTreeNode fieldRootNode;
032: DirectoryTool fieldDirectoryTool;
033: Repository fieldRepository;
034:
035: public DirectoryTool getDirectoryTool() {
036: if (fieldDirectoryTool == null) {
037: fieldDirectoryTool = new DirectoryTool();
038: }
039: return fieldDirectoryTool;
040: }
041:
042: public Repository getRepository() {
043: if (fieldRepository == null) {
044: fieldRepository = new XmlVersionRepository(
045: getDirectoryTool().getRootDirectory());
046: }
047: return fieldRepository;
048: }
049:
050: /**
051: * Constructor for PageTreeNodeTest.
052: *
053: * @param arg0
054: */
055: public RepositoryTreeNodeTest(String arg0) {
056: super (arg0);
057: }
058:
059: /**
060: *
061: */
062: public void testReloadChildren() {
063: fieldRootNode.reloadChildren();
064: assertEquals(".versions", ((RepositoryTreeNode) fieldRootNode
065: .getChild(0)).getName());
066: assertEquals("CVS", ((RepositoryTreeNode) fieldRootNode
067: .getChild(1)).getName());
068: assertEquals("dir1", ((RepositoryTreeNode) fieldRootNode
069: .getChild(2)).getName());
070: assertEquals("dir2", ((RepositoryTreeNode) fieldRootNode
071: .getChild(3)).getName());
072: assertEquals("file1", ((RepositoryTreeNode) fieldRootNode
073: .getChild(4)).getName());
074: assertEquals("file2", ((RepositoryTreeNode) fieldRootNode
075: .getChild(5)).getName());
076: }
077:
078: /**
079: * @see TestCase#setUp()
080: */
081: protected void setUp() throws Exception {
082: //BasicConfigurator.configure();
083: Repository repository = getRepository();
084: // This is the one that should be ignored
085:
086: repository.put(createRevision("/CVS/file"));
087: // Create a couple of files
088: repository.put(createRevision("/file1"));
089: repository.put(createRevision("/file2"));
090:
091: // Create a couple of directories
092: repository.put(createRevision("/dir1/file"));
093: repository.put(createRevision("/dir2/file"));
094: ContentItem root = repository.get("/");
095: fieldRootNode = new RepositoryTreeNode(repository, root);
096: fieldRootNode.setPageManager(getFixture().getPageManager());
097: }
098:
099: /**
100: * @see TestCase#tearDown()
101: */
102: protected void tearDown() throws Exception {
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)
112: throws Exception {
113: return new StringItem(inPath, "content", "UTF-8");
114: }
115: }
|