Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-28 02:26:37 +0000
committerMichael Valenta2002-05-28 02:26:37 +0000
commit25cbee6f9acfa32a7e85d271988a88c08b62651e (patch)
tree1b13d26c3d9f8501fc04c9b47965268ba1dc325d /tests/org.eclipse.team.tests.core
parenta477ec46690e3ac8b919234b429a19e474de672c (diff)
downloadeclipse.platform.team-25cbee6f9acfa32a7e85d271988a88c08b62651e.tar.gz
eclipse.platform.team-25cbee6f9acfa32a7e85d271988a88c08b62651e.tar.xz
eclipse.platform.team-25cbee6f9acfa32a7e85d271988a88c08b62651e.zip
Ensuring that get,put, isDirty and isOutOfDate support synchronization
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java1
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java54
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java16
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java24
4 files changed, 43 insertions, 52 deletions
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java
index 34a86df30..f93f74a9f 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTargetTests.java
@@ -35,6 +35,7 @@ public class AllTargetTests extends EclipseWorkspaceTest {
TestSuite suite = new TestSuite();
suite.addTest(TargetProviderTests.suite());
suite.addTest(RemoteResourceTests.suite());
+ suite.addTest(SyncElementTest.suite());
return new TargetTestSetup(suite);
}
}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
index 56ab5c814..5c5026620 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
@@ -114,6 +114,25 @@ public class SyncElementTest extends TeamTest {
IResource[] resources=getResources(project,resourceNames);
provider.put(resources,null);
}
+ /**
+ * Add the resources to an existing container and optionally upload them to the remote server
+ */
+ public IResource[] addResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
+ IResource[] newResources = buildResources(container, hierarchy, false);
+ if (checkin) getProvider(container).put(newResources, DEFAULT_MONITOR);
+ return newResources;
+ }
+ /**
+ * Delete the resources from an existing container and optionally add the changes to the remote server
+ */
+ public IResource[] deleteResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
+ IResource[] resources = getResources(container, hierarchy);
+ for (int i = 0; i < resources.length; i++) {
+ resources[0].delete(true, null);
+ }
+ if (checkin) getProvider(container).put(resources, DEFAULT_MONITOR);
+ return resources;
+ }
/*
* Perform a simple test that checks for the different types of incoming changes
*/
@@ -129,7 +148,7 @@ public class SyncElementTest extends TeamTest {
addResources(copy, new String[] { "folder2/folder3/add.txt" }, false);
deleteResources(copy, new String[] { "folder1/b.txt" }, false);
sleep(1500); // Wait so that timestamp of modified file differs from original
- putResourcesOntoTarget(copy,new String[] { "folder1/a.txt","folder2/folder3/add.txt"/*,"folder1/b.txt"*/ });
+ putResourcesOntoTarget(copy,new String[] { "folder1/a.txt","folder2/folder3/add.txt","folder1/b.txt" });
// Get the sync tree for the project
IRemoteSyncElement tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
@@ -154,6 +173,15 @@ public class SyncElementTest extends TeamTest {
IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION });
// Verify that we are in sync (except for "folder1/b.txt", which was deleted)
+ getResourcesFromTarget(project,
+ new String[] {
+ "file1.txt",
+ "folder1/",
+ "folder1/a.txt",
+ "folder1/b.txt",
+ "folder2/",
+ "folder2/folder3/",
+ "folder2/folder3/add.txt" });
tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
assertSyncEquals(
"testIncomingChanges",
@@ -321,10 +349,10 @@ public class SyncElementTest extends TeamTest {
new String[] { "file.txt", "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt" },
new int[] {
IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION,
- IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION,
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION });
// Release the conflict cases (MERGE is not required for add3.txt but we do it anyway to ensure it doesn't cause problems)
@@ -428,8 +456,8 @@ public class SyncElementTest extends TeamTest {
IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE,
- IRemoteSyncElement.IN_SYNC,
- IRemoteSyncElement.IN_SYNC });
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT });
// Catch up to remote changes.
@@ -440,7 +468,9 @@ public class SyncElementTest extends TeamTest {
"testDeletionConflictsA",
tree,
new String[] { "delete1.txt", "delete2.txt" },
- new int[] { IRemoteSyncElement.IN_SYNC, IRemoteSyncElement.IN_SYNC });
+ new int[] {
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT,
+ IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE | IRemoteSyncElement.PSEUDO_CONFLICT });
assertDeleted("testDeletionConflictsA", tree, new String[] { "delete3.txt", "delete4.txt", "delete5.txt" });
// Now redo the test case for case B
@@ -581,15 +611,15 @@ public class SyncElementTest extends TeamTest {
IProject copy = checkoutCopy(project, "-copy");
IFile file = copy.getFile("file1.txt");
sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "", true);
+ appendText(file, "a", true);
file = copy.getFile("folder1/a.txt");
file.setContents(getRandomContents(), false, false, null);
- putResourcesOntoTarget(project,new String[] { "file1.txt","folder1/a.txt" });
+ putResourcesOntoTarget(copy, new String[] { "file1.txt","folder1/a.txt" });
// Make the same modifications to the original
file = project.getFile("file1.txt");
sleep(1500); // Wait so that timestamp of modified file differs from original
- appendText(file, "", false);
+ appendText(file, "a", false);
file = project.getFile("folder1/a.txt");
file.setContents(new ByteArrayInputStream("unique text".getBytes()), false, false, null);
@@ -661,7 +691,7 @@ public class SyncElementTest extends TeamTest {
assertDeleted("testFolderDeletion", tree, new String[] { "folder1/a.txt" });
// Commit folder1/folder2/file.txt
- putResourcesOntoTarget(project, new String[] { "folder1/folder2/file.txt" });
+ putResourcesOntoTarget(project, new String[] { "folder1/", "folder1/folder2/", "folder1/folder2/file.txt" });
// Resync and verify that all are deleted
tree = getRemoteSyncTree(project, DEFAULT_MONITOR);
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
index 130024e7c..e8d7544fa 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
@@ -216,22 +216,6 @@ public class TargetProviderTests extends TeamTest {
fail("Shouldn't be able to get files that don't exist");
} catch (TeamException e) {}
}
- public void testCanGetWithPhantoms() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("canget");
- IResource[] resources = buildEmptyResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- for (int i = 0; i < resources.length; i++) {
- assertTrue("Shouldn't be able to retrieve phantom resources.",!target.canGet(resources[i]));
- }
- }
- public void testCanPutWithPhantoms() throws CoreException, TeamException {
- IProject project = getUniqueTestProject("canput");
- IResource[] resources = buildEmptyResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
- TargetProvider target = createProvider(project);
- for (int i = 0; i < resources.length; i++) {
- assertTrue("Shouldn't be able to upload phantom resources.",!target.canPut(resources[i]));
- }
- }
/**
* @see TestCase#setUp()
*/
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
index 5db655126..224d7de4a 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
@@ -225,14 +225,6 @@ public class TeamTest extends EclipseWorkspaceTest {
}
file.setContents(new ByteArrayInputStream(bos.toByteArray()), false, false, DEFAULT_MONITOR);
}
- /**
- * Add the resources to an existing container and optionally upload them to the remote server
- */
- public IResource[] addResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] newResources = buildResources(container, hierarchy, false);
- if (checkin) getProvider(container).put(newResources, DEFAULT_MONITOR);
- return newResources;
- }
/*
* Get the resources for the given resource names
*/
@@ -246,20 +238,4 @@ public class TeamTest extends EclipseWorkspaceTest {
}
return resources;
}
- /**
- * Delete the resources from an existing container and optionally add the changes to the remote server
- */
- public IResource[] deleteResources(IProject container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
- IResource[] resources = getResources(container, hierarchy);
- for (int i = 0; i < resources.length; i++) {
- resources[0].delete(true, null);
- }
- if (checkin) {
- //delete the resources on the server as well.
- //TargetProvider target=getProvider(container);
- //IRemoteResource remote=target.getRemoteResourceFor(resources[i]);
- //Currently the API does not support deletion of remote resources (well, according to Jean-Michael, anyway).
- }
- return resources;
- }
}

Back to the top