KickJava   Java API By Example, From Geeks To Geeks.

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


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

25
26 package org.netbeans.test.java.eventfiring.MethodChanged;
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 MethodChanged 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 MethodChanged() {
48         super("");
49     }
50     
51     public MethodChanged(java.lang.String JavaDoc testName) {
52         super(testName);
53     }
54     
55     public static NbTest suite() {
56         return new NbTestSuite(MethodChanged.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
// //cc.register(t, l);
79
//
80
// org.openide.src.MethodElement me = Common.createMethod("method1", java.lang.reflect.Modifier.PUBLIC | java.lang.reflect.Modifier.STATIC, org.openide.src.Type.VOID, Common.PARS1);
81
//
82
// clazz.addMethod(me);
83
// me = clazz.getMethods()[0];
84
//
85
// Thread.currentThread().sleep(DELAY*3);
86
//
87
// me.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
88
// public void propertyChange(java.beans.PropertyChangeEvent ev) {
89
// if (!ev.getPropertyName().equals("cookie")) { //hack to slow event firing
90
// ref("PropertyChanged: "+ev.getPropertyName());
91
// }
92
// }
93
// });
94
//
95
//
96
// Thread.currentThread().sleep(DELAY);
97
//
98
// me.setBody("//blah\n");
99
// Thread.currentThread().sleep(DELAY);
100
//
101
// me.setExceptions(new org.openide.src.Identifier[]{org.openide.src.Identifier.create("java.lang.Exception","java.io.IOException")});
102
// Thread.currentThread().sleep(DELAY);
103
//
104
//
105
// me.setModifiers(java.lang.reflect.Modifier.PROTECTED);
106
// Thread.currentThread().sleep(DELAY);
107
//
108
// me.setName(org.openide.src.Identifier.create("ranamedMethod"));
109
// Thread.currentThread().sleep(DELAY);
110
//
111
// me.setParameters(Common.PARS2);
112
// Thread.currentThread().sleep(DELAY);
113
//
114
// me.setReturn(org.openide.src.Type.CHAR);
115
// Thread.currentThread().sleep(DELAY);
116
//
117
// //cc.unregister(t, l);
118
//
119
// ref(System.getProperty(MyListener.RESULT_KEY));
120

121         return passed;
122     }
123     
124     protected boolean writeResult(DataObject DO) {
125         return true;
126     }
127     
128     /**
129      */

130     protected void setUp() {
131         super.setUp();
132         name = "JavaTestSourceEventFiringMethodChanged";
133         packageName = "org.netbeans.test.java.testsources";
134     }
135     
136     protected void tearDown() {
137         try {
138             Thread.sleep(2*DELAY);
139         } catch (InterruptedException JavaDoc e) {
140         }
141         super.tearDown();
142     }
143     
144 }
145
Popular Tags