1 19 20 package org.netbeans.beaninfo.editors; 21 22 import java.beans.PropertyEditorManager ; 23 import junit.framework.AssertionFailedError; 24 import junit.textui.TestRunner; 25 import org.netbeans.junit.*; 26 import java.io.InputStream ; 27 import java.lang.reflect.*; 28 import java.util.HashMap ; 29 30 33 public class FindEditorTest extends NbTestCase { 34 35 static { 36 org.netbeans.core.CoreBridgeImpl.getDefault().registerPropertyEditors(); 39 } 40 41 public FindEditorTest(String name) { 42 super(name); 43 } 44 45 public static void main(String [] args) { 46 TestRunner.run(new NbTestSuite(FindEditorTest.class)); 47 } 48 49 public void testFindStringEditor () throws Exception { 50 assertFind (String .class, org.netbeans.beaninfo.editors.StringEditor.class); 51 } 52 53 public void testFindStringArrayEditor () throws Exception { 54 assertFind ((new String [] { "" }).getClass (), org.netbeans.beaninfo.editors.StringArrayEditor.class); 55 } 56 57 public void testFindDataObjectEditor () throws Exception { 58 assertFind (org.openide.loaders.DataObject.class, org.netbeans.beaninfo.editors.DataObjectEditor.class); 59 } 60 61 public void testFindDataObjectArrayEditor () throws Exception { 62 org.openide.filesystems.FileObject fo = org.openide.filesystems.Repository.getDefault ().getDefaultFileSystem ().getRoot (); 63 Object obj = new org.openide.loaders.DataObject[] { org.openide.loaders.DataObject.find (fo) }; 64 assertFind (obj.getClass (), org.netbeans.beaninfo.editors.DataObjectArrayEditor.class); 65 } 66 67 private void assertFind (Class propertyTypeClass, Class editorClass) { 68 assertNotNull ("PropertyEditor for " + propertyTypeClass + " found.", PropertyEditorManager.findEditor (propertyTypeClass)); 69 assertEquals ("Editor is instance of ", editorClass, PropertyEditorManager.findEditor (propertyTypeClass).getClass ()); 70 } 71 } 72 | Popular Tags |