KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > util > UtilsTest


1 package org.sapia.soto.util;
2
3 import junit.framework.TestCase;
4
5 import java.io.File JavaDoc;
6
7
8 /**
9  * @author Yanick Duchesne
10  * 30-Sep-2003
11  */

12 public class UtilsTest extends TestCase {
13   /**
14    * Constructor for UtilsTest.
15    * @param arg0
16    */

17   public UtilsTest(String JavaDoc arg0) {
18     super(arg0);
19   }
20
21   public void testIsRelativePath() {
22     String JavaDoc path = "/absolute";
23     super.assertTrue("Path is absolute", !Utils.isRelativePath(path));
24     path = "relative";
25     super.assertTrue("Path is relative", Utils.isRelativePath(path));
26     path = "file:/relative";
27     super.assertTrue("Path is not relative", !Utils.isRelativePath(path));
28     path = "./etc/config";
29     super.assertTrue("Path is not relative", !Utils.isRelativePath(path));
30   }
31
32   public void testGetRelativePath() {
33     String JavaDoc base = "base";
34     String JavaDoc path = "relative";
35     super.assertEquals("base" + File.separator + "relative",
36       Utils.getRelativePath(base, path, false));
37
38     base = "root/base.xml";
39     super.assertEquals("root" + File.separator + "relative",
40       Utils.getRelativePath(base, path, true));
41
42     base = "base";
43     super.assertEquals("base" + File.separator + "relative",
44       Utils.getRelativePath(base, path, true));
45   }
46
47   public void testChopLocalUrl() {
48     String JavaDoc path = "resource:/org/sapia/soto\\included.xml";
49     super.assertEquals("/org/sapia/soto\\included.xml", Utils.chopScheme(path));
50   }
51
52   public void testChopNetworkUrl() {
53     String JavaDoc path = "http://org/sapia/soto\\included.xml";
54     super.assertEquals("/org/sapia/soto\\included.xml", Utils.chopScheme(path));
55   }
56
57   public void testChopRelativePath() {
58     String JavaDoc path = "org/sapia/soto\\included.xml";
59     super.assertEquals("org/sapia/soto\\included.xml", Utils.chopScheme(path));
60   }
61
62   public void testChopAbsolutePath() {
63     String JavaDoc path = "/org/sapia/soto\\included.xml";
64     super.assertEquals("/org/sapia/soto\\included.xml", Utils.chopScheme(path));
65   }
66 }
67
Popular Tags