sandbox/old-modules/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringPluginImplTest.java
1.1 --- a/sandbox/old-modules/bridges/refactoring/test/unit/src/org/netbeans/modules/jackpot30/refactoring/RenameRefactoringPluginImplTest.java Mon Dec 19 11:37:36 2016 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,111 +0,0 @@
1.4 -/*
1.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1.6 - *
1.7 - * Copyright 2009-2010 Sun Microsystems, Inc. All rights reserved.
1.8 - *
1.9 - * The contents of this file are subject to the terms of either the GNU
1.10 - * General Public License Version 2 only ("GPL") or the Common
1.11 - * Development and Distribution License("CDDL") (collectively, the
1.12 - * "License"). You may not use this file except in compliance with the
1.13 - * License. You can obtain a copy of the License at
1.14 - * http://www.netbeans.org/cddl-gplv2.html
1.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
1.16 - * specific language governing permissions and limitations under the
1.17 - * License. When distributing the software, include this License Header
1.18 - * Notice in each file and include the License file at
1.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
1.20 - * particular file as subject to the "Classpath" exception as provided
1.21 - * by Sun in the GPL Version 2 section of the License file that
1.22 - * accompanied this code. If applicable, add the following below the
1.23 - * License Header, with the fields enclosed by brackets [] replaced by
1.24 - * your own identifying information:
1.25 - * "Portions Copyrighted [year] [name of copyright owner]"
1.26 - *
1.27 - * If you wish your version of this file to be governed by only the CDDL
1.28 - * or only the GPL Version 2, indicate your decision by adding
1.29 - * "[Contributor] elects to include this software in this distribution
1.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
1.31 - * single choice of license, a recipient has the option to distribute
1.32 - * your version of this file under either the CDDL, the GPL Version 2 or
1.33 - * to extend the choice of license to its licensees as provided above.
1.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
1.35 - * Version 2 license, then the option applies only if the new code is
1.36 - * made subject to such option by the copyright holder.
1.37 - *
1.38 - * Contributor(s):
1.39 - *
1.40 - * Portions Copyrighted 2009-2010 Sun Microsystems, Inc.
1.41 - */
1.42 -package org.netbeans.modules.jackpot30.refactoring;
1.43 -
1.44 -import com.sun.source.tree.ClassTree;
1.45 -import com.sun.source.tree.CompilationUnitTree;
1.46 -import com.sun.source.tree.MethodTree;
1.47 -import com.sun.source.util.TreePath;
1.48 -import org.netbeans.api.java.source.CompilationController;
1.49 -import org.netbeans.api.java.source.JavaSource;
1.50 -import org.netbeans.api.java.source.Task;
1.51 -import org.netbeans.api.java.source.TreePathHandle;
1.52 -import org.netbeans.modules.refactoring.api.RenameRefactoring;
1.53 -import org.openide.util.lookup.Lookups;
1.54 -
1.55 -public class RenameRefactoringPluginImplTest extends RefactoringTestBase {
1.56 -
1.57 - public RenameRefactoringPluginImplTest(String name) {
1.58 - super(name);
1.59 - }
1.60 -
1.61 - public void testSimple1() throws Exception {
1.62 - writeFilesAndWaitForScan(src,
1.63 - new File("t/A.java", "package t; public class A {\n public void test() {\n}\n }"));
1.64 - final RenameRefactoring[] r = new RenameRefactoring[1];
1.65 -
1.66 - JavaSource.forFileObject(src.getFileObject("t/A.java")).runUserActionTask(new Task<CompilationController>() {
1.67 -
1.68 - public void run(CompilationController parameter) throws Exception {
1.69 - parameter.toPhase(JavaSource.Phase.RESOLVED);
1.70 - CompilationUnitTree cut = parameter.getCompilationUnit();
1.71 -
1.72 - MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
1.73 -
1.74 - TreePath tp = TreePath.getPath(cut, var);
1.75 - r[0] = new RenameRefactoring(Lookups.singleton(TreePathHandle.create(tp, parameter)));
1.76 - }
1.77 - }, true);
1.78 -
1.79 - r[0].setNewName("foo");
1.80 - r[0].getContext().add(new ExtraData(true, true, true));
1.81 -
1.82 - performRefactoring(r[0],
1.83 - new File("t/A.java", "package t; public class A { @Deprecated private void test() { foo(); } public void foo() { } }"),
1.84 - new File("META-INF/upgrade/t.A.hint", " $0.test() :: $0 instanceof t.A => $0.foo() ;; "));
1.85 - }
1.86 -
1.87 - public void testSimple2() throws Exception {
1.88 - writeFilesAndWaitForScan(src,
1.89 - new File("t/A.java", "package t; public class A {\n public void test() {\n}\n }"),
1.90 - new File("META-INF/upgrade/t.A.hint", "$0.isDirectory();; "));
1.91 - final RenameRefactoring[] r = new RenameRefactoring[1];
1.92 -
1.93 - JavaSource.forFileObject(src.getFileObject("t/A.java")).runUserActionTask(new Task<CompilationController>() {
1.94 -
1.95 - public void run(CompilationController parameter) throws Exception {
1.96 - parameter.toPhase(JavaSource.Phase.RESOLVED);
1.97 - CompilationUnitTree cut = parameter.getCompilationUnit();
1.98 -
1.99 - MethodTree var = (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(1);
1.100 -
1.101 - TreePath tp = TreePath.getPath(cut, var);
1.102 - r[0] = new RenameRefactoring(Lookups.singleton(TreePathHandle.create(tp, parameter)));
1.103 - }
1.104 - }, true);
1.105 -
1.106 - r[0].setNewName("foo");
1.107 - r[0].getContext().add(new ExtraData(true, /*XXX: false will fail badly here!!*/true, false));
1.108 -
1.109 - performRefactoring(r[0],
1.110 - new File("t/A.java", "package t; public class A { private void test() { foo(); } public void foo() { } }"),
1.111 - new File("META-INF/upgrade/t.A.hint", "$0.isDirectory();; $0.test() :: $0 instanceof t.A => $0.foo() ;; "));
1.112 - }
1.113 -
1.114 -}