1 22 package org.jboss.test.util.test; 23 24 import java.io.File ; 25 import java.net.URL ; 26 import java.net.URLConnection ; 27 28 import org.jboss.test.JBossTestCase; 29 import org.jboss.net.protocol.URLStreamHandlerFactory; 30 import org.jboss.net.protocol.resource.ResourceURLConnection; 31 import org.jboss.net.protocol.file.FileURLConnection; 32 33 39 public class ProtocolHandlerUnitTestCase extends JBossTestCase 40 { 41 public ProtocolHandlerUnitTestCase(String name) 42 { 43 super(name); 44 } 45 46 public void testJBossHandlers() 47 throws Exception 48 { 49 getLog().debug("+++ testJBossHandlers"); 50 URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory()); 52 File cwd = new File ("."); 53 URL cwdURL = cwd.toURL(); 54 URLConnection conn = cwdURL.openConnection(); 55 getLog().debug("File URLConnection: "+conn); 56 assertTrue("URLConnection is JBoss FileURLConnection", conn instanceof FileURLConnection); 57 long lastModified = conn.getLastModified(); 58 getLog().debug("CWD lastModified: "+lastModified); 59 assertTrue("CWD lastModified != 0", lastModified != 0); 60 61 URL resURL = new URL ("resource:log4j.xml"); 62 conn = resURL.openConnection(); 63 getLog().debug("log4j.xml URLConnection: "+conn); 64 assertTrue("URLConnection is JBoss ResourceURLConnection", conn instanceof ResourceURLConnection); 65 lastModified = conn.getLastModified(); 66 getLog().debug("log4j.xml lastModified: "+lastModified); 67 assertTrue("log4j.xml lastModified != 0", lastModified != 0); 68 } 69 70 72 public void testServerFound() 73 { 74 } 75 76 } 77 78 | Popular Tags |