KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > qa > form > beans > AddBeanForms


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.netbeans.qa.form.beans;
21
22 import org.netbeans.jellytools.modules.form.ComponentInspectorOperator;
23 import org.netbeans.jellytools.properties.Property;
24 import org.netbeans.junit.NbTestSuite;
25 import org.netbeans.qa.form.*;
26
27 /**
28  * Tests creating Bean Forms from visual and non-visual JavaBeans superclasses
29  * and tests value and access rights of inherited properties
30  *
31  * @author Jiri Vagner
32  */

33 public class AddBeanForms extends AddAndRemoveBeansTest {
34     
35     /**
36      * Constructor required by JUnit
37      * @param testName
38      */

39     public AddBeanForms(String JavaDoc testName) {
40         super(testName);
41         //this.DELETE_FILES = false;
42
}
43     
44     /**
45      * Method allowing to execute test directly from IDE.
46      * @param args
47      */

48     public static void main(java.lang.String JavaDoc[] args) {
49         junit.textui.TestRunner.run(suite());
50     }
51     
52     /**
53      * Creates suite from particular test cases.
54      * @return nb test suite
55      */

56     public static NbTestSuite suite() {
57         NbTestSuite suite = new NbTestSuite();
58         
59         suite.addTest(new AddBeanForms("testAddingBeanFormWithVisualBeanSuperclass")); // NOI18N
60
suite.addTest(new AddBeanForms("testAddingBeanFormWithNonVisualBeanSuperclass")); // NOI18N
61

62         return suite;
63     }
64     
65     /** Test adding Bean Form with visual bean superclass */
66     public void testAddingBeanFormWithVisualBeanSuperclass() {
67         String JavaDoc name = createBeanFormFile(VISUAL_BEAN_NAME);
68
69         ComponentInspectorOperator inspector = new ComponentInspectorOperator();
70         inspector.selectComponent(VISUAL_BEAN_NAME);
71         Property prop = new Property(inspector.properties(), "text"); // NOI18N
72
assertEquals("Text property of component " + name + " was not set correctly.",
73             prop.getValue(), TESTED_BEAN_TEXT); // NOI18N
74

75         removeFile(name);
76     }
77
78     /** Test adding Bean Form with non-visual bean superclass */
79     public void testAddingBeanFormWithNonVisualBeanSuperclass() {
80         String JavaDoc name = createBeanFormFile(NONVISUAL_BEAN_NAME);
81
82
83         ComponentInspectorOperator inspector = new ComponentInspectorOperator();
84         inspector.selectComponent(NONVISUAL_BEAN_NAME);
85         
86         Property prop = new Property(inspector.properties(), "power"); // NOI18N
87
assertEquals("Text property of component " + name + " was not set correctly.",
88             prop.getValue(), this.TESTED_BEAN_POWER); // NOI18N
89
assertEquals("Property of component " + name + " is read-only.",
90             prop.isEnabled(), true); // NOI18N
91

92         prop = new Property(inspector.properties(), "carName"); // NOI18N
93
assertEquals("Text property of component " + name + " was not set correctly.",
94             prop.getValue(), TESTED_BEAN_TEXT); // NOI18N
95
assertEquals("Property of component " + name + " is not read-only.",
96             prop.isEnabled(), false); // NOI18N
97

98         removeFile(name);
99     }
100 }
101
Popular Tags