KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > nodes > BeanNodeBug21285


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.nodes;
21
22 import java.beans.BeanInfo JavaDoc;
23 import java.beans.IndexedPropertyDescriptor JavaDoc;
24 import java.beans.Introspector JavaDoc;
25 import java.beans.PropertyDescriptor JavaDoc;
26 import java.util.Arrays JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import java.util.Set JavaDoc;
29 import org.netbeans.junit.NbTestCase;
30 import org.openide.nodes.Node.Property;
31
32 /**
33  * Regression test for bug #21285<br>
34  * For more info please see the
35  * <a HREF="http://openide.netbeans.org/issues/show_bug.cgi?id=21285">
36  * descrition in issuezilla</a>
37  *
38  * @author Petr Hrebejk
39  */

40 public class BeanNodeBug21285 extends NbTestCase {
41
42
43     /** Creates new TextTest */
44     public BeanNodeBug21285(String JavaDoc s) {
45         super(s);
46     }
47     
48     public static void main(String JavaDoc[] args)throws Exception JavaDoc {
49
50          
51         BeanInfo JavaDoc bi = Introspector.getBeanInfo( BadBeanHidden.class );
52         PropertyDescriptor JavaDoc[] 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 JavaDoc ) {
60                 System.out.println(" I Read : " + ((IndexedPropertyDescriptor JavaDoc)ps[i]).getIndexedReadMethod() );
61                 System.out.println(" I Write : " +((IndexedPropertyDescriptor JavaDoc)ps[i]).getIndexedWriteMethod() );
62                 System.out.println(" TYPE " + ((IndexedPropertyDescriptor JavaDoc)ps[i]).getIndexedPropertyType() );
63             }
64             
65             
66         }
67     }
68
69
70     /** Regression test to reproduce bug #21858. */
71     public void testBadBean() throws Exception JavaDoc {
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 JavaDoc<Property> props = new HashSet JavaDoc<Property>(
79                     Arrays.asList(ps[i].getProperties()));
80             }
81         }
82         catch ( NullPointerException JavaDoc e ) {
83             assertTrue( "The NullPointerException thrown", false );
84         }
85         
86         assertTrue( true );
87     }
88     
89 }
90
Popular Tags