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.modules.java.hints.errors;
029:
030: import org.netbeans.modules.java.hints.infrastructure.HintsTestBase;
031:
032: /**
033: * Tests for Uncaught Exceptions (add throws, aurround with try-catch)
034: * @author Max Sauer
035: */
036: public class UncaughtExceptionTest extends HintsTestBase {
037:
038: public UncaughtExceptionTest(String name) {
039: super (name);
040: }
041:
042: @Override
043: protected void setUp() throws Exception {
044: super
045: .doSetUp("org/netbeans/modules/java/hints/resources/layer.xml");
046: }
047:
048: @Override
049: protected boolean createCaches() {
050: return false;
051: }
052:
053: @Override
054: protected String testDataExtension() {
055: return "org/netbeans/test/java/hints/UncaughtExceptionTest/";
056: }
057:
058: /** Surround with try catch as this() parameter */
059: public void testBug113448() throws Exception {
060: performTestDoNotPerform("Test", 8, 22);
061: }
062:
063: /** Surround with try catch as this() parameter, deeper in path */
064: public void testBug113448b() throws Exception {
065: performTestDoNotPerform("Test", 12, 33);
066: }
067:
068: /**
069: * Surround with try catch as this() parameter
070: * exception-throwing-method call
071: */
072: public void testBug113448c() throws Exception {
073: performTestDoNotPerform("Test", 19, 33);
074: }
075:
076: /**
077: * Don't offer surround with t-c for fields
078: */
079: public void testBug95535() throws Exception {
080: performTestDoNotPerform("Test", 34, 21);
081: }
082:
083: /**
084: * Field access inside ctor
085: */
086: public void testBug113812() throws Exception {
087: performTestDoNotPerform("Test", 31, 23);
088: }
089:
090: /** Surround with try catch inside ctor */
091: public void testInsideCtor() throws Exception {
092: performTestDoNotPerform("Test", 16, 21);
093: }
094:
095: /** Surround with try catch as this() parameter,
096: * but inside anonymous class. Should offer in this case.
097: */
098: public void testThisParamInsideAnonymous() throws Exception {
099: performTestDoNotPerform("Test", 24, 30);
100: }
101:
102: /**
103: * Offer proper exception types for generic parametrized methods
104: */
105: public void testBug113380a() throws Exception {
106: performTestDoNotPerform("TestBug113380", 13, 17);
107: }
108:
109: public void testBug113380b() throws Exception {
110: performTestDoNotPerform("TestBug113380", 14, 17);
111: }
112:
113: public void testBug88923() throws Exception {
114: performTestDoNotPerform("TestBug88923", 8, 11);
115: }
116:
117: public void testBug123850a() throws Exception {
118: performTestDoNotPerform("TestBug123850a", 7, 18);
119: }
120:
121: public void testBug123850b() throws Exception {
122: performTestDoNotPerform("TestBug123850b", 7, 18);
123: }
124:
125: public void testBug123850c() throws Exception {
126: performTestDoNotPerform("TestBug123850c", 7, 18);
127: }
128:
129: public void testBug123850d() throws Exception {
130: performTestDoNotPerform("TestBug123850d", 7, 18);
131: }
132:
133: public void testBug123850e() throws Exception {
134: performTestDoNotPerform("TestBug123850e", 7, 18);
135: }
136:
137: public void testBug123093() throws Exception {
138: performTestDoNotPerform("TestBug123093", 11, 18);
139: }
140:
141: /**
142: * Duplicate entries should not be offered
143: * (ie, two same exception thrown on same line, like:<br>
144: * <code>new Filereader("").read();</code>
145: */
146: public void testDuplicateHintEntries() throws Exception {
147: performTestDoNotPerform("TestDuplicate", 5, 15);
148: }
149:
150: }
|