KickJava   Java API By Example, From Geeks To Geeks.

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


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.BeanDescriptor JavaDoc;
23 import java.beans.BeanInfo JavaDoc;
24 import java.beans.Introspector JavaDoc;
25 import org.netbeans.junit.NbTestCase;
26 import org.openide.util.HelpCtx;
27
28 /**
29  * Regression test for bug #21285<br>
30  * For more info please see the
31  * <a HREF="http://openide.netbeans.org/issues/show_bug.cgi?id=21285">
32  * descrition in issuezilla</a>
33  *
34  * @author Petr Hrebejk
35  */

36 public class BeanNodeBug21341 extends NbTestCase {
37
38
39     /** Creates new TextTest */
40     public BeanNodeBug21341(String JavaDoc s) {
41         super(s);
42     }
43     
44     public static void main(String JavaDoc[] args)throws Exception JavaDoc {
45
46          
47         BeanInfo JavaDoc bi = Introspector.getBeanInfo( Bean21341Hidden.class );
48         BeanDescriptor JavaDoc bd = bi.getBeanDescriptor();
49         
50         System.out.println(" shortDescription : " + bd.getShortDescription() );
51         System.out.println(" helpID : " + bd.getValue( "HelpID" ) );
52         //junit.textui.TestRunner.run(new NbTestSuite(BeanNodeBug21285.class));
53
}
54
55
56     /** Regression test to reproduce bug #21858. */
57     public void testHelpID() throws Exception JavaDoc {
58
59         BeanNode bn = new BeanNode( new Bean21341Hidden() );
60         HelpCtx hCtx = bn.getHelpCtx();
61         
62         // System.out.println("HCTX " + hCtx.getHelpID() );
63

64         assertTrue( "HelpID".equals( hCtx.getHelpID() ) );
65     }
66     
67     public void testPropertiesHelpID() throws Exception JavaDoc {
68
69         BeanNode bn = new BeanNode( new Bean21341Hidden() );
70         Node.PropertySet[] ps = bn.getPropertySets();
71         Node.PropertySet propertySet = null;
72         
73         for( int i = 0; i < ps.length; i++ ) {
74             if ( Sheet.PROPERTIES.equals( ps[i].getName() ) ) {
75                 propertySet = ps[i];
76                 break;
77             }
78         }
79         
80         // System.out.println("PsHelpId " + propertySet.getValue( "helpID" ) );
81

82         if ( propertySet == null ) {
83             fail( "Property set not found" );
84         }
85         else {
86             assertTrue( "PropertiesHelpID".equals( propertySet.getValue( "helpID" ) ) );
87         }
88     }
89     
90     public void testExpertHelpID() throws Exception JavaDoc {
91
92         BeanNode bn = new BeanNode( new Bean21341Hidden() );
93         Node.PropertySet[] ps = bn.getPropertySets();
94         Node.PropertySet propertySet = null;
95         
96         for( int i = 0; i < ps.length; i++ ) {
97             if ( Sheet.EXPERT.equals( ps[i].getName() ) ) {
98                 propertySet = ps[i];
99                 break;
100             }
101         }
102
103         // System.out.println("ExHelpId " + propertySet.getValue( "helpID" ) );
104

105         if ( propertySet == null ) {
106             fail( "Property set not found" );
107         }
108         else {
109             assertTrue( "ExpertHelpID".equals( propertySet.getValue( "helpID" ) ) );
110         }
111     }
112     
113 }
114
Popular Tags