1 22 package org.objectweb.petals.classloader.factory; 23 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.net.URL ; 27 28 import junit.framework.TestCase; 29 30 35 public class JarURLFactoryTest extends TestCase { 36 37 private String baseDir; 38 39 public void setUp() { 40 baseDir = this.getClass().getResource(".").toString(); 41 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 42 baseDir = baseDir.substring(baseDir.indexOf(":") + 1); 43 } 44 45 public void testGetURL() throws IOException { 46 JarURLFactory factory = new JarURLFactory(new URL ("file:" 47 + baseDir.replace(File.separator, "/") 48 + "src/test-data/petals-core-test.jar")); 49 URL url = factory.getURL("META-INF/MANIFEST.MF"); 50 assertEquals(url, new URL ("jar:file:" 51 + baseDir.replace(File.separator, "/") 52 + "src/test-data/petals-core-test.jar!/META-INF/MANIFEST.MF")); 53 } 54 55 public void testGetURLException() throws IOException { 56 URL url = new URL ("file:" + baseDir.replace(File.separator, "/") 57 + "src/test-data/petals-core-test.jar"); 58 JarURLFactory factory = new JarURLFactory(url); 59 assertEquals(url, factory.getURL("")); 60 } 61 62 } 63 | Popular Tags |