KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > jcr > impl > TestPath


1 /**
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5
6 package org.exoplatform.services.jcr.impl;
7
8 import org.exoplatform.services.jcr.BaseTest;
9 import org.exoplatform.services.jcr.core.ItemLocation;
10 import org.exoplatform.services.jcr.util.PathUtil;
11
12
13 /**
14  * Created by The eXo Platform SARL .
15  *
16  * @author <a HREF="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
17  * @version $Id: TestPath.java,v 1.2 2004/09/16 15:28:52 geaz Exp $
18  */

19
20 public class TestPath extends BaseTest {
21
22
23   public void testPathUtil() throws Exception JavaDoc {
24     int test = PathUtil.getDepth("/");
25     assertTrue(test == 0);
26     test = PathUtil.getDepth("/node1");
27     assertTrue(test == 1);
28     test = PathUtil.getDepth("/node1/");
29     assertTrue(test == 1);
30     test = PathUtil.getDepth("/node1/jcr:uuid");
31     assertTrue(test == 2);
32     assertFalse(PathUtil.isDescendant("/node1/jcr:uuid", "/", true));
33     assertTrue(PathUtil.isDescendant("/node1/jcr:uuid", "/", false));
34     assertTrue(PathUtil.isDescendant("/node1/jcr:uuid", "/node1", false));
35     assertTrue(PathUtil.isDescendant("/node1/jcr:uuid", "/node1", true));
36
37     assertFalse(PathUtil.isDescendant("/node11", "/node1", true));
38     assertFalse(PathUtil.isDescendant("/node11", "/node1", false));
39
40     assertFalse(PathUtil.isDescendant("/testNode1/node11", "/testNode", true));
41     assertFalse(PathUtil.isDescendant("/testNode1/node11", "/testNode", false));
42
43
44   }
45
46   public void testItemLocation() throws Exception JavaDoc {
47     ItemLocation loc = new ItemLocation("/root/node1", "node2");
48     assertEquals("/root/node1/node2", loc.getPath());
49     assertEquals("node2", loc.getName());
50     assertEquals("/root/node1", loc.getParentPath());
51     assertEquals("/", loc.getAncestorPath(3));
52     assertTrue(loc.getDepth() == 3);
53   }
54 }
55
Popular Tags