|
Lines 173-184
public class CopyTest extends RefactoringTest {
Link Here
|
| 173 |
private static final String NEW_FILE_NAME= "UnusedName.gif"; |
173 |
private static final String NEW_FILE_NAME= "UnusedName.gif"; |
| 174 |
private static final String NEW_FOLDER_NAME= "UnusedName"; |
174 |
private static final String NEW_FOLDER_NAME= "UnusedName"; |
| 175 |
private static final String NEW_CU_NAME= "UnusedName"; |
175 |
private static final String NEW_CU_NAME= "UnusedName"; |
|
|
176 |
private String fCuInitialSuggestedName= "unset"; |
| 177 |
private String fResourceInitialSuggestedName= "unset"; |
| 176 |
|
178 |
|
| 177 |
public INewNameQuery createNewCompilationUnitNameQuery(ICompilationUnit cu, String s) { |
179 |
public INewNameQuery createNewCompilationUnitNameQuery(ICompilationUnit cu, String s) { |
|
|
180 |
setCuInitialSuggestedName(s); |
| 178 |
return createStaticQuery(NEW_CU_NAME); |
181 |
return createStaticQuery(NEW_CU_NAME); |
| 179 |
} |
182 |
} |
| 180 |
|
183 |
|
| 181 |
public INewNameQuery createNewResourceNameQuery(IResource res, String s) { |
184 |
public INewNameQuery createNewResourceNameQuery(IResource res, String s) { |
|
|
185 |
setResourceInitialSuggestedName(s); |
| 182 |
if (res instanceof IFile) |
186 |
if (res instanceof IFile) |
| 183 |
return createStaticQuery(NEW_FILE_NAME); |
187 |
return createStaticQuery(NEW_FILE_NAME); |
| 184 |
else |
188 |
else |
|
Lines 204-209
public class CopyTest extends RefactoringTest {
Link Here
|
| 204 |
public INewNameQuery createNewPackageFragmentRootNameQuery(IPackageFragmentRoot root, String initialSuggestedName) { |
208 |
public INewNameQuery createNewPackageFragmentRootNameQuery(IPackageFragmentRoot root, String initialSuggestedName) { |
| 205 |
return createStaticQuery(NEW_PACKAGE_FRAGMENT_ROOT_NAME); |
209 |
return createStaticQuery(NEW_PACKAGE_FRAGMENT_ROOT_NAME); |
| 206 |
} |
210 |
} |
|
|
211 |
|
| 212 |
public String getCuInitialSuggestedName() { |
| 213 |
return fCuInitialSuggestedName; |
| 214 |
} |
| 215 |
|
| 216 |
private void setCuInitialSuggestedName(String cuInitialSuggestedName) { |
| 217 |
this.fCuInitialSuggestedName= cuInitialSuggestedName; |
| 218 |
} |
| 219 |
|
| 220 |
public String getResourceInitialSuggestedName() { |
| 221 |
return fResourceInitialSuggestedName; |
| 222 |
} |
| 223 |
|
| 224 |
public void setResourceInitialSuggestedName(String resourceInitialSuggestedName) { |
| 225 |
fResourceInitialSuggestedName= resourceInitialSuggestedName; |
| 226 |
} |
| 207 |
} |
227 |
} |
| 208 |
|
228 |
|
| 209 |
private static class MockCancelNameQueries implements INewNameQueries{ |
229 |
private static class MockCancelNameQueries implements INewNameQueries{ |
|
Lines 1481-1486
public class CopyTest extends RefactoringTest {
Link Here
|
| 1481 |
ParticipantTesting.testCopy(handles, new CopyArguments[] { |
1501 |
ParticipantTesting.testCopy(handles, new CopyArguments[] { |
| 1482 |
new CopyArguments(destination, log) |
1502 |
new CopyArguments(destination, log) |
| 1483 |
}); |
1503 |
}); |
|
|
1504 |
assertEquals("a2.txt", ((MockNewNameQueries)queries).getResourceInitialSuggestedName()); |
| 1484 |
} |
1505 |
} |
| 1485 |
|
1506 |
|
| 1486 |
public void testCopy_File_to_Same_Folder_Cancel() throws Exception { |
1507 |
public void testCopy_File_to_Same_Folder_Cancel() throws Exception { |
|
Lines 1541-1546
public class CopyTest extends RefactoringTest {
Link Here
|
| 1541 |
assertTrue("new file does not exist after copying", newFile.exists()); |
1562 |
assertTrue("new file does not exist after copying", newFile.exists()); |
| 1542 |
} |
1563 |
} |
| 1543 |
|
1564 |
|
|
|
1565 |
public void testCopy_File_to_Itself_Conflict() throws Exception { |
| 1566 |
IFolder parentFolder= (IFolder) getPackageP().getResource(); |
| 1567 |
String fileName= "A.java"; |
| 1568 |
IFile file= parentFolder.getFile(fileName); |
| 1569 |
file.create(getStream("123"), true, null); |
| 1570 |
String conflictingFileName= "A2.java"; |
| 1571 |
IFile conflictingFile= parentFolder.getFile(conflictingFileName); |
| 1572 |
conflictingFile.create(getStream("456"), true, null); |
| 1573 |
|
| 1574 |
INewNameQueries queries= new MockNewNameQueries(); |
| 1575 |
|
| 1576 |
IJavaElement[] javaElements= {}; |
| 1577 |
IResource[] resources= { file }; |
| 1578 |
JavaCopyProcessor ref= verifyEnabled(resources, javaElements, queries, createReorgQueries()); |
| 1579 |
|
| 1580 |
Object destination= file; |
| 1581 |
verifyValidDestination(ref, destination); |
| 1582 |
|
| 1583 |
assertTrue("source file does not exist before copying", file.exists()); |
| 1584 |
|
| 1585 |
RefactoringStatus status= performRefactoring(ref, false); |
| 1586 |
assertEquals(null, status); |
| 1587 |
|
| 1588 |
assertTrue("source file does not exist after copying", file.exists()); |
| 1589 |
|
| 1590 |
IFile newFile= parentFolder.getFile(MockNewNameQueries.NEW_FILE_NAME); |
| 1591 |
assertTrue("new file does not exist after copying", newFile.exists()); |
| 1592 |
assertEquals("A3.java", ((MockNewNameQueries)queries).getResourceInitialSuggestedName()); |
| 1593 |
} |
| 1594 |
|
| 1544 |
public void testCopy_File_to_AnotherFile() throws Exception { |
1595 |
public void testCopy_File_to_AnotherFile() throws Exception { |
| 1545 |
IFolder parentFolder= (IFolder) getPackageP().getResource(); |
1596 |
IFolder parentFolder= (IFolder) getPackageP().getResource(); |
| 1546 |
String fileName= "a.txt"; |
1597 |
String fileName= "a.txt"; |
|
Lines 1919-1924
public class CopyTest extends RefactoringTest {
Link Here
|
| 1919 |
|
1970 |
|
| 1920 |
ICompilationUnit newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); |
1971 |
ICompilationUnit newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java"); |
| 1921 |
assertTrue("new file does not exist after copying", newCu.exists()); |
1972 |
assertTrue("new file does not exist after copying", newCu.exists()); |
|
|
1973 |
assertEquals("A2", ((MockNewNameQueries)queries).getCuInitialSuggestedName()); |
| 1922 |
} |
1974 |
} |
| 1923 |
|
1975 |
|
| 1924 |
public void testCopy_Cu_to_OtherPackage() throws Exception { |
1976 |
public void testCopy_Cu_to_OtherPackage() throws Exception { |