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: * If you wish your version of this file to be governed by only the CDDL
025: * or only the GPL Version 2, indicate your decision by adding
026: * "[Contributor] elects to include this software in this distribution
027: * under the [CDDL or GPL Version 2] license." If you do not indicate a
028: * single choice of license, a recipient has the option to distribute
029: * your version of this file under either the CDDL, the GPL Version 2 or
030: * to extend the choice of license to its licensees as provided above.
031: * However, if you add GPL Version 2 code and therefore, elected the GPL
032: * Version 2 license, then the option applies only if the new code is
033: * made subject to such option by the copyright holder.
034: *
035: * Contributor(s):
036: *
037: * Portions Copyrighted 2007 Sun Microsystems, Inc.
038: */
039:
040: package org.netbeans.modules.ruby.hints;
041:
042: import java.util.HashSet;
043: import java.util.Set;
044: import org.netbeans.modules.ruby.hints.HintTestBase;
045:
046: /**
047: *
048: * @author Tor Norbye
049: */
050: public class DeprecationsTest extends HintTestBase {
051:
052: public DeprecationsTest(String testName) {
053: super (testName);
054: }
055:
056: public void testHint1() throws Exception {
057: findHints(this , new Deprecations(), "testfiles/require_gem.rb",
058: null);
059: }
060:
061: public void testHint2() throws Exception {
062: findHints(this , new Deprecations(),
063: "testfiles/deprecations.rb", null);
064: }
065:
066: public void testFix1() throws Exception {
067: applyHint(this , new Deprecations(), "testfiles/require_gem.rb",
068: "req^uire_gem", "Replace");
069: }
070:
071: public void testFix2() throws Exception {
072: applyHint(this , new Deprecations(),
073: "testfiles/deprecations.rb", "asse^rt_raises",
074: "Replace");
075: }
076:
077: public void testFix3() throws Exception {
078: applyHint(this , new Deprecations(), "testfiles/require_gem.rb",
079: "require_g^em 'rails', '2.0.1'", "Replace");
080: }
081:
082: public void testFix4() throws Exception {
083: applyHint(this , new Deprecations(), "testfiles/require_gem.rb",
084: "require^_gem \"rails\" #2", "Replace");
085: }
086:
087: public void testFix5() throws Exception {
088: applyHint(this , new Deprecations(), "testfiles/require_gem.rb",
089: "require_g^em File.dirname", "Replace");
090: }
091:
092: public void testNoPositives() throws Exception {
093: try {
094: parseErrorsOk = true;
095: Set<String> exceptions = new HashSet<String>();
096:
097: // Env.rb and parsearg.rb include deprecated require calls (optparse and printenv)
098: // Everything else is related to the assert_raises call.
099:
100: // Known exceptions
101: exceptions.add("assert.rb");
102: exceptions.add("invocation_test.rb");
103: exceptions.add("test_package_task.rb");
104: exceptions.add("Env.rb");
105: exceptions.add("parsearg.rb");
106: exceptions.add("dispatcher_action_controller_soap_test.rb");
107: exceptions.add("routing_test.rb");
108: exceptions.add("associations_test.rb");
109: exceptions.add("url_helper_test.rb");
110: exceptions.add("callbacks_test.rb");
111: exceptions.add("deprecated_finder_test.rb");
112: exceptions.add("finder_test.rb");
113: exceptions.add("test_tasks.rb");
114: exceptions.add("url_rewriter_test.rb");
115: exceptions.add("client_xmlrpc_test.rb");
116: exceptions.add("base_test.rb");
117: exceptions.add("locking_test.rb");
118: exceptions.add("inheritance_test.rb");
119: exceptions.add("resources_test.rb");
120: exceptions.add("casting_test.rb");
121: exceptions.add("redirect_test.rb");
122: exceptions.add("selector_test.rb");
123: exceptions.add("test_fileutils.rb");
124: exceptions.add("test_application.rb");
125: exceptions.add("test_definitions.rb");
126: exceptions.add("deprecated_associations_test.rb");
127: exceptions.add("api_test.rb");
128: exceptions.add("fixtures_test.rb");
129: exceptions.add("new_render_test.rb");
130: exceptions.add("format.rb");
131: exceptions.add("calculations_test.rb");
132: exceptions.add("render_test.rb");
133: exceptions.add("action_pack_assertions_test.rb");
134: exceptions.add("join_model_test.rb");
135: exceptions.add("validations_test.rb");
136: exceptions.add("filters_test.rb");
137: exceptions.add("test_rules.rb");
138: exceptions.add("eager_test.rb");
139: exceptions.add("assert_select_test.rb");
140: exceptions.add("container_test.rb");
141: exceptions.add("aggregations_test.rb");
142: exceptions.add("migration_test.rb");
143: exceptions.add("simple.rb");
144:
145: // Hits for require ftools.rb
146: exceptions.add("rake.rb");
147: exceptions.add("ri_generator.rb");
148: exceptions.add("install.rb");
149: exceptions.add("command-processor.rb");
150: exceptions.add("rdoc.rb");
151: exceptions.add("xml_generator.rb");
152: exceptions.add("html_generator.rb");
153: exceptions.add("filecreation.rb");
154: exceptions.add("sys.rb");
155:
156: // New in Rails 2.0.2:
157:
158: exceptions.add("authorization_test.rb");
159: exceptions.add("session_fixation_test.rb");
160: exceptions.add("request_forgery_protection_test.rb");
161: exceptions.add("test_helper_test.rb");
162: exceptions.add("test_test.rb");
163: exceptions.add("attribute_methods_test.rb");
164: exceptions.add("mail_render_test.rb");
165: exceptions.add("mime_responds_test.rb");
166: exceptions.add("request_test.rb");
167:
168: assertNoJRubyMatches(new Deprecations(), exceptions);
169:
170: } finally {
171: parseErrorsOk = false;
172: }
173: }
174:
175: }
|