001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * Portions Copyrighted 2007 Sun Microsystems, Inc.
027: */
028: package org.netbeans.test.java.hints;
029:
030: import junit.textui.TestRunner;
031: import org.netbeans.jellytools.EditorOperator;
032: import org.netbeans.jellytools.OptionsOperator;
033: import org.netbeans.jemmy.EventTool;
034: import org.netbeans.jemmy.operators.JSplitPaneOperator;
035: import org.netbeans.jemmy.operators.JTabbedPaneOperator;
036: import org.netbeans.jemmy.operators.JTreeOperator;
037:
038: /**
039: *
040: * @author jp159440
041: */
042: public class HintsTest extends HintsTestCase {
043:
044: public HintsTest(String testMethodName) {
045: super (testMethodName);
046: }
047:
048: public void testCast() {
049: String file = "castHint";
050: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
051: editor = new EditorOperator(file);
052: editor.setCaretPosition(9, 1);
053: useHint("Cast ...new Object(...) to String", new String[] {
054: "Cast ...new Object(...) to String",
055: "Change type of s to Object" },
056: ".*String s = \\(String\\) new Object\\(\\);.*");
057: }
058:
059: public void testCast2() {
060: String file = "castHint";
061: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
062: editor = new EditorOperator(file);
063: editor.setCaretPosition(12, 1);
064: useHint("Cast ...get(...) to File", new String[] {
065: "Cast ...get(...) to File",
066: "Change type of i to Object" },
067: ".*File i = \\(File\\) l.get\\(1\\);.*");
068: }
069:
070: public void testCast3() {
071: String file = "castHint";
072: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
073: editor = new EditorOperator(file);
074: editor.setCaretPosition(16, 1);
075: useHint("Cast ...get(...) to Integer", new String[] {
076: "Cast ...get(...) to Integer",
077: "Change type of i to Number" },
078: ".*Integer i = \\(Integer\\) nums.get\\(1\\);.*");
079: }
080:
081: public void testAddParam() {
082: String file = "addHint";
083: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
084: editor = new EditorOperator(file);
085: editor.setCaretPosition(13, 1);
086: useHint(
087: "Create Parameter x",
088: new String[] { "Create Parameter x",
089: "Create Local Variable x",
090: "Create Field x in org.netbeans.test.java.hints.HintsTest.addHint" },
091: ".*public addHint\\(String\\[\\] x\\) \\{.*");
092: }
093:
094: public void testAddParam2() {
095: String file = "addHint";
096: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
097: editor = new EditorOperator(file);
098: editor.setCaretPosition(22, 1);
099: useHint(
100: "Create Parameter",
101: new String[] { "Create Parameter a",
102: "Create Local Variable a",
103: "Create Field a in org.netbeans.test.java.hints.HintsTest.addHint" },
104: ".*public void method\\(String p1, int p2,int a\\) \\{.*");
105: }
106:
107: public void testAddParam3() {
108: String file = "addHint";
109: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
110: editor = new EditorOperator(file);
111: editor.setCaretPosition(23, 1);
112: useHint(
113: "Create Parameter",
114: new String[] { "Create Parameter b",
115: "Create Local Variable b",
116: "Create Field b in org.netbeans.test.java.hints.HintsTest.addHint" },
117: ".*public void method\\(String p1, int p2,long b\\) \\{.*");
118: }
119:
120: public void testAddParam4() {
121: String file = "addHint";
122: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
123: editor = new EditorOperator(file);
124: editor.setCaretPosition(24, 1);
125: useHint(
126: "Create Parameter",
127: new String[] { "Create Parameter c",
128: "Create Local Variable c",
129: "Create Field c in org.netbeans.test.java.hints.HintsTest.addHint" },
130: ".*public void method\\(String p1, int p2,char c\\) \\{.*");
131: }
132:
133: public void testAddParam5() {
134: String file = "addHint";
135: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
136: editor = new EditorOperator(file);
137: editor.setCaretPosition(25, 1);
138: useHint(
139: "Create Parameter",
140: new String[] { "Create Parameter d",
141: "Create Local Variable d",
142: "Create Field d in org.netbeans.test.java.hints.HintsTest.addHint" },
143: ".*public void method\\(String p1, int p2,byte d\\) \\{.*");
144: }
145:
146: public void testAddParam6() {
147: String file = "addHint";
148: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
149: editor = new EditorOperator(file);
150: editor.setCaretPosition(26, 1);
151: useHint(
152: "Create Parameter",
153: new String[] { "Create Parameter e",
154: "Create Local Variable e",
155: "Create Field e in org.netbeans.test.java.hints.HintsTest.addHint" },
156: ".*public void method\\(String p1, int p2,double e\\) \\{.*");
157: }
158:
159: public void testAddParam7() {
160: String file = "addHint";
161: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
162: editor = new EditorOperator(file);
163: editor.setCaretPosition(27, 1);
164: useHint(
165: "Create Parameter",
166: new String[] { "Create Parameter f",
167: "Create Local Variable f",
168: "Create Field f in org.netbeans.test.java.hints.HintsTest.addHint" },
169: ".*public void method\\(String p1, int p2,Integer f\\) \\{.*");
170: }
171:
172: public void testAddParam8() {
173: String file = "addHint";
174: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
175: editor = new EditorOperator(file);
176: editor.setCaretPosition(28, 1);
177: useHint(
178: "Create Parameter",
179: new String[] { "Create Parameter g",
180: "Create Local Variable g",
181: "Create Field g in org.netbeans.test.java.hints.HintsTest.addHint" },
182: ".*public void method\\(String p1, int p2,LinkedList<String> g\\) \\{.*");
183: }
184:
185: public void testAddParam9() {
186: String file = "addHint";
187: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
188: editor = new EditorOperator(file);
189: editor.setCaretPosition(29, 1);
190: useHint(
191: "Create Parameter",
192: new String[] { "Create Parameter h",
193: "Create Local Variable h",
194: "Create Field h in org.netbeans.test.java.hints.HintsTest.addHint" },
195: ".*public void method\\(String p1, int p2,String h\\) \\{.*");
196: }
197:
198: public void testAddParamA() {
199: String file = "addHint";
200: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
201: editor = new EditorOperator(file);
202: editor.setCaretPosition(34, 1);
203: useHint(
204: "Create Parameter",
205: new String[] { "Create Parameter a",
206: "Create Local Variable a",
207: "Create Field a in org.netbeans.test.java.hints.HintsTest.addHint" },
208: ".*public void method2\\(double x,int a, int ... y\\) \\{.*");
209: }
210:
211: public void testAddParamB() {
212: String file = "addHint";
213: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
214: editor = new EditorOperator(file);
215: editor.setCaretPosition(30, 1);
216: useHint(
217: "Create Parameter",
218: new String[] { "Create Parameter i",
219: "Create Local Variable i",
220: "Create Field i in org.netbeans.test.java.hints.HintsTest.addHint" },
221: ".*public void method\\(String p1, int p2,Map<String, List<String>> i\\) \\{.*");
222: }
223:
224: public void testAddLocal() {
225: String file = "addHint";
226: setInPlaceCreation(true);
227: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
228: editor = new EditorOperator(file);
229: editor.setCaretPosition(13, 1);
230: useHint(
231: "Create Local Variable",
232: new String[] { "Create Parameter x",
233: "Create Local Variable x",
234: "Create Field x in org.netbeans.test.java.hints.HintsTest.addHint" },
235: ".*String\\[\\] x = new String\\[\\]\\{\"array\"\\};.*");
236: }
237:
238: public void testAddLocal2() {
239: String file = "addHint";
240: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
241: editor = new EditorOperator(file);
242: editor.setCaretPosition(22, 1);
243: useHint(
244: "Create Local Variable",
245: new String[] { "Create Parameter a",
246: "Create Local Variable a",
247: "Create Field a in org.netbeans.test.java.hints.HintsTest.addHint" },
248: ".*int a = 3;.*");
249: }
250:
251: public void testAddLocal3() {
252: String file = "addHint";
253: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
254: editor = new EditorOperator(file);
255: editor.setCaretPosition(23, 1);
256: useHint(
257: "Create Local Variable",
258: new String[] { "Create Parameter b",
259: "Create Local Variable b",
260: "Create Field b in org.netbeans.test.java.hints.HintsTest.addHint" },
261: ".*long b = 3l;.*");
262: }
263:
264: public void testAddLocal4() {
265: String file = "addHint";
266: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
267: editor = new EditorOperator(file);
268: editor.setCaretPosition(24, 1);
269: useHint(
270: "Create Local Variable",
271: new String[] { "Create Parameter c",
272: "Create Local Variable c",
273: "Create Field c in org.netbeans.test.java.hints.HintsTest.addHint" },
274: ".*char c = 'c';.*");
275: }
276:
277: public void testAddLocal5() {
278: String file = "addHint";
279: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
280: editor = new EditorOperator(file);
281: editor.setCaretPosition(25, 1);
282: useHint(
283: "Create Local Variable",
284: new String[] { "Create Parameter d",
285: "Create Local Variable d",
286: "Create Field d in org.netbeans.test.java.hints.HintsTest.addHint" },
287: ".*byte d = \\(byte\\) 2;.*");
288: }
289:
290: public void testAddLocal6() {
291: String file = "addHint";
292: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
293: editor = new EditorOperator(file);
294: editor.setCaretPosition(26, 1);
295: useHint(
296: "Create Local Variable",
297: new String[] { "Create Parameter e",
298: "Create Local Variable e",
299: "Create Field e in org.netbeans.test.java.hints.HintsTest.addHint" },
300: ".*double e = 3.4;.*");
301: }
302:
303: public void testAddLocal7() {
304: String file = "addHint";
305: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
306: editor = new EditorOperator(file);
307: editor.setCaretPosition(27, 1);
308: useHint(
309: "Create Local Variable",
310: new String[] { "Create Parameter f",
311: "Create Local Variable f",
312: "Create Field f in org.netbeans.test.java.hints.HintsTest.addHint" },
313: ".*Integer f = new Integer\\(1\\).*");
314: }
315:
316: public void testAddLocal8() {
317: String file = "addHint";
318: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
319: editor = new EditorOperator(file);
320: editor.setCaretPosition(28, 1);
321: useHint(
322: "Create Local Variable",
323: new String[] { "Create Parameter g",
324: "Create Local Variable g",
325: "Create Field g in org.netbeans.test.java.hints.HintsTest.addHint" },
326: ".*LinkedList<String> g = new LinkedList<String>\\(\\);.*");
327: }
328:
329: public void testAddLocal9() {
330: String file = "addHint";
331: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
332: editor = new EditorOperator(file);
333: editor.setCaretPosition(29, 1);
334: useHint(
335: "Create Local Variable",
336: new String[] { "Create Parameter h",
337: "Create Local Variable h",
338: "Create Field h in org.netbeans.test.java.hints.HintsTest.addHint" },
339: ".*String h = \"ssss\";.*");
340: }
341:
342: public void testAddLocalA() {
343: String file = "addHint";
344: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
345: editor = new EditorOperator(file);
346: editor.setCaretPosition(34, 1);
347: useHint(
348: "Create Local Variable",
349: new String[] { "Create Parameter a",
350: "Create Local Variable a",
351: "Create Field a in org.netbeans.test.java.hints.HintsTest.addHint" },
352: ".*int a = 3;.*");
353: }
354:
355: public void testAddLocalB() {
356: String file = "addHint";
357: openSourceFile("org.netbeans.test.java.hints.HintsTest", file);
358: editor = new EditorOperator(file);
359: editor.setCaretPosition(30, 1);
360: useHint(
361: "Create Local Variable",
362: new String[] { "Create Parameter i",
363: "Create Local Variable i",
364: "Create Field i in org.netbeans.test.java.hints.HintsTest.addHint" },
365: ".*Map<String, List<String>> i = getMap\\(\\);.*");
366: }
367:
368: public static void main(String[] args) {
369: new TestRunner().run(HintsTest.class);
370: }
371:
372: }
|