KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > web > performance > WebPerformanceTestCase


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.test.web.performance;
21 import org.netbeans.jemmy.EventTool;
22 import org.netbeans.modules.editor.html.HTMLKit;
23 import org.netbeans.modules.editor.java.JavaKit;
24 import org.netbeans.modules.editor.options.BaseOptions;
25 import org.netbeans.modules.html.editor.options.HTMLOptions;
26 import org.netbeans.modules.java.editor.options.JavaOptions;
27 import org.netbeans.modules.web.core.syntax.JSPKit;
28 import org.netbeans.modules.web.core.syntax.settings.JSPOptions;
29 import org.netbeans.modules.xml.text.syntax.XMLKit;
30 import org.netbeans.modules.xml.text.syntax.XMLOptions;
31 import org.netbeans.performance.test.utilities.PerformanceTestCase;
32
33 /**
34  *
35  * @author ms113234
36  */

37 public abstract class WebPerformanceTestCase extends PerformanceTestCase {
38     // Options
39
private JSPOptions jspOptions = null;
40     private JavaOptions javaOptions = null;
41     private HTMLOptions htmlOptions = null;
42     private XMLOptions xmlOptions = null;
43     /* TODO doesn't work after retouche integration
44     private JavaSettings javaSettings = null;
45      */

46     // jsp options
47
private int defCaretBlinkingRate;
48     private boolean defCodeFoldindEnabled;
49     private int defCompletionAutoPopupDelayJsp;
50     private int defFontSize;
51     private boolean defJavaDocAutoPopupJsp;
52     private int defStatusBarCaretDelay;
53     // java options
54
private int defCompletionAutoPopupDelayJava;
55     private boolean defJavaDocAutoPopupJava;
56     // java settings
57
private int defParsingErrors;
58     private EventTool eventTool = null;
59     
60     /**
61      * Creates a new instance of WebPerformanceTestCase
62      * @param testName name of the test
63      */

64     public WebPerformanceTestCase(String JavaDoc testName) {
65         super(testName);
66         init();
67     }
68     
69     /**
70      * Creates a new instance of WebPerformanceTestCase
71      * @param testName name of the test
72      * @param performanceDataName name for measured performance data, measured values are stored to results under this name
73      */

74     public WebPerformanceTestCase(String JavaDoc testName, String JavaDoc performanceDataName) {
75         super(testName, performanceDataName);
76         init();
77     }
78     
79     protected void init() {
80         // timeouts
81
WAIT_AFTER_PREPARE = 1500;
82         WAIT_AFTER_OPEN = 2000;
83         HEURISTIC_FACTOR = -1;
84         // init options
85
jspOptions = (JSPOptions) BaseOptions.getOptions(JSPKit.class);
86         javaOptions = (JavaOptions) BaseOptions.getOptions(JavaKit.class);
87         htmlOptions = (HTMLOptions) BaseOptions.getOptions(HTMLKit.class);
88         xmlOptions = (XMLOptions) BaseOptions.getOptions(XMLKit.class);
89         /* TODO doesn't work after retouche integration
90         javaSettings = JavaSettings.getDefault();
91          */

92         // TODO replace by store/reload whole settings impl
93
// jsp options
94
defCaretBlinkingRate = jspOptions.getCaretBlinkRate();
95         defCodeFoldindEnabled = jspOptions.getCodeFoldingEnable();
96         defCompletionAutoPopupDelayJsp = jspOptions.getCompletionAutoPopupDelay();
97         defFontSize = jspOptions.getFontSize();
98         defJavaDocAutoPopupJsp = jspOptions.getJavaDocAutoPopup();
99         defStatusBarCaretDelay = jspOptions.getStatusBarCaretDelay();
100         // java options
101
defCompletionAutoPopupDelayJava = javaOptions.getCompletionAutoPopupDelay();
102         defJavaDocAutoPopupJava = javaOptions.getJavaDocAutoPopup();
103         // java settings
104
/* TODO doesn't work after retouche integration
105         defParsingErrors = javaSettings.getParsingErrors();
106          */

107         // turn off caret blinking
108
jspOptions.setCaretBlinkRate(0);
109         javaOptions.setCaretBlinkRate(0);
110         htmlOptions.setCaretBlinkRate(0);
111         xmlOptions.setCaretBlinkRate(0);
112 // try {
113
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
114
// // save default JSP Options
115
// ObjectOutputStream out = new ObjectOutputStream(baos);
116
// jspOptions.writeExternal(out);
117
// defJspOptions = baos.toByteArray();
118
// out.reset();
119
// // save default Java Options
120
// javaOptions.writeExternal(out);
121
// defJavaOptions = baos.toByteArray();
122
// out.reset();
123
// // save default Java Settings
124
// javaSettings.writeExternal(out);
125
// defJavaSettings = baos.toByteArray();
126
// out.reset();
127
// } catch (IOException ioe) {
128
// fail(ioe);
129
// }
130

131     }
132     
133     protected void resetOptions() {
134         // TODO replace by store/reload whole settings impl
135
jspOptions.setCodeFoldingEnable(defCodeFoldindEnabled);
136         jspOptions.setCompletionAutoPopupDelay(defCompletionAutoPopupDelayJsp);
137         jspOptions.setFontSize(defFontSize);
138         jspOptions.setJavaDocAutoPopup(defJavaDocAutoPopupJsp);
139         jspOptions.setStatusBarCaretDelay(defStatusBarCaretDelay);
140         // java options
141
javaOptions.setCompletionAutoPopupDelay(defCompletionAutoPopupDelayJava);
142         javaOptions.setJavaDocAutoPopup(defJavaDocAutoPopupJava);
143         // java settings
144
/* TODO doesn't work after retouche integration
145         javaSettings.setParsingErrors(defParsingErrors);
146          */

147 // try {
148
// System.out.println("defJavaSettings= " + defJavaSettings.length);
149
// System.out.println("defJavaOptions= " + defJavaOptions.length);
150
// System.out.println("defJspOptions= " + defJspOptions.length);
151
//
152
// // java settings
153
// ByteArrayInputStream bais = new ByteArrayInputStream(defJavaSettings);
154
// ObjectInputStream in = new ObjectInputStream(bais);
155
// javaSettings.readExternal(in);
156
// // java options
157
// bais = new ByteArrayInputStream(defJavaOptions);
158
// in = new ObjectInputStream(bais);
159
// javaOptions.readExternal(in);
160
// // jsp options
161
// bais = new ByteArrayInputStream(defJspOptions);
162
// in = new ObjectInputStream(bais);
163
// jspOptions.readExternal(in);
164
// } catch (Exception e) {
165
// fail(e);
166
// }
167
}
168     
169     protected JSPOptions jspOptions() {
170         return jspOptions;
171     }
172     
173     protected JavaOptions javaOptions() {
174         return javaOptions;
175     }
176     
177     /* TODO doesn't work after retouche integration
178     protected JavaSettings javaSettings() {
179         return javaSettings;
180     }
181     */

182     
183     protected void shutdown() {
184         resetOptions();
185         repaintManager().setRegionFilter(null);
186     }
187     
188     protected EventTool eventTool() {
189         if (eventTool == null) {
190             eventTool = new EventTool();
191         }
192         return eventTool;
193     }
194     
195     public String JavaDoc toString() {
196         return renamedTestCaseName.toString();
197     }
198 }
199
Popular Tags