|
Lines 16-25
Link Here
|
| 16 |
|
16 |
|
| 17 |
import junit.framework.Test; |
17 |
import junit.framework.Test; |
| 18 |
import junit.framework.TestSuite; |
18 |
import junit.framework.TestSuite; |
|
|
19 |
|
| 19 |
import org.eclipse.core.internal.resources.*; |
20 |
import org.eclipse.core.internal.resources.*; |
| 20 |
import org.eclipse.core.resources.*; |
21 |
import org.eclipse.core.resources.*; |
| 21 |
import org.eclipse.core.runtime.*; |
22 |
import org.eclipse.core.runtime.*; |
| 22 |
import org.eclipse.core.tests.harness.EclipseWorkspaceTest; |
23 |
import org.eclipse.core.tests.harness.EclipseWorkspaceTest; |
|
|
24 |
|
| 23 |
// |
25 |
// |
| 24 |
public class ISynchronizerTest extends EclipseWorkspaceTest { |
26 |
public class ISynchronizerTest extends EclipseWorkspaceTest { |
| 25 |
public static int NUMBER_OF_PARTNERS = 100; |
27 |
public static int NUMBER_OF_PARTNERS = 100; |
|
Lines 912-916
Link Here
|
| 912 |
} catch (CoreException e) { |
914 |
} catch (CoreException e) { |
| 913 |
fail("9.1", e); |
915 |
fail("9.1", e); |
| 914 |
} |
916 |
} |
|
|
917 |
} |
| 918 |
/** |
| 919 |
* Removes resources, sets sync info to <code>null</code> and ensures the |
| 920 |
* phantoms do not exist any more (see bug 3024) |
| 921 |
*/ |
| 922 |
public void testPhantomRemoval() { |
| 923 |
final QualifiedName partner = new QualifiedName("org.eclipse.core.tests.resources", "myTarget"); |
| 924 |
final IWorkspace workspace = getWorkspace(); |
| 925 |
final ISynchronizer synchronizer = workspace.getSynchronizer(); |
| 926 |
|
| 927 |
// set up |
| 928 |
synchronizer.add(partner); |
| 929 |
IProject project = workspace.getRoot().getProject("MyProject"); |
| 930 |
IFolder folder = project.getFolder("foo"); |
| 931 |
IFile file1 = folder.getFile("file1.txt"); |
| 932 |
IFile file2 = folder.getFile("file2.txt"); |
| 933 |
ensureExistsInWorkspace(new IResource[] {file1, file2}, true); |
| 934 |
|
| 935 |
// sets sync info for the folder and its children |
| 936 |
try { |
| 937 |
synchronizer.setSyncInfo(partner, folder, getRandomString().getBytes()); |
| 938 |
synchronizer.setSyncInfo(partner, file1, getRandomString().getBytes()); |
| 939 |
synchronizer.setSyncInfo(partner, file2, getRandomString().getBytes()); |
| 940 |
} catch (CoreException ce) { |
| 941 |
fail("1.0",ce); |
| 942 |
} |
| 943 |
|
| 944 |
// 1) tests with one child first |
| 945 |
assertTrue("1.1", file1.exists()); |
| 946 |
assertTrue("1.2", !file1.isPhantom()); |
| 947 |
// deletes file |
| 948 |
try { |
| 949 |
file1.delete(true,getMonitor()); |
| 950 |
} catch (CoreException ce) { |
| 951 |
fail("2.0",ce); |
| 952 |
} |
| 953 |
// file is now a phantom resource |
| 954 |
assertTrue("2.1", !file1.exists()); |
| 955 |
assertTrue("2.2", file1.isPhantom()); |
| 956 |
// removes sync info |
| 957 |
try { |
| 958 |
synchronizer.setSyncInfo(partner, file1, null); |
| 959 |
} catch (CoreException ce) { |
| 960 |
fail("3.0",ce); |
| 961 |
} |
| 962 |
// phantom should not exist any more |
| 963 |
assertTrue("3.1", !file1.exists()); |
| 964 |
assertTrue("3.2", !file1.isPhantom()); |
| 965 |
|
| 966 |
// 2) tests with the folder and remaining child |
| 967 |
assertTrue("4.1", folder.exists()); |
| 968 |
assertTrue("4.2", !folder.isPhantom()); |
| 969 |
assertTrue("4.3", file2.exists()); |
| 970 |
assertTrue("4.4", !file2.isPhantom()); |
| 971 |
// deletes the folder and its only child |
| 972 |
try { |
| 973 |
folder.delete(true,getMonitor()); |
| 974 |
} catch (CoreException ce) { |
| 975 |
fail("5.0",ce); |
| 976 |
} |
| 977 |
// both resources are now phantom resources |
| 978 |
assertTrue("5.1", !folder.exists()); |
| 979 |
assertTrue("5.2", folder.isPhantom()); |
| 980 |
assertTrue("5.3", !file2.exists()); |
| 981 |
assertTrue("5.4", file2.isPhantom()); |
| 982 |
// removes only folder sync info |
| 983 |
try { |
| 984 |
synchronizer.setSyncInfo(partner, folder, null); |
| 985 |
} catch (CoreException ce) { |
| 986 |
fail("6.0",ce); |
| 987 |
} |
| 988 |
// phantoms should not exist any more |
| 989 |
assertTrue("6.1", !folder.exists()); |
| 990 |
assertTrue("6.2", !folder.isPhantom()); |
| 991 |
assertTrue("6.3", !file2.exists()); |
| 992 |
assertTrue("6.4", !file2.isPhantom()); |
| 993 |
|
| 994 |
// clean-up |
| 995 |
synchronizer.remove(partner); |
| 996 |
ensureDoesNotExistInWorkspace(project); |
| 915 |
} |
997 |
} |
| 916 |
} |
998 |
} |