public void testURL() throws Exception { String url; ClassPool cp = new ClassPool(null); cp.appendSystemPath(); url = cp.find("java.lang.Object").toString(); System.out.println(url); assertTrue(url.startsWith("jar:file:")); assertTrue(url.endsWith(".jar!/java/lang/Object.class")); assertNull(cp.find("class.not.Exist")); cp = new ClassPool(null); cp.insertClassPath("."); url = cp.find("test2.Inner").toString(); System.out.println(url); assertTrue(url.startsWith("file:/")); assertTrue(url.endsWith("/test2/Inner.class")); assertNull(cp.find("test2.TestURL")); cp = new ClassPool(null); cp.insertClassPath(JAR_PATH + "javassist.jar"); url = cp.find("javassist.CtClass").toString(); System.out.println(url); assertTrue(url.startsWith("jar:file:")); assertTrue(url.endsWith("javassist.jar!/javassist/CtClass.class")); assertNull(cp.find("javassist.TestURL")); cp = new ClassPool(null); cp.insertClassPath(new LoaderClassPath(cloader)); url = cp.find("javassist.CtMethod").toString(); System.out.println(url); // assertTrue(url.startsWith("jar:file:")); // assertTrue(url.endsWith("javassist.jar!/javassist/CtMethod.class")); assertNull(cp.find("javassist.TestURL")); cp = new ClassPool(null); cp.insertClassPath(new ByteArrayClassPath("test2.ByteArray", null)); url = cp.find("test2.ByteArray").toString(); System.out.println(url); assertTrue(url.equals("file:/ByteArrayClassPath/test2/ByteArray.class")); assertNull(cp.find("test2.TestURL")); }
public void not_testURLClassPath() throws Exception { String host = "www.csg.is.titech.ac.jp"; String path = "/~chiba/tmp/"; String url; ClassPool cp = new ClassPool(null); cp.insertClassPath(new URLClassPath(host, 80, path, "test")); url = cp.find("test.TestClassPath").toString(); System.out.println(url); assertEquals("http://" + host + ":80" + path + "test/TestClassPath.class", url); assertNull(cp.find("test.No")); }