KickJava   Java API By Example, From Geeks To Geeks.

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


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

25
26 package org.netbeans.test.java.eventfiring.ClassChanged;
27
28 import org.netbeans.test.java.eventfiring.MyListener;
29 //import org.netbeans.modules.java.JavaConnections.Type;
30
//import org.openide.src.Identifier;
31
//import org.openide.src.ClassElement;
32
import java.lang.reflect.Modifier JavaDoc;
33 import java.beans.PropertyChangeListener JavaDoc;
34 //import org.netbeans.modules.java.JavaDataObject;
35
import org.openide.cookies.ConnectionCookie;
36 import org.netbeans.test.java.Common;
37 import org.openide.loaders.DataObject;
38
39 /**
40  * @author Jan Becicka <Jan.Becicka@sun.com>
41  */

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

70     public boolean go(Object JavaDoc o, java.io.PrintWriter JavaDoc log) throws Exception JavaDoc {
71         
72 // ClassElement clazz = ((org.openide.src.SourceElement) o).getClasses()[0];
73
// System.setProperty(MyListener.RESULT_KEY,"");
74
boolean passed = true;
75 //
76
// clazz.addPropertyChangeListener(new PropertyChangeListener() {
77
// public void propertyChange(java.beans.PropertyChangeEvent ev) {
78
// if (!ev.getPropertyName().equals("cookie")) { //hack to slow event firing
79
// ref("PropertyChanged: "+ev.getPropertyName());
80
// }
81
// }
82
// });
83
//
84
// JavaDataObject DO = (JavaDataObject) clazz.getSource().getCookie(JavaDataObject.class);
85
// ConnectionCookie cc = (ConnectionCookie) DO.getCookie(ConnectionCookie.class);
86
// MyListener l = new MyListener();
87
// //Type t = new Type(org.netbeans.modules.java.JavaConnections.TYPE_ALL);
88
//
89
// Thread.currentThread().sleep(DELAY * 4);
90
// //cc.register(t, l);
91
// ClassElement innerClass = new ClassElement();
92
// innerClass.setModifiers(Modifier.PUBLIC | Modifier.SYNCHRONIZED);
93
// innerClass.setSuperclass(Identifier.create("Object"));
94
// innerClass.setName(Identifier.create("InnerClass","InnerClass"));
95
//
96
// Thread.currentThread().sleep(DELAY);
97
//
98
//// clazz.addMethod(Common.createMethod("method1", Modifier.PRIVATE | Modifier.SYNCHRONIZED, org.openide.src.Type.INT, Common.PARS2));
99
// log.println("add method");
100
// Thread.currentThread().sleep(DELAY);
101
//
102
//// clazz.addField(Common.createField("field"));
103
// log.println("add field");
104
// Thread.currentThread().sleep(DELAY);
105
//
106
//// clazz.addConstructor(Common.createConstructor(null,Common.PARS1));
107
// log.println("add constructor");
108
// Thread.currentThread().sleep(DELAY);
109
//
110
// clazz.addClass(innerClass);
111
// log.println("add inner class");
112
// Thread.currentThread().sleep(DELAY);
113
//
114
//// clazz.addInitializer(Common.createInitializer());
115
// log.println("add initializer");
116
// Thread.currentThread().sleep(DELAY);
117
//
118
// clazz.addInterface(Identifier.create("Serializable"));
119
// log.println("add interface");
120
// Thread.currentThread().sleep(DELAY);
121
//
122
// clazz.removeFields(clazz.getFields());
123
// log.println("remove fields");
124
// Thread.currentThread().sleep(DELAY);
125
//
126
// clazz.removeMethods(clazz.getMethods());
127
// log.println("remove methods");
128
// Thread.currentThread().sleep(DELAY);
129
//
130
// clazz.removeClasses(clazz.getClasses());
131
// log.println("remove classes");
132
// Thread.currentThread().sleep(DELAY);
133
//
134
// clazz.removeInitializers(clazz.getInitializers());
135
// log.println("remove initializers");
136
// Thread.currentThread().sleep(DELAY);
137
//
138
// clazz.removeInterface(clazz.getInterfaces());
139
// log.println("remove interfaces");
140
// Thread.currentThread().sleep(DELAY);
141
//
142
// clazz.removeConstructors(clazz.getConstructors());
143
// log.println("remove constructors");
144
// Thread.currentThread().sleep(DELAY);
145
//
146
// //cc.unregister(t, l);
147
//
148
// ref(System.getProperty(MyListener.RESULT_KEY));
149

150         return passed;
151     }
152     
153     protected boolean writeResult(DataObject DO) {
154         return true;
155     }
156     
157     /**
158      */

159     protected void setUp() {
160         super.setUp();
161         name = "JavaTestSourceEventFiringClassChanged";
162         packageName = "org.netbeans.test.java.testsources";
163     }
164     
165     protected void tearDown() {
166         try {
167             Thread.sleep(2*DELAY);
168         } catch (InterruptedException JavaDoc e) {
169         }
170         super.tearDown();
171     }
172     
173 }
174
Popular Tags