1 17 18 package org.apache.geronimo.common.propertyeditor; 19 20 import java.beans.PropertyEditor ; 21 import java.io.File ; 22 import java.net.URL ; 23 24 import junit.framework.TestCase; 25 26 31 public class URLEditorTest extends TestCase { 32 PropertyEditor editor; 33 34 protected void setUp() { 35 editor = PropertyEditors.findEditor(URL .class); 36 } 37 38 public void testEditorClass() throws Exception { 39 assertEquals(URLEditor.class, editor.getClass()); 40 } 41 42 public void testHTTP() throws Exception { 43 checkURL("http://www.apache.org", null); 44 } 45 46 public void testFTP() throws Exception { 47 checkURL("ftp://ftp.apache.org", null); 48 } 49 50 public void testFileURL() throws Exception { 51 URL base = new URL ("file://test.resource"); 52 base = new File (base.getFile()).toURI().toURL(); 53 checkURL("file://test.resource", base); 54 } 55 56 public void testFile() throws Exception { 57 URL testValue = new File ("test.resource").toURI().toURL(); 58 checkURL("test.resource", testValue); 59 } 60 61 protected void checkURL(String text, URL test) throws Exception { 62 editor.setAsText(text); 63 if (test == null) { 64 test = new URL (text); 65 } 66 assertEquals(test, editor.getValue()); 67 } 68 } 69 | Popular Tags |