Added method to ensure that files are modified
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
index bcbbf94..b833655 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
@@ -89,7 +89,7 @@
 		return newResources;
 	}
 	
-	public void appendText(IResource resource, String text, boolean prepend) throws CoreException, IOException {
+	public void appendText(IResource resource, String text, boolean prepend) throws CoreException, IOException, CVSException {
 		IFile file = (IFile)resource;
 		InputStream in = file.getContents();
 		ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -107,7 +107,7 @@
 		} finally {
 			in.close();
 		}
-		file.setContents(new ByteArrayInputStream(bos.toByteArray()), false, false, DEFAULT_MONITOR);
+		setContentsAndEnsureModified(file, bos.toString());
 	}
 	
 	/**
@@ -119,7 +119,7 @@
 			IResource resource = container.findMember(hierarchy[i]);
 			if (resource.getType() == IResource.FILE) {
 				changedResources.add(resource);
-				((IFile)resource).setContents(getRandomContents(), false, false, null);
+				setContentsAndEnsureModified((IFile)resource);
 			}
 		}
 		IResource[] resources = (IResource[])changedResources.toArray(new IResource[changedResources.size()]);
@@ -547,7 +547,7 @@
 		getProvider(project).add((IResource[]) resourcesToAdd.toArray(new IResource[resourcesToAdd.size()]), IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
 		getProvider(project).checkin(new IResource[] {project}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
 		// Pause to ensure that future operations happen later than timestamp of committed resources
-		JUnitTestCase.waitMsec(1500);
+		waitMsec(1500);
 	}
 	
 	/**
@@ -557,5 +557,31 @@
 	public InputStream getRandomContents() {
 		return getRandomContents(RANDOM_CONTENT_SIZE);
 	}
+	
+	protected void setContentsAndEnsureModified(IFile file) throws CoreException, CVSException {
+		setContentsAndEnsureModified(file, getRandomContents().toString());
+	}
+	
+	protected void setContentsAndEnsureModified(IFile file, String contents) throws CoreException, CVSException {
+		ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
+		int count = 0;
+		if (contents == null) contents ="";
+		do {
+			file.setContents(new ByteArrayInputStream(contents.getBytes()), false, false, null);
+			assertTrue("Timestamp granularity is too small. Increase test wait factor", count <= CVSTestSetup.WAIT_FACTOR);
+			if (!cvsFile.isModified()) {
+				waitMsec(1500);
+				count++;
+			}
+		} while (!cvsFile.isModified());
+	}
+	
+	public void waitMsec(int msec) {	
+		try {
+			Thread.currentThread().sleep(msec);
+		} catch(InterruptedException e) {
+			fail("wait-problem");
+		}
+	}
 }
 
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
index 43f4dc9..22466da 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
@@ -114,9 +114,7 @@
 		
 		// Perform some operations on the project
 		IResource[] newResources = buildResources(project, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
-		IFile file = project.getFile("changed.txt");
-		JUnitTestCase.waitMsec(1500);
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(project.getFile("changed.txt"));
 		getProvider(project).add(newResources, IResource.DEPTH_ZERO, DEFAULT_MONITOR);
 		getProvider(project).delete(new IResource[] {project.getFile("deleted.txt")}, DEFAULT_MONITOR);
 		assertIsModified("testDeepCheckin: ", newResources);
@@ -153,9 +151,7 @@
 		
 		// Perform some operations on the copy
 		addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
-		IFile file = copy.getFile("changed.txt");
-		JUnitTestCase.waitMsec(1500);
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(copy.getFile("changed.txt"));
 		getProvider(copy).delete(new IResource[] {copy.getFile("deleted.txt")}, DEFAULT_MONITOR);
 		
 		// Commit the copy and update the project
@@ -171,7 +167,6 @@
 		
 		// Perform some operations on the copy and commit
 		IProject copy = checkoutCopy(project, "-copy");
-		JUnitTestCase.waitMsec(1500);
 		addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
 		changeResources(copy, new String[] {"changed.txt"}, false);
 		deleteResources(copy, new String[] {"deleted.txt"}, false);
@@ -257,9 +252,7 @@
 		IProject copy = checkoutCopy(project, "-copy");
 		//addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
 		deleteResources(copy, new String[] {"deleted.txt"}, false);
-		IFile file = copy.getFile("changed.txt");
-		JUnitTestCase.waitMsec(1500);
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(copy.getFile("changed.txt"));
 
 		// get the remote conetns
 		getProvider(copy).get(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
@@ -349,7 +342,7 @@
 		map.put(project.getFile("folder1/a.xtxt"), ksubst);
 		map.put(project.getFile("added.xtxt"), ksubst);
 		
-		JUnitTestCase.waitMsec(1500);
+		waitMsec(1500);
 		IStatus status = getProvider(project).setKeywordSubstitution(map, null);
 		assertTrue("Status should be ok, was: " + status.toString(), status.isOK());
 		assertHasKSubstOption(project, "binary.xbin", ksubst);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
index c4c5a74..a870bae 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
@@ -141,17 +141,6 @@
 		}
 		return project;
 	}
-	
-	/**
-	 * wait milliseconds to continou the execution
-	 */
-	protected static void waitMsec(int msec) {	
-		try {
-			Thread.currentThread().sleep(msec);
-		} catch(InterruptedException e) {
-			fail("wait-problem");
-		}
-	}
 
 	/*
 	 * Test the following definition
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
index 0db51cc..df097af 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
@@ -80,9 +80,7 @@
 		
 		// Make some changes to the copy and commit
 		IResource[] newResources = buildResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
-		IFile file = copy.getFile("changed.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(copy.getFile("changed.txt"));
 		CVSTeamProvider provider = getProvider(copy);
 		provider.add(newResources, IResource.DEPTH_ZERO, DEFAULT_MONITOR);
 		provider.delete(new IResource[] {copy.getFile("deleted.txt")}, DEFAULT_MONITOR);
@@ -149,9 +147,7 @@
 
 		// Checkout and modify a copy
 		IProject copy = checkoutCopy(project, "-copy");
-		IFile file = copy.getFile("folder2/folder3/c.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(copy.getFile("folder2/folder3/c.txt"));
 		addResources(copy, new String[] { "folder2/folder3/add.txt" }, false);
 		getProvider(copy).delete(new IResource[] {copy.getFile("folder2/folder3/b.txt")}, DEFAULT_MONITOR);
 		getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
@@ -211,8 +207,7 @@
 	 	// Create a project with an empty file
 		IProject project = createProject("testEmptyFile", new String[] { "file.txt"});
 		IFile file = project.getFile("file.txt");
-		JUnitTestCase.waitMsec(1500);
-		file.setContents(new ByteArrayInputStream(new byte[0]), false, false, DEFAULT_MONITOR);
+		setContentsAndEnsureModified(file, "");
 		commitResources(project, new String[] {"file.txt"});
 		
 		ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(file);
@@ -231,15 +226,12 @@
 	 	
 	 	// Create a project with an empty file
 		IProject project = createProject("testFileRevisions", new String[] { "file.txt"});
-		IFile file = project.getFile("file.txt");
-		JUnitTestCase.waitMsec(1500);
-		file.setContents(new ByteArrayInputStream("hi there".getBytes()), false, false, DEFAULT_MONITOR);
+		setContentsAndEnsureModified(project.getFile("file.txt"), "hi there");
 		commitResources(project, new String[] {"file.txt"});
-		JUnitTestCase.waitMsec(1500);
-		file.setContents(new ByteArrayInputStream("bye there".getBytes()), false, false, DEFAULT_MONITOR);
+		setContentsAndEnsureModified(project.getFile("file.txt"), "bye there");
 		commitResources(project, new String[] {"file.txt"});
 
-		ICVSRemoteFile remote = (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(file);
+		ICVSRemoteFile remote = (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("file.txt"));
 		ILogEntry[] entries = remote.getLogEntries(DEFAULT_MONITOR);
 		for (int i=0;i<entries.length;i++) {
 			InputStream in = entries[i].getRemoteFile().getContents(DEFAULT_MONITOR);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java
index 4f59e27..85665de 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java
@@ -138,12 +138,9 @@
 		
 		// Checkout and modify a copy
 		IProject copy = checkoutCopy(project, "-copy");
-		IFile file = copy.getFile("folder1/a.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(copy.getFile("folder1/a.txt"));
 		addResources(copy, new String[] { "folder2/folder3/add.txt" }, false);
 		deleteResources(copy, new String[] {"folder1/b.txt"}, false);
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
 		getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
 
 		// Get the sync tree for the project
@@ -191,9 +188,7 @@
 		IProject project = createProject("testIncomingChanges", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
 		
 		// Make some modifications
-		IFile file = project.getFile("folder1/a.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
 		addResources(project, new String[] { "folder2/folder3/add.txt" }, false);
 		deleteResources(project, new String[] {"folder1/b.txt"}, false);
 
@@ -285,20 +280,13 @@
 		
 		// Checkout a copy and make some modifications
 		IProject copy = checkoutCopy(project, "-copy");
-		IFile file = copy.getFile("file1.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		appendText(file, "prefix\n", true);
-		file = copy.getFile("folder1/a.txt");
-		file.setContents(new ByteArrayInputStream("Use a custom string to avoid intermitant errors!".getBytes()), false, false, null);
+		appendText(copy.getFile("file1.txt"), "prefix\n", true);
+		setContentsAndEnsureModified(copy.getFile("folder1/a.txt"), "Use a custom string to avoid intermitant errors!");
 		getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
 
 		// Make the same modifications to the original (We need to test both M and C!!!)
-		file = project.getFile("file1.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		appendText(file, "\npostfix", false); // This will test merges (M)
-		file = project.getFile("folder1/a.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null); // This will test conflicts (C)
+		appendText(project.getFile("file1.txt"), "\npostfix", false); // This will test merges (M)
+		setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
 
 		// Get the sync tree for the project
 		IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
@@ -444,24 +432,17 @@
 		IFile file = project.getFile("delete1.txt"); // WARNING: This does a "cvs remove"!!!
 		file.delete(false, DEFAULT_MONITOR);
 		deleteResources(project, new String[] {"delete2.txt"}, false);
-		file = project.getFile("delete3.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(project.getFile("delete3.txt"));
 		file = project.getFile("delete4.txt");
 		file.delete(false, DEFAULT_MONITOR);
 		deleteResources(project, new String[] {"delete5.txt"}, false);
 		
 		// Checkout a copy and commit the deletion
 		IProject copy = checkoutCopy(project, "-copy");
-		file = copy.getFile("delete1.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
-		file = copy.getFile("delete2.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(copy.getFile("delete1.txt"));
+		setContentsAndEnsureModified(copy.getFile("delete2.txt"));
 		deleteResources(copy, new String[] {"delete3.txt", "delete4.txt", "delete5.txt"}, false);
 		getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
-
 		
 		// Get the sync tree for the project
 		IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
@@ -498,25 +479,18 @@
 		file = project.getFile("delete1.txt");
 		file.delete(false, DEFAULT_MONITOR);
 		deleteResources(project, new String[] {"delete2.txt"}, false);
-		file = project.getFile("delete3.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(project.getFile("delete3.txt"));
 		file = project.getFile("delete4.txt");
 		file.delete(false, DEFAULT_MONITOR);
 		deleteResources(project, new String[] {"delete5.txt"}, false);
 		
 		// Checkout a copy and commit the deletion
 		copy = checkoutCopy(project, "-copy");
-		file = copy.getFile("delete1.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
-		file = copy.getFile("delete2.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(copy.getFile("delete1.txt"));
+		setContentsAndEnsureModified(copy.getFile("delete2.txt"));
 		deleteResources(copy, new String[] {"delete3.txt", "delete4.txt", "delete5.txt"}, false);
 		getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
 
-		
 		// Get the sync tree for the project
 		tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
 		assertSyncEquals("testDeletionConflictsB", tree, 
@@ -690,20 +664,14 @@
 		
 		// Checkout a copy and make some modifications
 		IProject copy = checkoutCopy(project, "-copy");
-		IFile file = copy.getFile("file1.txt");
-		appendText(file, "", true);
-		file = copy.getFile("folder1/a.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		appendText(copy.getFile("file1.txt"), "", true);
+		setContentsAndEnsureModified(copy.getFile("folder1/a.txt"));
 		getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
 
 		// Make the same modifications to the original
-		file = project.getFile("file1.txt");
-		appendText(file, "", false);
-		file = project.getFile("folder1/a.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(new ByteArrayInputStream("unique text".getBytes()), false, false, null);
-
+		appendText(project.getFile("file1.txt"), "", false);
+		setContentsAndEnsureModified(project.getFile("folder1/a.txt"), "unique text");
+		
 		// Get the sync tree for the project
 		IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
 		assertSyncEquals("testGranularityContents", tree, 
@@ -723,9 +691,7 @@
 		IProject copy = checkoutCopy(project, "-copy");
 		
 		// Make some modifications
-		IFile file = project.getFile("folder1/a.txt");
-		JUnitTestCase.waitMsec(1500); // Wait so that timestamp of modified file differs from original
-		file.setContents(getRandomContents(), false, false, null);
+		setContentsAndEnsureModified(project.getFile("folder1/a.txt"));
 		addResources(project, new String[] { "folder1/add.txt" }, false);
 		deleteResources(project, new String[] {"folder1/b.txt"}, false);
 		
@@ -752,7 +718,6 @@
 		// make changes on the branch		
 		addResources(copy, new String[] {"addition.txt", "folderAddition/", "folderAddition/new.txt"}, true);
 		deleteResources(copy, new String[] {"folder1/b.txt"}, true);
-		JUnitTestCase.waitMsec(1500);
 		changeResources(copy, new String[] {"file1.txt", "file2.txt"}, true);
 		
 		// make change to workspace working on HEAD
@@ -786,7 +751,6 @@
 
 		// Checkout and modify a copy
 		IProject copy = checkoutCopy(project, branch);
-		JUnitTestCase.waitMsec(1500);
 		addResources(copy, new String[] {"addition.txt", "folderAddition/", "folderAddition/new.txt"}, true);
 		deleteResources(copy, new String[] {"folder1/b.txt"}, true);
 		changeResources(copy, new String[] {"file1.txt", "file2.txt"}, true);