Probably safer way of touching file in FileUtilTest.testAddRecursiveListenerToFile.
http://deadlock.netbeans.org/hudson/job/NB-Core-Build/3316/testReport/org.netbeans.modules.masterfs.filebasedfs/FileUtilTest/testAddRecursiveListenerToFile/
junit.framework.AssertionFailedError: Attribute change event not fired (see #129178). expected:<2> but was:<1>
at org.netbeans.modules.masterfs.filebasedfs.FileUtilTest.testAddRecursiveListenerToFile(FileUtilTest.java:734)
1.1 --- a/openide.util/test/unit/src/org/openide/util/test/TestFileUtils.java Sun Sep 27 13:25:11 2009 -0400
1.2 +++ b/openide.util/test/unit/src/org/openide/util/test/TestFileUtils.java Tue Sep 29 10:20:39 2009 -0400
1.3 @@ -53,6 +53,7 @@
1.4 import java.util.zip.CRC32;
1.5 import java.util.zip.ZipEntry;
1.6 import java.util.zip.ZipOutputStream;
1.7 +import junit.framework.Assert;
1.8
1.9 /**
1.10 * Common utility methods for massaging and inspecting files from tests.
1.11 @@ -146,4 +147,24 @@
1.12 os.close();
1.13 }
1.14
1.15 + /**
1.16 + * Make sure the timestamp on a file changes.
1.17 + * @param f a file to touch (make newer)
1.18 + * @param ref if not null, make f newer than this file; else make f newer than it was before
1.19 + */
1.20 + public static void touch(File f, File ref) throws IOException, InterruptedException {
1.21 + long older = f.lastModified();
1.22 + if (ref != null) {
1.23 + older = Math.max(older, ref.lastModified());
1.24 + }
1.25 + for (long pause = 1; pause < 9999; pause *= 2) {
1.26 + Thread.sleep(pause);
1.27 + f.setLastModified(System.currentTimeMillis());
1.28 + if (f.lastModified() > older) {
1.29 + return;
1.30 + }
1.31 + }
1.32 + Assert.fail("Did not manage to touch " + f);
1.33 + }
1.34 +
1.35 }