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: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.java.hints.errors;
042:
043: import org.netbeans.modules.java.hints.infrastructure.*;
044:
045: /**
046: * @author Jan Lahoda
047: */
048: public class ErrorHintsTest extends HintsTestBase {
049:
050: /** Need to be defined because of JUnit */
051: public ErrorHintsTest(String name) {
052: super (name);
053:
054: }
055:
056: // public static TestSuite suite() {
057: // NbTestSuite suite = new NbTestSuite();
058: //
059: // suite.addTest(new JavaHintsTest("testImplementAbstractMethodsHint9"));
060: // suite.addTest(new JavaHintsTest("testImplementAbstractMethodsHint10"));
061: // suite.addTest(new JavaHintsTest("testImplementAbstractMethodsHint11"));
062: //// suite.addTest(new JavaHintsTest("testMakeClassAbstract3"));
063: //
064: // return suite;
065: // }
066:
067: //
068: // public void testImplementAbstractMethodsHint1() throws Exception {
069: // performTest("ImplementAbstractMethods1", "Implement", 16, 60);
070: // }
071: //
072: // public void testImplementAbstractMethodsHint2() throws Exception {
073: // performTest("ImplementAbstractMethods2", "Implement", 17, 15);
074: // }
075: //
076: // public void testImplementAbstractMethodsHint3() throws Exception {
077: // performTest("ImplementAbstractMethods3", "Implement", 17, 25);
078: // }
079: //
080: // public void testImplementAbstractMethodsHint4() throws Exception {
081: // performTest("ImplementAbstractMethods4", "Implement", 16, 30);
082: // }
083: //
084: // public void testImplementAbstractMethodsHint5() throws Exception {
085: // performTest("ImplementAbstractMethods5", "Implement", 16, 30);
086: // }
087: //
088: // public void testImplementAbstractMethodsHint6() throws Exception {
089: // performTest("ImplementAbstractMethods6", "Implement", 8, 5);
090: // }
091: //
092: // public void testImplementAbstractMethodsHint7() throws Exception {
093: // performTest("ImplementAbstractMethods7", "Implement", 9, 25);
094: // }
095: //
096: // public void testImplementAbstractMethodsHint8() throws Exception {
097: // performTest("ImplementAbstractMethods8", "Implement", 12, 43);
098: // }
099:
100: public void testImplementAbstractMethodsHint9() throws Exception {
101: performTestDoNotPerform("ImplementAbstractMethods9", 8, 15);
102: }
103:
104: public void testImplementAbstractMethodsHint10() throws Exception {
105: performTestDoNotPerform("ImplementAbstractMethods10", 8, 15);
106: }
107:
108: public void testImplementAbstractMethodsHint11() throws Exception {
109: performTest("ImplementAbstractMethods11", "Implement", 8, 15);
110: }
111:
112: // public void testAddSemicolonHint() throws Exception {
113: // performTest("org.netbeans.test.java.hints.AddSemicolon", "semicolon", 17, 15);
114: // }
115: //
116: public void testAddCastHint1() throws Exception {
117: performTest("org.netbeans.test.java.hints.AddCast1", "Cast",
118: 18, 15);
119: }
120:
121: public void testAddCastHint2() throws Exception {
122: performTest("org.netbeans.test.java.hints.AddCast2", "Cast",
123: 20, 13);
124: }
125:
126: public void testAddCastHint3() throws Exception {
127: performTest("org.netbeans.test.java.hints.AddCast3", "Cast",
128: 20, 20);
129: }
130:
131: public void testAddCastHint4() throws Exception {
132: performTest("org.netbeans.test.java.hints.AddCast4", "Cast",
133: 22, 10);
134: }
135:
136: public void testAddCastHint5() throws Exception {
137: performTest("org.netbeans.test.java.hints.AddCast5", "Cast",
138: 12, 1);
139: }
140:
141: public void testAddCastHint6() throws Exception {
142: performTest("org.netbeans.test.java.hints.AddCast6", "Cast",
143: 13, 23);
144: }
145:
146: public void testAddCastHint7() throws Exception {
147: performTest("org.netbeans.test.java.hints.AddCast7", "Cast",
148: 12, 18);
149: }
150:
151: public void testAddCastHint8() throws Exception {
152: performTest("org.netbeans.test.java.hints.AddCast8", "Cast",
153: 13, 18);
154: }
155:
156: public void testAddCastHint9() throws Exception {
157: //should not cause exception
158: //also tests Create field hint, which should not be proposed in this case:
159: performTestDoNotPerform(
160: "org.netbeans.test.java.hints.AddCast9", 11, 18);
161: }
162:
163: public void testAddCastHint10() throws Exception {
164: //should not cause exception
165: performTest("org.netbeans.test.java.hints.AddCast10", "Cast",
166: 13, 18);
167: }
168:
169: public void testAddCastHint11() throws Exception {
170: performTestDoNotPerform(
171: "org.netbeans.test.java.hints.AddCast11", 12, 18);
172: }
173:
174: //randomly fails, likely because of a bug in the change declaration hint:
175: // public void testAddCastHint12() throws Exception {
176: // performTestDoNotPerform("org.netbeans.test.java.hints.AddCast12", 12, 18);
177: // performTestDoNotPerform("org.netbeans.test.java.hints.AddCast12", 14, 18);
178: // performTestDoNotPerform("org.netbeans.test.java.hints.AddCast12", 16, 18);
179: // }
180:
181: public void testAddCastHintDoNotPropose() throws Exception {
182: //should not propose "cast to ..." hint if the actual problem is an undefined method
183: performTestDoNotPerform(
184: "org.netbeans.test.java.hints.AddCastDoNotPropose", 9,
185: 18);
186: }
187:
188: public void testAddThrowsClauseHint1() throws Exception {
189: performTest("org.netbeans.test.java.hints.AddThrowsClause1",
190: "throws", 19, 30);
191: }
192:
193: public void testAddThrowsClauseHint2() throws Exception {
194: performTest("org.netbeans.test.java.hints.AddThrowsClause2",
195: "throws", 22, 30);
196: }
197:
198: public void testAddThrowsClauseHint3() throws Exception {
199: performTest("org.netbeans.test.java.hints.AddThrowsClause3",
200: "throws", 11, 30);
201: }
202:
203: public void testAddThrowsClauseHint4() throws Exception {
204: performTest("org.netbeans.test.java.hints.AddThrowsClause4",
205: "throws", 11, 30);
206: }
207:
208: /**tests only if an exception is thrown during hints creation of errors for this file
209: */
210: public void testCreateElementException() throws Exception {
211: performTestDoNotPerform(
212: "org.netbeans.test.java.hints.CreateElementException",
213: 10, 27);
214: }
215:
216: // /**tests if an exception is thrown when the hint is approved:
217: // */
218: // public void testCreateFieldException() throws Exception {
219: // performTest("org.netbeans.test.java.hints.CreateFieldException", "Field", 17, 31);
220: // }
221:
222: //XXX: fails because of a bug in create constructor hint:
223: // public void testCreateFieldException2() throws Exception {
224: // performTestDoNotPerform("org.netbeans.test.java.hints.CreateFieldException2", 8, 15);
225: // }
226:
227: public void testCreateFieldException3() throws Exception {
228: performTestDoNotPerform(
229: "org.netbeans.test.java.hints.CreateFieldException3",
230: 9, 15);
231: }
232:
233: public void testCreateField1() throws Exception {
234: performTest("org.netbeans.test.java.hints.CreateField1",
235: "Field", 23, 18);
236: }
237:
238: public void testCreateField2() throws Exception {
239: performTest("org.netbeans.test.java.hints.CreateField2",
240: "Field", 23, 20);
241: }
242:
243: public void testCreateField3() throws Exception {
244: performTest("org.netbeans.test.java.hints.CreateField3",
245: "Field", 23, 20);
246: }
247:
248: // public void testCreateField4() throws Exception {
249: // performTest("org.netbeans.test.java.hints.CreateField4", "Field", 23, 20);
250: // }
251:
252: public void testCreateField5() throws Exception {
253: performTest("org.netbeans.test.java.hints.CreateField5",
254: "Field", 23, 18);
255: }
256:
257: public void testCreateField6() throws Exception {
258: performTest("org.netbeans.test.java.hints.CreateField6",
259: "Field", 25, 18);
260: }
261:
262: public void testCreateField7() throws Exception {
263: performTestDoNotPerform(
264: "org.netbeans.test.java.hints.CreateField7", 9, 18);
265: }
266:
267: //Create field which type is a type varaible, does not work yet:
268: // public void testCreateField8() throws Exception {
269: // performTest("org.netbeans.test.java.hints.CreateField8", "Field", 6, 18);
270: // }
271:
272: public void testCreateField10() throws Exception {
273: performTest("org.netbeans.test.java.hints.CreateField10",
274: "Field", 9, 10);
275: }
276:
277: public void testCreateFieldPrimitive() throws Exception {
278: performTest(
279: "org.netbeans.test.java.hints.CreateFieldPrimitive",
280: "Field", 23, 13);
281: }
282:
283: // public void testCreateFieldMethod1() throws Exception {
284: // performTest("org.netbeans.test.java.hints.CreateFieldMethod1", "Field", 23, 13);
285: // }
286:
287: public void testCreateFieldMethod2() throws Exception {
288: performTest("org.netbeans.test.java.hints.CreateFieldMethod2",
289: "Field", 23, 13);
290: }
291:
292: // public void testDoNotProposeCreateField1() throws Exception {
293: // performTestDoNotPerform("org.netbeans.test.java.hints.DoNotProposeCreateField1",9, 18);
294: // }
295: //
296: public void testDoNotProposeCreateField2() throws Exception {
297: performTestDoNotPerform(
298: "org.netbeans.test.java.hints.DoNotProposeCreateField2",
299: 7, 10);
300: }
301:
302: // public void testTryWrapper1() throws Exception {
303: // performTest("org.netbeans.test.java.hints.TryWrapper1", "try-catch", 19, 30);
304: // }
305: // public void testTryWrapper2() throws Exception {
306: // performTest("org.netbeans.test.java.hints.TryWrapper2", "try-catch", 19, 30);
307: // }
308: // public void testTryWrapper3() throws Exception {
309: // performTest("org.netbeans.test.java.hints.TryWrapper3", "try-catch", 20, 30);
310: // }
311: // public void testTryWrapper4() throws Exception {
312: // performTest("org.netbeans.test.java.hints.TryWrapper4", "try-catch", 19, 30);
313: // }
314: // public void testTryWrapper5() throws Exception {
315: // performTest("org.netbeans.test.java.hints.TryWrapper5", "try-catch", 19, 30);
316: // }
317: // public void testTryWrapper6() throws Exception {
318: // performTest("org.netbeans.test.java.hints.TryWrapper6", "try-catch", 19, 30);
319: // }
320: // public void testTryWrapper7() throws Exception {
321: // performTest("org.netbeans.test.java.hints.TryWrapper7", "try-catch", 19, 30);
322: // }
323: // public void testTryWrapper8() throws Exception {
324: // performTest("org.netbeans.test.java.hints.TryWrapper8", "try-catch", 21, 30);
325: // }
326: // public void testTryWrapper9() throws Exception {
327: // performTest("org.netbeans.test.java.hints.TryWrapper9", "try-catch", 19, 30);
328: // }
329: //
330: // public void testLocalAndParamIncorrect57990a() throws Exception {
331: // performTestDoNotPerform("org.netbeans.test.java.hints.LocalVarParam57990a", 23, 20);
332: // }
333: //
334: //// public void testLocalAndParamIncorrect57990b() throws Exception {
335: //// performTestDoNotPerform("org.netbeans.test.java.hints.LocalVarParam57990b", 23, 20);
336: //// }
337: //
338: // public void testLocalAndParamIncorrect57990c() throws Exception {
339: // performTestDoNotPerform("org.netbeans.test.java.hints.LocalVarParam57990c", 23, 20);
340: // }
341:
342: public void testCreateLocalVariable1() throws Exception {
343: performTest(
344: "org.netbeans.test.java.hints.CreateLocalVariable1",
345: "Local", 23, 15);
346: }
347:
348: // public void testCreateLocalVariable2() throws Exception {
349: // performTest("org.netbeans.test.java.hints.CreateLocalVariable2", "Local", 19, 20);
350: // }
351:
352: public void testCreateLocalVariable3() throws Exception {
353: performTest(
354: "org.netbeans.test.java.hints.CreateLocalVariable3",
355: "Local", 20, 20);
356: }
357:
358: public void testCreateLocalVariable4() throws Exception {
359: performTest(
360: "org.netbeans.test.java.hints.CreateLocalVariable4",
361: "Local", 8, 18);
362: }
363:
364: public void testCreateLocalVariable5() throws Exception {
365: performTest(
366: "org.netbeans.test.java.hints.CreateLocalVariable5",
367: "Local", 8, 18);
368: }
369:
370: public void testCreateLocalVariable6() throws Exception {
371: performTest(
372: "org.netbeans.test.java.hints.CreateLocalVariable6",
373: "Local", 8, 18);
374: }
375:
376: public void testCreateLocalVariable7() throws Exception {
377: performTest(
378: "org.netbeans.test.java.hints.CreateLocalVariable7",
379: "Local", 10, 18);
380: }
381:
382: public void testCreateLocalVariable8() throws Exception {
383: performTest(
384: "org.netbeans.test.java.hints.CreateLocalVariable8",
385: "Local", 9, 18);
386: }
387:
388: public void testCreateLocalVariable9() throws Exception {
389: performTest(
390: "org.netbeans.test.java.hints.CreateLocalVariable9",
391: "Local", 11, 18);
392: }
393:
394: public void testCreateLocalVariable10() throws Exception {
395: performTest(
396: "org.netbeans.test.java.hints.CreateLocalVariable10",
397: "Local", 10, 18);
398: }
399:
400: public void testCreateParam1() throws Exception {
401: performTest("org.netbeans.test.java.hints.CreateParam1",
402: "Parameter", 23, 15);
403: }
404:
405: public void testCreateParam2() throws Exception {
406: performTest("org.netbeans.test.java.hints.CreateParam2",
407: "Parameter", 20, 15);
408: }
409:
410: public void testCreateParam3() throws Exception {
411: performTest("org.netbeans.test.java.hints.CreateParam3",
412: "Parameter", 20, 15);
413: }
414:
415: public void testCreateParam4() throws Exception {
416: performTest("org.netbeans.test.java.hints.CreateParam4",
417: "Parameter", 9, 15);
418: }
419:
420: public void testCreateParam5() throws Exception {
421: performTest("org.netbeans.test.java.hints.CreateParam5",
422: "Parameter", 10, 15);
423: }
424:
425: // public void testIncorrectType57991() throws Exception {
426: // performTest("org.netbeans.test.java.hints.IncorrectType57991", "Field", 23, 20);
427: // }
428: //
429: // public void testImportBeforeCreateElement() throws Exception {
430: // performTestDoNotPerform("org.netbeans.test.java.hints.ImportBeforeCreateElement", 10, 21);
431: // }
432: //
433: // public void testIncorrectType58119a() throws Exception {
434: // performTest("org.netbeans.test.java.hints.IncorrectType58119a", "Field", 11, 9);
435: // }
436: //
437: // public void testIncorrectType58119b() throws Exception {
438: // performTest("org.netbeans.test.java.hints.IncorrectType58119b", "Parameter", 9, 9);
439: // }
440: //
441: // public void testIncorrectType58119c() throws Exception {
442: // performTest("org.netbeans.test.java.hints.IncorrectType58119c", "Local", 9, 9);
443: // }
444: //
445: // public void testIncorrectType58119d() throws Exception {
446: // performTest(
447: // "org.netbeans.test.java.hints.IncorrectType58119d",
448: // "org.netbeans.test.java.hints.IncorrectType58119d", "Create", 13, 37, false);
449: // }
450: //
451: // public void testIncorrectType58119e() throws Exception {
452: // performTest(
453: // "org.netbeans.test.java.hints.IncorrectType58119f",
454: // "org.netbeans.test.java.hints.IncorrectType58119e", "Create", 12, 24, false);
455: // }
456: //
457: // public void testTypeFromParama() throws Exception {
458: // performTest(
459: // "org.netbeans.test.java.hints.TypeFromParama",
460: // "org.netbeans.test.java.hints.TypeFromParama", "Field", 12, 9, false);
461: // }
462: //
463: // public void testTypeFromParamb() throws Exception {
464: // performTest(
465: // "org.netbeans.test.java.hints.TypeFromParamb",
466: // "org.netbeans.test.java.hints.TypeFromParamb", "Field", 12, 9, false);
467: // }
468: //
469: // public void testCastOrMethodInvocation58494a() throws Exception {
470: // performTest("org.netbeans.test.java.hints.CastOrMethodInvocation58494a", "Cast ...", 12, 14);
471: // }
472: //
473: // public void testCastOrMethodInvocation58494b() throws Exception {
474: // performTest("org.netbeans.test.java.hints.CastOrMethodInvocation58494b", "Cast ...", 13, 18);
475: // }
476: //
477: // public void testCastOrMethodInvocation58494e() throws Exception {
478: // performTestDoNotPerform("org.netbeans.test.java.hints.CastOrMethodInvocation58494e", 11, 24);
479: // }
480: //
481: // public void testCastOrMethodInvocation58494g() throws Exception {
482: // performTestDoNotPerform("org.netbeans.test.java.hints.CastOrMethodInvocation58494g", 13, 9);
483: // }
484: //
485: // public void testCastOrMethodInvocation58494h() throws Exception {
486: // performTestDoNotPerform("org.netbeans.test.java.hints.CastOrMethodInvocation58494h", 11, 22);
487: // }
488: //
489: // public void testInitializeVariable1() throws Exception {
490: // performTest("org.netbeans.test.java.hints.InitializeVariable1", "Initialize", 13, 17);
491: // }
492: //
493: // public void testInitializeVariable2() throws Exception {
494: // performTest("org.netbeans.test.java.hints.InitializeVariable2", "Initialize", 12, 17);
495: // }
496: //
497: // public void testInitializeVariable3() throws Exception {
498: // performTest("org.netbeans.test.java.hints.InitializeVariable3", "Initialize", 10, 1);
499: // }
500:
501: public void testNonAbstractClass85806() throws Exception {
502: performTestDoNotPerform(
503: "org.netbeans.test.java.hints.AbstractClass4", 8, 1);
504: }
505:
506: public void testMakeClassAbstract1() throws Exception {
507: performTest("org.netbeans.test.java.hints.MakeClassAbstract1",
508: "abstract", 3, 1);
509: }
510:
511: public void testMakeClassAbstract2() throws Exception {
512: performTest("org.netbeans.test.java.hints.MakeClassAbstract2",
513: "abstract", 3, 1);
514: }
515:
516: public void testMakeClassAbstract3() throws Exception {
517: performTest("org.netbeans.test.java.hints.MakeClassAbstract3",
518: "abstract", 3, 1);
519: }
520:
521: @Override
522: protected boolean createCaches() {
523: return false;
524: }
525:
526: }
|