]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/test/java/org/argeo/slc/core/structure/tree/TreeSPathTest.java
Introduce org.argeo.slc.support.simple
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / test / java / org / argeo / slc / core / structure / tree / TreeSPathTest.java
1 package org.argeo.slc.core.structure.tree;
2
3 import junit.framework.TestCase;
4
5 public class TreeSPathTest extends TestCase {
6
7 public void testNew() {
8 TreeSPath path = new TreeSPath("/test");
9 assertEquals("test", path.getName());
10 assertNull(path.getParent());
11
12 path = new TreeSPath("/root/subdir");
13 assertEquals("subdir", path.getName());
14 assertEquals(new TreeSPath("/root"), path.getParent());
15 }
16
17 public void testEquals() {
18 TreeSPath path1 = new TreeSPath("/test");
19 TreeSPath path2 = new TreeSPath("/test");
20 assertEquals(path1, path2);
21
22 path1 = new TreeSPath("/test/subdir/anotherdir");
23 path2 = new TreeSPath("/test/subdir/anotherdir");
24 assertEquals(path1, path2);
25
26 path1 = new TreeSPath("/test/subdir/anotherd");
27 path2 = new TreeSPath("/test/subdir/anotherdir");
28 assertNotSame(path1, path2);
29
30 path1 = new TreeSPath("/test/subdir");
31 path2 = new TreeSPath("/test/subdir/anotherdir");
32 assertNotSame(path1, path2);
33
34 path1 = new TreeSPath("/test/subd/anotherdir");
35 path2 = new TreeSPath("/test/subdir/anotherdir");
36 assertNotSame(path1, path2);
37 }
38
39 public void testCheckFormat() {
40 try {
41 new TreeSPath("hello");
42 fail("Bad format should be rejected");
43 } catch (Exception e) {
44 // exception expected
45 }
46
47 try {
48 new TreeSPath("/");
49 fail("Bad format should be rejected");
50 } catch (Exception e) {
51 // exception expected
52 }
53
54 assertEquals(new TreeSPath("/test"), new TreeSPath("/test/"));
55 assertEquals(new TreeSPath("/test/dir"), new TreeSPath(
56 "//test///dir////"));
57 }
58 }