1 24 25 package org.netbeans.modules.extbrowser; 26 27 import java.io.File ; 28 import java.net.URL ; 29 import junit.framework.*; 30 import org.netbeans.junit.*; 31 import java.beans.*; 32 import org.openide.ErrorManager; 33 import org.openide.execution.NbProcessDescriptor; 34 import org.openide.filesystems.FileObject; 35 import org.openide.filesystems.FileUtil; 36 import org.openide.modules.InstalledFileLocator; 37 import org.openide.util.NbBundle; 38 import org.openide.awt.HtmlBrowser; 39 40 44 public class URLUtilTest extends NbTestCase { 45 46 public URLUtilTest (java.lang.String testName) { 47 super(testName); 48 } 49 50 public static void main(java.lang.String [] args) { 51 junit.textui.TestRunner.run(suite()); 52 } 53 54 public void testCreateExternalURL() throws Exception { 55 File f = InstalledFileLocator.getDefault().locate("modules/docs/org-netbeans-modules-usersguide.jar", null, false); 58 assertNotNull("Usersguide module not found", f); 59 FileObject fo = FileUtil.toFileObject(f); 60 log("jar fileobject is " + fo); 61 assertNotNull("FileObject corresponding to usersguide module not found", fo); 62 FileObject jar = FileUtil.getArchiveRoot(fo); 63 assertNotNull("FileObject corresponding to usersguide as jar not found", jar); 64 FileObject pendingPage = jar.getFileObject("org/netbeans/modules/usersguide/pending.html"); 65 URL pendingURL = pendingPage.getURL(); 66 log("original url is " + pendingURL); 67 URL newURL1 = URLUtil.createExternalURL(pendingURL, true); 68 log("jar url " + newURL1); 69 URL newURL2 = URLUtil.createExternalURL(pendingURL, false); 70 log("http url " + newURL2); 71 assertEquals("HTTP URL is not local - does not contain 127.0.0.1", "127.0.0.1", newURL2.getHost()); 72 } 73 74 public static Test suite () { 75 TestSuite suite = new NbTestSuite (URLUtilTest.class); 76 return suite; 77 } 78 79 80 } 81 | Popular Tags |