Skip to content

Commit 6d48b5f

Browse files
committed
Add RandomAccessFileMode.io(String)
1 parent 9e8bae6 commit 6d48b5f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ public class IORandomAccessFileTest {
3434

3535
protected static final String FILE_NAME_RW = "target/" + AbstractOriginTest.class.getSimpleName() + ".txt";
3636

37+
private File newFileFixture() throws IOException {
38+
final File file = new File(FILE_NAME_RW);
39+
FileUtils.touch(file);
40+
return file;
41+
}
42+
3743
@ParameterizedTest
3844
@EnumSource(RandomAccessFileMode.class)
3945
public void testFile(final RandomAccessFileMode mode) throws IOException {
40-
final File file = new File(FILE_NAME_RW);
46+
final File file = newFileFixture();
4147
final String modeStr = mode.getMode();
4248
try (IORandomAccessFile raf = new IORandomAccessFile(file, modeStr)) {
4349
assertEquals(file, raf.getFile());
@@ -48,7 +54,7 @@ public void testFile(final RandomAccessFileMode mode) throws IOException {
4854
@ParameterizedTest
4955
@EnumSource(RandomAccessFileMode.class)
5056
public void testString(final RandomAccessFileMode mode) throws IOException {
51-
final File file = new File(FILE_NAME_RW);
57+
final File file = newFileFixture();
5258
final String modeStr = mode.getMode();
5359
try (IORandomAccessFile raf = new IORandomAccessFile(FILE_NAME_RW, modeStr)) {
5460
assertEquals(file, raf.getFile());
@@ -58,7 +64,7 @@ public void testString(final RandomAccessFileMode mode) throws IOException {
5864

5965
@Test
6066
public void testToString() throws IOException {
61-
final File file = new File(FILE_NAME_RW);
67+
final File file = newFileFixture();
6268
try (IORandomAccessFile raf = new IORandomAccessFile(FILE_NAME_RW, "r")) {
6369
assertEquals(file.toString(), raf.toString());
6470
}

0 commit comments

Comments
 (0)