diff options
author | Markus Keller | 2012-11-13 16:25:27 +0000 |
---|---|---|
committer | Markus Keller | 2012-11-13 16:25:27 +0000 |
commit | a9d28d0d237966d409e0e603033f3ce8cddb5d35 (patch) | |
tree | b4b92796bac98ca5c2720afb943ac037720d93db | |
parent | 11e96b521528eb1292ea4b28a55487a69a71c0d5 (diff) | |
download | eclipse.jdt.ui-a9d28d0d237966d409e0e603033f3ce8cddb5d35.tar.gz eclipse.jdt.ui-a9d28d0d237966d409e0e603033f3ce8cddb5d35.tar.xz eclipse.jdt.ui-a9d28d0d237966d409e0e603033f3ce8cddb5d35.zip |
Bug 391927: Speed up JDT UI tests by avoiding performDummySearch()v20121113-162527
Part 2: remove delete(..) calls that are unnecessary due to RefactoringTest#tearDown()
20 files changed, 3060 insertions, 4755 deletions
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractSupertypeTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractSupertypeTests.java index 9cdbdcd043..f786a932fd 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractSupertypeTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractSupertypeTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -85,45 +85,40 @@ public final class ExtractSupertypeTests extends RefactoringTest { private void helper1(String[] methodNames, String[][] signatures, boolean deleteAllInSourceType, boolean deleteAllMatchingMethods, boolean replaceOccurences) throws Exception { ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try { - IType type= getType(cu, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); - - ExtractSupertypeProcessor processor= createRefactoringProcessor(methods); - Refactoring refactoring= processor.getRefactoring(); - processor.setMembersToMove(methods); - - assertTrue("activation", refactoring.checkInitialConditions(new NullProgressMonitor()).isOK()); - - processor.setTypesToExtract(new IType[] { type}); - processor.setTypeName("Z"); - processor.setCreateMethodStubs(true); - processor.setInstanceOf(false); - processor.setReplace(replaceOccurences); - if (deleteAllInSourceType) - processor.setDeletedMethods(methods); - if (deleteAllMatchingMethods) - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - - RefactoringStatus status= refactoring.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to pass", !status.hasError()); - performChange(refactoring, false); - - String expected= getFileContents(getOutputTestFileName("A")); - String actual= cu.getSource(); - assertEqualLines(expected, actual); - - expected= getFileContents(getOutputTestFileName("Z")); - ICompilationUnit unit= getPackageP().getCompilationUnit("Z.java"); - if (!unit.exists()) - assertTrue("extracted compilation unit does not exist", false); - actual= unit.getBuffer().getContents(); - assertEqualLines(expected, actual); - - } finally { - performDummySearch(); - cu.delete(false, null); - } + IType type= getType(cu, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); + + ExtractSupertypeProcessor processor= createRefactoringProcessor(methods); + Refactoring refactoring= processor.getRefactoring(); + processor.setMembersToMove(methods); + + assertTrue("activation", refactoring.checkInitialConditions(new NullProgressMonitor()).isOK()); + + processor.setTypesToExtract(new IType[] { type}); + processor.setTypeName("Z"); + processor.setCreateMethodStubs(true); + processor.setInstanceOf(false); + processor.setReplace(replaceOccurences); + if (deleteAllInSourceType) + processor.setDeletedMethods(methods); + if (deleteAllMatchingMethods) + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + + RefactoringStatus status= refactoring.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to pass", !status.hasError()); + performChange(refactoring, false); + + String expected= getFileContents(getOutputTestFileName("A")); + String actual= cu.getSource(); + assertEqualLines(expected, actual); + + expected= getFileContents(getOutputTestFileName("Z")); + ICompilationUnit unit= getPackageP().getCompilationUnit("Z.java"); + if (!unit.exists()) + assertTrue("extracted compilation unit does not exist", false); + actual= unit.getBuffer().getContents(); + assertEqualLines(expected, actual); + } public void test0() throws Exception { diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java index 6cf0533718..9a72c81f10 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -152,46 +152,40 @@ public class MoveMembersTests extends RefactoringTest { } private void fieldMethodTypePackageHelper_failing(String[] fieldNames, - String[] methodNames, String[][] signatures, - String[] typeNames, - int errorLevel, String destinationTypeName, - IPackageFragment packForA, - IPackageFragment packForB) throws Exception { + String[] methodNames, String[][] signatures, + String[] typeNames, + int errorLevel, String destinationTypeName, + IPackageFragment packForA, + IPackageFragment packForB) throws Exception { ICompilationUnit cuA= createCUfromTestFile(packForA, "A"); - ICompilationUnit cuB= createCUfromTestFile(packForB, "B"); - try{ - IType typeA= getType(cuA, "A"); - IField[] fields= getFields(typeA, fieldNames); - IMethod[] methods= getMethods(typeA, methodNames, signatures); - IType[] types= getMemberTypes(typeA, typeNames); - - MoveRefactoring ref= createRefactoring(merge(methods, fields, types), destinationTypeName); - if (ref == null){ - assertEquals(errorLevel, RefactoringStatus.FATAL); - return; - } - - RefactoringStatus result= performRefactoring(ref); - if (fIsVerbose) - DebugUtils.dump("status:" + result); - assertNotNull("precondition was supposed to fail", result); - assertEquals("precondition was supposed to fail", errorLevel, result.getSeverity()); - - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); + createCUfromTestFile(packForB, "B"); + IType typeA= getType(cuA, "A"); + IField[] fields= getFields(typeA, fieldNames); + IMethod[] methods= getMethods(typeA, methodNames, signatures); + IType[] types= getMemberTypes(typeA, typeNames); + + MoveRefactoring ref= createRefactoring(merge(methods, fields, types), destinationTypeName); + if (ref == null){ + assertEquals(errorLevel, RefactoringStatus.FATAL); + return; } + + RefactoringStatus result= performRefactoring(ref); + if (fIsVerbose) + DebugUtils.dump("status:" + result); + assertNotNull("precondition was supposed to fail", result); + assertEquals("precondition was supposed to fail", errorLevel, result.getSeverity()); + } private void fieldMethodTypeHelper_failing(String[] fieldNames, - String[] methodNames, String[][] signatures, - String[] typeNames, - int errorLevel, String destinationTypeName) throws Exception { + String[] methodNames, String[][] signatures, + String[] typeNames, + int errorLevel, String destinationTypeName) throws Exception { IPackageFragment packForA= getPackageP(); IPackageFragment packForB= getPackageP(); fieldMethodTypePackageHelper_failing(fieldNames, methodNames, signatures, typeNames, - errorLevel, destinationTypeName, packForA, packForB); + errorLevel, destinationTypeName, packForA, packForB); } @@ -231,15 +225,8 @@ public class MoveMembersTests extends RefactoringTest { public void test8() throws Exception{ // printTestDisabledMessage("36835"); - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_passing(new String[]{"f"}, new String[0], new String[0][0], new String[0], getPackageP(), packageForB, false); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_passing(new String[]{"f"}, new String[0], new String[0][0], new String[0], getPackageP(), packageForB, false); } public void test9() throws Exception{ @@ -313,27 +300,13 @@ public class MoveMembersTests extends RefactoringTest { } public void test26() throws Exception{ - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_passing(new String[0], new String[]{"n"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_passing(new String[0], new String[]{"n"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); } public void test27() throws Exception{ - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_passing(new String[0], new String[]{"n"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_passing(new String[0], new String[]{"n"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); } public void test28() throws Exception{ @@ -438,30 +411,16 @@ public class MoveMembersTests extends RefactoringTest { public void test48() throws Exception{ //Move private unused method which calls another private method into another package - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_passing(new String[0], new String[]{"bar"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_passing(new String[0], new String[]{"bar"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); } // --- Visibility issues of the moved member itself public void test49() throws Exception{ //Move protected used field into another package - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_passing(new String[]{"someVar"}, new String[0], new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_passing(new String[]{"someVar"}, new String[0], new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); } public void test50() throws Exception{ @@ -524,29 +483,15 @@ public class MoveMembersTests extends RefactoringTest { public void test60() throws Exception{ // Move a static private "getter" of a static field into another class // only the field should be changed to public (bug 122490) - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("e", false, null); - fieldMethodTypePackageHelper_passing(new String[0], new String[] { "getNAME" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("e", false, null); + fieldMethodTypePackageHelper_passing(new String[0], new String[] { "getNAME" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); } public void test61() throws Exception{ // Move some method which references a field with a getter and a setter // only the field should be changed to public (bug 122490) - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("e", false, null); - fieldMethodTypePackageHelper_passing(new String[0], new String[] { "foo" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("e", false, null); + fieldMethodTypePackageHelper_passing(new String[0], new String[] { "foo" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false); } // parameterized type references @@ -561,98 +506,91 @@ public class MoveMembersTests extends RefactoringTest { //--- public void testFail0() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, - new String[0], - RefactoringStatus.FATAL, "p.B"); + new String[]{"m"}, new String[][]{new String[0]}, + new String[0], + RefactoringStatus.FATAL, "p.B"); } public void testFail1() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, - new String[0], - RefactoringStatus.ERROR, "p.B.X"); + new String[]{"m"}, new String[][]{new String[0]}, + new String[0], + RefactoringStatus.ERROR, "p.B.X"); } public void testFail2() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, - new String[0], - RefactoringStatus.ERROR, "p.B"); + new String[]{"m"}, new String[][]{new String[0]}, + new String[0], + RefactoringStatus.ERROR, "p.B"); } public void testFail3() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[]{"I", "I"}}, - new String[0], - RefactoringStatus.ERROR, "p.B"); + new String[]{"m"}, new String[][]{new String[]{"I", "I"}}, + new String[0], + RefactoringStatus.ERROR, "p.B"); } public void testFail4() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[]{"I", "I"}}, - new String[0], - RefactoringStatus.WARNING, "p.B"); + new String[]{"m"}, new String[][]{new String[]{"I", "I"}}, + new String[0], + RefactoringStatus.WARNING, "p.B"); } public void testFail5() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[]{"I", "I"}}, - new String[0], - RefactoringStatus.WARNING, "p.B"); + new String[]{"m"}, new String[][]{new String[]{"I", "I"}}, + new String[0], + RefactoringStatus.WARNING, "p.B"); } public void testFail6() throws Exception{ fieldMethodTypeHelper_failing(new String[]{"i"}, new String[0], new String[0][0], new String[0], - RefactoringStatus.ERROR, "p.B"); + RefactoringStatus.ERROR, "p.B"); } public void testFail7() throws Exception{ fieldMethodTypeHelper_failing(new String[]{"i"}, new String[0], new String[0][0], new String[0], - RefactoringStatus.ERROR, "p.B"); + RefactoringStatus.ERROR, "p.B"); } public void testFail8() throws Exception{ fieldMethodTypeHelper_failing(new String[]{"i"}, new String[0], new String[0][0], new String[0], - RefactoringStatus.ERROR, "p.B"); + RefactoringStatus.ERROR, "p.B"); } public void testFail15() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, new String[0], - RefactoringStatus.WARNING, "p.B"); + new String[]{"m"}, new String[][]{new String[0]}, new String[0], + RefactoringStatus.WARNING, "p.B"); } public void testFail16() throws Exception{ - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_failing(new String[]{"f"}, new String[0], new String[0][0], new String[0], - RefactoringStatus.ERROR, "r.B", - getPackageP(), packageForB); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_failing(new String[]{"f"}, new String[0], new String[0][0], new String[0], + RefactoringStatus.ERROR, "r.B", + getPackageP(), packageForB); } public void testFail17() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, new String[0], - RefactoringStatus.FATAL, "java.lang.Object"); + new String[]{"m"}, new String[][]{new String[0]}, new String[0], + RefactoringStatus.FATAL, "java.lang.Object"); } public void testFail18() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, new String[0], - RefactoringStatus.FATAL, "p.DontExist"); + new String[]{"m"}, new String[][]{new String[0]}, new String[0], + RefactoringStatus.FATAL, "p.DontExist"); } public void testFail19() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, new String[0], - RefactoringStatus.ERROR, "p.B"); + new String[]{"m"}, new String[][]{new String[0]}, new String[0], + RefactoringStatus.ERROR, "p.B"); } public void testFail20() throws Exception{ @@ -661,8 +599,8 @@ public class MoveMembersTests extends RefactoringTest { public void testFail21() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, new String[0], - RefactoringStatus.FATAL, "p.B"); + new String[]{"m"}, new String[][]{new String[0]}, new String[0], + RefactoringStatus.FATAL, "p.B"); } public void testFail22() throws Exception{ @@ -675,8 +613,8 @@ public class MoveMembersTests extends RefactoringTest { public void testFail24() throws Exception{ fieldMethodTypeHelper_failing(new String[0], - new String[]{"m"}, new String[][]{new String[0]}, new String[0], - RefactoringStatus.FATAL, "p.B"); + new String[]{"m"}, new String[][]{new String[0]}, new String[0], + RefactoringStatus.FATAL, "p.B"); } // Delegate creation @@ -698,15 +636,8 @@ public class MoveMembersTests extends RefactoringTest { public void testDelegate04() throws Exception{ // add import when moving to another package - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_passing(new String[0], new String[] { "foo" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, true); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_passing(new String[0], new String[] { "foo" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, true); } public void testDelegate05() throws Exception { @@ -726,14 +657,7 @@ public class MoveMembersTests extends RefactoringTest { public void testDelegate08() throws Exception{ // add import when moving to another package - IPackageFragment packageForB= null; - try{ - packageForB= getRoot().createPackageFragment("r", false, null); - fieldMethodTypePackageHelper_passing(new String[] { "FOO" }, new String[0], new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, true); - } finally{ - performDummySearch(); - if (packageForB != null) - packageForB.delete(true, null); - } + IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null); + fieldMethodTypePackageHelper_passing(new String[] { "FOO" }, new String[0], new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, true); } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java index 592c9b3ea9..922a71447b 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -85,33 +85,28 @@ public class PullUpTests extends RefactoringTest { private void fieldMethodHelper1(String[] fieldNames, String[] methodNames, String[][] signatures, boolean deleteAllInSourceType, boolean deleteAllMatchingMethods) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "B"); - IField[] fields= getFields(type, fieldNames); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cu, "B"); + IField[] fields= getFields(type, fieldNames); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(merge(methods, fields)); + PullUpRefactoringProcessor processor= createRefactoringProcessor(merge(methods, fields)); - Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + Refactoring ref= processor.getRefactoring(); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); - if (deleteAllInSourceType) - processor.setDeletedMethods(methods); - if (deleteAllMatchingMethods) - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); - performChange(ref, false); - - String expected= getFileContents(getOutputTestFileName("A")); - String actual= cu.getSource(); - assertEqualLines(expected, actual); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + if (deleteAllInSourceType) + processor.setDeletedMethods(methods); + if (deleteAllMatchingMethods) + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); + performChange(ref, false); + + String expected= getFileContents(getOutputTestFileName("A")); + String actual= cu.getSource(); + assertEqualLines(expected, actual); } private IType[] getPossibleTargetClasses(PullUpRefactoringProcessor processor) throws JavaModelException { @@ -130,84 +125,69 @@ public class PullUpTests extends RefactoringTest { private void addRequiredMembersHelper(String[] fieldNames, String[] methodNames, String[][] methodSignatures, String[] expectedFieldNames, String[] expectedMethodNames, String[][] expectedMethodSignatures) throws Exception { ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "B"); - IField[] fields= getFields(type, fieldNames); - IMethod[] methods= getMethods(type, methodNames, methodSignatures); - - IMember[] members= merge(methods, fields); + IType type= getType(cu, "B"); + IField[] fields= getFields(type, fieldNames); + IMethod[] methods= getMethods(type, methodNames, methodSignatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(members); - Refactoring ref= processor.getRefactoring(); + IMember[] members= merge(methods, fields); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + PullUpRefactoringProcessor processor= createRefactoringProcessor(members); + Refactoring ref= processor.getRefactoring(); - List additionalRequired= Arrays.asList(processor.getAdditionalRequiredMembersToPullUp(new NullProgressMonitor())); - List required= new ArrayList(); - required.addAll(additionalRequired); - required.addAll(Arrays.asList(members)); - IField[] expectedFields= getFields(type, expectedFieldNames); - IMethod[] expectedMethods= getMethods(type, expectedMethodNames, expectedMethodSignatures); - List expected= Arrays.asList(merge(expectedFields, expectedMethods)); - assertEquals("incorrect size", expected.size(), required.size()); - for (Iterator iter= expected.iterator(); iter.hasNext();) { - Object each= iter.next(); - assertTrue ("required does not contain " + each, required.contains(each)); - } - for (Iterator iter= required.iterator(); iter.hasNext();) { - Object each= iter.next(); - assertTrue ("expected does not contain " + each, expected.contains(each)); - } - } finally{ - performDummySearch(); - cu.delete(false, null); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); + + List additionalRequired= Arrays.asList(processor.getAdditionalRequiredMembersToPullUp(new NullProgressMonitor())); + List required= new ArrayList(); + required.addAll(additionalRequired); + required.addAll(Arrays.asList(members)); + IField[] expectedFields= getFields(type, expectedFieldNames); + IMethod[] expectedMethods= getMethods(type, expectedMethodNames, expectedMethodSignatures); + List expected= Arrays.asList(merge(expectedFields, expectedMethods)); + assertEquals("incorrect size", expected.size(), required.size()); + for (Iterator iter= expected.iterator(); iter.hasNext();) { + Object each= iter.next(); + assertTrue ("required does not contain " + each, required.contains(each)); + } + for (Iterator iter= required.iterator(); iter.hasNext();) { + Object each= iter.next(); + assertTrue ("expected does not contain " + each, expected.contains(each)); } } private void fieldHelper1(String[] fieldNames, int targetClassIndex) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "B"); - IField[] fields= getFields(type, fieldNames); + IType type= getType(cu, "B"); + IField[] fields= getFields(type, fieldNames); - PullUpRefactoringProcessor processor= createRefactoringProcessor(fields); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(fields); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setTargetClass(processor, targetClassIndex); - - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); - performChange(ref, false); - - String expected= getFileContents(getOutputTestFileName("A")); - String actual= cu.getSource(); - assertEqualLines(expected, actual); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setTargetClass(processor, targetClassIndex); + + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); + performChange(ref, false); + + String expected= getFileContents(getOutputTestFileName("A")); + String actual= cu.getSource(); + assertEqualLines(expected, actual); } private void fieldHelper2(String[] fieldNames, int targetClassIndex) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "B"); - IField[] fields= getFields(type, fieldNames); + IType type= getType(cu, "B"); + IField[] fields= getFields(type, fieldNames); - PullUpRefactoringProcessor processor= createRefactoringProcessor(fields); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(fields); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setTargetClass(processor, targetClassIndex); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setTargetClass(processor, targetClassIndex); - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); } private static IMethod[] getMethods(IMember[] members){ @@ -216,12 +196,12 @@ public class PullUpTests extends RefactoringTest { } private Refactoring createRefactoringPrepareForInputCheck(String[] selectedMethodNames, String[][] selectedMethodSignatures, - String[] selectedFieldNames, - String[] selectedTypeNames, String[] namesOfMethodsToPullUp, - String[][] signaturesOfMethodsToPullUp, - String[] namesOfFieldsToPullUp, String[] namesOfTypesToPullUp, - String[] namesOfMethodsToDeclareAbstract, String[][] signaturesOfMethodsToDeclareAbstract, - boolean deleteAllPulledUpMethods, boolean deleteAllMatchingMethods, int targetClassIndex, ICompilationUnit cu) throws CoreException { + String[] selectedFieldNames, + String[] selectedTypeNames, String[] namesOfMethodsToPullUp, + String[][] signaturesOfMethodsToPullUp, + String[] namesOfFieldsToPullUp, String[] namesOfTypesToPullUp, + String[] namesOfMethodsToDeclareAbstract, String[][] signaturesOfMethodsToDeclareAbstract, + boolean deleteAllPulledUpMethods, boolean deleteAllMatchingMethods, int targetClassIndex, ICompilationUnit cu) throws CoreException { IType type= getType(cu, "B"); IMethod[] selectedMethods= getMethods(type, selectedMethodNames, selectedMethodSignatures); IField[] selectedFields= getFields(type, selectedFieldNames); @@ -252,135 +232,109 @@ public class PullUpTests extends RefactoringTest { } private void declareAbstractFailHelper(String[] selectedMethodNames, String[][] selectedMethodSignatures, - String[] selectedFieldNames, - String[] selectedTypeNames, String[] namesOfMethodsToPullUp, - String[][] signaturesOfMethodsToPullUp, String[] namesOfFieldsToPullUp, - String[] namesOfMethodsToDeclareAbstract, - String[][] signaturesOfMethodsToDeclareAbstract, String[] namesOfTypesToPullUp, - boolean deleteAllPulledUpMethods, boolean deleteAllMatchingMethods, int targetClassIndex) throws Exception{ + String[] selectedFieldNames, + String[] selectedTypeNames, String[] namesOfMethodsToPullUp, + String[][] signaturesOfMethodsToPullUp, String[] namesOfFieldsToPullUp, + String[] namesOfMethodsToDeclareAbstract, + String[][] signaturesOfMethodsToDeclareAbstract, String[] namesOfTypesToPullUp, + boolean deleteAllPulledUpMethods, boolean deleteAllMatchingMethods, int targetClassIndex) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, namesOfFieldsToPullUp, namesOfTypesToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, deleteAllPulledUpMethods, - deleteAllMatchingMethods, targetClassIndex, cu); - - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, namesOfFieldsToPullUp, namesOfTypesToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, deleteAllPulledUpMethods, + deleteAllMatchingMethods, targetClassIndex, cu); + + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); } private void declareAbstractHelper(String[] selectedMethodNames, String[][] selectedMethodSignatures, - String[] selectedFieldNames, - String[] selectedTypeNames, String[] namesOfMethodsToPullUp, - String[][] signaturesOfMethodsToPullUp, String[] namesOfFieldsToPullUp, - String[] namesOfMethodsToDeclareAbstract, - String[][] signaturesOfMethodsToDeclareAbstract, String[] namesOfTypesToPullUp, - boolean deleteAllPulledUpMethods, boolean deleteAllMatchingMethods, int targetClassIndex) throws Exception{ + String[] selectedFieldNames, + String[] selectedTypeNames, String[] namesOfMethodsToPullUp, + String[][] signaturesOfMethodsToPullUp, String[] namesOfFieldsToPullUp, + String[] namesOfMethodsToDeclareAbstract, + String[][] signaturesOfMethodsToDeclareAbstract, String[] namesOfTypesToPullUp, + boolean deleteAllPulledUpMethods, boolean deleteAllMatchingMethods, int targetClassIndex) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, namesOfFieldsToPullUp, namesOfTypesToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, deleteAllPulledUpMethods, - deleteAllMatchingMethods, targetClassIndex, cu); - - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); - performChange(ref, false); - - String expected= getFileContents(getOutputTestFileName("A")); - String actual= cu.getSource(); - assertEqualLines(expected, actual); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, namesOfFieldsToPullUp, namesOfTypesToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, deleteAllPulledUpMethods, + deleteAllMatchingMethods, targetClassIndex, cu); + + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); + performChange(ref, false); + + String expected= getFileContents(getOutputTestFileName("A")); + String actual= cu.getSource(); + assertEqualLines(expected, actual); } private void helper1(String[] methodNames, String[][] signatures, boolean deleteAllInSourceType, boolean deleteAllMatchingMethods, int targetClassIndex) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cu, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setTargetClass(processor, targetClassIndex); + setTargetClass(processor, targetClassIndex); - if (deleteAllInSourceType) - processor.setDeletedMethods(methods); - if (deleteAllMatchingMethods) - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + if (deleteAllInSourceType) + processor.setDeletedMethods(methods); + if (deleteAllMatchingMethods) + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); - performChange(ref, false); + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to pass", !checkInputResult.hasError()); + performChange(ref, false); - String expected= getFileContents(getOutputTestFileName("A")); - String actual= cu.getSource(); - assertEqualLines(expected, actual); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + String expected= getFileContents(getOutputTestFileName("A")); + String actual= cu.getSource(); + assertEqualLines(expected, actual); } private void helper2(String[] methodNames, String[][] signatures, boolean deleteAllInSourceType, boolean deleteAllMatchingMethods, int targetClassIndex) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cu, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setTargetClass(processor, targetClassIndex); - - if (deleteAllInSourceType) - processor.setDeletedMethods(methods); - if (deleteAllMatchingMethods) - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setTargetClass(processor, targetClassIndex); + + if (deleteAllInSourceType) + processor.setDeletedMethods(methods); + if (deleteAllMatchingMethods) + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); } private void helper3(String[] methodNames, String[][] signatures, boolean deleteAllInSourceType, boolean deleteAllMatchingMethods, int targetClassIndex, boolean shouldActivationCheckPass) throws Exception { - ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); + createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ - IType type= getType(cuB, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cuB, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertEquals("activation", shouldActivationCheckPass, ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - if (! shouldActivationCheckPass) - return; - setTargetClass(processor, targetClassIndex); - - if (deleteAllInSourceType) - processor.setDeletedMethods(methods); - if (deleteAllMatchingMethods) - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); - } + assertEquals("activation", shouldActivationCheckPass, ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + if (! shouldActivationCheckPass) + return; + setTargetClass(processor, targetClassIndex); + + if (deleteAllInSourceType) + processor.setDeletedMethods(methods); + if (deleteAllMatchingMethods) + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to fail", !checkInputResult.isOK()); } //------------------ tests ------------- @@ -405,62 +359,50 @@ public class PullUpTests extends RefactoringTest { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ - String[] methodNames= new String[]{"m"}; - String[][] signatures= new String[][]{new String[]{"QList;"}}; + String[] methodNames= new String[]{"m"}; + String[][] signatures= new String[][]{new String[]{"QList;"}}; - IType type= getType(cuB, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cuB, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - RefactoringStatus result= performRefactoring(ref); - assertTrue("precondition was supposed to pass", result == null || !result.hasError()); + RefactoringStatus result= performRefactoring(ref); + assertTrue("precondition was supposed to pass", result == null || !result.hasError()); - assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); - assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); - } + assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); + assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); } public void test5() throws Exception{ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ - String[] methodNames= new String[]{"m"}; - String[][] signatures= new String[][]{new String[0]}; + String[] methodNames= new String[]{"m"}; + String[][] signatures= new String[][]{new String[0]}; - IType type= getType(cuB, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cuB, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - RefactoringStatus result= performRefactoring(ref); - assertTrue("precondition was supposed to pass", result == null || !result.hasError()); + RefactoringStatus result= performRefactoring(ref); + assertTrue("precondition was supposed to pass", result == null || !result.hasError()); - assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); - assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); - } + assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); + assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); } public void test6() throws Exception{ @@ -492,31 +434,25 @@ public class PullUpTests extends RefactoringTest { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ - String[] methodNames= new String[]{"m"}; - String[][] signatures= new String[][]{new String[0]}; + String[] methodNames= new String[]{"m"}; + String[][] signatures= new String[][]{new String[0]}; - IType type= getType(cuB, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cuB, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - RefactoringStatus result= performRefactoring(ref); - assertTrue("precondition was supposed to pass", result == null || !result.hasError()); + RefactoringStatus result= performRefactoring(ref); + assertTrue("precondition was supposed to pass", result == null || !result.hasError()); - assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); - assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); - } + assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); + assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); } public void test13() throws Exception{ @@ -589,11 +525,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test27() throws Exception{ @@ -607,11 +543,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test28() throws Exception{ @@ -626,11 +562,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test29() throws Exception{ @@ -644,11 +580,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test30() throws Exception{ @@ -662,11 +598,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test31() throws Exception{ @@ -680,11 +616,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test32() throws Exception{ @@ -698,11 +634,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test33() throws Exception{ @@ -716,11 +652,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {new String[0]}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test34() throws Exception{ @@ -734,11 +670,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test35() throws Exception{ @@ -752,11 +688,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test36() throws Exception{ @@ -770,11 +706,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test37() throws Exception{ @@ -788,11 +724,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {new String[0]}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test38() throws Exception{ @@ -806,11 +742,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void test39() throws Exception{ @@ -826,11 +762,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test40() throws Exception{ @@ -846,11 +782,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test41() throws Exception{ @@ -866,11 +802,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test42() throws Exception{ @@ -886,11 +822,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test43() throws Exception{ @@ -908,11 +844,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test44() throws Exception{ @@ -928,11 +864,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test45() throws Exception{ @@ -948,11 +884,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test46() throws Exception{ @@ -970,11 +906,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test47() throws Exception{ @@ -992,11 +928,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void test48() throws Exception{ @@ -1014,11 +950,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, false, false, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, false, false, 0); } public void test49() throws Exception{ @@ -1036,11 +972,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; declareAbstractHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, false, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, false, 0); } public void test50() throws Exception { @@ -1220,11 +1156,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void testFail21() throws Exception{ @@ -1238,11 +1174,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void testFail22() throws Exception{ @@ -1256,11 +1192,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void testFail23() throws Exception{ @@ -1274,11 +1210,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void testFail24() throws Exception{ @@ -1292,11 +1228,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - new String[0], namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); + selectedFieldNames, + new String[0], namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0); } public void testFail25() throws Exception{ @@ -1312,11 +1248,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void testFail26() throws Exception{ @@ -1332,11 +1268,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void testFail27() throws Exception{ @@ -1352,11 +1288,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void testFail28() throws Exception{ @@ -1372,11 +1308,11 @@ public class PullUpTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; declareAbstractFailHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - selectedTypeNames, namesOfMethodsToPullUp, - signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, - signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); + selectedFieldNames, + selectedTypeNames, namesOfMethodsToPullUp, + signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, + signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0); } public void testFail29() throws Exception { @@ -1736,7 +1672,6 @@ public class PullUpTests extends RefactoringTest { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ String[] methodNames= new String[]{"m"}; String[][] signatures= new String[][]{new String[] {"QS;"}}; @@ -1756,42 +1691,31 @@ public class PullUpTests extends RefactoringTest { assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); } - } public void testStaticImports1() throws Exception{ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ - String[] methodNames= new String[]{"m"}; - String[][] signatures= new String[][]{new String[] {"QS;"}}; + String[] methodNames= new String[]{"m"}; + String[][] signatures= new String[][]{new String[] {"QS;"}}; - IType type= getType(cuB, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cuB, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - RefactoringStatus result= performRefactoring(ref); - assertTrue("precondition was supposed to pass", result == null || !result.hasError()); + RefactoringStatus result= performRefactoring(ref); + assertTrue("precondition was supposed to pass", result == null || !result.hasError()); - assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); - assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); - } + assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); + assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); } public void testGenerics0() throws Exception{ @@ -1816,59 +1740,47 @@ public class PullUpTests extends RefactoringTest { // ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); // ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); // -// try{ -// String[] methodNames= new String[]{"m"}; -// String[][] signatures= new String[][]{new String[]{"QList<QT;>;"}}; +// String[] methodNames= new String[]{"m"}; +// String[][] signatures= new String[][]{new String[]{"QList<QT;>;"}}; // -// IType type= getType(cuB, "B"); -// IMethod[] methods= getMethods(type, methodNames, signatures); -// PullUpRefactoring ref= createRefactoring(methods); -// assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); -// setSuperclassAsTargetClass(ref); +// IType type= getType(cuB, "B"); +// IMethod[] methods= getMethods(type, methodNames, signatures); +// PullUpRefactoring ref= createRefactoring(methods); +// assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); +// setSuperclassAsTargetClass(ref); // -// ref.setMethodsToDelete(getMethods(ref.getMatchingElements(new NullProgressMonitor(), false))); +// ref.setMethodsToDelete(getMethods(ref.getMatchingElements(new NullProgressMonitor(), false))); // -// RefactoringStatus result= performRefactoring(ref); -// assertEquals("precondition was supposed to pass", null, result); +// RefactoringStatus result= performRefactoring(ref); +// assertEquals("precondition was supposed to pass", null, result); // -// assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); -// assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); -// } finally{ -// performDummySearch(); -// cuA.delete(false, null); -// cuB.delete(false, null); -// } +// assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); +// assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); } public void testGenerics5() throws Exception{ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ - String[] methodNames= new String[]{"m"}; - String[][] signatures= new String[][]{new String[] {"QS;"}}; + String[] methodNames= new String[]{"m"}; + String[][] signatures= new String[][]{new String[] {"QS;"}}; - IType type= getType(cuB, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cuB, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - RefactoringStatus result= performRefactoring(ref); - assertTrue("precondition was supposed to pass", result == null || !result.hasError()); + RefactoringStatus result= performRefactoring(ref); + assertTrue("precondition was supposed to pass", result == null || !result.hasError()); - assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); - assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); - } + assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); + assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); } public void testGenerics6() throws Exception{ @@ -1905,31 +1817,25 @@ public class PullUpTests extends RefactoringTest { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try{ - String[] methodNames= new String[]{"m"}; - String[][] signatures= new String[][]{new String[]{"QT;"}}; + String[] methodNames= new String[]{"m"}; + String[][] signatures= new String[][]{new String[]{"QT;"}}; - IType type= getType(cuB, "B"); - IMethod[] methods= getMethods(type, methodNames, signatures); + IType type= getType(cuB, "B"); + IMethod[] methods= getMethods(type, methodNames, signatures); - PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); - Refactoring ref= processor.getRefactoring(); + PullUpRefactoringProcessor processor= createRefactoringProcessor(methods); + Refactoring ref= processor.getRefactoring(); - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - setSuperclassAsTargetClass(processor); + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + setSuperclassAsTargetClass(processor); - processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); + processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false))); - RefactoringStatus result= performRefactoring(ref); - assertTrue("precondition was supposed to pass", result == null || !result.hasError()); + RefactoringStatus result= performRefactoring(ref); + assertTrue("precondition was supposed to pass", result == null || !result.hasError()); - assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); - assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); - } finally{ - performDummySearch(); - cuA.delete(false, null); - cuB.delete(false, null); - } + assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A"))); + assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B"))); } public void testGenerics13() throws Exception { diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java index 5a68b2cfa3..9bbb44e9d2 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -59,11 +59,11 @@ public class PushDownTests extends RefactoringTest { } private Refactoring createRefactoringPrepareForInputCheck(String[] selectedMethodNames, String[][] selectedMethodSignatures, - String[] selectedFieldNames, - String[] namesOfMethodsToPullUp, String[][] signaturesOfMethodsToPullUp, - String[] namesOfFieldsToPullUp, - String[] namesOfMethodsToDeclareAbstract, String[][] signaturesOfMethodsToDeclareAbstract, - ICompilationUnit cu) throws CoreException { + String[] selectedFieldNames, + String[] namesOfMethodsToPullUp, String[][] signaturesOfMethodsToPullUp, + String[] namesOfFieldsToPullUp, + String[] namesOfMethodsToDeclareAbstract, String[][] signaturesOfMethodsToDeclareAbstract, + ICompilationUnit cu) throws CoreException { IType type= getType(cu, "A"); IMethod[] selectedMethods= getMethods(type, selectedMethodNames, selectedMethodSignatures); @@ -101,45 +101,33 @@ public class PushDownTests extends RefactoringTest { } private void helper(String[] selectedMethodNames, String[][] selectedMethodSignatures, - String[] selectedFieldNames, - String[] namesOfMethodsToPullUp, String[][] signaturesOfMethodsToPullUp, - String[] namesOfFieldsToPullUp, String[] namesOfMethodsToDeclareAbstract, - String[][] signaturesOfMethodsToDeclareAbstract, String[] additionalCuNames, String[] additionalPackNames) throws Exception{ + String[] selectedFieldNames, + String[] namesOfMethodsToPullUp, String[][] signaturesOfMethodsToPullUp, + String[] namesOfFieldsToPullUp, String[] namesOfMethodsToDeclareAbstract, + String[][] signaturesOfMethodsToDeclareAbstract, String[] additionalCuNames, String[] additionalPackNames) throws Exception{ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - IPackageFragment[] addtionalPacks= createAdditionalPackages(additionalCuNames, additionalPackNames); - ICompilationUnit[] additonalCus= createAdditionalCus(additionalCuNames, addtionalPacks); + IPackageFragment[] additionalPacks= createAdditionalPackages(additionalCuNames, additionalPackNames); + ICompilationUnit[] additionalCus= createAdditionalCus(additionalCuNames, additionalPacks); - try{ - Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, namesOfMethodsToPullUp, signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, cuA); + Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, namesOfMethodsToPullUp, signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, cuA); - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertTrue("precondition was supposed to pass but got " + checkInputResult.toString(), !checkInputResult.hasError()); - performChange(ref, false); + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertTrue("precondition was supposed to pass but got " + checkInputResult.toString(), !checkInputResult.hasError()); + performChange(ref, false); - String expected= getFileContents(getOutputTestFileName("A")); - String actual= cuA.getSource(); - assertEqualLines("A.java", expected, actual); + String expected= getFileContents(getOutputTestFileName("A")); + String actual= cuA.getSource(); + assertEqualLines("A.java", expected, actual); - for (int i= 0; i < additonalCus.length; i++) { - ICompilationUnit unit= additonalCus[i]; - String expectedS= getFileContents(getOutputTestFileName(additionalCuNames[i])); - String actualS= unit.getSource(); - assertEqualLines(unit.getElementName(), expectedS, actualS); - } - - } finally{ - performDummySearch(); - cuA.delete(false, null); - for (int i= 0; i < additonalCus.length; i++) { - additonalCus[i].delete(false, null); - } - for (int i= 0; i < addtionalPacks.length; i++) { - if (! addtionalPacks[i].equals(getPackageP())) - addtionalPacks[i].delete(false, null); - } + for (int i= 0; i < additionalCus.length; i++) { + ICompilationUnit unit= additionalCus[i]; + String expectedS= getFileContents(getOutputTestFileName(additionalCuNames[i])); + String actualS= unit.getSource(); + assertEqualLines(unit.getElementName(), expectedS, actualS); } + } private ICompilationUnit[] createAdditionalCus(String[] additionalCuNames, IPackageFragment[] addtionalPacks) throws Exception { @@ -166,80 +154,63 @@ public class PushDownTests extends RefactoringTest { } private void failActivationHelper(String[] selectedMethodNames, String[][] selectedMethodSignatures, - String[] selectedFieldNames, - int expectedSeverity) throws Exception{ + String[] selectedFieldNames, + int expectedSeverity) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "A"); - IMethod[] selectedMethods= getMethods(type, selectedMethodNames, selectedMethodSignatures); - IField[] selectedFields= getFields(type, selectedFieldNames); - IMember[] selectedMembers= merge(selectedFields, selectedMethods); - - assertTrue(RefactoringAvailabilityTester.isPushDownAvailable(selectedMembers)); - PushDownRefactoringProcessor processor= new PushDownRefactoringProcessor(selectedMembers); - Refactoring ref= new ProcessorBasedRefactoring(processor); - - assertEquals("activation was expected to fail", expectedSeverity, ref.checkInitialConditions(new NullProgressMonitor()).getSeverity()); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + IType type= getType(cu, "A"); + IMethod[] selectedMethods= getMethods(type, selectedMethodNames, selectedMethodSignatures); + IField[] selectedFields= getFields(type, selectedFieldNames); + IMember[] selectedMembers= merge(selectedFields, selectedMethods); + + assertTrue(RefactoringAvailabilityTester.isPushDownAvailable(selectedMembers)); + PushDownRefactoringProcessor processor= new PushDownRefactoringProcessor(selectedMembers); + Refactoring ref= new ProcessorBasedRefactoring(processor); + + assertEquals("activation was expected to fail", expectedSeverity, ref.checkInitialConditions(new NullProgressMonitor()).getSeverity()); } private void failInputHelper(String[] selectedMethodNames, String[][] selectedMethodSignatures, - String[] selectedFieldNames, - String[] namesOfMethodsToPullUp, String[][] signaturesOfMethodsToPullUp, - String[] namesOfFieldsToPullUp, String[] namesOfMethodsToDeclareAbstract, - String[][] signaturesOfMethodsToDeclareAbstract, - int expectedSeverity) throws Exception{ + String[] selectedFieldNames, + String[] namesOfMethodsToPullUp, String[][] signaturesOfMethodsToPullUp, + String[] namesOfFieldsToPullUp, String[] namesOfMethodsToDeclareAbstract, + String[][] signaturesOfMethodsToDeclareAbstract, + int expectedSeverity) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - - - Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, namesOfMethodsToPullUp, signaturesOfMethodsToPullUp, - namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, cu); - RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); - assertEquals("precondition was expected to fail", expectedSeverity, checkInputResult.getSeverity()); - } finally{ - performDummySearch(); - cu.delete(false, null); - } + Refactoring ref= createRefactoringPrepareForInputCheck(selectedMethodNames, selectedMethodSignatures, selectedFieldNames, namesOfMethodsToPullUp, signaturesOfMethodsToPullUp, + namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, cu); + RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor()); + assertEquals("precondition was expected to fail", expectedSeverity, checkInputResult.getSeverity()); } private void addRequiredMembersHelper(String[] fieldNames, String[] methodNames, String[][] methodSignatures, String[] expectedFieldNames, String[] expectedMethodNames, String[][] expectedMethodSignatures) throws Exception { ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType type= getType(cu, "A"); - IField[] fields= getFields(type, fieldNames); - IMethod[] methods= getMethods(type, methodNames, methodSignatures); - - IMember[] members= merge(methods, fields); - assertTrue(RefactoringAvailabilityTester.isPushDownAvailable(members)); - PushDownRefactoringProcessor processor= new PushDownRefactoringProcessor(members); - Refactoring ref= new ProcessorBasedRefactoring(processor); - - assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); - - processor.computeAdditionalRequiredMembersToPushDown(new NullProgressMonitor()); - List required= getMembersToPushDown(processor); - processor.getMemberActionInfos(); - IField[] expectedFields= getFields(type, expectedFieldNames); - IMethod[] expectedMethods= getMethods(type, expectedMethodNames, expectedMethodSignatures); - List expected= Arrays.asList(merge(expectedFields, expectedMethods)); - assertEquals("incorrect size", expected.size(), required.size()); - for (Iterator iter= expected.iterator(); iter.hasNext();) { - Object each= iter.next(); - assertTrue ("required does not contain " + each, required.contains(each)); - } - for (Iterator iter= required.iterator(); iter.hasNext();) { - Object each= iter.next(); - assertTrue ("expected does not contain " + each, expected.contains(each)); - } - } finally{ - performDummySearch(); - cu.delete(false, null); + IType type= getType(cu, "A"); + IField[] fields= getFields(type, fieldNames); + IMethod[] methods= getMethods(type, methodNames, methodSignatures); + + IMember[] members= merge(methods, fields); + assertTrue(RefactoringAvailabilityTester.isPushDownAvailable(members)); + PushDownRefactoringProcessor processor= new PushDownRefactoringProcessor(members); + Refactoring ref= new ProcessorBasedRefactoring(processor); + + assertTrue("activation", ref.checkInitialConditions(new NullProgressMonitor()).isOK()); + + processor.computeAdditionalRequiredMembersToPushDown(new NullProgressMonitor()); + List required= getMembersToPushDown(processor); + processor.getMemberActionInfos(); + IField[] expectedFields= getFields(type, expectedFieldNames); + IMethod[] expectedMethods= getMethods(type, expectedMethodNames, expectedMethodSignatures); + List expected= Arrays.asList(merge(expectedFields, expectedMethods)); + assertEquals("incorrect size", expected.size(), required.size()); + for (Iterator iter= expected.iterator(); iter.hasNext();) { + Object each= iter.next(); + assertTrue ("required does not contain " + each, required.contains(each)); + } + for (Iterator iter= required.iterator(); iter.hasNext();) { + Object each= iter.next(); + assertTrue ("expected does not contain " + each, expected.contains(each)); } } @@ -266,10 +237,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test1() throws Exception{ @@ -283,10 +254,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test2() throws Exception{ @@ -300,10 +271,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test3() throws Exception{ @@ -317,10 +288,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test4() throws Exception{ @@ -334,10 +305,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test5() throws Exception{ @@ -351,10 +322,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test6() throws Exception{ @@ -368,10 +339,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test7() throws Exception{ @@ -385,10 +356,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test8() throws Exception{ @@ -402,10 +373,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test9() throws Exception{ @@ -419,10 +390,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test10() throws Exception{ @@ -436,10 +407,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test11() throws Exception{ @@ -453,10 +424,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test12() throws Exception{ @@ -470,10 +441,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test13() throws Exception{ @@ -487,10 +458,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test14() throws Exception{ @@ -504,10 +475,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test15() throws Exception{ @@ -521,10 +492,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test16() throws Exception{ @@ -538,10 +509,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test17() throws Exception{ @@ -555,10 +526,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test18() throws Exception{ @@ -572,10 +543,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test19() throws Exception{ @@ -589,10 +560,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test20() throws Exception{ @@ -606,11 +577,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {new String[0]}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - new String[]{"B"}, new String[]{"p"}); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + new String[]{"B"}, new String[]{"p"}); } public void test21() throws Exception{ @@ -624,11 +595,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - new String[]{"B", "C"}, new String[]{"p", "p"}); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + new String[]{"B", "C"}, new String[]{"p", "p"}); } public void test22() throws Exception{ @@ -642,10 +613,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test23() throws Exception{ @@ -659,10 +630,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test24() throws Exception{ @@ -676,10 +647,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test25() throws Exception{ @@ -693,10 +664,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test26() throws Exception{ @@ -710,10 +681,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test27() throws Exception{ @@ -727,10 +698,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test28() throws Exception{ @@ -748,10 +719,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test29() throws Exception{ @@ -765,10 +736,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test30() throws Exception{ @@ -782,10 +753,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test31() throws Exception{ @@ -799,10 +770,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test32() throws Exception{ @@ -816,10 +787,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void test33() throws Exception{ @@ -833,11 +804,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - new String[]{"B", "C"}, new String[]{"p", "p"}); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + new String[]{"B", "C"}, new String[]{"p", "p"}); } public void test34() throws Exception{ @@ -866,8 +837,8 @@ public class PushDownTests extends RefactoringTest { String[] selectedFieldNames= {}; failActivationHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - RefactoringStatus.FATAL); + selectedFieldNames, + RefactoringStatus.FATAL); } public void testFail1() throws Exception { @@ -876,8 +847,8 @@ public class PushDownTests extends RefactoringTest { String[] selectedFieldNames= {}; failActivationHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - RefactoringStatus.FATAL); + selectedFieldNames, + RefactoringStatus.FATAL); } public void testFail2() throws Exception { @@ -891,11 +862,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testFail3() throws Exception { @@ -909,11 +880,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testVisibility1() throws Exception { @@ -927,10 +898,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testVisibility2() throws Exception { @@ -944,10 +915,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testVisibility3() throws Exception { @@ -961,10 +932,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testFail7() throws Exception { @@ -978,11 +949,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testFail8() throws Exception { @@ -996,11 +967,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testFail9() throws Exception { @@ -1014,11 +985,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testFail10() throws Exception { @@ -1032,11 +1003,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testFail11() throws Exception { @@ -1050,11 +1021,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testFail12() throws Exception { @@ -1068,11 +1039,11 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; failInputHelper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, - RefactoringStatus.ERROR); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, + RefactoringStatus.ERROR); } public void testVisibility0() throws Exception { @@ -1086,10 +1057,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testAddingRequiredMembers0() throws Exception{ @@ -1326,10 +1297,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics1() throws Exception{ @@ -1343,10 +1314,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics2() throws Exception{ @@ -1360,10 +1331,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics3() throws Exception{ @@ -1377,10 +1348,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics4() throws Exception{ @@ -1394,10 +1365,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics5() throws Exception{ @@ -1411,10 +1382,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics6() throws Exception{ @@ -1428,10 +1399,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics7() throws Exception{ @@ -1445,10 +1416,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics8() throws Exception{ @@ -1462,10 +1433,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics9() throws Exception{ @@ -1479,10 +1450,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics10() throws Exception{ @@ -1496,10 +1467,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics11() throws Exception{ @@ -1513,10 +1484,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics12() throws Exception{ @@ -1530,10 +1501,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics13() throws Exception{ @@ -1547,10 +1518,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics14() throws Exception{ @@ -1564,10 +1535,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics15() throws Exception{ @@ -1581,10 +1552,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics16() throws Exception{ @@ -1598,10 +1569,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics17() throws Exception{ @@ -1615,10 +1586,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics18() throws Exception{ @@ -1632,10 +1603,10 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= {}; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } public void testGenerics19() throws Exception{ @@ -1649,9 +1620,9 @@ public class PushDownTests extends RefactoringTest { String[][] signaturesOfMethodsToDeclareAbstract= selectedMethodSignatures; helper(selectedMethodNames, selectedMethodSignatures, - selectedFieldNames, - namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, - namesOfFieldsToPushDown, - namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); + selectedFieldNames, + namesOfMethodsToPushDown, signaturesOfMethodsToPushDown, + namesOfFieldsToPushDown, + namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null); } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java index 4f763155e3..7f7c0e095e 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -141,6 +141,8 @@ public abstract class RefactoringTest extends TestCase { // Restore package 'p' if (!pExists) getRoot().createPackageFragment("p", true, null); + + tryDeletingAllNonJavaChildResources(getRoot()); } restoreTestProject(); @@ -197,6 +199,16 @@ public abstract class RefactoringTest extends TestCase { } } + private static void tryDeletingAllNonJavaChildResources(IPackageFragmentRoot root) throws CoreException { + Object[] nonJavaKids= root.getNonJavaResources(); + for (int i= 0; i < nonJavaKids.length; i++) { + if (nonJavaKids[i] instanceof IResource) { + IResource resource= (IResource)nonJavaKids[i]; + JavaProjectHelper.delete(resource); + } + } + } + private static void tryDeletingAllJavaChildren(IPackageFragment pack) throws CoreException { IJavaElement[] kids= pack.getChildren(); for (int i= 0; i < kids.length; i++){ diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameNonPrivateFieldTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameNonPrivateFieldTests.java index b9795ad0b6..e2fb9ac02c 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameNonPrivateFieldTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameNonPrivateFieldTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,7 +42,7 @@ import org.eclipse.jdt.internal.core.refactoring.descriptors.RefactoringSignatur import org.eclipse.jdt.internal.corext.refactoring.rename.RenameFieldProcessor; import org.eclipse.jdt.internal.corext.util.JdtFlags; -public class RenameNonPrivateFieldTests extends RefactoringTest{ +public class RenameNonPrivateFieldTests extends RefactoringTest { private static final Class clazz= RenameNonPrivateFieldTests.class; private static final String REFACTORING_PATH= "RenameNonPrivateField/"; @@ -111,11 +111,11 @@ public class RenameNonPrivateFieldTests extends RefactoringTest{ /** * Configure options by setting instance fields to non-default values. - * @param fieldName - * @param newFieldName - * @throws Exception + * @param fieldName + * @param newFieldName + * @throws Exception */ - private void helper2(String fieldName, String newFieldName) throws Exception{ + private void helper2(String fieldName, String newFieldName) throws Exception { helper2(fieldName, newFieldName, false); } @@ -159,8 +159,8 @@ public class RenameNonPrivateFieldTests extends RefactoringTest{ assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource()); ParticipantTesting.testRename( - renameHandles, - (RenameArguments[]) args.toArray(new RenameArguments[args.size()])); + renameHandles, + (RenameArguments[]) args.toArray(new RenameArguments[args.size()])); assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo()); assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo()); @@ -372,41 +372,26 @@ public class RenameNonPrivateFieldTests extends RefactoringTest{ //bug 77622 IPackageFragment test1= getRoot().createPackageFragment("test1", true, null); ICompilationUnit cuC= null; - try { - ICompilationUnit cuB= createCUfromTestFile(test1, "B"); - cuC= createCUfromTestFile(getRoot().getPackageFragment(""), "C"); - - helper2("PI", "e"); - - assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("B")), cuB.getSource()); - assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("C")), cuC.getSource()); - } finally { - if (test1.exists()) - test1.delete(true, null); - if (cuC != null && cuC.exists()) - cuC.delete(true, null); - } + ICompilationUnit cuB= createCUfromTestFile(test1, "B"); + cuC= createCUfromTestFile(getRoot().getPackageFragment(""), "C"); + + helper2("PI", "e"); + + assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("B")), cuB.getSource()); + assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("C")), cuC.getSource()); } public void testEnumConst() throws Exception { //bug 77619 IPackageFragment test1= getRoot().createPackageFragment("test1", true, null); ICompilationUnit cuC= null; - try { - ICompilationUnit cuB= createCUfromTestFile(test1, "B"); - cuC= createCUfromTestFile(getRoot().getPackageFragment(""), "C"); - - helper2("RED", "REDDISH"); - - assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("B")), cuB.getSource()); - assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("C")), cuC.getSource()); - } finally { - if (test1.exists()) - test1.delete(true, null); - if (cuC != null && cuC.exists()) - cuC.delete(true, null); - } + ICompilationUnit cuB= createCUfromTestFile(test1, "B"); + cuC= createCUfromTestFile(getRoot().getPackageFragment(""), "C"); + + helper2("RED", "REDDISH"); + assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("B")), cuB.getSource()); + assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("C")), cuC.getSource()); } public void testGenerics1() throws Exception { diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java index 4259f38bb2..e080ff8516 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamePackageTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -141,29 +141,19 @@ public class RenamePackageTests extends RefactoringTest { * the 0th one is the one to rename */ private void helper1(String packageNames[], String[][] packageFiles, String newPackageName) throws Exception{ - try{ - IPackageFragment[] packages= new IPackageFragment[packageNames.length]; - for (int i= 0; i < packageFiles.length; i++){ - packages[i]= getRoot().createPackageFragment(packageNames[i], true, null); - for (int j= 0; j < packageFiles[i].length; j++){ - createCUfromTestFile(packages[i], packageFiles[i][j], packageNames[i].replace('.', '/') + "/"); - //DebugUtils.dump(cu.getElementName() + "\n" + cu.getSource()); - } - } - IPackageFragment thisPackage= packages[0]; - RefactoringStatus result= performRefactoring(createRefactoringDescriptor(thisPackage, newPackageName)); - assertNotNull("precondition was supposed to fail", result); - if (fIsVerbose) - DebugUtils.dump("" + result); - } finally{ - performDummySearch(); - - for (int i= 0; i < packageNames.length; i++){ - IPackageFragment pack= getRoot().getPackageFragment(packageNames[i]); - if (pack.exists()) - pack.delete(true, null); + IPackageFragment[] packages= new IPackageFragment[packageNames.length]; + for (int i= 0; i < packageFiles.length; i++){ + packages[i]= getRoot().createPackageFragment(packageNames[i], true, null); + for (int j= 0; j < packageFiles[i].length; j++){ + createCUfromTestFile(packages[i], packageFiles[i][j], packageNames[i].replace('.', '/') + "/"); + //DebugUtils.dump(cu.getElementName() + "\n" + cu.getSource()); } } + IPackageFragment thisPackage= packages[0]; + RefactoringStatus result= performRefactoring(createRefactoringDescriptor(thisPackage, newPackageName)); + assertNotNull("precondition was supposed to fail", result); + if (fIsVerbose) + DebugUtils.dump("" + result); } private void helper1() throws Exception{ diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameResourceChangeTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameResourceChangeTests.java index caa2fc0147..10e082da0f 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameResourceChangeTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameResourceChangeTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,6 +13,8 @@ package org.eclipse.jdt.ui.tests.refactoring; import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.jdt.testplugin.JavaProjectHelper; + import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.resources.IFile; @@ -43,159 +45,128 @@ public class RenameResourceChangeTests extends RefactoringTest { public void testFile0() throws Exception{ IFolder folder= (IFolder)getPackageP().getCorrespondingResource(); String newName= "b.txt"; - try{ - - String oldName= "a.txt"; - IFile file= folder.getFile(oldName); - assertTrue("should not exist", ! file.exists()); - String content= "aaaaaaaaa"; - file.create(getStream(content), true, new NullProgressMonitor()); - assertTrue("should exist", file.exists()); - - Change change= new RenameResourceChange(file.getFullPath(), newName); - change.initializeValidationData(new NullProgressMonitor()); - performChange(change); - assertTrue("after: should exist", folder.getFile(newName).exists()); - assertTrue("after: old should not exist", ! folder.getFile(oldName).exists()); - } finally{ - performDummySearch(); - folder.getFile(newName).delete(true, false, new NullProgressMonitor()); - } + String oldName= "a.txt"; + IFile file= folder.getFile(oldName); + assertTrue("should not exist", ! file.exists()); + String content= "aaaaaaaaa"; + file.create(getStream(content), true, new NullProgressMonitor()); + assertTrue("should exist", file.exists()); + + Change change= new RenameResourceChange(file.getFullPath(), newName); + change.initializeValidationData(new NullProgressMonitor()); + performChange(change); + assertTrue("after: should exist", folder.getFile(newName).exists()); + assertTrue("after: old should not exist", ! folder.getFile(oldName).exists()); } public void testFile1() throws Exception{ IFolder folder= (IFolder)getPackageP().getCorrespondingResource(); String newName= "b.txt"; - try{ - String oldName= "a.txt"; - IFile file= folder.getFile(oldName); - assertTrue("should not exist", ! file.exists()); - String content= ""; - file.create(getStream(content), true, new NullProgressMonitor()); - assertTrue("should exist", file.exists()); - - - Change change= new RenameResourceChange(file.getFullPath(), newName); - change.initializeValidationData(new NullProgressMonitor()); - performChange(change); - assertTrue("after: should exist", folder.getFile(newName).exists()); - assertTrue("after: old should not exist", ! folder.getFile(oldName).exists()); - } finally{ - performDummySearch(); - folder.getFile(newName).delete(true, false, new NullProgressMonitor()); - } + String oldName= "a.txt"; + IFile file= folder.getFile(oldName); + assertTrue("should not exist", ! file.exists()); + String content= ""; + file.create(getStream(content), true, new NullProgressMonitor()); + assertTrue("should exist", file.exists()); + + + Change change= new RenameResourceChange(file.getFullPath(), newName); + change.initializeValidationData(new NullProgressMonitor()); + performChange(change); + assertTrue("after: should exist", folder.getFile(newName).exists()); + assertTrue("after: old should not exist", ! folder.getFile(oldName).exists()); } public void testFile2() throws Exception{ IFolder folder= (IFolder)getPackageP().getCorrespondingResource(); String oldName= "a.txt"; String newName= "b.txt"; - try{ - IFile file= folder.getFile(oldName); - assertTrue("should not exist", ! file.exists()); - String content= "aaaaaaaaa"; - file.create(getStream(content), true, new NullProgressMonitor()); - assertTrue("should exist", file.exists()); - - Change change= new RenameResourceChange(file.getFullPath(), newName); - change.initializeValidationData(new NullProgressMonitor()); - Change undo= performChange(change); - assertTrue("after: should exist", folder.getFile(newName).exists()); - assertTrue("after: old should not exist", ! folder.getFile(oldName).exists()); - //------ - - assertTrue("should be undoable", undo != null); - undo.initializeValidationData(new NullProgressMonitor()); - performChange(undo); - assertTrue("after undo: should exist", folder.getFile(oldName).exists()); - assertTrue("after undo: old should not exist", ! folder.getFile(newName).exists()); - } finally{ - performDummySearch(); - folder.getFile(oldName).delete(true, false, new NullProgressMonitor()); - } + IFile file= folder.getFile(oldName); + assertTrue("should not exist", ! file.exists()); + String content= "aaaaaaaaa"; + file.create(getStream(content), true, new NullProgressMonitor()); + assertTrue("should exist", file.exists()); + + Change change= new RenameResourceChange(file.getFullPath(), newName); + change.initializeValidationData(new NullProgressMonitor()); + Change undo= performChange(change); + assertTrue("after: should exist", folder.getFile(newName).exists()); + assertTrue("after: old should not exist", ! folder.getFile(oldName).exists()); + //------ + + assertTrue("should be undoable", undo != null); + undo.initializeValidationData(new NullProgressMonitor()); + performChange(undo); + assertTrue("after undo: should exist", folder.getFile(oldName).exists()); + assertTrue("after undo: old should not exist", ! folder.getFile(newName).exists()); } public void testFolder0() throws Exception{ IFolder folder= (IFolder)getPackageP().getCorrespondingResource(); String newName= "b"; - try{ - String oldName= "a"; - IFolder subFolder= folder.getFolder(oldName); - assertTrue("should not exist", ! subFolder.exists()); - subFolder.create(true, true, null); - assertTrue("should exist", subFolder.exists()); + String oldName= "a"; + IFolder subFolder= folder.getFolder(oldName); + assertTrue("should not exist", ! subFolder.exists()); + subFolder.create(true, true, null); + assertTrue("should exist", subFolder.exists()); - Change change= new RenameResourceChange(subFolder.getFullPath(), newName); - change.initializeValidationData(new NullProgressMonitor()); - performChange(change); - assertTrue("after: should exist", folder.getFolder(newName).exists()); - assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists()); - } finally{ - performDummySearch(); - folder.getFolder(newName).delete(true, false, new NullProgressMonitor()); - } + Change change= new RenameResourceChange(subFolder.getFullPath(), newName); + change.initializeValidationData(new NullProgressMonitor()); + performChange(change); + assertTrue("after: should exist", folder.getFolder(newName).exists()); + assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists()); } public void testFolder1() throws Exception{ IFolder folder= (IFolder)getPackageP().getCorrespondingResource(); String newName= "b"; - try{ - String oldName= "a"; - IFolder subFolder= folder.getFolder(oldName); - assertTrue("should not exist", ! subFolder.exists()); - subFolder.create(true, true, null); - IFile file1= subFolder.getFile("a.txt"); - IFile file2= subFolder.getFile("b.txt"); - file1.create(getStream("123"), true, null); - file2.create(getStream("123345"), true, null); - - assertTrue("should exist", subFolder.exists()); - assertTrue("file1 should exist", file1.exists()); - assertTrue("file2 should exist", file2.exists()); - - Change change= new RenameResourceChange(subFolder.getFullPath(), newName); - change.initializeValidationData(new NullProgressMonitor()); - performChange(change); - assertTrue("after: should exist", folder.getFolder(newName).exists()); - assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists()); - assertEquals("after: child count", 2, folder.getFolder(newName).members().length); - } finally{ - performDummySearch(); - folder.getFolder(newName).delete(true, false, new NullProgressMonitor()); - } + String oldName= "a"; + IFolder subFolder= folder.getFolder(oldName); + assertTrue("should not exist", ! subFolder.exists()); + subFolder.create(true, true, null); + IFile file1= subFolder.getFile("a.txt"); + IFile file2= subFolder.getFile("b.txt"); + file1.create(getStream("123"), true, null); + file2.create(getStream("123345"), true, null); + + assertTrue("should exist", subFolder.exists()); + assertTrue("file1 should exist", file1.exists()); + assertTrue("file2 should exist", file2.exists()); + + Change change= new RenameResourceChange(subFolder.getFullPath(), newName); + change.initializeValidationData(new NullProgressMonitor()); + performChange(change); + assertTrue("after: should exist", folder.getFolder(newName).exists()); + assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists()); + assertEquals("after: child count", 2, folder.getFolder(newName).members().length); } public void testFolder2() throws Exception{ IFolder folder= (IFolder)getPackageP().getCorrespondingResource(); String oldName= "a"; String newName= "b"; - try{ - IFolder subFolder= folder.getFolder(oldName); - assertTrue("should not exist", ! subFolder.exists()); - subFolder.create(true, true, null); - assertTrue("should exist", subFolder.exists()); - - - Change change= new RenameResourceChange(subFolder.getFullPath(), newName); - change.initializeValidationData(new NullProgressMonitor()); - Change undo= performChange(change); - assertTrue("after: should exist", folder.getFolder(newName).exists()); - assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists()); - - //--- - assertTrue("should be undoable", undo != null); - undo.initializeValidationData(new NullProgressMonitor()); - performChange(undo); - assertTrue("after undo: should exist", folder.getFolder(oldName).exists()); - assertTrue("after undo: old should not exist", ! folder.getFolder(newName).exists()); - } finally{ - performDummySearch(); - folder.getFolder(oldName).delete(true, false, new NullProgressMonitor()); - } + IFolder subFolder= folder.getFolder(oldName); + assertTrue("should not exist", ! subFolder.exists()); + subFolder.create(true, true, null); + assertTrue("should exist", subFolder.exists()); + + + Change change= new RenameResourceChange(subFolder.getFullPath(), newName); + change.initializeValidationData(new NullProgressMonitor()); + Change undo= performChange(change); + assertTrue("after: should exist", folder.getFolder(newName).exists()); + assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists()); + + //--- + assertTrue("should be undoable", undo != null); + undo.initializeValidationData(new NullProgressMonitor()); + performChange(undo); + assertTrue("after undo: should exist", folder.getFolder(oldName).exists()); + assertTrue("after undo: old should not exist", ! folder.getFolder(newName).exists()); } public void testJavaProject01() throws Exception { @@ -223,11 +194,10 @@ public class RenameResourceChangeTests extends RefactoringTest { assertTrue("after: linked folder should be linked", project2.getFolder(linkName).isLinked()); assertTrue("after: linked folder should contain cu", project2.getFolder(linkName).getFile("A.java").exists()); } finally { - performDummySearch(); if (project.exists()) - project.delete(true, null); + JavaProjectHelper.delete(project); if (project2.exists()) - project2.delete(true, null); + JavaProjectHelper.delete(project2); } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameSourceFolderChangeTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameSourceFolderChangeTests.java index ded3231e36..a6885e7970 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameSourceFolderChangeTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameSourceFolderChangeTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -124,7 +124,7 @@ public class RenameSourceFolderChangeTests extends RefactoringTest { assertEquals("src2/", rawClasspath[0].getExclusionPatterns()[0].toString()); assertEquals(projectPath.append("src2/"), rawClasspath[1].getPath()); } finally { - project.getProject().delete(true, null); + JavaProjectHelper.delete(project.getProject()); } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameStaticMethodTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameStaticMethodTests.java index 896c059ac8..2612661dc2 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameStaticMethodTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameStaticMethodTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,19 +51,14 @@ public class RenameStaticMethodTests extends RefactoringTest { } private void helper1_0(String methodName, String newMethodName, String[] signatures) throws Exception{ - IType classA= getType(createCUfromTestFile(getPackageP(), "A"), "A"); - try{ - IMethod method= classA.getMethod(methodName, signatures); - RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD); - descriptor.setJavaElement(method); - descriptor.setNewName(newMethodName); - descriptor.setUpdateReferences(true); - RefactoringStatus result= performRefactoring(descriptor); - assertNotNull("precondition was supposed to fail", result); - } finally{ - performDummySearch(); - classA.getCompilationUnit().delete(true, null); - } + IType classA= getType(createCUfromTestFile(getPackageP(), "A"), "A"); + IMethod method= classA.getMethod(methodName, signatures); + RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD); + descriptor.setJavaElement(method); + descriptor.setNewName(newMethodName); + descriptor.setUpdateReferences(true); + RefactoringStatus result= performRefactoring(descriptor); + assertNotNull("precondition was supposed to fail", result); } private void helper1() throws Exception{ @@ -72,36 +67,31 @@ public class RenameStaticMethodTests extends RefactoringTest { private void helper2_0(String methodName, String newMethodName, String[] signatures, boolean updateReferences, boolean createDelegate) throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); - try{ - IType classA= getType(cu, "A"); - IMethod method= classA.getMethod(methodName, signatures); - RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD); - descriptor.setUpdateReferences(updateReferences); - descriptor.setJavaElement(method); - descriptor.setNewName(newMethodName); - descriptor.setKeepOriginal(createDelegate); - descriptor.setDeprecateDelegate(true); - - assertEquals("was supposed to pass", null, performRefactoring(descriptor)); - assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource()); - - assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo()); - assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo()); - //assertEquals("1 to undo", 1, Refactoring.getUndoManager().getRefactoringLog().size()); - - RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor()); - assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource()); - - assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo()); - assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo()); - //assertEquals("1 to redo", 1, Refactoring.getUndoManager().getRedoStack().size()); - - RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor()); - assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource()); - } finally{ - performDummySearch(); - cu.delete(true, null); - } + IType classA= getType(cu, "A"); + IMethod method= classA.getMethod(methodName, signatures); + RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD); + descriptor.setUpdateReferences(updateReferences); + descriptor.setJavaElement(method); + descriptor.setNewName(newMethodName); + descriptor.setKeepOriginal(createDelegate); + descriptor.setDeprecateDelegate(true); + + assertEquals("was supposed to pass", null, performRefactoring(descriptor)); + assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource()); + + assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo()); + assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo()); + //assertEquals("1 to undo", 1, Refactoring.getUndoManager().getRefactoringLog().size()); + + RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor()); + assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource()); + + assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo()); + assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo()); + //assertEquals("1 to redo", 1, Refactoring.getUndoManager().getRedoStack().size()); + + RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor()); + assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource()); } private void helper2_0(String methodName, String newMethodName, String[] signatures) throws Exception{ helper2_0(methodName, newMethodName, signatures, true, false); @@ -216,24 +206,19 @@ public class RenameStaticMethodTests extends RefactoringTest { // if (true) return; IPackageFragment packageA= getRoot().createPackageFragment("a", false, new NullProgressMonitor()); IPackageFragment packageB= getRoot().createPackageFragment("b", false, new NullProgressMonitor()); - try { - ICompilationUnit cuA= createCUfromTestFile(packageA, "A"); - ICompilationUnit cuB= createCUfromTestFile(packageB, "B"); - - IType classA= getType(cuA, "A"); - IMethod method= classA.getMethod("method2", new String[0]); - RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD); - descriptor.setUpdateReferences(true); - descriptor.setJavaElement(method); - descriptor.setNewName("fred"); - - assertEquals("was supposed to pass", null, performRefactoring(descriptor)); - assertEqualLines("invalid renaming in A", getFileContents(getOutputTestFileName("A")), cuA.getSource()); - assertEqualLines("invalid renaming in B", getFileContents(getOutputTestFileName("B")), cuB.getSource()); - } finally{ - packageA.delete(true, new NullProgressMonitor()); - packageB.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cuA= createCUfromTestFile(packageA, "A"); + ICompilationUnit cuB= createCUfromTestFile(packageB, "B"); + + IType classA= getType(cuA, "A"); + IMethod method= classA.getMethod("method2", new String[0]); + RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD); + descriptor.setUpdateReferences(true); + descriptor.setJavaElement(method); + descriptor.setNewName("fred"); + + assertEquals("was supposed to pass", null, performRefactoring(descriptor)); + assertEqualLines("invalid renaming in A", getFileContents(getOutputTestFileName("A")), cuA.getSource()); + assertEqualLines("invalid renaming in B", getFileContents(getOutputTestFileName("B")), cuB.getSource()); } public void testUnicode01() throws Exception{ diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java index 1b43528ba4..0cd527fed7 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -59,42 +59,36 @@ public class RippleMethodFinderTests extends AbstractCUTestCase { } private void perform() throws Exception { - ICompilationUnit cu= null; - try { - IPackageFragment pack= RefactoringTestSetup.getPackageP(); - String name= adaptName("A_" + getName()); - cu= createCU(pack, name, getFileInputStream(getResourceLocation() + "/" + name)); - - String contents= cu.getBuffer().getContents(); - - IJavaElement[] elements= cu.codeSelect(contents.indexOf(TARGET) + TARGET.length(), 0); + IPackageFragment pack= RefactoringTestSetup.getPackageP(); + String name= adaptName("A_" + getName()); + ICompilationUnit cu= createCU(pack, name, getFileInputStream(getResourceLocation() + "/" + name)); + + String contents= cu.getBuffer().getContents(); + + IJavaElement[] elements= cu.codeSelect(contents.indexOf(TARGET) + TARGET.length(), 0); + assertEquals(1, elements.length); + IMethod target= (IMethod) elements[0]; + + List/*<IMethod>*/ rippleMethods= new ArrayList(); + rippleMethods.add(target); + int start= 0; + while (start < contents.length()) { + start= contents.indexOf(RIPPLE, start); + if (start == -1) + break; + elements= cu.codeSelect(start + RIPPLE.length(), 0); assertEquals(1, elements.length); - IMethod target= (IMethod) elements[0]; - - List/*<IMethod>*/ rippleMethods= new ArrayList(); - rippleMethods.add(target); - int start= 0; - while (start < contents.length()) { - start= contents.indexOf(RIPPLE, start); - if (start == -1) - break; - elements= cu.codeSelect(start + RIPPLE.length(), 0); - assertEquals(1, elements.length); - IMethod rippleMethod= (IMethod) elements[0]; - rippleMethods.add(rippleMethod); - start++; - } - - IMethod[] result= RippleMethodFinder2.getRelatedMethods(target, new NullProgressMonitor(), null); - for (int i= 0; i < result.length; i++) { - IMethod method= result[i]; - assertTrue("method not found: " + method, rippleMethods.remove(method)); - } - assertEquals("found wrong ripple methods: " + rippleMethods, 0, rippleMethods.size()); - } finally { - if (cu != null) - cu.delete(true, null); + IMethod rippleMethod= (IMethod) elements[0]; + rippleMethods.add(rippleMethod); + start++; + } + + IMethod[] result= RippleMethodFinder2.getRelatedMethods(target, new NullProgressMonitor(), null); + for (int i= 0; i < result.length; i++) { + IMethod method= result[i]; + assertTrue("method not found: " + method, rippleMethods.remove(method)); } + assertEquals("found wrong ripple methods: " + rippleMethods, 0, rippleMethods.size()); } public void test1() throws Exception { diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyResourcesToClipboardActionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyResourcesToClipboardActionTest.java index da1a18ce74..7ebbd0f06c 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyResourcesToClipboardActionTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyResourcesToClipboardActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,16 +16,11 @@ import junit.framework.TestSuite; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.widgets.Display; -import org.eclipse.core.runtime.CoreException; - import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.ISourceManipulation; -import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.ui.actions.SelectionDispatchAction; import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest; @@ -87,29 +82,7 @@ public class CopyResourcesToClipboardActionTest extends RefactoringTest{ protected void tearDown() throws Exception { super.tearDown(); - performDummySearch(); fClipboard.dispose(); - delete(fCuA); - delete(fCuB); - delete(fPackageQ_R); - delete(fPackageQ); - delete(faTxt); - } - - private static void delete(ISourceManipulation element) { - try { - if (element != null && ((IJavaElement)element).exists()) - element.delete(false, null); - } catch(JavaModelException e) { - //ignore, we must keep going - } - } - private static void delete(IFile element) { - try { - element.delete(true, false, null); - } catch(CoreException e) { - //ignore, we must keep going - } } private void checkEnabled(Object[] elements) { diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java index 78e1cb31dd..43d254801a 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -57,12 +57,12 @@ import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester import org.eclipse.jdt.internal.corext.refactoring.reorg.INewNameQueries; import org.eclipse.jdt.internal.corext.refactoring.reorg.INewNameQuery; import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgDestination; +import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.ICopyPolicy; import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgQueries; import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaCopyProcessor; import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgDestinationFactory; import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory; import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgUtils; -import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.ICopyPolicy; import org.eclipse.jdt.internal.corext.util.JavaElementResourceMapping; import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting; @@ -234,51 +234,33 @@ public class CopyTest extends RefactoringTest { //--------------- public void test_field_declared_in_multi_yes_type() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IField field= cu.getType("A").getField("bar"); - IType type= cu.getType("A"); - IJavaElement[] javaElements= { field }; - Object destination= type; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IField field= cu.getType("A").getField("bar"); + IType type= cu.getType("A"); + IJavaElement[] javaElements= { field }; + Object destination= type; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); } public void test_fields_declared_in_multi_yes_type() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IField field1= cu.getType("A").getField("bar"); - IField field2= cu.getType("A").getField("baz"); - IType type= cu.getType("A"); - IJavaElement[] javaElements= { field1, field2 }; - Object destination= type; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IField field1= cu.getType("A").getField("bar"); + IField field2= cu.getType("A").getField("baz"); + IType type= cu.getType("A"); + IJavaElement[] javaElements= { field1, field2 }; + Object destination= type; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); } public void test_fields_declared_in_multi_yes_type_1() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IField field1= cu.getType("A").getField("var11"); - IField field2= cu.getType("A").getField("var2"); - IField field3= cu.getType("A").getField("var3"); - IType type= cu.getType("A"); - IJavaElement[] javaElements= { field1, field2, field3}; - Object destination= type; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IField field1= cu.getType("A").getField("var11"); + IField field2= cu.getType("A").getField("var2"); + IField field3= cu.getType("A").getField("var3"); + IType type= cu.getType("A"); + IJavaElement[] javaElements= { field1, field2, field3}; + Object destination= type; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); } public void testDisabled_empty() throws Exception { @@ -344,105 +326,65 @@ public class CopyTest extends RefactoringTest { public void testDisabled_noCommonParent1() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IType classA= cu.getType("A"); - IMethod methodFoo= classA.getMethod("foo", new String[0]); - IJavaElement[] javaElements= { classA, methodFoo }; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IType classA= cu.getType("A"); + IMethod methodFoo= classA.getMethod("foo", new String[0]); + IJavaElement[] javaElements= { classA, methodFoo }; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } // public void testDisabled_noCommonParent2() throws Exception { // ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); -// try { -// IType classA= cu.getType("A"); -// IJavaElement[] javaElements= { classA, cu}; -// IResource[] resources= {}; -// verifyDisabled(resources, javaElements); -// } finally { -// performDummySearch(); -// cu.delete(true, new NullProgressMonitor()); -// } +// IType classA= cu.getType("A"); +// IJavaElement[] javaElements= { classA, cu}; +// IResource[] resources= {}; +// verifyDisabled(resources, javaElements); // } public void testDisabled_noCommonParent3() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= {cu, getPackageP()}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IJavaElement[] javaElements= {cu, getPackageP()}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent5() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= {cu, getRoot()}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IJavaElement[] javaElements= {cu, getRoot()}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent6() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= {cu, getRoot()}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IJavaElement[] javaElements= {cu, getRoot()}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent7() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{class Inner{}}", false, new NullProgressMonitor()); - try { - IType classA= cu.getType("A"); - IType classInner= classA.getType("Inner"); - IJavaElement[] javaElements= { classA, classInner}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IType classA= cu.getType("A"); + IType classInner= classA.getType("Inner"); + IJavaElement[] javaElements= { classA, classInner}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent8() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try { - IType classA= cu.getType("A"); - IMethod methodFoo= classA.getMethod("foo", new String[0]); - IJavaElement[] javaElements= { methodFoo, classA}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IType classA= cu.getType("A"); + IMethod methodFoo= classA.getMethod("foo", new String[0]); + IJavaElement[] javaElements= { methodFoo, classA}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testEnabled_cu() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= { cu}; - IResource[] resources= {}; - verifyEnabled(resources, javaElements, null, createReorgQueries()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IJavaElement[] javaElements= { cu}; + IResource[] resources= {}; + verifyEnabled(resources, javaElements, null, createReorgQueries()); } public void testEnabled_package() throws Exception { @@ -473,14 +415,9 @@ public class CopyTest extends RefactoringTest { IFolder folder= (IFolder)getPackageP().getResource(); IFile file= folder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - verifyEnabled(resources, javaElements, null, createReorgQueries()); - } finally{ - performDummySearch(); - file.delete(true, false, null); - } + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + verifyEnabled(resources, javaElements, null, createReorgQueries()); } public void testEnabled_folder() throws Exception{ @@ -497,15 +434,9 @@ public class CopyTest extends RefactoringTest { file.create(getStream("123"), true, null); IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file, folder}; - verifyEnabled(resources, javaElements, null, createReorgQueries()); - } finally{ - performDummySearch(); - file.delete(true, false, null); - folder.delete(true, false, null); - } + IJavaElement[] javaElements= {}; + IResource[] resources= {file, folder}; + verifyEnabled(resources, javaElements, null, createReorgQueries()); } public void testEnabled_fileFolderCu() throws Exception { @@ -514,17 +445,10 @@ public class CopyTest extends RefactoringTest { file.create(getStream("123"), true, null); IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file, folder}; - verifyEnabled(resources, javaElements, null, createReorgQueries()); - } finally{ - performDummySearch(); - file.delete(true, false, null); - folder.delete(true, false, null); - cu.delete(true, new NullProgressMonitor()); - } + getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file, folder}; + verifyEnabled(resources, javaElements, null, createReorgQueries()); } public void testDestination_package_no_1() throws Exception{ @@ -537,17 +461,12 @@ public class CopyTest extends RefactoringTest { public void testDestination_package_no_2() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= { getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination=cu; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination=cu; + verifyInvalidDestination(ref, destination); } public void testDestination_package_no_3() throws Exception{ @@ -555,17 +474,12 @@ public class CopyTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try { - IJavaElement[] javaElements= { getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= file; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - } + Object destination= file; + verifyInvalidDestination(ref, destination); } public void testDestination_package_no_4() throws Exception{ @@ -573,17 +487,12 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try { - IJavaElement[] javaElements= { getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); - } finally { - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } + Object destination= folder; + verifyValidDestination(ref, destination); } public void testDestination_cu_no_1() throws Exception{ @@ -591,17 +500,15 @@ public class CopyTest extends RefactoringTest { IProject closedProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); closedProject.create(null); assertTrue(! closedProject.isOpen()); - try{ + try { IJavaElement[] javaElements= { cu1}; IResource[] resources= {}; JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); Object destination= closedProject; verifyInvalidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - closedProject.delete(true, true, null); + } finally { + JavaProjectHelper.delete(closedProject); } } @@ -609,17 +516,12 @@ public class CopyTest extends RefactoringTest { IProject superFolder= RefactoringTestSetup.getProject().getProject(); IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= folder;//same folder - verifyInvalidDestination(ref, destination); - }finally{ - performDummySearch(); - folder.delete(true, false, null); - } + Object destination= folder;//same folder + verifyInvalidDestination(ref, destination); } public void testDestination_folder_no_1() throws Exception{ @@ -629,18 +531,12 @@ public class CopyTest extends RefactoringTest { IFolder childFolder= folder.getFolder("folder"); childFolder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= childFolder; - verifyInvalidDestination(ref, destination); - }finally{ - performDummySearch(); - folder.delete(true, false, null); - childFolder.delete(true, false, null); - } + Object destination= childFolder; + verifyInvalidDestination(ref, destination); } public void testDestination_folder_no_2() throws Exception{ @@ -650,18 +546,12 @@ public class CopyTest extends RefactoringTest { IFile childFile= folder.getFile("a.txt"); childFile.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= childFile; - verifyInvalidDestination(ref, destination); - }finally{ - performDummySearch(); - folder.delete(true, false, null); - childFile.delete(true, false, null); - } + Object destination= childFile; + verifyInvalidDestination(ref, destination); } public void testDestination_folder_no_3() throws Exception{ @@ -672,7 +562,7 @@ public class CopyTest extends RefactoringTest { IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); simpleProject.create(null); assertTrue(! simpleProject.isOpen()); - try{ + try { IJavaElement[] javaElements= {}; IResource[] resources= {folder}; JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); @@ -680,9 +570,7 @@ public class CopyTest extends RefactoringTest { Object destination= simpleProject; verifyInvalidDestination(ref, destination); } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - simpleProject.delete(true, true, new NullProgressMonitor()); + JavaProjectHelper.delete(simpleProject); } } @@ -699,34 +587,24 @@ public class CopyTest extends RefactoringTest { public void testDestination_root_no_1() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= { getRoot()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getRoot()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= cu; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= cu; + verifyInvalidDestination(ref, destination); } public void testDestination_root_no_2() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= { getRoot()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getRoot()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - IType classB= cu.getType("B"); - Object destination= classB; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IType classB= cu.getType("B"); + Object destination= classB; + verifyInvalidDestination(ref, destination); } public void testDestination_root_no_3() throws Exception{ @@ -734,110 +612,74 @@ public class CopyTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try { - IJavaElement[] javaElements= { getRoot()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getRoot()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= file; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - } + Object destination= file; + verifyInvalidDestination(ref, destination); } public void testDestination_root_no_4() throws Exception{ IProject superFolder= RefactoringTestSetup.getProject().getProject(); IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try { - IJavaElement[] javaElements= { getRoot()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getRoot()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); - } finally { - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } + Object destination= folder; + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_0() throws Exception{ ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= cu1; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - } + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + Object destination= cu1; + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_1() throws Exception{ ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getPackageP(); - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - } + Object destination= getPackageP(); + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_2() throws Exception{ ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); IPackageFragment otherPackage= getRoot().createPackageFragment("otherPackage", true, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= otherPackage; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - otherPackage.delete(true, new NullProgressMonitor()); - } + Object destination= otherPackage; + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_3() throws Exception{ ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getRoot(); - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - } + Object destination= getRoot(); + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_4() throws Exception{ ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - } + Object destination= RefactoringTestSetup.getProject(); + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_5() throws Exception{ @@ -845,17 +687,15 @@ public class CopyTest extends RefactoringTest { IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); simpleProject.create(null); simpleProject.open(null); - try{ + try { IJavaElement[] javaElements= { cu1}; IResource[] resources= {}; JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); Object destination= simpleProject; verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - simpleProject.delete(true, true, null); + } finally { + JavaProjectHelper.delete(simpleProject); } } @@ -864,18 +704,12 @@ public class CopyTest extends RefactoringTest { IProject superFolder= RefactoringTestSetup.getProject().getProject(); IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= file; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - file.delete(true, false, null); - } + Object destination= file; + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_7() throws Exception{ @@ -883,35 +717,23 @@ public class CopyTest extends RefactoringTest { IProject superFolder= RefactoringTestSetup.getProject().getProject(); IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - folder.delete(true, false, null); - } + Object destination= folder; + verifyValidDestination(ref, destination); } public void testDestination_cu_yes_8() throws Exception{ ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); ICompilationUnit cu2= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= cu2; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - cu1.delete(true, new NullProgressMonitor()); - cu2.delete(true, new NullProgressMonitor()); - } + Object destination= cu2; + verifyValidDestination(ref, destination); } @@ -919,17 +741,12 @@ public class CopyTest extends RefactoringTest { IProject superFolder= RefactoringTestSetup.getProject().getProject(); IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= file; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - } + Object destination= file; + verifyValidDestination(ref, destination); } public void testDestination_file_yes_1() throws Exception{ @@ -940,18 +757,12 @@ public class CopyTest extends RefactoringTest { IFile otherFile= superFolder.getFile("b.txt"); otherFile.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= otherFile; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - otherFile.delete(true, new NullProgressMonitor()); - } + Object destination= otherFile; + verifyValidDestination(ref, destination); } public void testDestination_file_yes_3() throws Exception{ @@ -962,18 +773,12 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - folder.delete(true, new NullProgressMonitor()); - } + Object destination= folder; + verifyValidDestination(ref, destination); } public void testDestination_file_yes_4() throws Exception{ @@ -982,18 +787,12 @@ public class CopyTest extends RefactoringTest { file.create(getStream("123"), true, null); ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= cu1; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - cu1.delete(true, new NullProgressMonitor()); - } + Object destination= cu1; + verifyValidDestination(ref, destination); } public void testDestination_file_yes_5() throws Exception{ @@ -1001,17 +800,12 @@ public class CopyTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getPackageP(); - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - } + Object destination= getPackageP(); + verifyValidDestination(ref, destination); } public void testDestination_file_yes_6() throws Exception{ @@ -1019,17 +813,12 @@ public class CopyTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getRoot(); - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - } + Object destination= getRoot(); + verifyValidDestination(ref, destination); } public void testDestination_file_yes_7() throws Exception{ @@ -1037,17 +826,12 @@ public class CopyTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - } + Object destination= RefactoringTestSetup.getProject(); + verifyValidDestination(ref, destination); } public void testDestination_file_yes_8() throws Exception{ @@ -1055,17 +839,12 @@ public class CopyTest extends RefactoringTest { IFile file= parentFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= parentFolder; - verifyValidDestination(ref, destination); - }finally{ - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - } + Object destination= parentFolder; + verifyValidDestination(ref, destination); } public void testDestination_file_yes_9() throws Exception{ @@ -1074,18 +853,12 @@ public class CopyTest extends RefactoringTest { file.create(getStream("123"), true, null); ICompilationUnit cu2= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= cu2; - verifyValidDestination(ref, destination); - } finally { - performDummySearch(); - file.delete(true, new NullProgressMonitor()); - cu2.delete(true, new NullProgressMonitor()); - } + Object destination= cu2; + verifyValidDestination(ref, destination); } public void testDestination_folder_yes_0() throws Exception{ @@ -1096,18 +869,12 @@ public class CopyTest extends RefactoringTest { IFolder otherFolder= superFolder.getFolder("otherfolder"); otherFolder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= otherFolder; - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - otherFolder.delete(true, new NullProgressMonitor()); - } + Object destination= otherFolder; + verifyValidDestination(ref, destination); } public void testDestination_folder_yes_1() throws Exception{ @@ -1115,17 +882,12 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } + Object destination= RefactoringTestSetup.getProject(); + verifyValidDestination(ref, destination); } public void testDestination_folder_yes_2() throws Exception{ @@ -1133,17 +895,12 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getRoot(); - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } + Object destination= getRoot(); + verifyValidDestination(ref, destination); } public void testDestination_folder_yes_3() throws Exception{ @@ -1151,17 +908,12 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getPackageP(); - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } + Object destination= getPackageP(); + verifyValidDestination(ref, destination); } public void testDestination_folder_yes_4() throws Exception{ @@ -1174,18 +926,12 @@ public class CopyTest extends RefactoringTest { IFile fileInAnotherFolder= otherFolder.getFile("f.tex"); fileInAnotherFolder.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= fileInAnotherFolder; - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - otherFolder.delete(true, new NullProgressMonitor()); - } + Object destination= fileInAnotherFolder; + verifyValidDestination(ref, destination); } public void testDestination_folder_yes_5() throws Exception{ @@ -1194,18 +940,12 @@ public class CopyTest extends RefactoringTest { folder.create(true, true, null); ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= cu; - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= cu; + verifyValidDestination(ref, destination); } public void testDestination_folder_yes_6() throws Exception{ @@ -1216,7 +956,7 @@ public class CopyTest extends RefactoringTest { IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); simpleProject.create(null); simpleProject.open(null); - try{ + try { IJavaElement[] javaElements= {}; IResource[] resources= {folder}; JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); @@ -1224,9 +964,7 @@ public class CopyTest extends RefactoringTest { Object destination= simpleProject; verifyValidDestination(ref, destination); } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - simpleProject.delete(true, true, new NullProgressMonitor()); + JavaProjectHelper.delete(simpleProject); } } @@ -1248,17 +986,12 @@ public class CopyTest extends RefactoringTest { public void testDestination_package_yes_2() throws Exception{ IPackageFragment otherPackage= getRoot().createPackageFragment("other.pack", true, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= { getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= otherPackage; - verifyValidDestination(ref, destination); - } finally { - performDummySearch(); - otherPackage.delete(true, new NullProgressMonitor()); - } + Object destination= otherPackage; + verifyValidDestination(ref, destination); } public void testDestination_root_yes_0() throws Exception{ @@ -1273,123 +1006,85 @@ public class CopyTest extends RefactoringTest { public void testDestination_root_yes_1() throws Exception{ IJavaProject otherJavaProject= JavaProjectHelper.createJavaProject("other", "bin"); - try { - IJavaElement[] javaElements= { getRoot()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + IJavaElement[] javaElements= { getRoot()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= otherJavaProject; - verifyValidDestination(ref, destination); - } finally { - performDummySearch(); - JavaProjectHelper.delete(otherJavaProject); - } + Object destination= otherJavaProject; + verifyValidDestination(ref, destination); } public void testDestination_method_no_package() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getPackageP(); - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= getPackageP(); + verifyInvalidDestination(ref, destination); } public void testDestination_method_no_file() throws Exception{ - ICompilationUnit cu= null; IFolder parentFolder= (IFolder) getPackageP().getResource(); String fileName= "a.txt"; IFile file= parentFolder.getFile(fileName); file.create(getStream("123"), true, null); - try { - cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= file; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - file.delete(true, false, null); - } + Object destination= file; + verifyInvalidDestination(ref, destination); } public void testDestination_method_no_folder() throws Exception{ - ICompilationUnit cu= null; IProject parentFolder= RefactoringTestSetup.getProject().getProject(); String folderName= "folder"; IFolder folder= parentFolder.getFolder(folderName); folder.create(true, true, null); - try { - cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= folder; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - folder.delete(true, false, null); - } + Object destination= folder; + verifyInvalidDestination(ref, destination); } public void testDestination_method_no_root() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getRoot(); - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= getRoot(); + verifyInvalidDestination(ref, destination); } public void testDestination_method_no_java_project() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= RefactoringTestSetup.getProject(); + verifyInvalidDestination(ref, destination); } public void testDestination_method_no_simple_project() throws Exception{ - ICompilationUnit cu= null; IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); simpleProject.create(null); simpleProject.open(null); try { - cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); IMethod method= cu.getType("A").getMethod("foo", new String[0]); IJavaElement[] javaElements= { method }; IResource[] resources= {}; @@ -1398,485 +1093,319 @@ public class CopyTest extends RefactoringTest { Object destination= simpleProject; verifyInvalidDestination(ref, destination); } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - simpleProject.delete(true, true, null); + JavaProjectHelper.delete(simpleProject); } } public void testDestination_method_no_import_container() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - IImportContainer importContainer= cu.getImportContainer(); - Object destination= importContainer; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IImportContainer importContainer= cu.getImportContainer(); + Object destination= importContainer; + verifyInvalidDestination(ref, destination); } public void testDestination_method_no_import_declaration() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - IImportDeclaration importDeclaration= cu.getImport("java.util.*"); - Object destination= importDeclaration; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IImportDeclaration importDeclaration= cu.getImport("java.util.*"); + Object destination= importDeclaration; + verifyInvalidDestination(ref, destination); } public void testDestination_method_no_package_declaration() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor()); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= cu.getPackageDeclaration("p"); - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= cu.getPackageDeclaration("p"); + verifyInvalidDestination(ref, destination); } public void test_method_yes_itself() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - Object destination= method; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + Object destination= method; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); } public void test_method_yes_cu_with_main_type() throws Exception{ - ICompilationUnit cu= null; ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C"); - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - Object destination= otherCu; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + Object destination= otherCu; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - otherCu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); } - + public void test_method_yes_other_method() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IMethod otherMethod= cu.getType("A").getMethod("bar", new String[0]); - IJavaElement[] javaElements= { method }; - Object destination= otherMethod; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IMethod otherMethod= cu.getType("A").getMethod("bar", new String[0]); + IJavaElement[] javaElements= { method }; + Object destination= otherMethod; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); } public void test_method_yes_other_method_back() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IMethod otherMethod= cu.getType("A").getMethod("bar", new String[0]); - IJavaElement[] javaElements= { method }; - Object destination= otherMethod; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IMethod otherMethod= cu.getType("A").getMethod("bar", new String[0]); + IJavaElement[] javaElements= { method }; + Object destination= otherMethod; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); } public void test_method_yes_field() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IField field= cu.getType("A").getField("bar"); - IJavaElement[] javaElements= { method }; - Object destination= field; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IField field= cu.getType("A").getField("bar"); + IJavaElement[] javaElements= { method }; + Object destination= field; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); } public void test_method_yes_field_back() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IField field= cu.getType("A").getField("bar"); - IJavaElement[] javaElements= { method }; - Object destination= field; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IField field= cu.getType("A").getField("bar"); + IJavaElement[] javaElements= { method }; + Object destination= field; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); } public void test_method_yes_type() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - Object destination= cu.getType("A"); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + Object destination= cu.getType("A"); - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); } public void test_method_yes_initializer() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - Object destination= cu.getType("A").getInitializer(1); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + Object destination= cu.getType("A").getInitializer(1); - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); } public void test_method_yes_initializer_back() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - Object destination= cu.getType("A").getInitializer(1); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + Object destination= cu.getType("A").getInitializer(1); - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); } public void test_field_yes_field() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IField field= cu.getType("A").getField("bar"); - IField otherField= cu.getType("A").getField("baz"); - IJavaElement[] javaElements= { field }; - Object destination= otherField; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IField field= cu.getType("A").getField("bar"); + IField otherField= cu.getType("A").getField("baz"); + IJavaElement[] javaElements= { field }; + Object destination= otherField; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); } public void test_field_yes_field_back() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IField field= cu.getType("A").getField("bar"); - IField otherField= cu.getType("A").getField("baz"); - IJavaElement[] javaElements= { field }; - Object destination= otherField; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IField field= cu.getType("A").getField("bar"); + IField otherField= cu.getType("A").getField("baz"); + IJavaElement[] javaElements= { field }; + Object destination= otherField; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); } public void test_inner_type_yes_cu() throws Exception{ - ICompilationUnit cu= null; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IType type= cu.getType("A").getType("Inner"); + IJavaElement[] javaElements= { type }; + ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C"); + Object destination= otherCu; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IType type= cu.getType("A").getType("Inner"); - IJavaElement[] javaElements= { type }; - Object destination= otherCu; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{otherCu, cu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - otherCu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{otherCu, cu}, destination, javaElements); } public void test_type_yes_package() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{}", true, new NullProgressMonitor()); - ICompilationUnit newCu= null; - try { - ParticipantTesting.reset(); - IType type= cu.getType("A"); - IJavaElement[] javaElements= { type }; - IResource[] resources= {}; - ResourceMapping mapping= JavaElementResourceMapping.create(type.getCompilationUnit()); - String[] handles= ParticipantTesting.createHandles(type.getCompilationUnit(), mapping); - IPackageFragment destination= getPackageP(); - INewNameQueries queries= new MockNewNameQueries(); - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); - assertTrue("source cu does not exist after copying", cu.exists()); - newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); - assertTrue("new cu does not exist after copying", newCu.exists()); - ReorgExecutionLog executionLog= new ReorgExecutionLog(); - executionLog.setNewName(type.getCompilationUnit(), MockNewNameQueries.NEW_CU_NAME + ".java"); - executionLog.setNewName(mapping, MockNewNameQueries.NEW_CU_NAME + ".java"); - executionLog.markAsProcessed(type.getCompilationUnit()); - executionLog.markAsProcessed(mapping); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + ParticipantTesting.reset(); + IType type= cu.getType("A"); + IJavaElement[] javaElements= { type }; + IResource[] resources= {}; + ResourceMapping mapping= JavaElementResourceMapping.create(type.getCompilationUnit()); + String[] handles= ParticipantTesting.createHandles(type.getCompilationUnit(), mapping); + IPackageFragment destination= getPackageP(); + INewNameQueries queries= new MockNewNameQueries(); + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + verifyValidDestination(ref, destination); + assertTrue("source cu does not exist before copying", cu.exists()); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); + assertTrue("source cu does not exist after copying", cu.exists()); + ICompilationUnit newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); + assertTrue("new cu does not exist after copying", newCu.exists()); + ReorgExecutionLog executionLog= new ReorgExecutionLog(); + executionLog.setNewName(type.getCompilationUnit(), MockNewNameQueries.NEW_CU_NAME + ".java"); + executionLog.setNewName(mapping, MockNewNameQueries.NEW_CU_NAME + ".java"); + executionLog.markAsProcessed(type.getCompilationUnit()); + executionLog.markAsProcessed(mapping); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, executionLog), new CopyArguments(destination.getResource(), executionLog) - }); - } finally { - performDummySearch(); - if (newCu != null && newCu.exists()) - newCu.delete(true, new NullProgressMonitor()); - cu.delete(true, new NullProgressMonitor()); - } + }); } public void test_type_canel_package() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{}", true, new NullProgressMonitor()); + ParticipantTesting.reset(); + IType type= cu.getType("A"); + IJavaElement[] javaElements= { type }; + IResource[] resources= {}; + ResourceMapping mapping= JavaElementResourceMapping.create(type.getCompilationUnit()); + String[] handles= ParticipantTesting.createHandles(type.getCompilationUnit(), mapping); + IPackageFragment destination= getPackageP(); + INewNameQueries queries= new MockCancelNameQueries(); + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + verifyValidDestination(ref, destination); + assertTrue("source cu does not exist before copying", cu.exists()); try { - ParticipantTesting.reset(); - IType type= cu.getType("A"); - IJavaElement[] javaElements= { type }; - IResource[] resources= {}; - ResourceMapping mapping= JavaElementResourceMapping.create(type.getCompilationUnit()); - String[] handles= ParticipantTesting.createHandles(type.getCompilationUnit(), mapping); - IPackageFragment destination= getPackageP(); - INewNameQueries queries= new MockCancelNameQueries(); - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); - try { - performRefactoring(ref, false); - } catch (OperationCanceledException e) { - } - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsCanceled(); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + performRefactoring(ref, false); + } catch (OperationCanceledException e) { + } + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsCanceled(); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + }); } public void test_type_yes_other_package() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{}", true, new NullProgressMonitor()); IPackageFragment otherPackage= getRoot().createPackageFragment("other", true, new NullProgressMonitor()); - ICompilationUnit newCu= null; - try { - ParticipantTesting.reset(); + ParticipantTesting.reset(); - IType type= cu.getType("A"); - IJavaElement[] javaElements= { type }; - IResource[] resources= {}; - IPackageFragment destination= otherPackage; - ResourceMapping mapping= JavaElementResourceMapping.create(type.getCompilationUnit()); - String[] handles= ParticipantTesting.createHandles(type.getCompilationUnit(), mapping); + IType type= cu.getType("A"); + IJavaElement[] javaElements= { type }; + IResource[] resources= {}; + IPackageFragment destination= otherPackage; + ResourceMapping mapping= JavaElementResourceMapping.create(type.getCompilationUnit()); + String[] handles= ParticipantTesting.createHandles(type.getCompilationUnit(), mapping); - INewNameQueries queries= new MockNewNameQueries(); - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); - assertTrue("source cu does not exist after copying", cu.exists()); - newCu= otherPackage.getCompilationUnit(cu.getElementName()); - assertTrue("new cu does not exist after copying", newCu.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsProcessed(type.getCompilationUnit()); - log.markAsProcessed(mapping); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + INewNameQueries queries= new MockNewNameQueries(); + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + verifyValidDestination(ref, destination); + assertTrue("source cu does not exist before copying", cu.exists()); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); + assertTrue("source cu does not exist after copying", cu.exists()); + ICompilationUnit newCu= otherPackage.getCompilationUnit(cu.getElementName()); + assertTrue("new cu does not exist after copying", newCu.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsProcessed(type.getCompilationUnit()); + log.markAsProcessed(mapping); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); + }); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - if (newCu != null && newCu.exists()) - newCu.delete(true, new NullProgressMonitor()); - otherPackage.delete(true, new NullProgressMonitor()); - } } public void testDestination_initializer_no_package() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}{}}", false, new NullProgressMonitor()); - IInitializer initializer= cu.getType("A").getInitializer(1); - IJavaElement[] javaElements= { initializer }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}{}}", false, new NullProgressMonitor()); + IInitializer initializer= cu.getType("A").getInitializer(1); + IJavaElement[] javaElements= { initializer }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getPackageP(); - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= getPackageP(); + verifyInvalidDestination(ref, destination); } public void test_initializer_yes_type() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IInitializer initializer= cu.getType("A").getInitializer(1); - IJavaElement[] javaElements= { initializer }; - Object destination= cu.getType("A"); - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IInitializer initializer= cu.getType("A").getInitializer(1); + IJavaElement[] javaElements= { initializer }; + Object destination= cu.getType("A"); + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements); } public void test_initializer_yes_method() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IInitializer initializer= cu.getType("A").getInitializer(1); - IJavaElement[] javaElements= { initializer }; - Object destination= cu.getType("A").getMethod("foo", new String[0]); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IInitializer initializer= cu.getType("A").getInitializer(1); + IJavaElement[] javaElements= { initializer }; + Object destination= cu.getType("A").getMethod("foo", new String[0]); - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements); } public void test_initializer_yes_method_back() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IInitializer initializer= cu.getType("A").getInitializer(1); - IJavaElement[] javaElements= { initializer }; - Object destination= cu.getType("A").getMethod("foo", new String[0]); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IInitializer initializer= cu.getType("A").getInitializer(1); + IJavaElement[] javaElements= { initializer }; + Object destination= cu.getType("A").getMethod("foo", new String[0]); - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements); } public void testDestination_import_container_no_package() throws Exception{ - ICompilationUnit cu= null; - try { - cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}{}}", false, new NullProgressMonitor()); - IImportContainer container= cu.getImportContainer(); - IJavaElement[] javaElements= { container }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); + ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}{}}", false, new NullProgressMonitor()); + IImportContainer container= cu.getImportContainer(); + IJavaElement[] javaElements= { container }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries()); - Object destination= getPackageP(); - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object destination= getPackageP(); + verifyInvalidDestination(ref, destination); } public void test_import_container_yes_type_in_different_cu() throws Exception{ - ICompilationUnit cu= null; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C"); - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IImportContainer container= cu.getImportContainer(); - IJavaElement[] javaElements= { container }; - Object destination= otherCu; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - otherCu.delete(true, new NullProgressMonitor()); - } + IImportContainer container= cu.getImportContainer(); + IJavaElement[] javaElements= { container }; + Object destination= otherCu; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); } public void test_import_container_yes_method_in_different_cu() throws Exception{ - ICompilationUnit cu= null; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C"); - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IImportContainer container= cu.getImportContainer(); - IJavaElement[] javaElements= { container }; - Object destination= otherCu; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - otherCu.delete(true, new NullProgressMonitor()); - } + IImportContainer container= cu.getImportContainer(); + IJavaElement[] javaElements= { container }; + Object destination= otherCu; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); } public void test_import_container_yes_cu() throws Exception{ - ICompilationUnit cu= null; + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C"); - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IImportContainer container= cu.getImportContainer(); - IJavaElement[] javaElements= { container }; - Object destination= otherCu; - verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - otherCu.delete(true, new NullProgressMonitor()); - } + IImportContainer container= cu.getImportContainer(); + IJavaElement[] javaElements= { container }; + Object destination= otherCu; + verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements); } @@ -1891,41 +1420,31 @@ public class CopyTest extends RefactoringTest { IFolder destinationFolder= superFolder.getFolder("folder"); destinationFolder.create(true, true, null); - IFile newFile= null; - try { + INewNameQueries queries= new MockNewNameQueries(); - INewNameQueries queries= new MockNewNameQueries(); - - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - String[] handles= ParticipantTesting.createHandles(file); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + String[] handles= ParticipantTesting.createHandles(file); - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= destinationFolder; - verifyValidDestination(ref, destination); + Object destination= destinationFolder; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= destinationFolder.getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsProcessed(file); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + IFile newFile= destinationFolder.getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsProcessed(file); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log) - }); - } finally { - performDummySearch(); - file.delete(true, false, null); - destinationFolder.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + }); } public void testCopy_File_to_Same_Folder() throws Exception { @@ -1937,39 +1456,31 @@ public class CopyTest extends RefactoringTest { IFolder destinationFolder= parentFolder; - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - String[] handles= ParticipantTesting.createHandles(file); - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + String[] handles= ParticipantTesting.createHandles(file); + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= destinationFolder; - verifyValidDestination(ref, destination); + Object destination= destinationFolder; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= destinationFolder.getFile(MockNewNameQueries.NEW_FILE_NAME); - assertTrue("new file does not exist after copying", newFile.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.setNewName(file, MockNewNameQueries.NEW_FILE_NAME); - log.markAsProcessed(file); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + IFile newFile= destinationFolder.getFile(MockNewNameQueries.NEW_FILE_NAME); + assertTrue("new file does not exist after copying", newFile.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.setNewName(file, MockNewNameQueries.NEW_FILE_NAME); + log.markAsProcessed(file); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log) - }); - } finally { - performDummySearch(); - file.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + }); } public void testCopy_File_to_Same_Folder_Cancel() throws Exception { @@ -1981,32 +1492,27 @@ public class CopyTest extends RefactoringTest { IFolder destinationFolder= parentFolder; - try { - INewNameQueries queries= new MockCancelNameQueries(); + INewNameQueries queries= new MockCancelNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - String[] handles= ParticipantTesting.createHandles(file); - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + String[] handles= ParticipantTesting.createHandles(file); + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= destinationFolder; - verifyValidDestination(ref, destination); + Object destination= destinationFolder; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - try { - performRefactoring(ref, false); - } catch(OperationCanceledException e) { - } - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsCanceled(); - ParticipantTesting.testCopy(handles, new CopyArguments[] { - new CopyArguments(destination, log) - }); - } finally { - performDummySearch(); - file.delete(true, false, null); + try { + performRefactoring(ref, false); + } catch(OperationCanceledException e) { } + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsCanceled(); + ParticipantTesting.testCopy(handles, new CopyArguments[] { + new CopyArguments(destination, log) + }); } public void testCopy_File_to_Itself() throws Exception { @@ -2015,32 +1521,24 @@ public class CopyTest extends RefactoringTest { IFile file= parentFolder.getFile(fileName); file.create(getStream("123"), true, null); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= file; - verifyValidDestination(ref, destination); + Object destination= file; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= parentFolder.getFile(MockNewNameQueries.NEW_FILE_NAME); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - file.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= parentFolder.getFile(MockNewNameQueries.NEW_FILE_NAME); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_File_to_AnotherFile() throws Exception { @@ -2052,33 +1550,24 @@ public class CopyTest extends RefactoringTest { IFile otherFile= RefactoringTestSetup.getProject().getProject().getFile("b.txt"); otherFile.create(getStream("123"), true, null); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= otherFile; - verifyValidDestination(ref, destination); + Object destination= otherFile; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - file.delete(true, false, null); - otherFile.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_File_to_Package() throws Exception { @@ -2088,33 +1577,24 @@ public class CopyTest extends RefactoringTest { file.create(getStream("123"), true, null); IPackageFragment otherPackage= getRoot().createPackageFragment("other.pack", true, new NullProgressMonitor()); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= otherPackage; - verifyValidDestination(ref, destination); + Object destination= otherPackage; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= ((IFolder)otherPackage.getResource()).getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - file.delete(true, false, null); - otherPackage.delete(true, new NullProgressMonitor()); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= ((IFolder)otherPackage.getResource()).getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_File_to_DefaultPackage() throws Exception { @@ -2126,32 +1606,24 @@ public class CopyTest extends RefactoringTest { IPackageFragment defaultPackage= getRoot().getPackageFragment(""); assertTrue(defaultPackage.exists()); assertTrue(defaultPackage.isDefaultPackage()); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= defaultPackage; - verifyValidDestination(ref, destination); + Object destination= defaultPackage; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= ((IFolder)defaultPackage.getResource()).getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - file.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= ((IFolder)defaultPackage.getResource()).getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_File_to_SourceFolder() throws Exception { @@ -2160,32 +1632,24 @@ public class CopyTest extends RefactoringTest { IFile file= parentFolder.getFile(fileName); file.create(getStream("123"), true, null); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= getRoot(); - verifyValidDestination(ref, destination); + Object destination= getRoot(); + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= ((IFolder)getRoot().getResource()).getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - file.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= ((IFolder)getRoot().getResource()).getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_File_to_JavaProject() throws Exception { @@ -2194,32 +1658,24 @@ public class CopyTest extends RefactoringTest { IFile file= parentFolder.getFile(fileName); file.create(getStream("123"), true, null); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyValidDestination(ref, destination); + Object destination= RefactoringTestSetup.getProject(); + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - file.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_File_to_Cu() throws Exception { @@ -2228,34 +1684,25 @@ public class CopyTest extends RefactoringTest { IFile file= parentFolder.getFile(fileName); file.create(getStream("123"), true, null); - IFile newFile= null; ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= cu; - verifyValidDestination(ref, destination); + Object destination= cu; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", file.exists()); + assertTrue("source file does not exist before copying", file.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", file.exists()); + assertTrue("source file does not exist after copying", file.exists()); - newFile= parentFolder.getFile(MockNewNameQueries.NEW_FILE_NAME); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - file.delete(true, false, null); - cu.delete(true, new NullProgressMonitor()); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= parentFolder.getFile(MockNewNameQueries.NEW_FILE_NAME); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_File_to_SimpleProject() throws Exception { @@ -2264,7 +1711,6 @@ public class CopyTest extends RefactoringTest { IFile file= parentFolder.getFile(fileName); file.create(getStream("123"), true, null); - IFile newFile= null; IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); simpleProject.create(null); simpleProject.open(null); @@ -2285,14 +1731,10 @@ public class CopyTest extends RefactoringTest { assertTrue("source file does not exist after copying", file.exists()); - newFile= simpleProject.getFile(fileName); + IFile newFile= simpleProject.getFile(fileName); assertTrue("new file does not exist after copying", newFile.exists()); } finally { - performDummySearch(); - file.delete(true, false, null); - simpleProject.delete(true, new NullProgressMonitor()); - if (newFile != null) - newFile.delete(true, false, null); + JavaProjectHelper.delete(simpleProject); } } @@ -2304,33 +1746,24 @@ public class CopyTest extends RefactoringTest { IFolder destinationFolder= superFolder.getFolder("folder"); destinationFolder.create(true, true, null); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= { }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= { }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= destinationFolder; - verifyValidDestination(ref, destination); + Object destination= destinationFolder; + verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); + assertTrue("source cu does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source cu does not exist after copying", cu.exists()); + assertTrue("source cu does not exist after copying", cu.exists()); - newFile= destinationFolder.getFile(fileName); - assertTrue("new cu does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - destinationFolder.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= destinationFolder.getFile(fileName); + assertTrue("new cu does not exist after copying", newFile.exists()); } public void testCopy_Bug67124() throws Exception { @@ -2342,49 +1775,36 @@ public class CopyTest extends RefactoringTest { IFolder destinationFolder= superFolder.getFolder("folder"); destinationFolder.create(true, true, null); - IFile newFile= null; - try { - FileBuffers.getTextFileBufferManager().connect(cuPath, LocationKind.IFILE, null); - ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(cuPath, LocationKind.IFILE); - buffer.getDocument().replace(0, 0, "Dirty"); + FileBuffers.getTextFileBufferManager().connect(cuPath, LocationKind.IFILE, null); + ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(cuPath, LocationKind.IFILE); + buffer.getDocument().replace(0, 0, "Dirty"); - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= { }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= { }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= destinationFolder; - verifyValidDestination(ref, destination); + Object destination= destinationFolder; + verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); + assertTrue("source cu does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source cu does not exist after copying", cu.exists()); + assertTrue("source cu does not exist after copying", cu.exists()); - newFile= destinationFolder.getFile(fileName); - assertTrue("new cu does not exist after copying", newFile.exists()); + IFile newFile= destinationFolder.getFile(fileName); + assertTrue("new cu does not exist after copying", newFile.exists()); - IPath newFilePath= newFile.getFullPath(); - try { - FileBuffers.getTextFileBufferManager().connect(newFilePath, LocationKind.IFILE, null); - ITextFileBuffer newBuffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(newFilePath, LocationKind.IFILE); - assertEquals(buffer.getDocument().get(), newBuffer.getDocument().get()); - } finally { - FileBuffers.getTextFileBufferManager().disconnect(newFilePath, LocationKind.IFILE, null); - } + IPath newFilePath= newFile.getFullPath(); + try { + FileBuffers.getTextFileBufferManager().connect(newFilePath, LocationKind.IFILE, null); + ITextFileBuffer newBuffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(newFilePath, LocationKind.IFILE); + assertEquals(buffer.getDocument().get(), newBuffer.getDocument().get()); } finally { - performDummySearch(); - FileBuffers.getTextFileBufferManager().disconnect(cuPath, LocationKind.IFILE, null); - - cu.delete(true, new NullProgressMonitor()); - destinationFolder.delete(true, false, null); - if (newFile != null) - newFile.delete(true, false, null); - } } @@ -2393,44 +1813,35 @@ public class CopyTest extends RefactoringTest { String fileName= "A.java"; ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - ICompilationUnit newCu= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= { }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(cu); - String[] handles= ParticipantTesting.createHandles(cu, mapping); + IJavaElement[] javaElements= {cu}; + IResource[] resources= { }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(cu); + String[] handles= ParticipantTesting.createHandles(cu, mapping); - IPackageFragment destination= getPackageP(); - verifyValidDestination(ref, destination); + IPackageFragment destination= getPackageP(); + verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); + assertTrue("source cu does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source cu does not exist after copying", cu.exists()); + assertTrue("source cu does not exist after copying", cu.exists()); - String newName= MockNewNameQueries.NEW_CU_NAME + ".java"; - newCu= getPackageP().getCompilationUnit(newName); - assertTrue("new cu does not exist after copying", newCu.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.setNewName(cu, newName); - log.setNewName(mapping, newName); - log.markAsProcessed(cu); - log.markAsProcessed(mapping); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + String newName= MockNewNameQueries.NEW_CU_NAME + ".java"; + ICompilationUnit newCu= getPackageP().getCompilationUnit(newName); + assertTrue("new cu does not exist after copying", newCu.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.setNewName(cu, newName); + log.setNewName(mapping, newName); + log.markAsProcessed(cu); + log.markAsProcessed(mapping); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - if (newCu != null && newCu.exists()){ - newCu.delete(true, new NullProgressMonitor()); - } - } + }); } public void testCopy_Cu_to_Same_Package_Cancel() throws Exception { @@ -2438,102 +1849,76 @@ public class CopyTest extends RefactoringTest { String fileName= "A.java"; ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try { - INewNameQueries queries= new MockCancelNameQueries(); + INewNameQueries queries= new MockCancelNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= { }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(cu); - String[] handles= ParticipantTesting.createHandles(cu, mapping); + IJavaElement[] javaElements= {cu}; + IResource[] resources= { }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(cu); + String[] handles= ParticipantTesting.createHandles(cu, mapping); - IPackageFragment destination= getPackageP(); - verifyValidDestination(ref, destination); + IPackageFragment destination= getPackageP(); + verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); + assertTrue("source cu does not exist before copying", cu.exists()); - try { - performRefactoring(ref, false); - } catch (OperationCanceledException e) { - } - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsCanceled(); - ParticipantTesting.testCopy(handles, new CopyArguments[] { - new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); + try { + performRefactoring(ref, false); + } catch (OperationCanceledException e) { } + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsCanceled(); + ParticipantTesting.testCopy(handles, new CopyArguments[] { + new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) + }); } public void test_type_yes_type() throws Exception{ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C"); - ICompilationUnit newCu= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= { }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= { }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= otherCu; - verifyValidDestination(ref, destination); + Object destination= otherCu; + verifyValidDestination(ref, destination); - assertTrue("source cu does not exist before copying", cu.exists()); + assertTrue("source cu does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source cu does not exist after copying", cu.exists()); + assertTrue("source cu does not exist after copying", cu.exists()); - newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); - assertTrue("new cu does not exist after copying", newCu.exists()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - if (newCu != null && newCu.exists()){ - newCu.delete(true, new NullProgressMonitor()); - } - if (otherCu != null && otherCu.exists()){ - otherCu.delete(true, new NullProgressMonitor()); - } - } + ICompilationUnit newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); + assertTrue("new cu does not exist after copying", newCu.exists()); } public void testCopy_Cu_to_Itself() throws Exception { String fileName= "A.java"; ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - ICompilationUnit newCu= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= { }; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= { }; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= cu; - verifyValidDestination(ref, destination); + Object destination= cu; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", cu.exists()); + assertTrue("source file does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", cu.exists()); + assertTrue("source file does not exist after copying", cu.exists()); - newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); - assertTrue("new file does not exist after copying", newCu.exists()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - if (newCu != null && newCu.exists()){ - newCu.delete(true, new NullProgressMonitor()); - } - } + ICompilationUnit newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); + assertTrue("new file does not exist after copying", newCu.exists()); } public void testCopy_Cu_to_OtherPackage() throws Exception { @@ -2542,38 +1927,32 @@ public class CopyTest extends RefactoringTest { ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); IPackageFragment otherPackage= getRoot().createPackageFragment("other.pack", true, new NullProgressMonitor()); - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(cu); - String[] handles= ParticipantTesting.createHandles(cu, mapping); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(cu); + String[] handles= ParticipantTesting.createHandles(cu, mapping); - IPackageFragment destination= otherPackage; - verifyValidDestination(ref, destination); + IPackageFragment destination= otherPackage; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", cu.exists()); + assertTrue("source file does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", cu.exists()); + assertTrue("source file does not exist after copying", cu.exists()); - ICompilationUnit newCu= otherPackage.getCompilationUnit(fileName); - assertTrue("new file does not exist after copying", newCu.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsProcessed(cu); - log.markAsProcessed(mapping); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + ICompilationUnit newCu= otherPackage.getCompilationUnit(fileName); + assertTrue("new file does not exist after copying", newCu.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsProcessed(cu); + log.markAsProcessed(mapping); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - otherPackage.delete(true, new NullProgressMonitor()); - } + }); } public void testCopy_Cu_to_DefaultPackage() throws Exception { @@ -2584,99 +1963,80 @@ public class CopyTest extends RefactoringTest { IPackageFragment defaultPackage= getRoot().getPackageFragment(""); assertTrue(defaultPackage.exists()); assertTrue(defaultPackage.isDefaultPackage()); - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(cu); - String[] handles= ParticipantTesting.createHandles(cu, mapping); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(cu); + String[] handles= ParticipantTesting.createHandles(cu, mapping); - IPackageFragment destination= defaultPackage; - verifyValidDestination(ref, destination); + IPackageFragment destination= defaultPackage; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", cu.exists()); + assertTrue("source file does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", cu.exists()); + assertTrue("source file does not exist after copying", cu.exists()); - ICompilationUnit newCu= defaultPackage.getCompilationUnit(fileName); - assertTrue("new file does not exist after copying", newCu.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsProcessed(cu); - log.markAsProcessed(mapping); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + ICompilationUnit newCu= defaultPackage.getCompilationUnit(fileName); + assertTrue("new file does not exist after copying", newCu.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsProcessed(cu); + log.markAsProcessed(mapping); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + }); } public void testCopy_Cu_to_SourceFolder() throws Exception { String fileName= "A.java"; ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - ICompilationUnit newCu= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= getRoot(); - verifyValidDestination(ref, destination); + Object destination= getRoot(); + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", cu.exists()); + assertTrue("source file does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", cu.exists()); + assertTrue("source file does not exist after copying", cu.exists()); - newCu= getRoot().getPackageFragment("").getCompilationUnit(fileName); - assertTrue("new file does not exist after copying", newCu.exists()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + ICompilationUnit newCu= getRoot().getPackageFragment("").getCompilationUnit(fileName); + assertTrue("new file does not exist after copying", newCu.exists()); } public void testCopy_Cu_to_JavaProject() throws Exception { String fileName= "A.java"; ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyValidDestination(ref, destination); + Object destination= RefactoringTestSetup.getProject(); + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", cu.exists()); + assertTrue("source file does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", cu.exists()); + assertTrue("source file does not exist after copying", cu.exists()); - newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - if (newFile != null) - newFile.delete(true, false, null); - } + IFile newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_Cu_to_File_In_Package() throws Exception { @@ -2688,37 +2048,27 @@ public class CopyTest extends RefactoringTest { file.create(getStream("123"), true, null); assertTrue(file.exists()); - ICompilationUnit newCu= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= file; - verifyValidDestination(ref, destination); + Object destination= file; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", cu.exists()); + assertTrue("source file does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", cu.exists()); + assertTrue("source file does not exist after copying", cu.exists()); - newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); - assertTrue("new file does not exist after copying", newCu.exists()); + ICompilationUnit newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); + assertTrue("new file does not exist after copying", newCu.exists()); - String expectedSource= "package p;class "+ MockNewNameQueries.NEW_CU_NAME +"{void foo(){}class Inner{}}"; - assertEqualLines("source compare failed", expectedSource, newCu.getSource()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - file.delete(true, false, null); - if (newCu != null && newCu.exists()){ - newCu.delete(true, new NullProgressMonitor()); - } - } + String expectedSource= "package p;class "+ MockNewNameQueries.NEW_CU_NAME +"{void foo(){}class Inner{}}"; + assertEqualLines("source compare failed", expectedSource, newCu.getSource()); } public void testCopy_Cu_to_File_In_Resource_Folder() throws Exception { @@ -2729,32 +2079,24 @@ public class CopyTest extends RefactoringTest { IFile file= parentFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - IFile newFile= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= file; - verifyValidDestination(ref, destination); + Object destination= file; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before copying", cu.exists()); + assertTrue("source file does not exist before copying", cu.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source file does not exist after copying", cu.exists()); + assertTrue("source file does not exist after copying", cu.exists()); - newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); - assertTrue("new file does not exist after copying", newFile.exists()); - } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - file.delete(true, false, null); - newFile.delete(true, false, null); - } + IFile newFile= RefactoringTestSetup.getProject().getProject().getFile(fileName); + assertTrue("new file does not exist after copying", newFile.exists()); } public void testCopy_Cu_to_SimpleProject() throws Exception { @@ -2765,7 +2107,6 @@ public class CopyTest extends RefactoringTest { simpleProject.create(null); simpleProject.open(null); - IFile newFile= null; try { INewNameQueries queries= new MockNewNameQueries(); @@ -2783,155 +2124,127 @@ public class CopyTest extends RefactoringTest { assertTrue("source file does not exist after copying", cu.exists()); - newFile= simpleProject.getFile(fileName); + IFile newFile= simpleProject.getFile(fileName); assertTrue("new file does not exist after copying", newFile.exists()); } finally { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - simpleProject.delete(true, false, null); - newFile.delete(true, false, null); + JavaProjectHelper.delete(simpleProject); } } public void testCopy_Package_to_Its_Root() throws Exception { ParticipantTesting.reset(); - IPackageFragment newPackage= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(getPackageP()); - String[] handles= ParticipantTesting.createHandles(getPackageP(), mapping); + IJavaElement[] javaElements= {getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(getPackageP()); + String[] handles= ParticipantTesting.createHandles(getPackageP(), mapping); - IPackageFragmentRoot destination= getRoot(); - verifyValidDestination(ref, destination); + IPackageFragmentRoot destination= getRoot(); + verifyValidDestination(ref, destination); - assertTrue("source package does not exist before copying", getPackageP().exists()); + assertTrue("source package does not exist before copying", getPackageP().exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source package does not exist after copying", getPackageP().exists()); + assertTrue("source package does not exist after copying", getPackageP().exists()); - newPackage= getRoot().getPackageFragment(MockNewNameQueries.NEW_PACKAGE_NAME); - assertTrue("new package does not exist after copying", newPackage.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.setNewName(getPackageP(), MockNewNameQueries.NEW_PACKAGE_NAME); - log.setNewName(mapping, MockNewNameQueries.NEW_PACKAGE_NAME); - log.markAsProcessed(getPackageP()); - log.markAsProcessed(mapping); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + IPackageFragment newPackage= getRoot().getPackageFragment(MockNewNameQueries.NEW_PACKAGE_NAME); + assertTrue("new package does not exist after copying", newPackage.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.setNewName(getPackageP(), MockNewNameQueries.NEW_PACKAGE_NAME); + log.setNewName(mapping, MockNewNameQueries.NEW_PACKAGE_NAME); + log.markAsProcessed(getPackageP()); + log.markAsProcessed(mapping); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - if (newPackage != null) - newPackage.delete(true, new NullProgressMonitor()); - } + }); } public void testCopy_Package_to_Its_Root_Cancel() throws Exception { ParticipantTesting.reset(); - try { - INewNameQueries queries= new MockCancelNameQueries(); + INewNameQueries queries= new MockCancelNameQueries(); - IJavaElement[] javaElements= {getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(getPackageP()); - String[] handles= ParticipantTesting.createHandles(getPackageP(), mapping); + IJavaElement[] javaElements= {getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(getPackageP()); + String[] handles= ParticipantTesting.createHandles(getPackageP(), mapping); - IPackageFragmentRoot destination= getRoot(); - verifyValidDestination(ref, destination); + IPackageFragmentRoot destination= getRoot(); + verifyValidDestination(ref, destination); - assertTrue("source package does not exist before copying", getPackageP().exists()); + assertTrue("source package does not exist before copying", getPackageP().exists()); - try { - performRefactoring(ref, false); - } catch(OperationCanceledException e) { - } - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsCanceled(); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + try { + performRefactoring(ref, false); + } catch(OperationCanceledException e) { + } + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsCanceled(); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - } + }); } public void testCopy_Package_to_Itself() throws Exception { ParticipantTesting.reset(); - IPackageFragment newPackage= null; - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(getPackageP()); - String[] handles= ParticipantTesting.createHandles(getPackageP(), mapping); + IJavaElement[] javaElements= {getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(getPackageP()); + String[] handles= ParticipantTesting.createHandles(getPackageP(), mapping); - IPackageFragment destination= getPackageP(); - verifyValidDestination(ref, destination); + IPackageFragment destination= getPackageP(); + verifyValidDestination(ref, destination); - assertTrue("source package does not exist before copying", getPackageP().exists()); + assertTrue("source package does not exist before copying", getPackageP().exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source package does not exist after copying", getPackageP().exists()); + assertTrue("source package does not exist after copying", getPackageP().exists()); - newPackage= getRoot().getPackageFragment(MockNewNameQueries.NEW_PACKAGE_NAME); - assertTrue("new package does not exist after copying", newPackage.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsProcessed(getPackageP()); - log.markAsProcessed(mapping); - log.setNewName(getPackageP(), MockNewNameQueries.NEW_PACKAGE_NAME); - log.setNewName(mapping, MockNewNameQueries.NEW_PACKAGE_FOLDER_NAME); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + IPackageFragment newPackage= getRoot().getPackageFragment(MockNewNameQueries.NEW_PACKAGE_NAME); + assertTrue("new package does not exist after copying", newPackage.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsProcessed(getPackageP()); + log.markAsProcessed(mapping); + log.setNewName(getPackageP(), MockNewNameQueries.NEW_PACKAGE_NAME); + log.setNewName(mapping, MockNewNameQueries.NEW_PACKAGE_FOLDER_NAME); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination.getParent(), log), new CopyArguments(destination.getParent().getResource(), log) - }); - } finally { - performDummySearch(); - if (newPackage != null && newPackage.exists()) - newPackage.delete(true, new NullProgressMonitor()); - } + }); } public void testCopy_Package_to_Another_Root() throws Exception { IPackageFragmentRoot otherRoot= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "otherRoot"); - IPackageFragment newPackage= null; String packageName= getPackageP().getElementName(); - try { - INewNameQueries queries= new MockNewNameQueries(); + INewNameQueries queries= new MockNewNameQueries(); - IJavaElement[] javaElements= {getPackageP()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); + IJavaElement[] javaElements= {getPackageP()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); - Object destination= otherRoot; - verifyValidDestination(ref, destination); + Object destination= otherRoot; + verifyValidDestination(ref, destination); - assertTrue("source package does not exist before copying", getPackageP().exists()); + assertTrue("source package does not exist before copying", getPackageP().exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source package does not exist after copying", getPackageP().exists()); + assertTrue("source package does not exist after copying", getPackageP().exists()); - newPackage= otherRoot.getPackageFragment(packageName); - assertTrue("new package does not exist after copying", newPackage.exists()); - } finally { - performDummySearch(); - newPackage.delete(true, new NullProgressMonitor()); - otherRoot.delete(0, 0, new NullProgressMonitor()); - } + IPackageFragment newPackage= otherRoot.getPackageFragment(packageName); + assertTrue("new package does not exist after copying", newPackage.exists()); } public void testCopy_Package_to_JavaProject_That_Is_Root() throws Exception { @@ -2964,7 +2277,6 @@ public class CopyTest extends RefactoringTest { } assertNotNull(newPackage); } finally { - performDummySearch(); JavaProjectHelper.delete(otherProject); } } @@ -2979,33 +2291,27 @@ public class CopyTest extends RefactoringTest { IFolder otherFolder= superFolder.getFolder("otherfolder"); otherFolder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - String[] handles= ParticipantTesting.createHandles(folder); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); + String[] handles= ParticipantTesting.createHandles(folder); - Object destination= otherFolder; - verifyValidDestination(ref, destination); + Object destination= otherFolder; + verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); + assertTrue("source does not exist before copying", folder.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source does not exist after copying", folder.exists()); - assertTrue("copied folder does not exist after copying", otherFolder.getFolder(folderName).exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsProcessed(folder); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + assertTrue("source does not exist after copying", folder.exists()); + assertTrue("copied folder does not exist after copying", otherFolder.getFolder(folderName).exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsProcessed(folder); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log) - }); + }); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - otherFolder.delete(true, new NullProgressMonitor()); - } } public void testCopy_folder_to_same_container() throws Exception { @@ -3014,37 +2320,29 @@ public class CopyTest extends RefactoringTest { String folderName= "folder"; IFolder folder= superFolder.getFolder(folderName); folder.create(true, true, null); - IFolder newFolder= null; - - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - String[] handles= ParticipantTesting.createHandles(folder); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); + String[] handles= ParticipantTesting.createHandles(folder); - Object destination= superFolder; - verifyValidDestination(ref, destination); + Object destination= superFolder; + verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); + assertTrue("source does not exist before copying", folder.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source does not exist after copying", folder.exists()); - newFolder= superFolder.getFolder(MockNewNameQueries.NEW_FOLDER_NAME); - assertTrue("copied folder does not exist after copying", newFolder.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsProcessed(folder); - log.setNewName(folder, MockNewNameQueries.NEW_FOLDER_NAME); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + assertTrue("source does not exist after copying", folder.exists()); + IFolder newFolder= superFolder.getFolder(MockNewNameQueries.NEW_FOLDER_NAME); + assertTrue("copied folder does not exist after copying", newFolder.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsProcessed(folder); + log.setNewName(folder, MockNewNameQueries.NEW_FOLDER_NAME); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log) - }); + }); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - newFolder.delete(true, new NullProgressMonitor()); - } } public void testCopy_folder_to_same_container_cancel() throws Exception { @@ -3054,31 +2352,26 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder(folderName); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockCancelNameQueries(), createReorgQueries()); - String[] handles= ParticipantTesting.createHandles(folder); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockCancelNameQueries(), createReorgQueries()); + String[] handles= ParticipantTesting.createHandles(folder); - Object destination= superFolder; - verifyValidDestination(ref, destination); + Object destination= superFolder; + verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); + assertTrue("source does not exist before copying", folder.exists()); - try { - performRefactoring(ref, false); - } catch (OperationCanceledException e) { - } - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsCanceled(); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + try { + performRefactoring(ref, false); + } catch (OperationCanceledException e) { + } + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsCanceled(); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log) - }); + }); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } } public void testCopy_folder_Java_project() throws Exception { @@ -3087,25 +2380,20 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder(folderName); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyValidDestination(ref, destination); + Object destination= RefactoringTestSetup.getProject(); + verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + assertTrue("source does not exist before copying", folder.exists()); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source does not exist after copying", folder.exists()); + assertTrue("source does not exist after copying", folder.exists()); - assertTrue("copied folder does not exist after copying", RefactoringTestSetup.getProject().getProject().getFolder(folderName).exists()); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } + assertTrue("copied folder does not exist after copying", RefactoringTestSetup.getProject().getProject().getFolder(folderName).exists()); } public void testCopy_folder_to_source_folder() throws Exception { @@ -3114,25 +2402,20 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder(folderName); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - Object destination= getRoot(); - verifyValidDestination(ref, destination); + Object destination= getRoot(); + verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + assertTrue("source does not exist before copying", folder.exists()); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source does not exist after copying", folder.exists()); + assertTrue("source does not exist after copying", folder.exists()); - assertTrue("copied folder does not exist after copying", ((IFolder)getRoot().getResource()).getFolder(folderName).exists()); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } + assertTrue("copied folder does not exist after copying", ((IFolder)getRoot().getResource()).getFolder(folderName).exists()); } public void testCopy_folder_to_package() throws Exception { @@ -3141,54 +2424,18 @@ public class CopyTest extends RefactoringTest { IFolder folder= superFolder.getFolder(folderName); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - - IPackageFragment destination= getPackageP(); - verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); - - assertTrue("source does not exist after copying", folder.exists()); - assertTrue("copied folder does not exist after copying", ((IFolder)destination.getResource()).getFolder(folderName).exists()); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - } - - } - public void testCopy_folder_to_file_in_another_folder() throws Exception { - IProject superFolder= RefactoringTestSetup.getProject().getProject(); - String folderName= "folder"; - IFolder folder= superFolder.getFolder(folderName); - folder.create(true, true, null); - - IFolder otherFolder= superFolder.getFolder("otherfolder"); - otherFolder.create(true, true, null); - IFile fileInAnotherFolder= otherFolder.getFile("f.tex"); - fileInAnotherFolder.create(getStream("123"), true, null); - - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - Object destination= fileInAnotherFolder; - verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + IPackageFragment destination= getPackageP(); + verifyValidDestination(ref, destination); + assertTrue("source does not exist before copying", folder.exists()); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source does not exist after copying", folder.exists()); - assertTrue("copied folder does not exist after copying", otherFolder.getFolder(folderName).exists()); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - otherFolder.delete(true, new NullProgressMonitor()); - } + assertTrue("source does not exist after copying", folder.exists()); + assertTrue("copied folder does not exist after copying", ((IFolder)destination.getResource()).getFolder(folderName).exists()); } public void testCopy_folder_to_cu() throws Exception { @@ -3198,24 +2445,18 @@ public class CopyTest extends RefactoringTest { folder.create(true, true, null); ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - ICompilationUnit destination= cu; - verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", folder.exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + ICompilationUnit destination= cu; + verifyValidDestination(ref, destination); + assertTrue("source does not exist before copying", folder.exists()); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); - assertTrue("source does not exist after copying", folder.exists()); - assertTrue("copied folder does not exist after copying", ((IFolder)getPackageP().getResource()).getFolder(folderName).exists()); - } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - cu.delete(true, new NullProgressMonitor()); - } + assertTrue("source does not exist after copying", folder.exists()); + assertTrue("copied folder does not exist after copying", ((IFolder)getPackageP().getResource()).getFolder(folderName).exists()); } public void testCopy_folder_to_simple_project() throws Exception { @@ -3227,7 +2468,7 @@ public class CopyTest extends RefactoringTest { IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); simpleProject.create(null); simpleProject.open(null); - try{ + try { IJavaElement[] javaElements= {}; IResource[] resources= {folder}; JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); @@ -3241,78 +2482,65 @@ public class CopyTest extends RefactoringTest { assertTrue("source does not exist after copying", folder.exists()); assertTrue("copied folder does not exist after copying", simpleProject.getFolder(folderName).exists()); } finally{ - performDummySearch(); - folder.delete(true, new NullProgressMonitor()); - simpleProject.delete(true, true, new NullProgressMonitor()); + JavaProjectHelper.delete(simpleProject); } } public void testCopy_root_to_same_Java_project() throws Exception { ParticipantTesting.reset(); - IPackageFragmentRoot newRoot= null; - try { - // Delete the unnamed folder so that the delta is a ADD not a CHANGED - IResource folder= RefactoringTestSetup.getProject().getProject().findMember(MockNewNameQueries.NEW_PACKAGE_FRAGMENT_ROOT_NAME); - if (folder != null) { - folder.delete(IResource.FORCE, null); - } - - IJavaElement[] javaElements= { getRoot() }; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(getRoot()); - String[] handles= ParticipantTesting.createHandles(getRoot(), mapping); + // Delete the unnamed folder so that the delta is a ADD not a CHANGED + IResource folder= RefactoringTestSetup.getProject().getProject().findMember(MockNewNameQueries.NEW_PACKAGE_FRAGMENT_ROOT_NAME); + if (folder != null) { + folder.delete(IResource.FORCE, null); + } - IJavaProject destination= getRoot().getJavaProject(); - verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", getRoot().exists()); - RefactoringStatus status= performRefactoring(ref, false); - assertEquals(null, status); + IJavaElement[] javaElements= { getRoot() }; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockNewNameQueries(), createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(getRoot()); + String[] handles= ParticipantTesting.createHandles(getRoot(), mapping); - assertTrue("source does not exist after copying", getRoot().exists()); - String newName= MockNewNameQueries.NEW_PACKAGE_FRAGMENT_ROOT_NAME; - newRoot= getSourceFolder(RefactoringTestSetup.getProject(), newName); - assertNotNull("copied folder does not exist after copying", newRoot); - assertTrue("copied folder does not exist after copying", newRoot.exists()); - ReorgExecutionLog log= new ReorgExecutionLog(); - log.setNewName(getRoot(), newName); - log.setNewName(mapping, newName); - log.markAsProcessed(getRoot()); - log.markAsProcessed(mapping); - ParticipantTesting.testCopy(handles, new CopyArguments[] { + IJavaProject destination= getRoot().getJavaProject(); + verifyValidDestination(ref, destination); + assertTrue("source does not exist before copying", getRoot().exists()); + RefactoringStatus status= performRefactoring(ref, false); + assertEquals(null, status); + + assertTrue("source does not exist after copying", getRoot().exists()); + String newName= MockNewNameQueries.NEW_PACKAGE_FRAGMENT_ROOT_NAME; + IPackageFragmentRoot newRoot= getSourceFolder(RefactoringTestSetup.getProject(), newName); + assertNotNull("copied folder does not exist after copying", newRoot); + assertTrue("copied folder does not exist after copying", newRoot.exists()); + ReorgExecutionLog log= new ReorgExecutionLog(); + log.setNewName(getRoot(), newName); + log.setNewName(mapping, newName); + log.markAsProcessed(getRoot()); + log.markAsProcessed(mapping); + ParticipantTesting.testCopy(handles, new CopyArguments[] { new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); - if (newRoot != null && newRoot.exists()) - newRoot.delete(0, 0, new NullProgressMonitor()); - } + }); } public void testCopy_root_to_same_Java_project_cancel() throws Exception { ParticipantTesting.reset(); - try { - IJavaElement[] javaElements= { getRoot()}; - IResource[] resources= {}; - JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockCancelNameQueries(), createReorgQueries()); - ResourceMapping mapping= JavaElementResourceMapping.create(getRoot()); - String[] handles= ParticipantTesting.createHandles(getRoot(), mapping); + IJavaElement[] javaElements= { getRoot()}; + IResource[] resources= {}; + JavaCopyProcessor ref= verifyEnabled(resources, javaElements, new MockCancelNameQueries(), createReorgQueries()); + ResourceMapping mapping= JavaElementResourceMapping.create(getRoot()); + String[] handles= ParticipantTesting.createHandles(getRoot(), mapping); - IJavaProject destination= getRoot().getJavaProject(); - verifyValidDestination(ref, destination); - assertTrue("source does not exist before copying", getRoot().exists()); - try { - performRefactoring(ref, false); - } catch (OperationCanceledException e) { - } - ReorgExecutionLog log= new ReorgExecutionLog(); - log.markAsCanceled(); - ParticipantTesting.testCopy(handles, new CopyArguments[] { - new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) - }); - } finally { - performDummySearch(); + IJavaProject destination= getRoot().getJavaProject(); + verifyValidDestination(ref, destination); + assertTrue("source does not exist before copying", getRoot().exists()); + try { + performRefactoring(ref, false); + } catch (OperationCanceledException e) { } + ReorgExecutionLog log= new ReorgExecutionLog(); + log.markAsCanceled(); + ParticipantTesting.testCopy(handles, new CopyArguments[] { + new CopyArguments(destination, log), new CopyArguments(destination.getResource(), log) + }); } public void testCopy_root_to_other_Java_project() throws Exception { @@ -3340,10 +2568,9 @@ public class CopyTest extends RefactoringTest { log.markAsProcessed(getRoot()); log.markAsProcessed(mapping); ParticipantTesting.testCopy(handles, new CopyArguments[] { - new CopyArguments(destination, log), new CopyArguments(destination.getProject(), log) + new CopyArguments(destination, log), new CopyArguments(destination.getProject(), log) }); } finally { - performDummySearch(); JavaProjectHelper.delete(otherJavaProject); } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java index 74fd16c436..8e6b50f0ef 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,9 +36,7 @@ import org.eclipse.ui.part.ResourceTransfer; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.ISourceManipulation; import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.corext.refactoring.TypedSource; import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaElementTransfer; @@ -127,12 +125,6 @@ public class CopyToClipboardActionTest extends RefactoringTest{ performDummySearch(); fClipboard.dispose(); fLabelProvider.dispose(); - delete(fCuA); - delete(fCuB); - delete(fPackageQ_R); - delete(fPackageQ); - delete(faTxt); - delete(fOlder); } private IFile createFile(IFolder folder, String fileName) throws Exception { @@ -147,30 +139,6 @@ public class CopyToClipboardActionTest extends RefactoringTest{ return folder; } - private static void delete(ISourceManipulation element) { - try { - if (element != null && ((IJavaElement)element).exists()) - element.delete(true, null); - } catch(JavaModelException e) { - //ignore, we must keep going - } - } - private static void delete(IFile element) { - try { - element.delete(true, false, null); - } catch(CoreException e) { - //ignore, we must keep going - } - } - - private static void delete(IFolder element) { - try { - element.delete(true, false, null); - } catch(CoreException e) { - //ignore, we must keep going - } - } - private void checkDisabled(Object[] elements){ CopyToClipboardAction copyAction= new CopyToClipboardAction(new MockWorkbenchSite(elements), fClipboard); copyAction.setAutoRepeatOnFailure(true); @@ -307,6 +275,9 @@ public class CopyToClipboardActionTest extends RefactoringTest{ case IJavaElement.COMPILATION_UNIT : case IJavaElement.CLASS_FILE : count++; + break; + default: + break; } } return count; diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java index d04bbd6760..8cc1d72ea6 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,7 +62,7 @@ import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest; import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup; -public class DeleteTest extends RefactoringTest{ +public class DeleteTest extends RefactoringTest { private static final boolean BUG_55221= true; private static final Class clazz= DeleteTest.class; @@ -138,26 +138,15 @@ public class DeleteTest extends RefactoringTest{ } private void checkDelete(IJavaElement[] elems, boolean deleteCu) throws JavaModelException, Exception { - ICompilationUnit newCuA= null; - try { - DeleteRefactoring refactoring= createRefactoring(elems); - assertNotNull(refactoring); - RefactoringStatus status= performRefactoring(refactoring, true); - assertEquals("precondition was supposed to pass", null, status); - - newCuA= getPackageP().getCompilationUnit(CU_NAME + ".java"); - assertTrue("A.java does not exist", newCuA.exists() == !deleteCu); - if (! deleteCu) - assertEqualLines("incorrect content of A.java", getFileContents(getOutputTestFileName(CU_NAME)), newCuA.getSource()); - } finally { - performDummySearch(); - if (newCuA != null && newCuA.exists()) - newCuA.delete(true, null); - if (fCuA != null && fCuA.exists()){ - fCuA.delete(true, null); - fCuA= null; - } - } + DeleteRefactoring refactoring= createRefactoring(elems); + assertNotNull(refactoring); + RefactoringStatus status= performRefactoring(refactoring, true); + assertEquals("precondition was supposed to pass", null, status); + + ICompilationUnit newCuA= getPackageP().getCompilationUnit(CU_NAME + ".java"); + assertTrue("A.java does not exist", newCuA.exists() == !deleteCu); + if (! deleteCu) + assertEqualLines("incorrect content of A.java", getFileContents(getOutputTestFileName(CU_NAME)), newCuA.getSource()); } private DeleteRefactoring createRefactoring(Object[] elements) { @@ -198,8 +187,8 @@ public class DeleteTest extends RefactoringTest{ * @param packsToBeDeleted First half of elements which must be deleted after the refactoring * @param othersToBeDeleted Second half (halfs will be merged). * @param deleteSubs true if subpackages should be deleted as well. - * @throws CoreException - * @throws Exception + * @throws CoreException xxx + * @throws Exception xxx */ private void executeDeletePackage(Object[] markedForDelete, IPackageFragment[] packsToBeDeleted, Object[] othersToBeDeleted, boolean deleteSubs) throws CoreException, Exception { @@ -336,15 +325,10 @@ public class DeleteTest extends RefactoringTest{ public void testEnabled_defaultPackage() throws Exception{ IPackageFragment defaultPackage= getRoot().getPackageFragment(""); - ICompilationUnit cu= defaultPackage.createCompilationUnit("A.java", "", false, new NullProgressMonitor()); - - try{ - Object[] elements= {defaultPackage}; - verifyEnabled(elements); - } finally{ - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + defaultPackage.createCompilationUnit("A.java", "", false, new NullProgressMonitor()); + + Object[] elements= {defaultPackage}; + verifyEnabled(elements); } public void testDisabled_simpleProject() throws Exception{ @@ -355,45 +339,30 @@ public class DeleteTest extends RefactoringTest{ public void testEnabled_cu() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "", false, new NullProgressMonitor()); - try{ - Object[] elements= {cu}; - verifyEnabled(elements); - } finally{ - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + Object[] elements= {cu}; + verifyEnabled(elements); } public void testEnabled_sourceReferences1() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "", false, new NullProgressMonitor()); - try{ - IJavaElement importD= cu.createImport("java.lang.*", null, new NullProgressMonitor()); - IJavaElement packageD= cu.createPackageDeclaration("p", new NullProgressMonitor()); - IJavaElement type= cu.createType("class A{}", null, false, new NullProgressMonitor()); - - Object[] elements= {packageD, importD, type}; - verifyEnabled(elements); - } finally{ - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IJavaElement importD= cu.createImport("java.lang.*", null, new NullProgressMonitor()); + IJavaElement packageD= cu.createPackageDeclaration("p", new NullProgressMonitor()); + IJavaElement type= cu.createType("class A{}", null, false, new NullProgressMonitor()); + + Object[] elements= {packageD, importD, type}; + verifyEnabled(elements); } public void testEnabled_sourceReferences2() throws Exception{ ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "", false, new NullProgressMonitor()); - try{ - IType type= cu.createType("class A{}", null, false, new NullProgressMonitor()); - IJavaElement field= type.createField("int i;", null, false, new NullProgressMonitor()); - IJavaElement method= type.createMethod("void f(){}", null, false, new NullProgressMonitor()); - IJavaElement initializer= type.createInitializer("{ int k= 0;}", null, new NullProgressMonitor()); - IJavaElement innerType= type.createType("class Inner{}", null, false, new NullProgressMonitor()); - - Object[] elements= {field, method, initializer, innerType}; - verifyEnabled(elements); - } finally{ - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } + IType type= cu.createType("class A{}", null, false, new NullProgressMonitor()); + IJavaElement field= type.createField("int i;", null, false, new NullProgressMonitor()); + IJavaElement method= type.createMethod("void f(){}", null, false, new NullProgressMonitor()); + IJavaElement initializer= type.createInitializer("{ int k= 0;}", null, new NullProgressMonitor()); + IJavaElement innerType= type.createType("class Inner{}", null, false, new NullProgressMonitor()); + + Object[] elements= {field, method, initializer, innerType}; + verifyEnabled(elements); } @@ -401,13 +370,8 @@ public class DeleteTest extends RefactoringTest{ IFolder folder= (IFolder)getPackageP().getResource(); IFile file= folder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - Object[] elements= {file}; - verifyEnabled(elements); - } finally{ - performDummySearch(); - file.delete(true, false, null); - } + Object[] elements= {file}; + verifyEnabled(elements); } public void testEnabled_folder() throws Exception{ @@ -1152,7 +1116,7 @@ public class DeleteTest extends RefactoringTest{ Object[] deleted= new Object[]{a}; Object[] exist= new Object[]{defaultP, file}; doTestUndoRedo(deleted, exist); - + JavaProjectHelper.delete(newJavaProject); } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java index 35685698e8..cc190a6ec2 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,7 +18,6 @@ import junit.framework.TestSuite; import org.eclipse.jdt.testplugin.JavaProjectHelper; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; @@ -51,11 +50,11 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester; import org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery; import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgDestination; +import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy; import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgQueries; import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor; import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgDestinationFactory; import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory; -import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy; import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting; import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest; @@ -191,7 +190,7 @@ public class MoveTest extends RefactoringTest { int severity= status.getSeverity(); if (severity == RefactoringStatus.INFO) // see ReorgPolicyFactory.MoveFilesFoldersAndCusPolicy.verifyDestination(..) return; - + assertEquals("destination was expected to be valid: " + status.getMessageMatchingSeverity(severity), RefactoringStatus.OK, severity); } @@ -201,20 +200,6 @@ public class MoveTest extends RefactoringTest { assertEquals("destination was expected to be not valid", RefactoringStatus.FATAL, status.getSeverity()); } - private void safeDelete(ICompilationUnit cu) throws JavaModelException { - if (cu != null && cu.exists()) - cu.delete(true, new NullProgressMonitor()); - } - private void safeDelete(IPackageFragment pack) throws JavaModelException { - if (pack != null && pack.exists()) - pack.delete(true, new NullProgressMonitor()); - } - private void safeDelete(IResource res) throws CoreException { - if (res != null && res.exists()) - res.delete(true, null); - } - - public void testDisabled_empty() throws Exception { IJavaElement[] javaElements= {}; IResource[] resources= {}; @@ -278,93 +263,58 @@ public class MoveTest extends RefactoringTest { public void testDisabled_noCommonParent1() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IType classA= cu.getType("A"); - IMethod methodFoo= classA.getMethod("foo", new String[0]); - IJavaElement[] javaElements= { classA, methodFoo }; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - safeDelete(cu); - } + IType classA= cu.getType("A"); + IMethod methodFoo= classA.getMethod("foo", new String[0]); + IJavaElement[] javaElements= { classA, methodFoo }; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } // public void testDisabled_noCommonParent2() throws Exception { // ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); -// try { -// IType classA= cu.getType("A"); -// IJavaElement[] javaElements= { classA, cu}; -// IResource[] resources= {}; -// verifyDisabled(resources, javaElements); -// } finally { -// performDummySearch(); -// cu.delete(true, new NullProgressMonitor()); -// } +// IType classA= cu.getType("A"); +// IJavaElement[] javaElements= { classA, cu}; +// IResource[] resources= {}; +// verifyDisabled(resources, javaElements); // } public void testDisabled_noCommonParent3() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= {cu, getPackageP()}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - safeDelete(cu); - } + IJavaElement[] javaElements= {cu, getPackageP()}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent5() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= {cu, getRoot()}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - safeDelete(cu); - } + IJavaElement[] javaElements= {cu, getRoot()}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent6() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor()); - try { - IJavaElement[] javaElements= {cu, getRoot()}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - safeDelete(cu); - } + IJavaElement[] javaElements= {cu, getRoot()}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent7() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{class Inner{}}", false, new NullProgressMonitor()); - try { - IType classA= cu.getType("A"); - IType classInner= classA.getType("Inner"); - IJavaElement[] javaElements= { classA, classInner}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - safeDelete(cu); - } + IType classA= cu.getType("A"); + IType classInner= classA.getType("Inner"); + IJavaElement[] javaElements= { classA, classInner}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDisabled_noCommonParent8() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try { - IType classA= cu.getType("A"); - IMethod methodFoo= classA.getMethod("foo", new String[0]); - IJavaElement[] javaElements= { methodFoo, classA}; - IResource[] resources= {}; - verifyDisabled(resources, javaElements); - } finally { - performDummySearch(); - safeDelete(cu); - } + IType classA= cu.getType("A"); + IMethod methodFoo= classA.getMethod("foo", new String[0]); + IJavaElement[] javaElements= { methodFoo, classA}; + IResource[] resources= {}; + verifyDisabled(resources, javaElements); } public void testDestination_no_fileToItself() throws Exception { @@ -372,17 +322,12 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= file; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - file.delete(true, false, null); - } + Object destination= file; + verifyInvalidDestination(ref, destination); } public void testDestination_no_fileToSiblingFile() throws Exception { @@ -392,67 +337,45 @@ public class MoveTest extends RefactoringTest { IFile file2= superFolder.getFile("b.txt"); file2.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file1}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file1}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= file2; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - file1.delete(true, false, null); - file2.delete(true, false, null); - } + Object destination= file2; + verifyInvalidDestination(ref, destination); } public void testDestination_no_folderToItsef() throws Exception { IFolder superFolder= (IFolder)getPackageP().getResource(); IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= folder; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, false, null); - } + Object destination= folder; + verifyInvalidDestination(ref, destination); } public void testDestination_no_cuToItsef() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - } + Object destination= cu; + verifyInvalidDestination(ref, destination); } public void testDestination_no_cuToSiblingCu() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); ICompilationUnit cu1= getPackageP().createCompilationUnit("B.java", "package p;class A{}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu1; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - safeDelete(cu1); - } + Object destination= cu1; + verifyInvalidDestination(ref, destination); } public void testDestination_no_cuToSiblingFile() throws Exception { @@ -462,18 +385,12 @@ public class MoveTest extends RefactoringTest { IFile file1= superFolder.getFile("a.txt"); file1.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= file1; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - safeDelete(file1); - } + Object destination= file1; + verifyInvalidDestination(ref, destination); } public void testDestination_no_packageToItsef() throws Exception { @@ -496,18 +413,13 @@ public class MoveTest extends RefactoringTest { public void testDestination_no_methodToItsef() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= method; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - } + Object destination= method; + verifyInvalidDestination(ref, destination); } public void testDestination_no_fileToParentFolder() throws Exception { @@ -517,18 +429,12 @@ public class MoveTest extends RefactoringTest { IFile file= folder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= folder; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - folder.delete(true, false, null); - file.delete(true, false, null); - } + Object destination= folder; + verifyInvalidDestination(ref, destination); } public void testDestination_no_fileToParentPackage() throws Exception { @@ -536,17 +442,12 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getPackageP(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - file.delete(true, false, null); - } + Object destination= getPackageP(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_fileToParentSourceFolder() throws Exception { @@ -554,17 +455,12 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getRoot(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - file.delete(true, false, null); - } + Object destination= getRoot(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_fileToParentDefaultPackage() throws Exception { @@ -574,16 +470,11 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try { - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= defaultPackage; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - file.delete(true, false, null); - } + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + Object destination= defaultPackage; + verifyInvalidDestination(ref, destination); } public void testDestination_no_fileToParentDefaultPackage2() throws Exception { @@ -594,17 +485,11 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try { - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - file.delete(true, false, null); - safeDelete(cu); - } + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + Object destination= cu; + verifyInvalidDestination(ref, destination); } public void testDestination_no_fileToParentSourceFolder2() throws Exception { @@ -614,16 +499,11 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try { - IJavaElement[] javaElements= {}; - IResource[] resources= { file }; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= root; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - file.delete(true, false, null); - } + IJavaElement[] javaElements= {}; + IResource[] resources= { file }; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + Object destination= root; + verifyInvalidDestination(ref, destination); } public void testDestination_no_folderToParentFolder() throws Exception { @@ -634,32 +514,22 @@ public class MoveTest extends RefactoringTest { IFolder folder= parentFolder.getFolder("subfolder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {parentFolder}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {parentFolder}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= parentFolder; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - parentFolder.delete(true, false, null); - } + Object destination= parentFolder; + verifyInvalidDestination(ref, destination); } public void testDestination_no_cuToParentPackage() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {cu}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {cu}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu.getParent(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - } + Object destination= cu.getParent(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_packageToParentSourceFolder() throws Exception { @@ -682,53 +552,37 @@ public class MoveTest extends RefactoringTest { public void testDestination_no_methodToParentType() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu.getType("A"); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - } + Object destination= cu.getType("A"); + verifyInvalidDestination(ref, destination); } public void testDestination_no_cuToMethod() throws Exception { IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor()); ICompilationUnit cu= pack1.createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); ICompilationUnit cu1= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {cu1}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {cu1}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= method; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(pack1); - safeDelete(cu1); - } + Object destination= method; + verifyInvalidDestination(ref, destination); } public void testDestination_no_packageToCu() throws Exception { IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor()); ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {pack1}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {pack1}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(pack1); - } + Object destination= cu; + verifyInvalidDestination(ref, destination); } public void testDestination_no_packageToFile() throws Exception { @@ -737,18 +591,12 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {pack1}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {pack1}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= file; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(pack1); - file.delete(true, false, null); - } + Object destination= file; + verifyInvalidDestination(ref, destination); } public void testDestination_no_packageToFolder() throws Exception { @@ -757,18 +605,12 @@ public class MoveTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {pack1}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {pack1}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(pack1); - folder.delete(true, false, null); - } + Object destination= folder; + verifyValidDestination(ref, destination); } public void testDestination_no_packageToSimpleProject() throws Exception { @@ -785,9 +627,7 @@ public class MoveTest extends RefactoringTest { Object destination= simpleProject; verifyValidDestination(ref, destination); } finally{ - performDummySearch(); - safeDelete(pack1); - simpleProject.delete(true, true, null); + JavaProjectHelper.delete(simpleProject); } } @@ -803,57 +643,39 @@ public class MoveTest extends RefactoringTest { // Object destination= otherProject; // verifyInvalidDestination(ref, destination); // } finally{ -// performDummySearch(); -// pack1.delete(true, new NullProgressMonitor()); // JavaProjectHelper.delete(otherProject); // } // } public void testDestination_no_packageToSiblingPackage() throws Exception { IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {getPackageP()}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {getPackageP()}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= pack1; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(pack1); - } + Object destination= pack1; + verifyInvalidDestination(ref, destination); } public void testDestination_no_sourceFolderToCu() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - try{ - IJavaElement[] javaElements= {sourceFolder}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {sourceFolder}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - sourceFolder.delete(0, 0, new NullProgressMonitor()); - } + Object destination= cu; + verifyInvalidDestination(ref, destination); } public void testDestination_no_sourceFolderToPackage() throws Exception { IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - try{ - IJavaElement[] javaElements= {sourceFolder}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {sourceFolder}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getPackageP(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - sourceFolder.delete(0, 0, new NullProgressMonitor()); - } + Object destination= getPackageP(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_sourceFolderToFile() throws Exception { @@ -862,18 +684,12 @@ public class MoveTest extends RefactoringTest { file.create(getStream("123"), true, null); IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - try{ - IJavaElement[] javaElements= {sourceFolder}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {sourceFolder}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= file; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - sourceFolder.delete(0, 0, new NullProgressMonitor()); - file.delete(true, false, null); - } + Object destination= file; + verifyInvalidDestination(ref, destination); } public void testDestination_no_sourceFolderToFolder() throws Exception { @@ -882,33 +698,22 @@ public class MoveTest extends RefactoringTest { folder.create(true, true, null); IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - try{ - IJavaElement[] javaElements= {sourceFolder}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {sourceFolder}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); - } finally{ - performDummySearch(); - sourceFolder.delete(0, 0, new NullProgressMonitor()); - folder.delete(true, false, null); - } + Object destination= folder; + verifyValidDestination(ref, destination); } public void testDestination_no_sourceFolderToSourceFolder() throws Exception { IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - try{ - IJavaElement[] javaElements= {sourceFolder}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {sourceFolder}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getRoot(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - sourceFolder.delete(0, 0, new NullProgressMonitor()); - } + Object destination= getRoot(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_sourceFolderToSimpleProject() throws Exception { @@ -925,9 +730,7 @@ public class MoveTest extends RefactoringTest { Object destination= simpleProject; verifyValidDestination(ref, destination); } finally{ - performDummySearch(); - sourceFolder.delete(0, 0, new NullProgressMonitor()); - simpleProject.delete(true, true, null); + JavaProjectHelper.delete(simpleProject); } } @@ -944,8 +747,6 @@ public class MoveTest extends RefactoringTest { Object destination= otherProject; verifyInvalidDestination(ref, destination); }finally{ - performDummySearch(); - sourceFolder.delete(0, 0, new NullProgressMonitor()); JavaProjectHelper.delete(otherProject); } } @@ -953,31 +754,25 @@ public class MoveTest extends RefactoringTest { public void testDestination_yes_methodToCu() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){/*impl*/}}", false, new NullProgressMonitor()); ICompilationUnit cu1= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu1; - verifyValidDestination(ref, destination); + Object destination= cu1; + verifyValidDestination(ref, destination); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - assertTrue("source method not moved", ! method.exists()); + assertTrue("source method not moved", ! method.exists()); + + IType typeB= cu1.getType("B"); + IMethod methodBfoo= typeB.getMethod("foo", new String[0]); + assertTrue("method does not exist after", methodBfoo.exists()); + + assertEquals("void foo(){/*impl*/}", methodBfoo.getSource()); - IType typeB= cu1.getType("B"); - IMethod methodBfoo= typeB.getMethod("foo", new String[0]); - assertTrue("method does not exist after", methodBfoo.exists()); - - assertEquals("void foo(){/*impl*/}", methodBfoo.getSource()); - - } finally{ - performDummySearch(); - safeDelete(cu); - safeDelete(cu1); - } } public void testDestination_no_methodToFile() throws Exception { @@ -986,19 +781,13 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= file; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - file.delete(true, false, null); - } + Object destination= file; + verifyInvalidDestination(ref, destination); } public void testDestination_no_methodToFolder() throws Exception { @@ -1007,67 +796,46 @@ public class MoveTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= folder; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - folder.delete(true, false, null); - } + Object destination= folder; + verifyInvalidDestination(ref, destination); } public void testDestination_no_methodToPackage() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getPackageP(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - } + Object destination= getPackageP(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_methodToSourceFolder() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getRoot(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - } + Object destination= getRoot(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_methodToJavaProject() throws Exception { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {method}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {method}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(cu); - } + Object destination= RefactoringTestSetup.getProject(); + verifyInvalidDestination(ref, destination); } public void testDestination_no_methodToSimpleProject() throws Exception { @@ -1084,24 +852,17 @@ public class MoveTest extends RefactoringTest { Object destination= simpleProject; verifyInvalidDestination(ref, destination); } finally{ - performDummySearch(); - safeDelete(cu); - simpleProject.delete(true, true, null); + JavaProjectHelper.delete(simpleProject); } } public void testDestination_no_cuToItself() throws Exception{ ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu1; - verifyInvalidDestination(ref, destination); - }finally{ - performDummySearch(); - safeDelete(cu1); - } + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + Object destination= cu1; + verifyInvalidDestination(ref, destination); } public void testDestination_yes_cuToOtherPackage() throws Exception{ @@ -1109,33 +870,28 @@ public class MoveTest extends RefactoringTest { String oldSource= "package p;class A{void foo(){}class Inner{}}"; String newSource= "package otherPackage;class A{void foo(){}class Inner{}}"; ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", oldSource, false, new NullProgressMonitor()); - try{ - ParticipantTesting.reset(); - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); - JavaMoveProcessor processor= verifyEnabled(resources, javaElements, createReorgQueries()); - - Object destination= otherPackage; - verifyValidDestination(processor, destination); - - assertTrue("source file does not exist before moving", cu1.exists()); - RefactoringStatus status= performRefactoring(processor, true); - assertEquals(null, status); - assertTrue("source file exists after moving", ! cu1.exists()); - ICompilationUnit newCu= otherPackage.getCompilationUnit(cu1.getElementName()); - assertTrue("new file does not exist after moving", newCu.exists()); - assertEqualLines("source differs", newSource, newCu.getSource()); - ParticipantTesting.testMove( + ParticipantTesting.reset(); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); + JavaMoveProcessor processor= verifyEnabled(resources, javaElements, createReorgQueries()); + + Object destination= otherPackage; + verifyValidDestination(processor, destination); + + assertTrue("source file does not exist before moving", cu1.exists()); + RefactoringStatus status= performRefactoring(processor, true); + assertEquals(null, status); + assertTrue("source file exists after moving", ! cu1.exists()); + ICompilationUnit newCu= otherPackage.getCompilationUnit(cu1.getElementName()); + assertTrue("new file does not exist after moving", newCu.exists()); + assertEqualLines("source differs", newSource, newCu.getSource()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(otherPackage, processor.getUpdateReferences()), - new MoveArguments(otherPackage, processor.getUpdateReferences()), - new MoveArguments(otherPackage.getResource(), processor.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(otherPackage); - } + new MoveArguments(otherPackage, processor.getUpdateReferences()), + new MoveArguments(otherPackage, processor.getUpdateReferences()), + new MoveArguments(otherPackage.getResource(), processor.getUpdateReferences())}); } public void testDestination_yes_cuToOtherPackageWithMultiRoot() throws Exception { @@ -1151,35 +907,29 @@ public class MoveTest extends RefactoringTest { String oldRef= "package p;\npublic class Ref { A t = new A(); }"; String newRef= "package p;\n\nimport otherPackage.A;\n\npublic class Ref { A t = new A(); }"; ICompilationUnit cuRef= testP.createCompilationUnit("Ref.java", oldRef, false, new NullProgressMonitor()); - try{ - IJavaElement[] javaElements= {cuA}; - IResource[] resources= {}; - String[] handles= ParticipantTesting.createHandles(new Object[] {cuA, cuA.getTypes()[0], cuA.getResource()}); - JavaMoveProcessor processor= verifyEnabled(resources, javaElements, createReorgQueries()); - - Object destination= otherPackage; - verifyValidDestination(processor, destination); - - assertTrue("source file does not exist before moving", cuA.exists()); - RefactoringStatus status= performRefactoring(processor, true); - assertEquals(null, status); - assertTrue("source file exists after moving", ! cuA.exists()); - ICompilationUnit newCu= otherPackage.getCompilationUnit(cuA.getElementName()); - assertTrue("new file does not exist after moving", newCu.exists()); - assertEqualLines("source differs", newA, newCu.getSource()); - assertEqualLines("Ref differs", newRef, cuRef.getSource()); - - ParticipantTesting.testMove( + IJavaElement[] javaElements= {cuA}; + IResource[] resources= {}; + String[] handles= ParticipantTesting.createHandles(new Object[] {cuA, cuA.getTypes()[0], cuA.getResource()}); + JavaMoveProcessor processor= verifyEnabled(resources, javaElements, createReorgQueries()); + + Object destination= otherPackage; + verifyValidDestination(processor, destination); + + assertTrue("source file does not exist before moving", cuA.exists()); + RefactoringStatus status= performRefactoring(processor, true); + assertEquals(null, status); + assertTrue("source file exists after moving", ! cuA.exists()); + ICompilationUnit newCu= otherPackage.getCompilationUnit(cuA.getElementName()); + assertTrue("new file does not exist after moving", newCu.exists()); + assertEqualLines("source differs", newA, newCu.getSource()); + assertEqualLines("Ref differs", newRef, cuRef.getSource()); + + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(otherPackage, processor.getUpdateReferences()), - new MoveArguments(otherPackage, processor.getUpdateReferences()), - new MoveArguments(otherPackage.getResource(), processor.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(otherPackage); - JavaProjectHelper.removeSourceContainer(RefactoringTestSetup.getProject(), testSrc.getElementName()); - } + new MoveArguments(otherPackage, processor.getUpdateReferences()), + new MoveArguments(otherPackage, processor.getUpdateReferences()), + new MoveArguments(otherPackage.getResource(), processor.getUpdateReferences())}); } public void testDestination_yes_cuToOtherPackageWithMultiRootBug109145() throws Exception { @@ -1201,41 +951,36 @@ public class MoveTest extends RefactoringTest { ICompilationUnit reference= testP.createCompilationUnit("Class1.java", buf.toString(), false, new NullProgressMonitor()); IPackageFragment destination= testSrc.createPackageFragment("p2", true, new NullProgressMonitor()); - try { - String[] handles= ParticipantTesting.createHandles(new Object[] { toMove, toMove.getTypes()[0], toMove.getResource() }); - JavaMoveProcessor processor= verifyEnabled(new IResource[] {}, new IJavaElement[] { toMove }, createReorgQueries()); + String[] handles= ParticipantTesting.createHandles(new Object[] { toMove, toMove.getTypes()[0], toMove.getResource() }); + JavaMoveProcessor processor= verifyEnabled(new IResource[] {}, new IJavaElement[] { toMove }, createReorgQueries()); - verifyValidDestination(processor, destination); + verifyValidDestination(processor, destination); - assertTrue("source file does not exist before moving", toMove.exists()); - RefactoringStatus status= performRefactoring(processor, true); - assertEquals(null, status); - assertTrue("source file exists after moving", !toMove.exists()); - ICompilationUnit newCu= destination.getCompilationUnit(toMove.getElementName()); - assertTrue("new file does not exist after moving", newCu.exists()); - - buf= new StringBuffer(); - buf.append("package p2;\n"); - buf.append("\n"); - buf.append("import p.Class1;\n"); - buf.append("\n"); - buf.append("public class Class2 {\n"); - buf.append(" Class1 c;\n"); - buf.append("}\n"); - assertEqualLines(buf.toString(), newCu.getSource()); - - buf= new StringBuffer(); - buf.append("package p;\n"); - buf.append("public class Class1 {\n"); - buf.append("}\n"); - assertEqualLines(buf.toString(), reference.getSource()); - - ParticipantTesting.testMove(handles, new MoveArguments[] { new MoveArguments(destination, processor.getUpdateReferences()), - new MoveArguments(destination, processor.getUpdateReferences()), new MoveArguments(destination.getResource(), processor.getUpdateReferences()) }); - } finally { - performDummySearch(); - JavaProjectHelper.removeSourceContainer(RefactoringTestSetup.getProject(), testSrc.getElementName()); - } + assertTrue("source file does not exist before moving", toMove.exists()); + RefactoringStatus status= performRefactoring(processor, true); + assertEquals(null, status); + assertTrue("source file exists after moving", !toMove.exists()); + ICompilationUnit newCu= destination.getCompilationUnit(toMove.getElementName()); + assertTrue("new file does not exist after moving", newCu.exists()); + + buf= new StringBuffer(); + buf.append("package p2;\n"); + buf.append("\n"); + buf.append("import p.Class1;\n"); + buf.append("\n"); + buf.append("public class Class2 {\n"); + buf.append(" Class1 c;\n"); + buf.append("}\n"); + assertEqualLines(buf.toString(), newCu.getSource()); + + buf= new StringBuffer(); + buf.append("package p;\n"); + buf.append("public class Class1 {\n"); + buf.append("}\n"); + assertEqualLines(buf.toString(), reference.getSource()); + + ParticipantTesting.testMove(handles, new MoveArguments[] { new MoveArguments(destination, processor.getUpdateReferences()), + new MoveArguments(destination, processor.getUpdateReferences()), new MoveArguments(destination.getResource(), processor.getUpdateReferences()) }); } public void testDestination_yes_cuToRoot() throws Exception{ @@ -1244,34 +989,28 @@ public class MoveTest extends RefactoringTest { String oldSource= "package p;class A{void foo(){}class Inner{}}"; ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", oldSource, false, new NullProgressMonitor()); IPackageFragmentRoot destination= JavaProjectHelper.addSourceContainer(getRoot().getJavaProject(), "src2"); - ICompilationUnit newCu= null; - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - verifyValidDestination(ref, destination); + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before moving", cu1.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); - assertTrue("source file exists after moving", ! cu1.exists()); - newCu= destination.getPackageFragment("p").getCompilationUnit(cu1.getElementName()); - assertTrue("new file does not exist after moving", newCu.exists()); - assertEqualLines("source differs", newSource, newCu.getSource()); + assertTrue("source file does not exist before moving", cu1.exists()); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); + assertTrue("source file exists after moving", ! cu1.exists()); + ICompilationUnit newCu= destination.getPackageFragment("p").getCompilationUnit(cu1.getElementName()); + assertTrue("new file does not exist after moving", newCu.exists()); + assertEqualLines("source differs", newSource, newCu.getSource()); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(destination.getPackageFragment("p"), ref.getUpdateReferences()), - new MoveArguments(destination.getPackageFragment("p"), ref.getUpdateReferences()), - new MoveArguments(destination.getPackageFragment("p").getResource(), ref.getUpdateReferences()) }); + new MoveArguments(destination.getPackageFragment("p"), ref.getUpdateReferences()), + new MoveArguments(destination.getPackageFragment("p"), ref.getUpdateReferences()), + new MoveArguments(destination.getPackageFragment("p").getResource(), ref.getUpdateReferences()) }); - }finally{ - performDummySearch(); - safeDelete(newCu); - } } public void testDestination_yes_cuFromRoot() throws Exception{ @@ -1313,16 +1052,12 @@ public class MoveTest extends RefactoringTest { assertEqualLines("Reference.java differs", newRef, cuRef.getSource()); ParticipantTesting.testMove( - handles, - new MoveArguments[] { - new MoveArguments(org, ref.getUpdateReferences()), - new MoveArguments(org, ref.getUpdateReferences()), - new MoveArguments(org.getResource(), ref.getUpdateReferences())}); + handles, + new MoveArguments[] { + new MoveArguments(org, ref.getUpdateReferences()), + new MoveArguments(org, ref.getUpdateReferences()), + new MoveArguments(org.getResource(), ref.getUpdateReferences())}); }finally{ - performDummySearch(); - safeDelete(newCuD); - safeDelete(orgTest); - safeDelete(org); javaProject.setOptions(originalOptions); } } @@ -1363,10 +1098,6 @@ public class MoveTest extends RefactoringTest { assertEqualLines("Reference.java differs", newRef, cuRef.getSource()); }finally{ - performDummySearch(); - safeDelete(newCuD); - safeDelete(orgTest); - safeDelete(org); javaProject.setOptions(originalOptions); } } @@ -1376,34 +1107,28 @@ public class MoveTest extends RefactoringTest { String oldSource= "package p;class A{void foo(){}class Inner{}}"; String newSource= oldSource; ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", oldSource, false, new NullProgressMonitor()); - IFile newFile= null; - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - IJavaProject project= RefactoringTestSetup.getProject(); - Object destination= project; - verifyValidDestination(ref, destination); + IJavaProject project= RefactoringTestSetup.getProject(); + Object destination= project; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before moving", cu1.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); - assertTrue("source file exists after moving", ! cu1.exists()); - newFile= project.getProject().getFile(cu1.getElementName()); - assertEqualLines("source differs", newSource, getContents(newFile)); + assertTrue("source file does not exist before moving", cu1.exists()); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); + assertTrue("source file exists after moving", ! cu1.exists()); + IFile newFile= project.getProject().getFile(cu1.getElementName()); + assertEqualLines("source differs", newSource, getContents(newFile)); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(project.getProject(), ref.getUpdateReferences()), - new MoveArguments(project.getProject(), ref.getUpdateReferences()), - new MoveArguments(project.getResource(), ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(newFile); - } + new MoveArguments(project.getProject(), ref.getUpdateReferences()), + new MoveArguments(project.getProject(), ref.getUpdateReferences()), + new MoveArguments(project.getResource(), ref.getUpdateReferences())}); } public void testDestination_yes_cuToSimpleProject() throws Exception{ @@ -1414,7 +1139,6 @@ public class MoveTest extends RefactoringTest { IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject"); simpleProject.create(null); simpleProject.open(null); - IFile newFile= null; try{ IJavaElement[] javaElements= { cu1}; IResource[] resources= {}; @@ -1428,18 +1152,17 @@ public class MoveTest extends RefactoringTest { RefactoringStatus status= performRefactoring(ref, true); assertEquals(null, status); assertTrue("source file exists after moving", ! cu1.exists()); - newFile= simpleProject.getFile(cu1.getElementName()); + IFile newFile= simpleProject.getFile(cu1.getElementName()); assertEqualLines("source differs", newSource, getContents(newFile)); ParticipantTesting.testMove( - handles, - new MoveArguments[] { - new MoveArguments(simpleProject, ref.getUpdateReferences()), - new MoveArguments(simpleProject, ref.getUpdateReferences()), - new MoveArguments(simpleProject, ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(simpleProject); + handles, + new MoveArguments[] { + new MoveArguments(simpleProject, ref.getUpdateReferences()), + new MoveArguments(simpleProject, ref.getUpdateReferences()), + new MoveArguments(simpleProject, ref.getUpdateReferences())}); + } finally { + JavaProjectHelper.delete(simpleProject); } } @@ -1451,41 +1174,33 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - ICompilationUnit newCu= null; - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= file; - verifyValidDestination(ref, destination); + Object destination= file; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before", cu1.exists()); + assertTrue("source file does not exist before", cu1.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - assertTrue("source file not moved", ! cu1.exists()); + assertTrue("source file not moved", ! cu1.exists()); - newCu= otherPackage.getCompilationUnit(cu1.getElementName()); - assertTrue("new file does not exist after", newCu.exists()); + ICompilationUnit newCu= otherPackage.getCompilationUnit(cu1.getElementName()); + assertTrue("new file does not exist after", newCu.exists()); - String expectedSource= "package other;class A{void foo(){}class Inner{}}"; - assertEqualLines("source compare failed", expectedSource, newCu.getSource()); + String expectedSource= "package other;class A{void foo(){}class Inner{}}"; + assertEqualLines("source compare failed", expectedSource, newCu.getSource()); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(otherPackage, ref.getUpdateReferences()), - new MoveArguments(otherPackage, ref.getUpdateReferences()), - new MoveArguments(otherPackage.getResource(), ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(otherPackage); - safeDelete(newCu); - safeDelete(file); - } + new MoveArguments(otherPackage, ref.getUpdateReferences()), + new MoveArguments(otherPackage, ref.getUpdateReferences()), + new MoveArguments(otherPackage.getResource(), ref.getUpdateReferences())}); } public void testDestination_yes_cuToFolder() throws Exception{ @@ -1495,40 +1210,33 @@ public class MoveTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - IFile newFile= null; - try{ - IJavaElement[] javaElements= { cu1}; - IResource[] resources= {}; - String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= { cu1}; + IResource[] resources= {}; + String[] handles= ParticipantTesting.createHandles(new Object[] {cu1, cu1.getTypes()[0], cu1.getResource()}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); + Object destination= folder; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before", cu1.exists()); - String expectedSource= cu1.getSource(); + assertTrue("source file does not exist before", cu1.exists()); + String expectedSource= cu1.getSource(); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - assertTrue("source file not moved", ! cu1.exists()); + assertTrue("source file not moved", ! cu1.exists()); - newFile= folder.getFile(cu1.getElementName()); - assertTrue("new file does not exist after", newFile.exists()); + IFile newFile= folder.getFile(cu1.getElementName()); + assertTrue("new file does not exist after", newFile.exists()); - assertEqualLines("source compare failed", expectedSource, getContents(newFile)); + assertEqualLines("source compare failed", expectedSource, getContents(newFile)); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(destination, ref.getUpdateReferences()), - new MoveArguments(destination, ref.getUpdateReferences()), - new MoveArguments(folder, ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(newFile); - safeDelete(folder); - } + new MoveArguments(destination, ref.getUpdateReferences()), + new MoveArguments(destination, ref.getUpdateReferences()), + new MoveArguments(folder, ref.getUpdateReferences())}); } public void testDestination_yes_fileToSiblingFolder() throws Exception{ @@ -1540,35 +1248,28 @@ public class MoveTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - IFile newFile= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - String[] handles= ParticipantTesting.createHandles(new Object[] {file}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + String[] handles= ParticipantTesting.createHandles(new Object[] {file}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= folder; - verifyValidDestination(ref, destination); + Object destination= folder; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before", file.exists()); + assertTrue("source file does not exist before", file.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - assertTrue("source file not moved", ! file.exists()); + assertTrue("source file not moved", ! file.exists()); - newFile= folder.getFile(file.getName()); - assertTrue("new file does not exist after", newFile.exists()); + IFile newFile= folder.getFile(file.getName()); + assertTrue("new file does not exist after", newFile.exists()); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(folder, ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(newFile); - safeDelete(folder); - } + new MoveArguments(folder, ref.getUpdateReferences())}); } public void testDestination_yes_fileToCu() throws Exception{ @@ -1578,35 +1279,28 @@ public class MoveTest extends RefactoringTest { file.create(getStream("123"), true, null); ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - IFile newFile= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - String[] handles= ParticipantTesting.createHandles(new Object[] {file}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + String[] handles= ParticipantTesting.createHandles(new Object[] {file}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu1; - verifyValidDestination(ref, destination); + Object destination= cu1; + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before", file.exists()); + assertTrue("source file does not exist before", file.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - assertTrue("source file not moved", ! file.exists()); + assertTrue("source file not moved", ! file.exists()); - newFile= ((IFolder)cu1.getParent().getResource()).getFile(file.getName()); - assertTrue("new file does not exist after", newFile.exists()); + IFile newFile= ((IFolder)cu1.getParent().getResource()).getFile(file.getName()); + assertTrue("new file does not exist after", newFile.exists()); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(newFile); - safeDelete(cu1); - } + new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())}); } public void testDestination_yes_fileToPackage() throws Exception{ @@ -1615,34 +1309,28 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - IFile newFile= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - String[] handles= ParticipantTesting.createHandles(new Object[] {file}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + String[] handles= ParticipantTesting.createHandles(new Object[] {file}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getPackageP(); - verifyValidDestination(ref, destination); + Object destination= getPackageP(); + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before", file.exists()); + assertTrue("source file does not exist before", file.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - assertTrue("source file not moved", ! file.exists()); + assertTrue("source file not moved", ! file.exists()); - newFile= ((IFolder)getPackageP().getResource()).getFile(file.getName()); - assertTrue("new file does not exist after", newFile.exists()); + IFile newFile= ((IFolder)getPackageP().getResource()).getFile(file.getName()); + assertTrue("new file does not exist after", newFile.exists()); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(newFile); - } + new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())}); } public void testDestination_no_fileToMethod() throws Exception { @@ -1650,19 +1338,13 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - try{ - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= method; - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(file); - safeDelete(cu); - } + Object destination= method; + verifyInvalidDestination(ref, destination); } public void testDestination_yes_fileToRoot() throws Exception{ @@ -1671,33 +1353,27 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - IFile newFile= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - String[] handles= ParticipantTesting.createHandles(new Object[] {file}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + String[] handles= ParticipantTesting.createHandles(new Object[] {file}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= getRoot(); - verifyValidDestination(ref, destination); + Object destination= getRoot(); + verifyValidDestination(ref, destination); - assertTrue("source file does not exist before", file.exists()); + assertTrue("source file does not exist before", file.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - assertTrue("source file not moved", ! file.exists()); + assertTrue("source file not moved", ! file.exists()); - newFile= ((IFolder)getRoot().getResource()).getFile(file.getName()); - assertTrue("new file does not exist after", newFile.exists()); - ParticipantTesting.testMove( + IFile newFile= ((IFolder)getRoot().getResource()).getFile(file.getName()); + assertTrue("new file does not exist after", newFile.exists()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(getRoot().getResource(), ref.getUpdateReferences())}); - }finally{ - performDummySearch(); - safeDelete(newFile); - } + new MoveArguments(getRoot().getResource(), ref.getUpdateReferences())}); } public void testDestination_no_fileToParentProject() throws Exception{ @@ -1705,17 +1381,12 @@ public class MoveTest extends RefactoringTest { IFile file= superFolder.getFile("a.txt"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyInvalidDestination(ref, destination); - }finally{ - performDummySearch(); - safeDelete(file); - } + Object destination= RefactoringTestSetup.getProject(); + verifyInvalidDestination(ref, destination); } public void testDestination_yes_folderToSiblingFolder() throws Exception{ @@ -1727,31 +1398,24 @@ public class MoveTest extends RefactoringTest { IFolder otherFolder= superFolder.getFolder("otherfolder"); otherFolder.create(true, true, null); - IFolder newFolder= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= otherFolder; - verifyValidDestination(ref, destination); + Object destination= otherFolder; + verifyValidDestination(ref, destination); - assertTrue("folder does not exist before", folder.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); - assertTrue("folder not moved", ! folder.exists()); - newFolder= otherFolder.getFolder(folder.getName()); - assertTrue("new folder does not exist after", newFolder.exists()); - ParticipantTesting.testMove( + assertTrue("folder does not exist before", folder.exists()); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); + assertTrue("folder not moved", ! folder.exists()); + IFolder newFolder= otherFolder.getFolder(folder.getName()); + assertTrue("new folder does not exist after", newFolder.exists()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(destination, ref.getUpdateReferences())}); - } finally{ - performDummySearch(); - safeDelete(newFolder); - safeDelete(otherFolder); - } + new MoveArguments(destination, ref.getUpdateReferences())}); } public void testDestination_no_folderToParentProject() throws Exception{ @@ -1759,17 +1423,12 @@ public class MoveTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= RefactoringTestSetup.getProject(); - verifyInvalidDestination(ref, destination); - } finally{ - performDummySearch(); - safeDelete(folder); - } + Object destination= RefactoringTestSetup.getProject(); + verifyInvalidDestination(ref, destination); } public void testDestination_yes_folderToSiblingRoot() throws Exception{ @@ -1778,30 +1437,24 @@ public class MoveTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - IPackageFragment newPackage= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - - Object destination= getRoot(); - verifyValidDestination(ref, destination); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - assertTrue("folder does not exist before", folder.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); - assertTrue("folder not moved", ! folder.exists()); - newPackage= getRoot().getPackageFragment(folder.getName()); - assertTrue("new folder does not exist after", newPackage.exists()); - ParticipantTesting.testMove( + Object destination= getRoot(); + verifyValidDestination(ref, destination); + + assertTrue("folder does not exist before", folder.exists()); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); + assertTrue("folder not moved", ! folder.exists()); + IPackageFragment newPackage= getRoot().getPackageFragment(folder.getName()); + assertTrue("new folder does not exist after", newPackage.exists()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(getRoot().getResource(), ref.getUpdateReferences())}); - } finally{ - performDummySearch(); - safeDelete(newPackage); - } + new MoveArguments(getRoot().getResource(), ref.getUpdateReferences())}); } public void testDestination_yes_folderToPackage() throws Exception{ @@ -1810,30 +1463,24 @@ public class MoveTest extends RefactoringTest { IFolder folder= superFolder.getFolder("folder"); folder.create(true, true, null); - IPackageFragment newPackage= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - - Object destination= getPackageP(); - verifyValidDestination(ref, destination); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - assertTrue("folder does not exist before", folder.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); - assertTrue("folder not moved", ! folder.exists()); - newPackage= getRoot().getPackageFragment(getPackageP().getElementName() + "." + folder.getName()); - assertTrue("new package does not exist after", newPackage.exists()); - ParticipantTesting.testMove( + Object destination= getPackageP(); + verifyValidDestination(ref, destination); + + assertTrue("folder does not exist before", folder.exists()); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); + assertTrue("folder not moved", ! folder.exists()); + IPackageFragment newPackage= getRoot().getPackageFragment(getPackageP().getElementName() + "." + folder.getName()); + assertTrue("new package does not exist after", newPackage.exists()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())}); - } finally{ - performDummySearch(); - safeDelete(newPackage); - } + new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())}); } public void testDestination_yes_folderToFileInAnotherFolder() throws Exception{ @@ -1847,31 +1494,24 @@ public class MoveTest extends RefactoringTest { IFile fileInAnotherFolder= otherFolder.getFile("f.tex"); fileInAnotherFolder.create(getStream("123"), true, null); - IFolder newFolder= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= fileInAnotherFolder; - verifyValidDestination(ref, destination); + Object destination= fileInAnotherFolder; + verifyValidDestination(ref, destination); - assertTrue("folder does not exist before", folder.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); - assertTrue("folder not moved", ! folder.exists()); - newFolder= otherFolder.getFolder(folder.getName()); - assertTrue("new folder does not exist after", newFolder.exists()); - ParticipantTesting.testMove( + assertTrue("folder does not exist before", folder.exists()); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); + assertTrue("folder not moved", ! folder.exists()); + IFolder newFolder= otherFolder.getFolder(folder.getName()); + assertTrue("new folder does not exist after", newFolder.exists()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(otherFolder, ref.getUpdateReferences())}); - } finally{ - performDummySearch(); -// folder.delete(true, new NullProgressMonitor()); - safeDelete(otherFolder); - } + new MoveArguments(otherFolder, ref.getUpdateReferences())}); } public void testDestination_yes_folderToCu() throws Exception{ @@ -1882,31 +1522,24 @@ public class MoveTest extends RefactoringTest { ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor()); - IPackageFragment newPackage= null; - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {folder}; - String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IJavaElement[] javaElements= {}; + IResource[] resources= {folder}; + String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= cu; - verifyValidDestination(ref, destination); + Object destination= cu; + verifyValidDestination(ref, destination); - assertTrue("folder does not exist before", folder.exists()); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); - assertTrue("folder not moved", ! folder.exists()); - newPackage= getRoot().getPackageFragment(getPackageP().getElementName() + "." + folder.getName()); - assertTrue("new package does not exist after", newPackage.exists()); - ParticipantTesting.testMove( + assertTrue("folder does not exist before", folder.exists()); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); + assertTrue("folder not moved", ! folder.exists()); + IPackageFragment newPackage= getRoot().getPackageFragment(getPackageP().getElementName() + "." + folder.getName()); + assertTrue("new package does not exist after", newPackage.exists()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(cu.getParent().getResource(), ref.getUpdateReferences())}); - } finally{ - performDummySearch(); - safeDelete(newPackage); - safeDelete(cu); - } + new MoveArguments(cu.getParent().getResource(), ref.getUpdateReferences())}); } public void testDestination_yes_folderToSimpleProject() throws Exception{ @@ -1919,8 +1552,7 @@ public class MoveTest extends RefactoringTest { simpleProject.create(null); simpleProject.open(null); - IFolder newFolder= null; - try{ + try { IJavaElement[] javaElements= {}; IResource[] resources= {folder}; String[] handles= ParticipantTesting.createHandles(new Object[] {folder}); @@ -1933,16 +1565,14 @@ public class MoveTest extends RefactoringTest { RefactoringStatus status= performRefactoring(ref, true); assertEquals(null, status); assertTrue("folder not moved", ! folder.exists()); - newFolder= simpleProject.getFolder(folder.getName()); + IFolder newFolder= simpleProject.getFolder(folder.getName()); assertTrue("new folder does not exist after", newFolder.exists()); ParticipantTesting.testMove( - handles, - new MoveArguments[] { - new MoveArguments(simpleProject, ref.getUpdateReferences())}); - } finally{ - performDummySearch(); - safeDelete(folder); - simpleProject.delete(true, true, new NullProgressMonitor()); + handles, + new MoveArguments[] { + new MoveArguments(simpleProject, ref.getUpdateReferences())}); + } finally { + JavaProjectHelper.delete(simpleProject); } } @@ -1951,7 +1581,6 @@ public class MoveTest extends RefactoringTest { IJavaProject otherJavaProject= JavaProjectHelper.createJavaProject("other", "bin"); IPackageFragmentRoot oldRoot= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "newSrc"); - IPackageFragmentRoot newRoot= null; try { IJavaElement[] javaElements= { oldRoot }; IResource[] resources= {}; @@ -1965,105 +1594,80 @@ public class MoveTest extends RefactoringTest { RefactoringStatus status= performRefactoring(ref, false); assertEquals(null, status); assertTrue("folder not moved", ! oldRoot.exists()); - newRoot= getSourceFolder(otherJavaProject, oldRoot.getElementName()); + IPackageFragmentRoot newRoot= getSourceFolder(otherJavaProject, oldRoot.getElementName()); assertTrue("new folder does not exist after", newRoot.exists()); ParticipantTesting.testMove( - handles, - new MoveArguments[] { - new MoveArguments(otherJavaProject, ref.getUpdateReferences()), - new MoveArguments(otherJavaProject.getResource(), ref.getUpdateReferences())}); + handles, + new MoveArguments[] { + new MoveArguments(otherJavaProject, ref.getUpdateReferences()), + new MoveArguments(otherJavaProject.getResource(), ref.getUpdateReferences())}); } finally { - performDummySearch(); JavaProjectHelper.delete(otherJavaProject); } } public void testDestination_no_methodToItself() throws Exception{ - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - Object destination= method; - verifyInvalidDestination(ref, destination); - } finally { - performDummySearch(); - safeDelete(cu); - } + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + Object destination= method; + verifyInvalidDestination(ref, destination); } public void testDestination_yes_methodToOtherType() throws Exception{ ParticipantTesting.reset(); - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IMethod method= cu.getType("A").getMethod("foo", new String[0]); - IJavaElement[] javaElements= { method }; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - IType otherType= cu.getType("B"); - Object destination= otherType; - verifyValidDestination(ref, destination); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IMethod method= cu.getType("A").getMethod("foo", new String[0]); + IJavaElement[] javaElements= { method }; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IType otherType= cu.getType("B"); + Object destination= otherType; + verifyValidDestination(ref, destination); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName()))); - assertEqualLines("source differs", expected, cu.getSource()); - ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} ); - } finally { - performDummySearch(); - safeDelete(cu); - } + String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName()))); + assertEqualLines("source differs", expected, cu.getSource()); + ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} ); } public void testDestination_yes_fieldToOtherType() throws Exception{ ParticipantTesting.reset(); - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IField field= cu.getType("A").getField("f"); - IJavaElement[] javaElements= { field }; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - IType otherType= cu.getType("B"); - Object destination= otherType; - verifyValidDestination(ref, destination); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IField field= cu.getType("A").getField("f"); + IJavaElement[] javaElements= { field }; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IType otherType= cu.getType("B"); + Object destination= otherType; + verifyValidDestination(ref, destination); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName()))); - assertEqualLines("source differs", expected, cu.getSource()); - ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} ); - } finally { - performDummySearch(); - safeDelete(cu); - } + String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName()))); + assertEqualLines("source differs", expected, cu.getSource()); + ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} ); } public void testDestination_yes_initializerToOtherType() throws Exception{ ParticipantTesting.reset(); - ICompilationUnit cu= null; - try { - cu= createCUfromTestFile(getPackageP(), "A"); - IInitializer initializer= cu.getType("A").getInitializer(1); - IJavaElement[] javaElements= { initializer }; - IResource[] resources= {}; - JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); - IType otherType= cu.getType("B"); - Object destination= otherType; - verifyValidDestination(ref, destination); - RefactoringStatus status= performRefactoring(ref, true); - assertEquals(null, status); + ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A"); + IInitializer initializer= cu.getType("A").getInitializer(1); + IJavaElement[] javaElements= { initializer }; + IResource[] resources= {}; + JavaMoveProcessor ref= verifyEnabled(resources, javaElements, createReorgQueries()); + IType otherType= cu.getType("B"); + Object destination= otherType; + verifyValidDestination(ref, destination); + RefactoringStatus status= performRefactoring(ref, true); + assertEquals(null, status); - String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName()))); - assertEqualLines("source differs", expected, cu.getSource()); - ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} ); - } finally { - performDummySearch(); - safeDelete(cu); - } + String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName()))); + assertEqualLines("source differs", expected, cu.getSource()); + ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} ); } public void testDestination_bug79318() throws Exception{ @@ -2073,18 +1677,13 @@ public class MoveTest extends RefactoringTest { IFile file= folder.getFile("bar"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; - move(javaElements, resources, superFolder, null, IReorgDestination.LOCATION_ON, true, true); + move(javaElements, resources, superFolder, null, IReorgDestination.LOCATION_ON, true, true); - assertIsParent(folder, file); - assertIsParent(superFolder, folder); - }finally{ - performDummySearch(); - safeDelete(file); - } + assertIsParent(folder, file); + assertIsParent(superFolder, folder); } public void testDestination_bug196303() throws Exception{ @@ -2097,66 +1696,49 @@ public class MoveTest extends RefactoringTest { IFile file= folder.getFile("bar"); file.create(getStream("123"), true, null); - try{ - IJavaElement[] javaElements= {}; - IResource[] resources= {file}; + IJavaElement[] javaElements= {}; + IResource[] resources= {file}; - move(javaElements, resources, superFolder, null, IReorgDestination.LOCATION_ON, false, true); + move(javaElements, resources, superFolder, null, IReorgDestination.LOCATION_ON, false, true); - assertIsParent(folder, file); - assertIsParent(superFolder, folder); - }finally{ - performDummySearch(); - safeDelete(file); - } + assertIsParent(folder, file); + assertIsParent(superFolder, folder); } public void testDestination_fieldWithImport() throws Exception { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - try { - IType typeA= cuA.getType("A"); - IJavaElement fieldF= typeA.getField("f"); - IJavaElement fieldG= typeA.getField("g"); + IType typeA= cuA.getType("A"); + IJavaElement fieldF= typeA.getField("f"); + IJavaElement fieldG= typeA.getField("g"); - move(new IJavaElement[] {fieldF} , new IResource[0], null, fieldG, IReorgDestination.LOCATION_AFTER, true, true); + move(new IJavaElement[] {fieldF} , new IResource[0], null, fieldG, IReorgDestination.LOCATION_AFTER, true, true); - compareContents("A"); - } finally{ - delete(cuA); - } + compareContents("A"); } public void testDestination_fieldWithImport_back() throws Exception { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - try { - IType typeA= cuA.getType("A"); - IJavaElement fieldF= typeA.getField("f"); - IJavaElement fieldG= typeA.getField("g"); + IType typeA= cuA.getType("A"); + IJavaElement fieldF= typeA.getField("f"); + IJavaElement fieldG= typeA.getField("g"); - move(new IJavaElement[] {fieldF} , new IResource[0], null, fieldG, IReorgDestination.LOCATION_BEFORE, true, true); + move(new IJavaElement[] {fieldF} , new IResource[0], null, fieldG, IReorgDestination.LOCATION_BEFORE, true, true); - compareContents("A"); - } finally{ - delete(cuA); - } + compareContents("A"); } public void testDestination_fieldWithImportMoveAcross() throws Exception { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try { - IType typeA= cuA.getType("A"); - IJavaElement fieldF= typeA.getField("f"); + IType typeA= cuA.getType("A"); + IJavaElement fieldF= typeA.getField("f"); - IType typeB= cuB.getType("B"); + IType typeB= cuB.getType("B"); - move(new IJavaElement[] {fieldF} , new IResource[0], null, typeB, IReorgDestination.LOCATION_ON, true, true); + move(new IJavaElement[] {fieldF} , new IResource[0], null, typeB, IReorgDestination.LOCATION_ON, true, true); - compareContents("A"); - compareContents("B"); - } finally{ - delete(cuA); - } + compareContents("A"); + compareContents("B"); } public void testDestination_bug31125() throws Exception { @@ -2215,16 +1797,6 @@ public class MoveTest extends RefactoringTest { performRefactoring(ref, providesUndo); } - private void delete(ICompilationUnit cu) throws Exception { - try { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } catch (JavaModelException e) { - e.printStackTrace(); - //ingore and keep going - } - } - private void compareContents(String cuName) throws JavaModelException, IOException { assertEqualLines(cuName, getFileContents(getOutputTestFileName(cuName)), getPackageP().getCompilationUnit(cuName + ".java").getSource()); } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java index 1df2dfdd1d..aa086f69bc 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,12 +32,11 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy; import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor; import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgDestinationFactory; import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory; -import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy; import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting; import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest; @@ -79,403 +78,330 @@ public class MultiMoveTest extends RefactoringTest { return createCU(pack, cuName, getFileContents(getRefactoringPath() + cuPath)); } - private void delete(IPackageFragment pack) throws Exception { - performDummySearch(); - try { - if (pack != null && pack.exists()) - pack.delete(true, null); - } catch(JavaModelException e) { - //ignore, we should keep going - e.printStackTrace(); - } - } - - private void delete(IPackageFragmentRoot root) throws Exception { - performDummySearch(); - try { - if (root != null && root.exists()) - root.delete(IResource.FORCE, IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH, null); - } catch(JavaModelException e) { - //ignore, we should keep going - e.printStackTrace(); - } - } - //-------- public void test0() throws Exception{ ParticipantTesting.reset(); - IPackageFragment packP1= null; - IPackageFragment packP2= null; - try { - final String p1Name= "p1"; - final String inDir= "/in/"; - final String outDir= "/out/"; - - packP1= createPackage(p1Name); - ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/A.java", "A.java"); - ICompilationUnit p1B= createCu(packP1, getName() + inDir + p1Name + "/B.java", "B.java"); - - String p2Name= "p2"; - packP2= createPackage(p2Name); - ICompilationUnit p2C= createCu(packP2, getName() + inDir + p2Name + "/C.java", "C.java"); - - String[] handles= ParticipantTesting.createHandles(new Object[] { + final String p1Name= "p1"; + final String inDir= "/in/"; + final String outDir= "/out/"; + + IPackageFragment packP1= createPackage(p1Name); + ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/A.java", "A.java"); + ICompilationUnit p1B= createCu(packP1, getName() + inDir + p1Name + "/B.java", "B.java"); + + String p2Name= "p2"; + IPackageFragment packP2= createPackage(p2Name); + ICompilationUnit p2C= createCu(packP2, getName() + inDir + p2Name + "/C.java", "C.java"); + + String[] handles= ParticipantTesting.createHandles(new Object[] { p1A, p1A.getTypes()[0], p1B, p1B.getTypes()[0], p1A.getResource(), p1B.getResource()}); - IResource[] resources= {}; - IJavaElement[] javaElements= {p1A, p1B}; - IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); - JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); - processor.setReorgQueries(new MockReorgQueries()); - processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); - processor.setUpdateReferences(true); - performDummySearch(); - RefactoringStatus status= performRefactoring(processor, true); + IResource[] resources= {}; + IJavaElement[] javaElements= {p1A, p1B}; + IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); + JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); + processor.setReorgQueries(new MockReorgQueries()); + processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); + processor.setUpdateReferences(true); + performDummySearch(); + RefactoringStatus status= performRefactoring(processor, true); - //-- checks - assertEquals("status should be ok here", null, status); + //-- checks + assertEquals("status should be ok here", null, status); - assertEquals("p1 files", 0, packP1.getChildren().length); - assertEquals("p2 files", 3, packP2.getChildren().length); + assertEquals("p1 files", 0, packP1.getChildren().length); + assertEquals("p2 files", 3, packP2.getChildren().length); - String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/A.java"); - assertEqualLines("incorrect update of A", expectedSource, packP2.getCompilationUnit("A.java").getSource()); + String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/A.java"); + assertEqualLines("incorrect update of A", expectedSource, packP2.getCompilationUnit("A.java").getSource()); - expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/B.java"); - assertEqualLines("incorrect update of B", expectedSource, packP2.getCompilationUnit("B.java").getSource()); + expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/B.java"); + assertEqualLines("incorrect update of B", expectedSource, packP2.getCompilationUnit("B.java").getSource()); - expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/C.java"); - assertEqualLines("incorrect update of C", expectedSource, p2C.getSource()); - ParticipantTesting.testMove( + expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/C.java"); + assertEqualLines("incorrect update of C", expectedSource, p2C.getSource()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), - new MoveArguments(packP2.getResource(), processor.getUpdateReferences()) + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), + new MoveArguments(packP2.getResource(), processor.getUpdateReferences()) }); - } finally { - delete(packP1); - delete(packP2); - } } public void test1() throws Exception{ ParticipantTesting.reset(); - IPackageFragment packP1= null; - IPackageFragment packP2= null; - try { - final String p1Name= "p1"; - final String inDir= "/in/"; - final String outDir= "/out/"; - - packP1= createPackage(p1Name); - ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/A.java", "A.java"); - ICompilationUnit p1B= createCu(packP1, getName() + inDir + p1Name + "/B.java", "B.java"); - - String p2Name= "p2"; - packP2= createPackage(p2Name); - ICompilationUnit p2C= createCu(packP2, getName() + inDir + p2Name + "/C.java", "C.java"); - - String[] handles= ParticipantTesting.createHandles(new Object[] { + final String p1Name= "p1"; + final String inDir= "/in/"; + final String outDir= "/out/"; + + IPackageFragment packP1= createPackage(p1Name); + ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/A.java", "A.java"); + ICompilationUnit p1B= createCu(packP1, getName() + inDir + p1Name + "/B.java", "B.java"); + + String p2Name= "p2"; + IPackageFragment packP2= createPackage(p2Name); + ICompilationUnit p2C= createCu(packP2, getName() + inDir + p2Name + "/C.java", "C.java"); + + String[] handles= ParticipantTesting.createHandles(new Object[] { p1A, p1A.getTypes()[0], p1B, p1B.getTypes()[0], p1A.getResource(), p1B.getResource()}); - IResource[] resources= {}; - IJavaElement[] javaElements= {p1A, p1B}; - IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); - JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); - processor.setReorgQueries(new MockReorgQueries()); - processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); - processor.setUpdateReferences(true); - performDummySearch(); - RefactoringStatus status= performRefactoring(processor, true); + IResource[] resources= {}; + IJavaElement[] javaElements= {p1A, p1B}; + IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); + JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); + processor.setReorgQueries(new MockReorgQueries()); + processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); + processor.setUpdateReferences(true); + performDummySearch(); + RefactoringStatus status= performRefactoring(processor, true); - //-- checks - assertEquals("status should be ok here", null, status); + //-- checks + assertEquals("status should be ok here", null, status); - assertEquals("p1 files", 0, packP1.getChildren().length); - assertEquals("p2 files", 3, packP2.getChildren().length); + assertEquals("p1 files", 0, packP1.getChildren().length); + assertEquals("p2 files", 3, packP2.getChildren().length); - String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/A.java"); - assertEqualLines("incorrect update of A", expectedSource, packP2.getCompilationUnit("A.java").getSource()); + String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/A.java"); + assertEqualLines("incorrect update of A", expectedSource, packP2.getCompilationUnit("A.java").getSource()); - expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/B.java"); - assertEqualLines("incorrect update of B", expectedSource, packP2.getCompilationUnit("B.java").getSource()); + expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/B.java"); + assertEqualLines("incorrect update of B", expectedSource, packP2.getCompilationUnit("B.java").getSource()); - expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/C.java"); - assertEqualLines("incorrect update of C", expectedSource, p2C.getSource()); - ParticipantTesting.testMove( + expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/C.java"); + assertEqualLines("incorrect update of C", expectedSource, p2C.getSource()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), - new MoveArguments(packP2.getResource(), processor.getUpdateReferences()) + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), + new MoveArguments(packP2.getResource(), processor.getUpdateReferences()) }); - } finally { - delete(packP1); - delete(packP2); - } } public void test2() throws Exception{ ParticipantTesting.reset(); - IPackageFragment packP1= null; - IPackageFragment packP2= null; - try { - final String p1Name= "p1"; - final String inDir= "/in/"; - final String outDir= "/out/"; - - packP1= createPackage(p1Name); - ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/A.java", "A.java"); - createCu(packP1, getName() + inDir + p1Name + "/B.java", "B.java"); - - String p2Name= "p2"; - packP2= createPackage(p2Name); - ICompilationUnit p2C= createCu(packP2, getName() + inDir + p2Name + "/C.java", "C.java"); - - String[] handles= ParticipantTesting.createHandles(new Object[] { + final String p1Name= "p1"; + final String inDir= "/in/"; + final String outDir= "/out/"; + + IPackageFragment packP1= createPackage(p1Name); + ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/A.java", "A.java"); + createCu(packP1, getName() + inDir + p1Name + "/B.java", "B.java"); + + String p2Name= "p2"; + IPackageFragment packP2= createPackage(p2Name); + ICompilationUnit p2C= createCu(packP2, getName() + inDir + p2Name + "/C.java", "C.java"); + + String[] handles= ParticipantTesting.createHandles(new Object[] { p1A, p1A.getTypes()[0], p1A.getResource()}); - IResource[] resources= {}; - IJavaElement[] javaElements= {p1A}; - IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); - JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); - processor.setReorgQueries(new MockReorgQueries()); - processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); - processor.setUpdateReferences(true); - performDummySearch(); - RefactoringStatus status= performRefactoring(processor, true); + IResource[] resources= {}; + IJavaElement[] javaElements= {p1A}; + IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); + JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); + processor.setReorgQueries(new MockReorgQueries()); + processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); + processor.setUpdateReferences(true); + performDummySearch(); + RefactoringStatus status= performRefactoring(processor, true); - //-- checks - assertEquals("status should be ok here", null, status); + //-- checks + assertEquals("status should be ok here", null, status); - assertEquals("p1 files", 1, packP1.getChildren().length); - assertEquals("p2 files", 2, packP2.getChildren().length); + assertEquals("p1 files", 1, packP1.getChildren().length); + assertEquals("p2 files", 2, packP2.getChildren().length); - String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/A.java"); - assertEqualLines("incorrect update of A", expectedSource, packP2.getCompilationUnit("A.java").getSource()); + String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/A.java"); + assertEqualLines("incorrect update of A", expectedSource, packP2.getCompilationUnit("A.java").getSource()); - expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p1Name + "/B.java"); - assertEqualLines("incorrect update of B", expectedSource, packP1.getCompilationUnit("B.java").getSource()); + expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p1Name + "/B.java"); + assertEqualLines("incorrect update of B", expectedSource, packP1.getCompilationUnit("B.java").getSource()); - expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/C.java"); - assertEqualLines("incorrect update of C", expectedSource, p2C.getSource()); + expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/C.java"); + assertEqualLines("incorrect update of C", expectedSource, p2C.getSource()); - ParticipantTesting.testMove( + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), }); - } finally { - delete(packP1); - delete(packP2); - } } public void test3() throws Exception{ ParticipantTesting.reset(); - IPackageFragment packP1= null; - IPackageFragment packP3= null; - IPackageFragment packP2= null; - try { - final String p1Name= "p1"; - final String p3Name= "p3"; - final String inDir= "/in/"; - final String outDir= "/out/"; - - packP1= createPackage(p1Name); - packP3= createPackage(p3Name); - ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/Outer.java", "Outer.java"); - createCu(packP3, getName() + inDir + p3Name + "/Test.java", "Test.java"); - - String p2Name= "p2"; - packP2= createPackage(p2Name); - - String[] handles= ParticipantTesting.createHandles(new Object[] { + final String p1Name= "p1"; + final String p3Name= "p3"; + final String inDir= "/in/"; + final String outDir= "/out/"; + + IPackageFragment packP1= createPackage(p1Name); + IPackageFragment packP3= createPackage(p3Name); + ICompilationUnit p1A= createCu(packP1, getName() + inDir + p1Name + "/Outer.java", "Outer.java"); + createCu(packP3, getName() + inDir + p3Name + "/Test.java", "Test.java"); + + String p2Name= "p2"; + IPackageFragment packP2= createPackage(p2Name); + + String[] handles= ParticipantTesting.createHandles(new Object[] { p1A, p1A.getTypes()[0], p1A.getResource()}); - IResource[] resources= {}; - IJavaElement[] javaElements= {p1A}; - IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); - JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); - processor.setReorgQueries(new MockReorgQueries()); - processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); - processor.setUpdateReferences(true); - performDummySearch(); - RefactoringStatus status= performRefactoring(processor, true); - - //-- checks - assertEquals("status should be ok here", null, status); - - assertEquals("p1 files", 0, packP1.getChildren().length); - assertEquals("p2 files", 1, packP2.getChildren().length); - assertEquals("p1 files", 1, packP3.getChildren().length); - - String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/Outer.java"); - assertEqualLines("incorrect update of Outer", expectedSource, packP2.getCompilationUnit("Outer.java").getSource()); - - expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p3Name + "/Test.java"); - assertEqualLines("incorrect update of Test", expectedSource, packP3.getCompilationUnit("Test.java").getSource()); - ParticipantTesting.testMove( + IResource[] resources= {}; + IJavaElement[] javaElements= {p1A}; + IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); + JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); + processor.setReorgQueries(new MockReorgQueries()); + processor.setDestination(ReorgDestinationFactory.createDestination(packP2)); + processor.setUpdateReferences(true); + performDummySearch(); + RefactoringStatus status= performRefactoring(processor, true); + + //-- checks + assertEquals("status should be ok here", null, status); + + assertEquals("p1 files", 0, packP1.getChildren().length); + assertEquals("p2 files", 1, packP2.getChildren().length); + assertEquals("p1 files", 1, packP3.getChildren().length); + + String expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p2Name + "/Outer.java"); + assertEqualLines("incorrect update of Outer", expectedSource, packP2.getCompilationUnit("Outer.java").getSource()); + + expectedSource= getFileContents(getRefactoringPath() + getName() + outDir + p3Name + "/Test.java"); + assertEqualLines("incorrect update of Test", expectedSource, packP3.getCompilationUnit("Test.java").getSource()); + ParticipantTesting.testMove( handles, new MoveArguments[] { - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2, processor.getUpdateReferences()), - new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2, processor.getUpdateReferences()), + new MoveArguments(packP2.getResource(), processor.getUpdateReferences()), }); - } finally { - delete(packP1); - delete(packP2); - delete(packP3); - } } public void testPackageMoveParticipants() throws Exception { ParticipantTesting.reset(); - IPackageFragmentRoot r1= null; - IPackageFragmentRoot r2= null; - try { - r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1"); - r2= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - IPackageFragment p1= r1.createPackageFragment("p1", true, null); - p1.createCompilationUnit("A.java", "public class A {}", true, null); - p1.createCompilationUnit("B.java", "public class B {}", true, null); - - String[] moveHandes= ParticipantTesting.createHandles(new Object[] {p1, p1.getResource()}); - - IResource[] resources= {}; - IJavaElement[] javaElements= {p1}; - IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); - JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); - processor.setReorgQueries(new MockReorgQueries()); - processor.setDestination(ReorgDestinationFactory.createDestination(r2)); - performDummySearch(); - RefactoringStatus status= performRefactoring(processor, false); - - //-- checks - assertEquals("status should be ok here", null, status); - - ParticipantTesting.testMove( + IPackageFragmentRoot r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1"); + IPackageFragmentRoot r2= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); + IPackageFragment p1= r1.createPackageFragment("p1", true, null); + p1.createCompilationUnit("A.java", "public class A {}", true, null); + p1.createCompilationUnit("B.java", "public class B {}", true, null); + + String[] moveHandes= ParticipantTesting.createHandles(new Object[] {p1, p1.getResource()}); + + IResource[] resources= {}; + IJavaElement[] javaElements= {p1}; + IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); + JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); + processor.setReorgQueries(new MockReorgQueries()); + processor.setDestination(ReorgDestinationFactory.createDestination(r2)); + performDummySearch(); + RefactoringStatus status= performRefactoring(processor, false); + + //-- checks + assertEquals("status should be ok here", null, status); + + ParticipantTesting.testMove( moveHandes, new MoveArguments[] { - new MoveArguments(r2, processor.getUpdateReferences()), - new MoveArguments(r2.getResource(), processor.getUpdateReferences()), + new MoveArguments(r2, processor.getUpdateReferences()), + new MoveArguments(r2.getResource(), processor.getUpdateReferences()), }); - } finally { - delete(r1); - delete(r2); - } } public void testPackageMoveParticipants2() throws Exception { fIsPreDeltaTest= false; ParticipantTesting.reset(); - IPackageFragmentRoot r1= null; - IPackageFragmentRoot r2= null; - try { - r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1"); - r2= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - IPackageFragment p1= r1.createPackageFragment("p1", true, null); - r1.createPackageFragment("p1.p2", true, null); - ICompilationUnit c1= p1.createCompilationUnit("A.java", "public class A {}", true, null); - IFile file= ((IContainer)p1.getResource()).getFile(new Path("Z.txt")); - file.create(getStream("123"), true, null); - - String[] moveHandles= ParticipantTesting.createHandles(new Object[] { + IPackageFragmentRoot r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1"); + IPackageFragmentRoot r2= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); + IPackageFragment p1= r1.createPackageFragment("p1", true, null); + r1.createPackageFragment("p1.p2", true, null); + ICompilationUnit c1= p1.createCompilationUnit("A.java", "public class A {}", true, null); + IFile file= ((IContainer)p1.getResource()).getFile(new Path("Z.txt")); + file.create(getStream("123"), true, null); + + String[] moveHandles= ParticipantTesting.createHandles(new Object[] { p1, c1.getResource(), file }); - IResource[] resources= {}; - IJavaElement[] javaElements= {p1}; - IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); - JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); - processor.setReorgQueries(new MockReorgQueries()); - processor.setDestination(ReorgDestinationFactory.createDestination(r2)); - performDummySearch(); - RefactoringStatus status= performRefactoring(processor, false); + IResource[] resources= {}; + IJavaElement[] javaElements= {p1}; + IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); + JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); + processor.setReorgQueries(new MockReorgQueries()); + processor.setDestination(ReorgDestinationFactory.createDestination(r2)); + performDummySearch(); + RefactoringStatus status= performRefactoring(processor, false); - //-- checks - assertEquals("status should be ok here", null, status); + //-- checks + assertEquals("status should be ok here", null, status); - IPath path= r2.getResource().getFullPath(); - path= path.append(p1.getElementName().replace('.', '/')); - IFolder target= ResourcesPlugin.getWorkspace().getRoot().getFolder(path); - String[] createHandles= ParticipantTesting.createHandles(new Object[] {target}); + IPath path= r2.getResource().getFullPath(); + path= path.append(p1.getElementName().replace('.', '/')); + IFolder target= ResourcesPlugin.getWorkspace().getRoot().getFolder(path); + String[] createHandles= ParticipantTesting.createHandles(new Object[] {target}); - ParticipantTesting.testCreate(createHandles); + ParticipantTesting.testCreate(createHandles); - ParticipantTesting.testMove( + ParticipantTesting.testMove( moveHandles, new MoveArguments[] { - new MoveArguments(r2, processor.getUpdateReferences()), - new MoveArguments(target, processor.getUpdateReferences()), - new MoveArguments(target, processor.getUpdateReferences()), + new MoveArguments(r2, processor.getUpdateReferences()), + new MoveArguments(target, processor.getUpdateReferences()), + new MoveArguments(target, processor.getUpdateReferences()), }); - } finally { - delete(r1); - delete(r2); - } } public void testPackageMoveParticipants3() throws Exception { ParticipantTesting.reset(); - IPackageFragmentRoot r1= null; - IPackageFragmentRoot r2= null; - try { - r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1"); - r2= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); - IPackageFragment p1= r1.createPackageFragment("p1", true, null); - r2.createPackageFragment("p1", true, null); - ICompilationUnit c1= p1.createCompilationUnit("A.java", "public class A {}", true, null); - - String[] moveHandles= ParticipantTesting.createHandles(new Object[] { - p1, c1.getResource()}); - String[] deleteHandles= ParticipantTesting.createHandles(new Object[] {p1.getResource()}); + IPackageFragmentRoot r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1"); + IPackageFragmentRoot r2= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2"); + IPackageFragment p1= r1.createPackageFragment("p1", true, null); + r2.createPackageFragment("p1", true, null); + ICompilationUnit c1= p1.createCompilationUnit("A.java", "public class A {}", true, null); - IResource[] resources= {}; - IJavaElement[] javaElements= {p1}; - IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); - JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); - processor.setReorgQueries(new MockReorgQueries()); - processor.setDestination(ReorgDestinationFactory.createDestination(r2)); - performDummySearch(); - RefactoringStatus status= performRefactoring(processor, false); + String[] moveHandles= ParticipantTesting.createHandles(new Object[] { + p1, c1.getResource()}); + String[] deleteHandles= ParticipantTesting.createHandles(new Object[] {p1.getResource()}); + + IResource[] resources= {}; + IJavaElement[] javaElements= {p1}; + IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements); + JavaMoveProcessor processor= (policy.canEnable() ? new JavaMoveProcessor(policy) : null); + processor.setReorgQueries(new MockReorgQueries()); + processor.setDestination(ReorgDestinationFactory.createDestination(r2)); + performDummySearch(); + RefactoringStatus status= performRefactoring(processor, false); - //-- checks - assertEquals("status should be ok here", null, status); + //-- checks + assertEquals("status should be ok here", null, status); - IPath path= r2.getResource().getFullPath(); - path= path.append(p1.getElementName().replace('.', '/')); - IFolder target= ResourcesPlugin.getWorkspace().getRoot().getFolder(path); + IPath path= r2.getResource().getFullPath(); + path= path.append(p1.getElementName().replace('.', '/')); + IFolder target= ResourcesPlugin.getWorkspace().getRoot().getFolder(path); - ParticipantTesting.testDelete(deleteHandles); + ParticipantTesting.testDelete(deleteHandles); - ParticipantTesting.testMove( + ParticipantTesting.testMove( moveHandles, new MoveArguments[] { - new MoveArguments(r2, processor.getUpdateReferences()), - new MoveArguments(target, processor.getUpdateReferences()), + new MoveArguments(r2, processor.getUpdateReferences()), + new MoveArguments(target, processor.getUpdateReferences()), }); - } finally { - delete(r1); - delete(r2); - } } private RefactoringStatus performRefactoring(JavaMoveProcessor processor, boolean providesUndo) throws Exception { diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java index 9fda78ca0b..0f4d1a1bde 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,7 +26,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; @@ -142,16 +141,6 @@ public class PasteActionTest extends RefactoringTest{ assertEqualLines(cuName, getFileContents(getOutputTestFileName(cuName)), getPackageP().getCompilationUnit(cuName + ".java").getSource()); } - private void delete(ICompilationUnit cu) throws Exception { - try { - performDummySearch(); - cu.delete(true, new NullProgressMonitor()); - } catch (JavaModelException e) { - e.printStackTrace(); - //ingore and keep going - } - } - public void test0() throws Exception{ if (BUG_NOT_IMPLEMENTED_YET) { printTestDisabledMessage("not implemented yet"); @@ -161,50 +150,40 @@ public class PasteActionTest extends RefactoringTest{ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try { - IType typeA= cuA.getType("A"); - IType typeB= cuB.getType("B"); + IType typeA= cuA.getType("A"); + IType typeB= cuB.getType("B"); - assertTrue("A does not exist", typeA.exists()); - assertTrue("B does not exist", typeB.exists()); + assertTrue("A does not exist", typeA.exists()); + assertTrue("B does not exist", typeB.exists()); - IJavaElement[] copyJavaElements= {typeA}; - IResource[] copyResources= {}; - IJavaElement[] pasteJavaElements= {typeB}; - IResource[] pasteResources= {}; - PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); - paste.run((IStructuredSelection)paste.getSelection()); - compareContents("A"); - compareContents("B"); - } finally{ - delete(cuA); - delete(cuB); - } + IJavaElement[] copyJavaElements= {typeA}; + IResource[] copyResources= {}; + IJavaElement[] pasteJavaElements= {typeB}; + IResource[] pasteResources= {}; + PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); + paste.run((IStructuredSelection)paste.getSelection()); + compareContents("A"); + compareContents("B"); } public void test2() throws Exception{ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try { - IField fieldY= cuA.getType("A").getField("y"); - IType typeB= cuB.getType("B"); + IField fieldY= cuA.getType("A").getField("y"); + IType typeB= cuB.getType("B"); - assertTrue("y does not exist", fieldY.exists()); - assertTrue("B does not exist", typeB.exists()); + assertTrue("y does not exist", fieldY.exists()); + assertTrue("B does not exist", typeB.exists()); - IJavaElement[] copyJavaElements= {fieldY}; - IResource[] copyResources= {}; - IJavaElement[] pasteJavaElements= {typeB}; - IResource[] pasteResources= {}; - PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); - paste.run((IStructuredSelection)paste.getSelection()); - compareContents("A"); - compareContents("B"); - } finally{ - delete(cuA); - delete(cuB); - } + IJavaElement[] copyJavaElements= {fieldY}; + IResource[] copyResources= {}; + IJavaElement[] pasteJavaElements= {typeB}; + IResource[] pasteResources= {}; + PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); + paste.run((IStructuredSelection)paste.getSelection()); + compareContents("A"); + compareContents("B"); } public void test3() throws Exception{ @@ -212,47 +191,38 @@ public class PasteActionTest extends RefactoringTest{ ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B"); - try { - IJavaElement elem0= cuA.getImport("java.lang.*"); - IImportContainer importContainer= cuB.getImportContainer(); + IJavaElement elem0= cuA.getImport("java.lang.*"); + IImportContainer importContainer= cuB.getImportContainer(); - assertTrue("y does not exist", elem0.exists()); - assertTrue("B does not exist", importContainer.exists()); + assertTrue("y does not exist", elem0.exists()); + assertTrue("B does not exist", importContainer.exists()); - IJavaElement[] copyJavaElements= {elem0}; - IResource[] copyResources= {}; - IJavaElement[] pasteJavaElements= {importContainer}; - IResource[] pasteResources= {}; - PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); - paste.run((IStructuredSelection)paste.getSelection()); - compareContents("A"); - compareContents("B"); - } finally{ - delete(cuA); - delete(cuB); - } + IJavaElement[] copyJavaElements= {elem0}; + IResource[] copyResources= {}; + IJavaElement[] pasteJavaElements= {importContainer}; + IResource[] pasteResources= {}; + PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); + paste.run((IStructuredSelection)paste.getSelection()); + compareContents("A"); + compareContents("B"); } public void test4() throws Exception{ // printTestDisabledMessage("test for bug 20151"); ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - try { - IJavaElement elem0= cuA.getType("A").getMethod("f", new String[0]); - IMethod method= cuA.getType("A").getMethod("f1", new String[0]); - - assertTrue("y does not exist", elem0.exists()); - assertTrue("B does not exist", method.exists()); - - IJavaElement[] copyJavaElements= {elem0}; - IResource[] copyResources= {}; - IJavaElement[] pasteJavaElements= {method}; - IResource[] pasteResources= {}; - PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); - paste.run((IStructuredSelection)paste.getSelection()); - compareContents("A"); - } finally{ - delete(cuA); - } + IJavaElement elem0= cuA.getType("A").getMethod("f", new String[0]); + IMethod method= cuA.getType("A").getMethod("f1", new String[0]); + + assertTrue("y does not exist", elem0.exists()); + assertTrue("B does not exist", method.exists()); + + IJavaElement[] copyJavaElements= {elem0}; + IResource[] copyResources= {}; + IJavaElement[] pasteJavaElements= {method}; + IResource[] pasteResources= {}; + PasteAction paste= verifyEnabled(copyResources, copyJavaElements, pasteResources, pasteJavaElements); + paste.run((IStructuredSelection)paste.getSelection()); + compareContents("A"); } public void testPastingJavaElementIntoWorkingSet() throws Exception { @@ -281,9 +251,7 @@ public class PasteActionTest extends RefactoringTest{ assertEquals("Only one element", 1, ws.getElements().length); assertEquals(folder, ws.getElements()[0]); } finally { - performDummySearch(); PlatformUI.getWorkbench().getWorkingSetManager().removeWorkingSet(ws); - folder.delete(true, false, null); } } @@ -303,7 +271,7 @@ public class PasteActionTest extends RefactoringTest{ public void testPastingExistingElementIntoWorkingSet() throws Exception { IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", - new IAdaptable[] {RefactoringTestSetup.getProject()}); + new IAdaptable[] {RefactoringTestSetup.getProject()}); try { IResource[] resources= {}; IJavaElement[] jElements= {RefactoringTestSetup.getProject()}; @@ -318,7 +286,7 @@ public class PasteActionTest extends RefactoringTest{ public void testPastingChildJavaElementIntoWorkingSet() throws Exception { IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", - new IAdaptable[] {RefactoringTestSetup.getProject()}); + new IAdaptable[] {RefactoringTestSetup.getProject()}); try { IResource[] resources= {}; IJavaElement[] jElements= {getPackageP()}; @@ -335,7 +303,7 @@ public class PasteActionTest extends RefactoringTest{ IFolder folder= RefactoringTestSetup.getProject().getProject().getFolder("folder"); folder.create(true, true, null); IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", - new IAdaptable[] {folder}); + new IAdaptable[] {folder}); IFolder sub= folder.getFolder("sub"); sub.create(true, true, null); try { @@ -346,16 +314,13 @@ public class PasteActionTest extends RefactoringTest{ assertEquals("Only one element", 1, ws.getElements().length); assertEquals(folder, ws.getElements()[0]); } finally { - performDummySearch(); - folder.delete(true, false, null); - sub.delete(true, false, null); PlatformUI.getWorkbench().getWorkingSetManager().removeWorkingSet(ws); } } public void testPastingChildResourceIntoWorkingSetContainingParent() throws Exception { IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", - new IAdaptable[] {RefactoringTestSetup.getProject()}); + new IAdaptable[] {RefactoringTestSetup.getProject()}); IFolder folder= RefactoringTestSetup.getProject().getProject().getFolder("folder"); folder.create(true, true, null); try { @@ -366,8 +331,6 @@ public class PasteActionTest extends RefactoringTest{ assertEquals("Only one element", 1, ws.getElements().length); assertEquals(RefactoringTestSetup.getProject(), ws.getElements()[0]); } finally { - performDummySearch(); - folder.delete(true, false, null); PlatformUI.getWorkbench().getWorkingSetManager().removeWorkingSet(ws); } } @@ -394,61 +357,45 @@ public class PasteActionTest extends RefactoringTest{ public void testPastingTypedResources0() throws Exception { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - try { - IJavaElement methodM= cuA.getType("A").getMethod("m", new String[0]); - IJavaElement[] elemsForClipboard= {methodM}; - IJavaElement[] pasteSelectedJavaElements= {methodM}; - boolean enabled= true; - copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); - compareContents("A"); - } finally{ - delete(cuA); - } + IJavaElement methodM= cuA.getType("A").getMethod("m", new String[0]); + IJavaElement[] elemsForClipboard= {methodM}; + IJavaElement[] pasteSelectedJavaElements= {methodM}; + boolean enabled= true; + copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); + compareContents("A"); } public void testPastingTypedResources1() throws Exception { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - try { - IType typeA= cuA.getType("A"); - IJavaElement fieldF= typeA.getField("f"); - IJavaElement[] elemsForClipboard= {fieldF}; - IJavaElement[] pasteSelectedJavaElements= {typeA}; - boolean enabled= true; - copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); - compareContents("A"); - } finally{ - delete(cuA); - } + IType typeA= cuA.getType("A"); + IJavaElement fieldF= typeA.getField("f"); + IJavaElement[] elemsForClipboard= {fieldF}; + IJavaElement[] pasteSelectedJavaElements= {typeA}; + boolean enabled= true; + copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); + compareContents("A"); } public void testPastingTypedResources2() throws Exception { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - try { - IType typeA= cuA.getType("A"); - IJavaElement fieldF= typeA.getField("f"); - IJavaElement[] elemsForClipboard= {fieldF}; - IJavaElement[] pasteSelectedJavaElements= {typeA}; - boolean enabled= true; - copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); - compareContents("A"); - } finally{ - delete(cuA); - } + IType typeA= cuA.getType("A"); + IJavaElement fieldF= typeA.getField("f"); + IJavaElement[] elemsForClipboard= {fieldF}; + IJavaElement[] pasteSelectedJavaElements= {typeA}; + boolean enabled= true; + copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); + compareContents("A"); } public void testPastingTypedResources3() throws Exception { ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A"); - try { - IType typeA= cuA.getType("A"); - IJavaElement fieldF= typeA.getField("f"); - IJavaElement fieldG= typeA.getField("g"); - IJavaElement[] elemsForClipboard= {fieldF, fieldG}; - IJavaElement[] pasteSelectedJavaElements= {typeA}; - boolean enabled= true; - copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); - compareContents("A"); - } finally{ - delete(cuA); - } + IType typeA= cuA.getType("A"); + IJavaElement fieldF= typeA.getField("f"); + IJavaElement fieldG= typeA.getField("g"); + IJavaElement[] elemsForClipboard= {fieldF, fieldG}; + IJavaElement[] pasteSelectedJavaElements= {typeA}; + boolean enabled= true; + copyAndPasteTypedSources(elemsForClipboard, pasteSelectedJavaElements, enabled); + compareContents("A"); } } diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java index 5c6f4ff5e3..e227285514 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/extensions/ExtensionPointTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,9 +14,6 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.jdt.testplugin.JavaProjectHelper; - -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.resources.IFolder; @@ -57,8 +54,6 @@ public class ExtensionPointTests extends TestCase { StatusContextViewerDescriptor descriptor= StatusContextViewerDescriptor.get(context); assertNotNull(descriptor); assertNotNull(descriptor.createViewer()); - JavaProjectHelper.performDummySearch(); - unit.delete(true, new NullProgressMonitor()); } private IPackageFragment getTestPackage() { diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java index b2e7c74ae7..c780a8d1ad 100644 --- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java +++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java @@ -76,13 +76,11 @@ public class JavaProjectHelper { private static final boolean PERFORM_DUMMY_SEARCH= false; /** - * @deprecated - * @see #RT_STUBS_15 + * @deprecated use {@link #RT_STUBS_15} */ public static final IPath RT_STUBS_13= new Path("testresources/rtstubs.jar"); /** - * @deprecated - * @see #JUNIT_SRC_381 + * @deprecated use {@link #JUNIT_SRC_381} */ public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip"); @@ -269,7 +267,7 @@ public class JavaProjectHelper { } /** - * Removes a IJavaElement. Retries if deletion failed (e.g. because the indexer + * Removes an IJavaElement's resource. Retries if deletion failed (e.g. because the indexer * still locks the file). * * @param elem the element to delete @@ -304,7 +302,7 @@ public class JavaProjectHelper { public static void delete(IResource resource) throws CoreException { for (int i= 0; i < MAX_RETRY; i++) { try { - resource.delete(true, null); + resource.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, null); i= MAX_RETRY; } catch (CoreException e) { if (i == MAX_RETRY - 1) { @@ -312,8 +310,8 @@ public class JavaProjectHelper { throw e; } try { - JavaPlugin.log(new IllegalStateException("sleep before retrying JavaProjectHelper.delete()")); - Thread.sleep(1000); // sleep a second + JavaPlugin.log(new IllegalStateException("sleep before retrying JavaProjectHelper.delete() for " + resource.getLocationURI())); + Thread.sleep(1000); // give other threads time to close the file } catch (InterruptedException e1) { } } |