KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > util > PathUtilitiesTest


1 /*
2  * Created on Mar 17, 2004
3  *
4  */

5 package com.openedit.util;
6
7
8 import junit.framework.TestCase;
9
10 /**
11  * @author dbrown
12  *
13  */

14 public class PathUtilitiesTest extends TestCase
15 {
16     private static final String JavaDoc FILE_PATH = "/basedir/resources/source/test1.html";
17
18     public PathUtilitiesTest(String JavaDoc arg0)
19     {
20         super(arg0);
21     }
22
23     public void testResolveRelative1()
24     {
25         String JavaDoc relativePath = "./layout.html";
26         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, FILE_PATH );
27         assertEquals( "/basedir/resources/source/layout.html", combinedPath );
28     }
29
30     public void testResolveRelative2()
31     {
32         String JavaDoc relativePath = "../layout.html";
33         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, FILE_PATH );
34         assertEquals( "/basedir/resources/layout.html", combinedPath );
35     }
36
37     public void testResolveRelative3()
38     {
39         String JavaDoc relativePath = "./graphics/image.gif";
40         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, FILE_PATH );
41         assertEquals( "/basedir/resources/source/graphics/image.gif", combinedPath );
42     }
43
44     public void testResolveRelative4()
45     {
46         String JavaDoc relativePath = "../../junk";
47         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, FILE_PATH );
48         assertEquals( "/basedir/junk", combinedPath );
49     }
50
51     public void testResolveRelative5()
52     {
53         String JavaDoc relativePath = "/basedir/resources/./source/layout.html";
54         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, FILE_PATH );
55         assertEquals( "/basedir/resources/source/layout.html", combinedPath );
56     }
57
58     public void testResolveRelative6()
59     {
60         String JavaDoc relativePath = "layout.html";
61         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, FILE_PATH );
62         assertEquals( "/basedir/resources/source/layout.html", combinedPath );
63     }
64
65     public void testResolveRelative7()
66     {
67         String JavaDoc filePath = "/basedir/resources/source/junk/";
68         String JavaDoc relativePath = "layout.html";
69         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, filePath );
70         assertEquals( "/basedir/resources/source/junk/layout.html", combinedPath );
71     }
72
73     public void testResolveRelative8()
74     {
75         String JavaDoc filePath = "/basedir/resources/";
76         String JavaDoc relativePath = "../../junk";
77         String JavaDoc combinedPath = PathUtilities.resolveRelativePath( relativePath, filePath );
78         assertEquals( "/junk", combinedPath );
79     }
80 }
81
Popular Tags