Skip to content

Commit

Permalink
Add RandomAccessFileMode.io(String)
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 12, 2024
1 parent 9e8bae6 commit 6d48b5f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/test/java/org/apache/commons/io/IORandomAccessFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ public class IORandomAccessFileTest {

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

private File newFileFixture() throws IOException {
final File file = new File(FILE_NAME_RW);
FileUtils.touch(file);
return file;
}

@ParameterizedTest
@EnumSource(RandomAccessFileMode.class)
public void testFile(final RandomAccessFileMode mode) throws IOException {
final File file = new File(FILE_NAME_RW);
final File file = newFileFixture();
final String modeStr = mode.getMode();
try (IORandomAccessFile raf = new IORandomAccessFile(file, modeStr)) {
assertEquals(file, raf.getFile());
Expand All @@ -48,7 +54,7 @@ public void testFile(final RandomAccessFileMode mode) throws IOException {
@ParameterizedTest
@EnumSource(RandomAccessFileMode.class)
public void testString(final RandomAccessFileMode mode) throws IOException {
final File file = new File(FILE_NAME_RW);
final File file = newFileFixture();
final String modeStr = mode.getMode();
try (IORandomAccessFile raf = new IORandomAccessFile(FILE_NAME_RW, modeStr)) {
assertEquals(file, raf.getFile());
Expand All @@ -58,7 +64,7 @@ public void testString(final RandomAccessFileMode mode) throws IOException {

@Test
public void testToString() throws IOException {
final File file = new File(FILE_NAME_RW);
final File file = newFileFixture();
try (IORandomAccessFile raf = new IORandomAccessFile(FILE_NAME_RW, "r")) {
assertEquals(file.toString(), raf.toString());
}
Expand Down

0 comments on commit 6d48b5f

Please sign in to comment.