assertTrue(vd.getAsStream() instanceof FileInputStream);
}
public void testIfFinalizeRemovesTempFileStreamValueData() throws Exception
{
FileCleaner testFileCleaner = new FileCleaner(1000, true);
try
{
byte[] buf = "0123456789".getBytes();
SwapFile file = SwapFile.get(new File("target"), "testIfFinalizeRemovesTempFileStreamValueData");
//File file = new File("target/testIfFinalizeRemovesTempFileStreamValueData");
//if (file.exists())
// file.delete();
FileOutputStream out = new FileOutputStream(file);
out.write(buf);
out.close();
CleanableFilePersistedValueData vd =
new CleanableFilePersistedValueData(0, file, SpoolConfig.getDefaultSpoolConfig());
assertTrue(file.exists());
vd = null;
long purgeStartTime = System.currentTimeMillis();
while (file.exists() && (System.currentTimeMillis() - purgeStartTime < 2 * 60 * 1000))
{
System.gc();
try
{
Thread.sleep(500);
}
catch (InterruptedException e)
{
}
}
assertFalse(file.exists());
}
finally
{
testFileCleaner.halt();
}
}