2424
2525import java .io .BufferedOutputStream ;
2626import java .io .File ;
27+ import java .io .FileNotFoundException ;
2728import java .io .IOException ;
2829import java .io .RandomAccessFile ;
2930import java .lang .ref .ReferenceQueue ;
@@ -50,6 +51,10 @@ public class FileCleaningTrackerTestCase {
5051 private File testFile ;
5152
5253 private FileCleaningTracker theInstance ;
54+ public RandomAccessFile createRandomAccessFile () throws FileNotFoundException {
55+ return new RandomAccessFile (testFile , "rw" );
56+ }
57+
5358 protected FileCleaningTracker newInstance () {
5459 return new FileCleaningTracker ();
5560 }
@@ -195,7 +200,7 @@ public void testFileCleanerExitWhenFinished1() throws Exception {
195200 final String path = testFile .getPath ();
196201
197202 assertFalse (testFile .exists (), "1-testFile exists: " + testFile );
198- RandomAccessFile r = new RandomAccessFile ( testFile , "rw" );
203+ RandomAccessFile r = createRandomAccessFile ( );
199204 assertTrue (testFile .exists (), "2-testFile exists" );
200205
201206 assertEquals (0 , theInstance .getTrackCount (), "3-Track Count" );
@@ -227,7 +232,7 @@ public void testFileCleanerExitWhenFinished2() throws Exception {
227232 final String path = testFile .getPath ();
228233
229234 assertFalse (testFile .exists ());
230- RandomAccessFile r = new RandomAccessFile ( testFile , "rw" );
235+ RandomAccessFile r = createRandomAccessFile ( );
231236 assertTrue (testFile .exists ());
232237
233238 assertEquals (0 , theInstance .getTrackCount ());
@@ -276,7 +281,7 @@ public void testFileCleanerFile() throws Exception {
276281 final String path = testFile .getPath ();
277282
278283 assertFalse (testFile .exists ());
279- RandomAccessFile r = new RandomAccessFile ( testFile , "rw" );
284+ RandomAccessFile r = createRandomAccessFile ( );
280285 assertTrue (testFile .exists ());
281286
282287 assertEquals (0 , theInstance .getTrackCount ());
0 commit comments