]>
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) 2007-2012 Mathieu Baudier
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.
16 package org
.argeo
.slc
.core
.structure
.tree
;
18 import junit
.framework
.TestCase
;
20 public class TreeSPathTest
extends TestCase
{
22 public void testNew() {
23 TreeSPath path
= new TreeSPath("/test");
24 assertEquals("test", path
.getName());
25 assertNull(path
.getParent());
27 path
= new TreeSPath("/root/subdir");
28 assertEquals("subdir", path
.getName());
29 assertEquals(new TreeSPath("/root"), path
.getParent());
32 public void testEquals() {
33 TreeSPath path1
= new TreeSPath("/test");
34 TreeSPath path2
= new TreeSPath("/test");
35 assertEquals(path1
, path2
);
37 path1
= new TreeSPath("/test/subdir/anotherdir");
38 path2
= new TreeSPath("/test/subdir/anotherdir");
39 assertEquals(path1
, path2
);
41 path1
= new TreeSPath("/test/subdir/anotherd");
42 path2
= new TreeSPath("/test/subdir/anotherdir");
43 assertNotSame(path1
, path2
);
45 path1
= new TreeSPath("/test/subdir");
46 path2
= new TreeSPath("/test/subdir/anotherdir");
47 assertNotSame(path1
, path2
);
49 path1
= new TreeSPath("/test/subd/anotherdir");
50 path2
= new TreeSPath("/test/subdir/anotherdir");
51 assertNotSame(path1
, path2
);
54 public void testCheckFormat() {
56 new TreeSPath("hello");
57 fail("Bad format should be rejected");
58 } catch (Exception e
) {
64 fail("Bad format should be rejected");
65 } catch (Exception e
) {
69 assertEquals(new TreeSPath("/test"), new TreeSPath("/test/"));
70 assertEquals(new TreeSPath("/test/dir"), new TreeSPath(