KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > java > eventfiring > FieldChanged


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 /*
21  * FieldChanged.java
22  *
23  * Created on June 26, 2000, 9:29 AM
24  */

25
26 package org.netbeans.test.java.eventfiring.FieldChanged;
27
28 import org.netbeans.test.java.Common;
29 //import org.openide.src.*;
30
import java.lang.reflect.Modifier JavaDoc;
31 import org.netbeans.junit.*;
32 import org.netbeans.test.java.eventfiring.*;
33 import org.openide.loaders.DataObject;
34
35 /**
36  * @author Jan Becicka <Jan.Becicka@sun.com>
37  */

38
39 public class FieldChanged extends org.netbeans.test.java.XRunner {
40
41     final static int DELAY = 2000;
42
43     public static void main(java.lang.String JavaDoc[] args) {
44         junit.textui.TestRunner.run(suite());
45     }
46     
47     public FieldChanged() {
48         super("");
49     }
50     
51     public FieldChanged(java.lang.String JavaDoc testName) {
52         super(testName);
53     }
54     
55     public static NbTest suite() {
56         return new NbTestSuite(FieldChanged.class);
57     }
58     
59     /** "body" of this TestCase
60      * @param o SourceElement - target for generating
61      * @param log log is used for logging StackTraces
62      * @throws Exception
63      * @return true if test passed
64      * false if failed
65      */

66     public boolean go(Object JavaDoc o, java.io.PrintWriter JavaDoc log) throws Exception JavaDoc {
67         
68 // org.openide.src.ClassElement clazz = ((org.openide.src.SourceElement) o).getClasses()[0];
69
// System.setProperty(org.netbeans.test.java.eventfiring.MyListener.RESULT_KEY,"");
70
boolean passed = true;
71         
72 // org.netbeans.modules.java.JavaDataObject DO = (org.netbeans.modules.java.JavaDataObject) clazz.getSource().getCookie(org.netbeans.modules.java.JavaDataObject.class);
73
// org.openide.cookies.ConnectionCookie cc = (org.openide.cookies.ConnectionCookie) DO.getCookie(org.openide.cookies.ConnectionCookie.class);
74
// MyListener l = new MyListener();
75
// //org.netbeans.modules.java.JavaConnections.Type t = new org.netbeans.modules.java.JavaConnections.Type(org.netbeans.modules.java.JavaConnections.TYPE_ALL);
76
//
77
// Thread.currentThread().sleep(DELAY*3);
78
//
79
// //cc.register(t, l);
80
// org.openide.src.FieldElement fe = Common.createField("newField",java.lang.reflect.Modifier.PUBLIC | java.lang.reflect.Modifier.STATIC , org.openide.src.Type.BOOLEAN);
81
// clazz.addField(fe);
82
//
83
// fe = clazz.getField(org.openide.src.Identifier.create("newField"));
84
//
85
// fe.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
86
// public void propertyChange(java.beans.PropertyChangeEvent ev) {
87
// if (!ev.getPropertyName().equals("cookie")) { //hack to slow event firing
88
// ref("PropertyChanged: "+ev.getPropertyName());
89
// }
90
// }
91
// });
92
//
93
// Thread.currentThread().sleep(DELAY);
94
//
95
// fe.setType(org.openide.src.Type.FLOAT);
96
// Thread.currentThread().sleep(DELAY);
97
//
98
// fe.setInitValue("3");
99
// Thread.currentThread().sleep(DELAY);
100
//
101
// fe.setModifiers(java.lang.reflect.Modifier.PROTECTED);
102
// Thread.currentThread().sleep(DELAY);
103
//
104
// fe.setName(org.openide.src.Identifier.create("ranamedField"));
105
// Thread.currentThread().sleep(DELAY);
106
//
107
// //cc.unregister(t, l);
108
//
109
// ref(System.getProperty(MyListener.RESULT_KEY));
110

111         return passed;
112     }
113     
114     protected boolean writeResult(DataObject DO) {
115         return true;
116     }
117     
118     /**
119      */

120     protected void setUp() {
121         super.setUp();
122         name = "JavaTestSourceEventFiringFieldChanged";
123         packageName = "org.netbeans.test.java.testsources";
124     }
125     
126     protected void tearDown() {
127         try {
128             Thread.sleep(2*DELAY);
129         } catch (InterruptedException JavaDoc e) {
130         }
131         super.tearDown();
132     }
133     
134 }
135
Popular Tags