}
public void testAtomicUpdate() throws Exception
{
final String text = "Blah, blah";
FileSource src = new FileSource("file", m_tempDir);
FileSource child = (FileSource) src.getChild("child.txt");
assertTrue("New file already exists", !child.exists());
fillSource(child, text + " and blah!");
long length = child.getContentLength();
SourceValidity validity = child.getValidity();
assertEquals("Validity is not valid", 1, validity.isValid());
// Wait 2 seconds before updating the file
Thread.sleep(2 * 1000L);
// Now change its content
PrintWriter pw = new PrintWriter(child.getOutputStream());
pw.write(text);
assertEquals("File length modified", length, child.getContentLength());
pw.close();
assertTrue("File length not modified", length != child.getContentLength());
assertEquals("Validity is valid", -1, validity.isValid());
}