1 13 package info.magnolia.cms.util; 14 15 import junit.framework.TestCase; 16 17 import java.net.URL ; 18 import java.net.MalformedURLException ; 19 import java.io.File ; 20 21 25 public class ClasspathResourcesUtilTest extends TestCase { 26 public void testSanitizeUrlToFile() throws MalformedURLException { 27 assertSanitizeToFile("/foo/bar/baz.jar", new URL ("file:///foo/bar/baz.jar")); 28 assertSanitizeToFile("/foo/bar/baz.jar", new URL ("file:///foo/bar/baz.jar!/")); 29 assertSanitizeToFile("/foo/bar/baz.jar", new URL ("file:/foo/bar/baz.jar!/")); 30 assertSanitizeToFile("//foo/bar/baz.jar", new URL ("jar:file:///foo/bar/baz.jar!/")); 31 assertSanitizeToFile("/foo/bar/baz.jar", new URL ("jar:file:/foo/bar/baz.jar!/")); 32 } 33 34 private void assertSanitizeToFile(String expectedAbsPath, URL url) throws MalformedURLException { 35 final File file = ClasspathResourcesUtil.sanitizeToFile(url); 36 assertEquals(new File (expectedAbsPath).getAbsolutePath(), file.getAbsolutePath()); 37 } 38 } 39 | Popular Tags |