aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorChris Aniszczyk <caniszczyk@gmail.com>2010-08-05 14:57:14 -0400
committerCode Review <codereview-daemon@eclipse.org>2010-08-05 14:57:14 -0400
commitbc27ac66cd3cd73fb3fa053393202680bf70fefa (patch)
tree90507a05408171d7fdc07d30d27abf60cba426d2 /org.eclipse.jgit.test
parentc293f8fbafad233c988783cab8925c3fec63b881 (diff)
parent7bbe203578def873f0409454d7035d69347fc31e (diff)
downloadjgit-bc27ac66cd3cd73fb3fa053393202680bf70fefa.tar.gz
jgit-bc27ac66cd3cd73fb3fa053393202680bf70fefa.zip
Merge "add fsTick() to RepositoryTestCase"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java32
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java36
2 files changed, 36 insertions, 32 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
index c29f1a0d72..e208b27e6b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
@@ -160,38 +160,6 @@ public class RacyGitTests extends RepositoryTestCase {
indexState(SMUDGE|MOD_TIME|LENGTH));
}
- /**
- * Waits until it is guaranteed that the filesystem timer (used e.g. for
- * lastModified) has a value greater than the lastmodified time of the given
- * file. This is done by touch a file, reading the lastmodified and sleeping
- * attribute sleeping
- *
- * @param lastFile
- * @return return the last measured value of the filesystem timer which is
- * greater than then the lastmodification time of lastfile.
- * @throws InterruptedException
- * @throws IOException
- */
- public static long fsTick(File lastFile) throws InterruptedException,
- IOException {
- long sleepTime = 1;
- File tmp = File.createTempFile("FileTreeIteratorWithTimeControl", null);
- try {
- long startTime = (lastFile == null) ? tmp.lastModified() : lastFile
- .lastModified();
- long actTime = tmp.lastModified();
- while (actTime <= startTime) {
- Thread.sleep(sleepTime);
- sleepTime *= 5;
- tmp.setLastModified(System.currentTimeMillis());
- actTime = tmp.lastModified();
- }
- return actTime;
- } finally {
- tmp.delete();
- }
- }
-
private void addToIndex(TreeSet<Long> modTimes)
throws FileNotFoundException, IOException {
DirCacheBuilder builder = db.lockDirCache().builder();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java
index cb1f385560..36b28ae077 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java
@@ -232,4 +232,40 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
}
return name;
}
+
+ /**
+ * Waits until it is guaranteed that a subsequent file modification has a
+ * younger modification timestamp than the modification timestamp of the
+ * given file. This is done by touching a temporary file, reading the
+ * lastmodified attribute and, if needed, sleeping. After sleeping this loop
+ * starts again until the filesystem timer has advanced enough.
+ *
+ * @param lastFile
+ * the file on which we want to wait until the filesystem timer
+ * has advanced more than the lastmodification timestamp of this
+ * file
+ * @return return the last measured value of the filesystem timer which is
+ * greater than then the lastmodification time of lastfile.
+ * @throws InterruptedException
+ * @throws IOException
+ */
+ public static long fsTick(File lastFile) throws InterruptedException,
+ IOException {
+ long sleepTime = 1;
+ File tmp = File.createTempFile("FileTreeIteratorWithTimeControl", null);
+ try {
+ long startTime = (lastFile == null) ? tmp.lastModified() : lastFile
+ .lastModified();
+ long actTime = tmp.lastModified();
+ while (actTime <= startTime) {
+ Thread.sleep(sleepTime);
+ sleepTime *= 5;
+ tmp.setLastModified(System.currentTimeMillis());
+ actTime = tmp.lastModified();
+ }
+ return actTime;
+ } finally {
+ tmp.delete();
+ }
+ }
}