KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > util > ClasspathResourcesUtilTest


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.util;
14
15 import junit.framework.TestCase;
16
17 import java.net.URL JavaDoc;
18 import java.net.MalformedURLException JavaDoc;
19 import java.io.File JavaDoc;
20
21 /**
22  * @author gjoseph
23  * @version $Revision: $ ($Author: $)
24  */

25 public class ClasspathResourcesUtilTest extends TestCase {
26     public void testSanitizeUrlToFile() throws MalformedURLException JavaDoc {
27         assertSanitizeToFile("/foo/bar/baz.jar", new URL JavaDoc("file:///foo/bar/baz.jar"));
28         assertSanitizeToFile("/foo/bar/baz.jar", new URL JavaDoc("file:///foo/bar/baz.jar!/"));
29         assertSanitizeToFile("/foo/bar/baz.jar", new URL JavaDoc("file:/foo/bar/baz.jar!/"));
30         assertSanitizeToFile("//foo/bar/baz.jar", new URL JavaDoc("jar:file:///foo/bar/baz.jar!/"));
31         assertSanitizeToFile("/foo/bar/baz.jar", new URL JavaDoc("jar:file:/foo/bar/baz.jar!/"));
32     }
33
34     private void assertSanitizeToFile(String JavaDoc expectedAbsPath, URL JavaDoc url) throws MalformedURLException JavaDoc {
35         final File JavaDoc file = ClasspathResourcesUtil.sanitizeToFile(url);
36         assertEquals(new File JavaDoc(expectedAbsPath).getAbsolutePath(), file.getAbsolutePath());
37     }
38 }
39
Popular Tags