1 9 package org.jboss.portal.test.common; 10 11 import junit.framework.TestCase; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import java.net.URL ; 16 17 import org.jboss.portal.common.net.jar.JarURLNavigationProvider; 18 import org.jboss.portal.common.net.URLVisitor; 19 20 24 public class URLNavigatorTestCase extends TestCase 25 { 26 27 public URLNavigatorTestCase(String name) 28 { 29 super(name); 30 } 31 32 public void testJar() throws Exception 33 { 34 File libDir = new File (System.getProperty("build.lib")); 35 assertTrue(libDir.exists()); 36 assertTrue(libDir.isDirectory()); 37 File jarFile = new File (libDir, "test.jar"); 38 assertTrue(jarFile.exists()); 39 assertFalse(jarFile.isDirectory()); 40 41 URL jarURL = new URL ("jar", "", jarFile.toURL() + "!" + "/a1/b1/"); 43 JarURLNavigationProvider provider = new JarURLNavigationProvider(); 44 provider.visit(jarURL, new URLVisitor() 45 { 46 public void startDir(String name) 47 { 48 System.out.println("<name = " + name + " >"); 49 } 50 public void endDir(String name) 51 { 52 System.out.println("</name = " + name + " >"); 53 } 54 public void file(String name, URL url) 55 { 56 System.out.println("url = " + url); 57 try 58 { 59 Object content = url.getContent(); 60 System.out.println("content = " + content); 61 } 62 catch (IOException e) 63 { 64 e.printStackTrace(); 65 } 66 } 67 }); 68 69 jarFile.deleteOnExit(); 71 } 72 73 } 74 | Popular Tags |