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