001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.test.cms;
023:
024: import junit.framework.TestSuite;
025: import org.jboss.portal.cms.util.NodeUtil;
026:
027: /**
028: * Tests RepositoryUtil
029: *
030: * @author Roy Russo : roy at jboss dot org
031: */
032: public class TestRepositoryUtil extends AbstractCMSTestCase {
033: // public void testCreateRepository()
034: // {
035: // try
036: // {
037: // // --------------------------------------------
038: // // Clean the directory structure, first!
039: // // --------------------------------------------
040: // File w = new File("repotest/workspaces");
041: // FileUtils.deleteDirectory(w);
042: // File v = new File("repotest/versions");
043: // FileUtils.deleteDirectory(v);
044: // File r = new File("repotest/repository");
045: // FileUtils.deleteDirectory(r);
046: //
047: // JackrabbitUtil.registerRepository("repo", "resources/test/jcr/repository.xml", "repotest");
048: // JackrabbitUtil.registerCustomNodeTypes(JackrabbitUtil.getRepository("repo"));
049: // }
050: // catch(Exception e)
051: // {
052: // fail("Cannot create repository : " + e);
053: // }
054: //
055: // }
056: //
057: // public void testGetRepositoryAndLogin()
058: // {
059: // try
060: // {
061: // Repository repository = JackrabbitUtil.getRepository("repo");
062: // assertNotNull("The repository is null!", repository);
063: // Session session = RepositoryUtil.login(repository, "anonid", "");
064: // Node rootNode = session.getRootNode();
065: // System.out.println(rootNode.getPrimaryNodeType().getName());
066: // assertNotNull("Root node is null", rootNode);
067: // }
068: // catch(Exception e)
069: // {
070: // e.printStackTrace();
071: // fail("" + e);
072: // }
073: //
074: // }
075:
076: public void testGetParentPath() {
077: try {
078: String parentPath = NodeUtil.getParentPath("/foo");
079: assertNotNull("NULL parent for /foo", parentPath);
080: assertTrue("Wrong parent for /foo", parentPath.equals("/"));
081:
082: parentPath = NodeUtil.getParentPath("/alpha/omega");
083: assertNotNull("NULL parent for /alpha/omega", parentPath);
084: assertTrue("Wrong parent for /alpha/omega", parentPath
085: .equals("/alpha"));
086:
087: } catch (Exception e) {
088: e.printStackTrace();
089: fail("" + e);
090: }
091: }
092:
093: public void testGetNodeName() {
094: try {
095: String nodeName = NodeUtil.getNodeName("/root");
096: assertNotNull("Node name is NULL for /root", nodeName);
097: assertTrue("Wrong node name for /root", nodeName
098: .equals("root"));
099:
100: nodeName = NodeUtil.getNodeName("/alpha/omega");
101: assertNotNull("Node name is NULL for /alpha/omega",
102: nodeName);
103: assertTrue("Wrong node name for /alpha/omega", nodeName
104: .equals("omega"));
105:
106: } catch (Exception e) {
107: e.printStackTrace();
108: fail("" + e);
109: }
110: }
111:
112: public TestRepositoryUtil() {
113: }
114:
115: public void setUp() throws Exception {
116: super .setUp();
117: }
118:
119: public void tearDown() throws Exception {
120: super .tearDown();
121:
122: }
123:
124: public static TestSuite suite() throws Exception {
125: return createTestSuite(TestRepositoryUtil.class);
126: }
127: }
|