1 19 20 package org.openide.nodes; 21 22 import java.beans.BeanInfo ; 23 import java.beans.IndexedPropertyDescriptor ; 24 import java.beans.Introspector ; 25 import java.beans.PropertyDescriptor ; 26 import java.util.Arrays ; 27 import java.util.HashSet ; 28 import java.util.Set ; 29 import org.netbeans.junit.NbTestCase; 30 import org.openide.nodes.Node.Property; 31 32 40 public class BeanNodeBug21285 extends NbTestCase { 41 42 43 44 public BeanNodeBug21285(String s) { 45 super(s); 46 } 47 48 public static void main(String [] args)throws Exception { 49 50 51 BeanInfo bi = Introspector.getBeanInfo( BadBeanHidden.class ); 52 PropertyDescriptor [] ps = bi.getPropertyDescriptors(); 53 54 for ( int i = 0; i < ps.length; i++ ) { 55 System.out.println( i + " : " + ps[i]); 56 System.out.println(" Read : " + ps[i].getReadMethod() ); 57 System.out.println(" Write : " + ps[i].getWriteMethod() ); 58 System.out.println(" TYPE " + ps[i].getPropertyType() ); 59 if ( ps[i] instanceof IndexedPropertyDescriptor ) { 60 System.out.println(" I Read : " + ((IndexedPropertyDescriptor )ps[i]).getIndexedReadMethod() ); 61 System.out.println(" I Write : " +((IndexedPropertyDescriptor )ps[i]).getIndexedWriteMethod() ); 62 System.out.println(" TYPE " + ((IndexedPropertyDescriptor )ps[i]).getIndexedPropertyType() ); 63 } 64 65 66 } 67 } 68 69 70 71 public void testBadBean() throws Exception { 72 73 BeanNode bn = new BeanNode( new BadBeanHidden() ); 74 Node.PropertySet ps[] = bn.getPropertySets(); 75 76 try { 77 for (int i = 0; i < ps.length; i++) { 78 Set <Property> props = new HashSet <Property>( 79 Arrays.asList(ps[i].getProperties())); 80 } 81 } 82 catch ( NullPointerException e ) { 83 assertTrue( "The NullPointerException thrown", false ); 84 } 85 86 assertTrue( true ); 87 } 88 89 } 90 | Popular Tags |