]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/structure/tree/TreeSPathTest.java
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.core
.structure
.tree
;
19 import junit
.framework
.TestCase
;
21 public class TreeSPathTest
extends TestCase
{
23 public void testNew() {
24 TreeSPath path
= new TreeSPath("/test");
25 assertEquals("test", path
.getName());
26 assertNull(path
.getParent());
28 path
= new TreeSPath("/root/subdir");
29 assertEquals("subdir", path
.getName());
30 assertEquals(new TreeSPath("/root"), path
.getParent());
33 public void testEquals() {
34 TreeSPath path1
= new TreeSPath("/test");
35 TreeSPath path2
= new TreeSPath("/test");
36 assertEquals(path1
, path2
);
38 path1
= new TreeSPath("/test/subdir/anotherdir");
39 path2
= new TreeSPath("/test/subdir/anotherdir");
40 assertEquals(path1
, path2
);
42 path1
= new TreeSPath("/test/subdir/anotherd");
43 path2
= new TreeSPath("/test/subdir/anotherdir");
44 assertNotSame(path1
, path2
);
46 path1
= new TreeSPath("/test/subdir");
47 path2
= new TreeSPath("/test/subdir/anotherdir");
48 assertNotSame(path1
, path2
);
50 path1
= new TreeSPath("/test/subd/anotherdir");
51 path2
= new TreeSPath("/test/subdir/anotherdir");
52 assertNotSame(path1
, path2
);
55 public void testCheckFormat() {
57 new TreeSPath("hello");
58 fail("Bad format should be rejected");
59 } catch (Exception e
) {
65 fail("Bad format should be rejected");
66 } catch (Exception e
) {
70 assertEquals(new TreeSPath("/test"), new TreeSPath("/test/"));
71 assertEquals(new TreeSPath("/test/dir"), new TreeSPath(