File historyFile = new File(tempDir, "history.xml");
historyFile.deleteOnExit();
if (historyFile.exists()) {
historyFile.delete();
}
TargetHistoryTable table = new TargetHistoryTable(null, new File(
tempDir));
//
// create a dummy compiled unit
//
compiledFile = new File(tempDir, "dummy.o");
FileOutputStream compiledStream = new FileOutputStream(compiledFile);
compiledStream.close();
//
// lastModified times can be slightly less than
// task start time due to file system resolution.
// Mimic this by slightly incrementing the last modification time.
//
long startTime = compiledFile.lastModified() + 1;
//
// update the table
//
table.update(new MockProcessorConfiguration(),
new String[]{"dummy.o"}, null);
//
// commit. If "compiled" file was judged to be
// valid we should have a history file.
//
table.commit();
historyFile = table.getHistoryFile();
assertTrue("History file was not created", historyFile.exists());
assertTrue("History file was empty", historyFile.length() > 10);
} finally {
if (compiledFile != null && compiledFile.exists()) {
compiledFile.delete();