KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > propertyeditors > PropertyType_String


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 gui.propertyeditors;
21
22 import org.netbeans.jellytools.properties.editors.StringCustomEditorOperator;
23
24 import org.netbeans.junit.NbTestSuite;
25
26
27 /**
28  * Tests of String Property Editor.
29  *
30  * @author Marian.Mirilovic@Sun.Com
31  */

32 public class PropertyType_String extends PropertyEditorsTest {
33
34     public String JavaDoc propertyName_L;
35     public String JavaDoc propertyValue_L;
36
37     /** Creates a new instance of PropertyType_Boolean */
38     public PropertyType_String(String JavaDoc testName) {
39         super(testName);
40     }
41
42
43     public void setUp(){
44         propertyName_L = "String";
45         super.setUp();
46     }
47     
48     public static NbTestSuite suite() {
49         NbTestSuite suite = new NbTestSuite();
50         suite.addTest(new PropertyType_String("verifyCustomizer"));
51         suite.addTest(new PropertyType_String("testCustomizerCancel"));
52         suite.addTest(new PropertyType_String("testCustomizerOk"));
53         suite.addTest(new PropertyType_String("testByInPlace"));
54         return suite;
55     }
56     
57     public void testCustomizerOk() {
58         propertyValue_L = "My String - ok";
59         setByCustomizerOk(propertyName_L, true);
60     }
61     
62     public void testCustomizerCancel(){
63         propertyValue_L = "My String - cancel";
64         setByCustomizerCancel(propertyName_L, false);
65     }
66     
67     public void testByInPlace(){
68         propertyValue_L = "My String - in-place";
69         setByInPlace(propertyName_L, propertyValue_L, true);
70     }
71     
72     public void verifyCustomizer() {
73         verifyCustomizer(propertyName_L);
74     }
75     
76     public void setCustomizerValue() {
77         StringCustomEditorOperator customizer = new StringCustomEditorOperator(propertyCustomizer);
78         customizer.setStringValue(propertyValue_L);
79     }
80     
81     public void verifyPropertyValue(boolean expectation) {
82         String JavaDoc newValue = getValue(propertyName_L);
83         
84         if( ( !newValue.equals(propertyInitialValue) && propertyValue_L.equals(newValue) ) && expectation) {
85             log("New value is {"+newValue+"} and old value is{"+propertyInitialValue+"} - expactation is {"+expectation+"} --> PASS");
86         }else if ( newValue.equals(propertyInitialValue) && !propertyValue_L.equals(newValue) && !expectation ) {
87             log("New value is {"+newValue+"} and old value is{"+propertyInitialValue+"} - expactation is {"+expectation+"} --> PASS");
88         }else {
89             fail("New value is {"+newValue+"} and old value is{"+propertyInitialValue+"} - expactation is {"+expectation+"} --> FAIL");
90         }
91     }
92     
93     public void verifyCustomizerLayout() {
94         StringCustomEditorOperator customizer = new StringCustomEditorOperator(propertyCustomizer);
95         customizer.verify();
96         customizer.btOK();
97         customizer.btCancel();
98     }
99     
100     /** Test could be executed internaly in Forte without XTest
101      * @param args arguments from command line
102      */

103     public static void main(String JavaDoc[] args) {
104         //junit.textui.TestRunner.run(new NbTestSuite(PropertyType_String.class));
105
junit.textui.TestRunner.run(suite());
106     }
107     
108 }
109
Popular Tags