Skip to content

Commit e95c77c

Browse files
author
Gary Gregory
committed
Refactor commons code.
1 parent 218b5e7 commit e95c77c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.BufferedOutputStream;
2626
import java.io.File;
27+
import java.io.FileNotFoundException;
2728
import java.io.IOException;
2829
import java.io.RandomAccessFile;
2930
import 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

Comments
 (0)