Lines 13-18
Link Here
|
13 |
import junit.framework.Test; |
13 |
import junit.framework.Test; |
14 |
|
14 |
|
15 |
import org.eclipse.core.resources.IFile; |
15 |
import org.eclipse.core.resources.IFile; |
|
|
16 |
import org.eclipse.core.resources.IResource; |
17 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
16 |
import org.eclipse.core.runtime.CoreException; |
18 |
import org.eclipse.core.runtime.CoreException; |
17 |
import org.eclipse.core.runtime.IProgressMonitor; |
19 |
import org.eclipse.core.runtime.IProgressMonitor; |
18 |
import org.eclipse.core.runtime.QualifiedName; |
20 |
import org.eclipse.core.runtime.QualifiedName; |
Lines 214-220
Link Here
|
214 |
/** |
216 |
/** |
215 |
* Ensures that a CU can be copied to a different package. |
217 |
* Ensures that a CU can be copied to a different package. |
216 |
*/ |
218 |
*/ |
217 |
public void testCopyCU() throws CoreException { |
219 |
public void testCopyCU01() throws CoreException { |
218 |
this.createFolder("/P/src/p1"); |
220 |
this.createFolder("/P/src/p1"); |
219 |
this.createFile( |
221 |
this.createFile( |
220 |
"/P/src/p1/X.java", |
222 |
"/P/src/p1/X.java", |
Lines 236-242
Link Here
|
236 |
* This operation should fail as copying a CU and a CU member at the |
238 |
* This operation should fail as copying a CU and a CU member at the |
237 |
* same time is not supported. |
239 |
* same time is not supported. |
238 |
*/ |
240 |
*/ |
239 |
public void testCopyCUAndType() throws CoreException { |
241 |
public void testCopyCU02() throws CoreException { |
240 |
this.createFolder("/P/src/p1"); |
242 |
this.createFolder("/P/src/p1"); |
241 |
this.createFile( |
243 |
this.createFile( |
242 |
"/P/src/p1/X.java", |
244 |
"/P/src/p1/X.java", |
Lines 257-263
Link Here
|
257 |
/** |
259 |
/** |
258 |
* Ensures that a CU can be copied to a different package, replacing an existing CU. |
260 |
* Ensures that a CU can be copied to a different package, replacing an existing CU. |
259 |
*/ |
261 |
*/ |
260 |
public void testCopyCUForce() throws CoreException { |
262 |
public void testCopyCU03() throws CoreException { |
261 |
this.createFolder("/P/src/p1"); |
263 |
this.createFolder("/P/src/p1"); |
262 |
this.createFile( |
264 |
this.createFile( |
263 |
"/P/src/p1/X.java", |
265 |
"/P/src/p1/X.java", |
Lines 281-287
Link Here
|
281 |
/** |
283 |
/** |
282 |
* Ensures that a CU can be copied from a default package to a non-default package. |
284 |
* Ensures that a CU can be copied from a default package to a non-default package. |
283 |
*/ |
285 |
*/ |
284 |
public void testCopyCUFromDefaultToNonDefault() throws CoreException { |
286 |
public void testCopyCU04() throws CoreException { |
285 |
createFile( |
287 |
createFile( |
286 |
"/P/src/X.java", |
288 |
"/P/src/X.java", |
287 |
"public class X {\n" + |
289 |
"public class X {\n" + |
Lines 301-307
Link Here
|
301 |
* Ensures that a CU can be copied to a different package, |
303 |
* Ensures that a CU can be copied to a different package, |
302 |
* and be renamed. |
304 |
* and be renamed. |
303 |
*/ |
305 |
*/ |
304 |
public void testCopyCURename() throws CoreException { |
306 |
public void testCopyCU05() throws CoreException { |
305 |
this.createFolder("/P/src/p1"); |
307 |
this.createFolder("/P/src/p1"); |
306 |
this.createFile( |
308 |
this.createFile( |
307 |
"/P/src/p1/X.java", |
309 |
"/P/src/p1/X.java", |
Lines 319-325
Link Here
|
319 |
/** |
321 |
/** |
320 |
* Ensures that a read-only CU can be copied to a different package. |
322 |
* Ensures that a read-only CU can be copied to a different package. |
321 |
*/ |
323 |
*/ |
322 |
public void testCopyCUReadOnly() throws CoreException { |
324 |
public void testCopyCU06() throws CoreException { |
323 |
if (!Util.isReadOnlySupported()) { |
325 |
if (!Util.isReadOnlySupported()) { |
324 |
// Do not test if file system does not support read-only attribute |
326 |
// Do not test if file system does not support read-only attribute |
325 |
return; |
327 |
return; |
Lines 359-365
Link Here
|
359 |
* Ensures that a CU can be copied to a different package, |
361 |
* Ensures that a CU can be copied to a different package, |
360 |
* and be renamed, overwriting an existing CU |
362 |
* and be renamed, overwriting an existing CU |
361 |
*/ |
363 |
*/ |
362 |
public void testCopyCURenameForce() throws CoreException { |
364 |
public void testCopyCU07() throws CoreException { |
363 |
this.createFolder("/P/src/p1"); |
365 |
this.createFolder("/P/src/p1"); |
364 |
this.createFile( |
366 |
this.createFile( |
365 |
"/P/src/p1/X.java", |
367 |
"/P/src/p1/X.java", |
Lines 383-389
Link Here
|
383 |
/** |
385 |
/** |
384 |
* Ensures that a CU cannot be copied to a different package,over an existing CU when no force. |
386 |
* Ensures that a CU cannot be copied to a different package,over an existing CU when no force. |
385 |
*/ |
387 |
*/ |
386 |
public void testCopyCUWithCollision() throws CoreException { |
388 |
public void testCopyCU08() throws CoreException { |
387 |
this.createFolder("/P/src/p1"); |
389 |
this.createFolder("/P/src/p1"); |
388 |
this.createFile( |
390 |
this.createFile( |
389 |
"/P/src/p1/X.java", |
391 |
"/P/src/p1/X.java", |
Lines 407-413
Link Here
|
407 |
/** |
409 |
/** |
408 |
* Ensures that a CU cannot be copied to an invalid destination |
410 |
* Ensures that a CU cannot be copied to an invalid destination |
409 |
*/ |
411 |
*/ |
410 |
public void testCopyCUWithInvalidDestination() throws CoreException { |
412 |
public void testCopyCU09() throws CoreException { |
411 |
this.createFolder("/P/src/p1"); |
413 |
this.createFolder("/P/src/p1"); |
412 |
this.createFile( |
414 |
this.createFile( |
413 |
"/P/src/p1/X.java", |
415 |
"/P/src/p1/X.java", |
Lines 422-428
Link Here
|
422 |
/** |
424 |
/** |
423 |
* Ensures that a CU can be copied to a null container |
425 |
* Ensures that a CU can be copied to a null container |
424 |
*/ |
426 |
*/ |
425 |
public void testCopyCUWithNullContainer() throws CoreException { |
427 |
public void testCopyCU10() throws CoreException { |
426 |
this.createFolder("/P/src/p1"); |
428 |
this.createFolder("/P/src/p1"); |
427 |
this.createFile( |
429 |
this.createFile( |
428 |
"/P/src/p1/X.java", |
430 |
"/P/src/p1/X.java", |
Lines 443-449
Link Here
|
443 |
* Ensures that a CU can be copied to along with its server properties. |
445 |
* Ensures that a CU can be copied to along with its server properties. |
444 |
* (Regression test for PR #1G56QT9) |
446 |
* (Regression test for PR #1G56QT9) |
445 |
*/ |
447 |
*/ |
446 |
public void testCopyCUWithServerProperties() throws CoreException { |
448 |
public void testCopyCU11() throws CoreException { |
447 |
this.createFolder("/P/src/p1"); |
449 |
this.createFolder("/P/src/p1"); |
448 |
this.createFile( |
450 |
this.createFile( |
449 |
"/P/src/p1/X.java", |
451 |
"/P/src/p1/X.java", |
Lines 470-475
Link Here
|
470 |
propertyValue |
472 |
propertyValue |
471 |
); |
473 |
); |
472 |
} |
474 |
} |
|
|
475 |
/* |
476 |
* Ensures that the correct scheduling rule is used when copying a CU |
477 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=142990 ) |
478 |
*/ |
479 |
public void testCopyCU12() throws Exception { |
480 |
createFolder("/P/src/p1"); |
481 |
createFile("/P/src/p1/X.java", "package p1; public class X {}"); |
482 |
this.createFolder("/P/src/p2"); |
483 |
|
484 |
IWorkspaceRunnable runnable = new IWorkspaceRunnable(){ |
485 |
public void run(IProgressMonitor monitor) throws CoreException { |
486 |
ICompilationUnit cuSource = getCompilationUnit("/P/src/p1/X.java"); |
487 |
IPackageFragment pkgDest = getPackage("/P/src/p2"); |
488 |
cuSource.copy(pkgDest, null, null, false, null); |
489 |
assertTrue("/P/src/p2/X.java should exist", getCompilationUnit("/P/src/p2/X.java").exists()); |
490 |
} |
491 |
}; |
492 |
getWorkspace().run(runnable, getFolder("/P/src/p2"), IResource.NONE, null); |
493 |
} |
473 |
/** |
494 |
/** |
474 |
* Ensures that a package fragment can be copied to a different package fragment root. |
495 |
* Ensures that a package fragment can be copied to a different package fragment root. |
475 |
*/ |
496 |
*/ |
Lines 743-749
Link Here
|
743 |
/** |
764 |
/** |
744 |
* Ensures that a CU can be moved to a different package. |
765 |
* Ensures that a CU can be moved to a different package. |
745 |
*/ |
766 |
*/ |
746 |
public void testMoveCU() throws CoreException { |
767 |
public void testMoveCU01() throws CoreException { |
747 |
this.createFolder("/P/src/p1"); |
768 |
this.createFolder("/P/src/p1"); |
748 |
this.createFile( |
769 |
this.createFile( |
749 |
"/P/src/p1/X.java", |
770 |
"/P/src/p1/X.java", |
Lines 765-771
Link Here
|
765 |
* This operation should fail as moving a CU and a CU member at the |
786 |
* This operation should fail as moving a CU and a CU member at the |
766 |
* same time is not supported. |
787 |
* same time is not supported. |
767 |
*/ |
788 |
*/ |
768 |
public void testMoveCUAndType() throws CoreException { |
789 |
public void testMoveCU02() throws CoreException { |
769 |
this.createFolder("/P/src/p1"); |
790 |
this.createFolder("/P/src/p1"); |
770 |
this.createFile( |
791 |
this.createFile( |
771 |
"/P/src/p1/X.java", |
792 |
"/P/src/p1/X.java", |
Lines 787-793
Link Here
|
787 |
* Ensures that a CU can be moved to a different package, replacing an |
808 |
* Ensures that a CU can be moved to a different package, replacing an |
788 |
* existing CU. |
809 |
* existing CU. |
789 |
*/ |
810 |
*/ |
790 |
public void testMoveCUForce() throws CoreException { |
811 |
public void testMoveCU03() throws CoreException { |
791 |
this.createFolder("/P/src/p1"); |
812 |
this.createFolder("/P/src/p1"); |
792 |
this.createFile( |
813 |
this.createFile( |
793 |
"/P/src/p1/X.java", |
814 |
"/P/src/p1/X.java", |
Lines 812-818
Link Here
|
812 |
* Ensures that a CU can be moved to a different package, |
833 |
* Ensures that a CU can be moved to a different package, |
813 |
* be renamed |
834 |
* be renamed |
814 |
*/ |
835 |
*/ |
815 |
public void testMoveCURename() throws CoreException { |
836 |
public void testMoveCU04() throws CoreException { |
816 |
this.createFolder("/P/src/p1"); |
837 |
this.createFolder("/P/src/p1"); |
817 |
this.createFile( |
838 |
this.createFile( |
818 |
"/P/src/p1/X.java", |
839 |
"/P/src/p1/X.java", |
Lines 831-837
Link Here
|
831 |
* Ensures that a CU can be moved to a different package, |
852 |
* Ensures that a CU can be moved to a different package, |
832 |
* be renamed, overwriting an existing resource. |
853 |
* be renamed, overwriting an existing resource. |
833 |
*/ |
854 |
*/ |
834 |
public void testMoveCURenameForce() throws CoreException { |
855 |
public void testMoveCU05() throws CoreException { |
835 |
this.createFolder("/P/src/p1"); |
856 |
this.createFolder("/P/src/p1"); |
836 |
this.createFile( |
857 |
this.createFile( |
837 |
"/P/src/p1/X.java", |
858 |
"/P/src/p1/X.java", |
Lines 856-862
Link Here
|
856 |
* Ensures that a CU cannot be moved to a different package, replacing an |
877 |
* Ensures that a CU cannot be moved to a different package, replacing an |
857 |
* existing CU when not forced. |
878 |
* existing CU when not forced. |
858 |
*/ |
879 |
*/ |
859 |
public void testMoveCUWithCollision() throws CoreException { |
880 |
public void testMoveCU06() throws CoreException { |
860 |
this.createFolder("/P/src/p1"); |
881 |
this.createFolder("/P/src/p1"); |
861 |
this.createFile( |
882 |
this.createFile( |
862 |
"/P/src/p1/X.java", |
883 |
"/P/src/p1/X.java", |
Lines 880-886
Link Here
|
880 |
/** |
901 |
/** |
881 |
* Ensures that a CU cannot be moved to an invalid destination. |
902 |
* Ensures that a CU cannot be moved to an invalid destination. |
882 |
*/ |
903 |
*/ |
883 |
public void testMoveCUWithInvalidDestination() throws CoreException { |
904 |
public void testMoveCU07() throws CoreException { |
884 |
this.createFolder("/P/src/p1"); |
905 |
this.createFolder("/P/src/p1"); |
885 |
this.createFile( |
906 |
this.createFile( |
886 |
"/P/src/p1/X.java", |
907 |
"/P/src/p1/X.java", |
Lines 895-901
Link Here
|
895 |
/** |
916 |
/** |
896 |
* Ensures that a CU cannot be moved to a null container |
917 |
* Ensures that a CU cannot be moved to a null container |
897 |
*/ |
918 |
*/ |
898 |
public void testMoveCUWithNullContainer() throws CoreException { |
919 |
public void testMoveCU08() throws CoreException { |
899 |
this.createFolder("/P/src/p1"); |
920 |
this.createFolder("/P/src/p1"); |
900 |
this.createFile( |
921 |
this.createFile( |
901 |
"/P/src/p1/X.java", |
922 |
"/P/src/p1/X.java", |
Lines 912-917
Link Here
|
912 |
} |
933 |
} |
913 |
assertTrue("Should not be able to move a cu to a null container", false); |
934 |
assertTrue("Should not be able to move a cu to a null container", false); |
914 |
} |
935 |
} |
|
|
936 |
/* |
937 |
* Ensures that the correct scheduling rule is used when moving a CU |
938 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=142990 ) |
939 |
*/ |
940 |
public void testMoveCU09() throws Exception { |
941 |
createFolder("/P/src/p1"); |
942 |
createFile("/P/src/p1/X.java", "package p1; public class X {}"); |
943 |
this.createFolder("/P/src/p2"); |
944 |
|
945 |
IWorkspaceRunnable runnable = new IWorkspaceRunnable(){ |
946 |
public void run(IProgressMonitor monitor) throws CoreException { |
947 |
ICompilationUnit cuSource = getCompilationUnit("/P/src/p1/X.java"); |
948 |
IPackageFragment pkgDest = getPackage("/P/src/p2"); |
949 |
cuSource.move(pkgDest, null, null, false, null); |
950 |
assertFalse("/P/src/p1/X.java should no longer exist", cuSource.exists()); |
951 |
} |
952 |
}; |
953 |
getWorkspace().run(runnable, getFolder("/P/src"), IResource.NONE, null); |
954 |
} |
915 |
/** |
955 |
/** |
916 |
* Ensures that a package fragment can be moved to a different package fragment root. |
956 |
* Ensures that a package fragment can be moved to a different package fragment root. |
917 |
*/ |
957 |
*/ |