You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/08/29 17:18:16 UTC

[commons-io] 02/02: Move test fixtures to package specific location.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 567ef2645505c08ae079770a3ed060070c5f3d72
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Aug 29 13:18:06 2020 -0400

    Move test fixtures to package specific location.
---
 .../org/apache/commons/io/IOUtilsTestCase.java     |  35 +++++++-------
 .../commons/io/input/CharSequenceReaderTest.java   |   2 +-
 .../io/input/RandomAccessFileInputStreamTest.java  |   2 +-
 .../ReversedLinesFileReaderTestParamBlockSize.java |  34 ++++++-------
 .../ReversedLinesFileReaderTestParamFile.java      |  13 +++--
 .../input/ReversedLinesFileReaderTestSimple.java   |  10 ++--
 .../org/apache/commons/io/input/TailerTest.java    |   2 +-
 .../org/apache/commons/io/input/TestResources.java |  53 +++++++++++++++++++++
 .../commons/io/{input => }/CharSequenceReader.bin  | Bin
 .../{ => org/apache/commons/io}/io639-1.bin        |   0
 .../{ => org/apache/commons/io}/io639-2.bin        |   0
 .../{ => org/apache/commons/io}/io639-3.bin        |   0
 .../{ => org/apache/commons/io}/io639-4.bin        |   0
 .../{ => org/apache/commons/io}/io639-5.bin        |   0
 .../apache/commons/io}/test-file-20byteslength.bin |   0
 .../apache/commons/io}/test-file-empty.bin         |   0
 .../{ => org/apache/commons/io}/test-file-gbk.bin  |   0
 .../test-file-iso8859-1-shortlines-win-linebr.bin  |   0
 .../apache/commons/io}/test-file-iso8859-1.bin     |   0
 .../apache/commons/io}/test-file-shiftjis.bin      |   0
 .../apache/commons/io}/test-file-simple-utf8.bin   |   0
 .../apache/commons/io}/test-file-utf16be.bin       | Bin
 .../apache/commons/io}/test-file-utf16le.bin       | Bin
 .../apache/commons/io}/test-file-utf8-cr-only.bin  |   0
 .../commons/io}/test-file-utf8-win-linebr.bin      |   0
 .../{ => org/apache/commons/io}/test-file-utf8.bin |   0
 .../apache/commons/io}/test-file-windows-31j.bin   |   0
 .../apache/commons/io}/test-file-x-windows-949.bin |   0
 .../apache/commons/io}/test-file-x-windows-950.bin |   0
 29 files changed, 104 insertions(+), 47 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
index 0c2b732..38f2d65 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
@@ -63,6 +63,7 @@ import java.util.List;
 
 import org.apache.commons.io.function.IOConsumer;
 import org.apache.commons.io.input.NullInputStream;
+import org.apache.commons.io.input.TestResources;
 import org.apache.commons.io.output.AppendableWriter;
 import org.apache.commons.io.output.NullOutputStream;
 import org.apache.commons.io.output.StringBuilderWriter;
@@ -1020,28 +1021,28 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtRootPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-utf8.bin").toURI()).length();
-        final byte[] bytes = IOUtils.resourceToByteArray("/test-file-utf8.bin");
+        final long fileSize = TestResources.getFile("test-file-utf8.bin").length();
+        final byte[] bytes = IOUtils.resourceToByteArray("/org/apache/commons/io/test-file-utf8.bin");
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtRootPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-utf8.bin").toURI()).length();
-        final byte[] bytes = IOUtils.resourceToByteArray("test-file-utf8.bin", ClassLoader.getSystemClassLoader());
+        final long fileSize = TestResources.getFile("test-file-utf8.bin").length();
+        final byte[] bytes = IOUtils.resourceToByteArray("org/apache/commons/io/test-file-utf8.bin", ClassLoader.getSystemClassLoader());
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtSubPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
+        final long fileSize = TestResources.getFile("FileUtilsTestDataCR.dat").length();
         final byte[] bytes = IOUtils.resourceToByteArray("/org/apache/commons/io/FileUtilsTestDataCR.dat");
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtSubPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
+        final long fileSize = TestResources.getFile("FileUtilsTestDataCR.dat").length();
         final byte[] bytes = IOUtils.resourceToByteArray("org/apache/commons/io/FileUtilsTestDataCR.dat", ClassLoader.getSystemClassLoader());
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);
@@ -1065,17 +1066,17 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToString_ExistingResourceAtRootPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-simple-utf8.bin").toURI()).length();
-        final String content = IOUtils.resourceToString("/test-file-simple-utf8.bin", StandardCharsets.UTF_8);
+        final long fileSize = TestResources.getFile("test-file-simple-utf8.bin").length();
+        final String content = IOUtils.resourceToString("/org/apache/commons/io/test-file-simple-utf8.bin", StandardCharsets.UTF_8);
 
         assertNotNull(content);
         assertEquals(fileSize, content.getBytes().length);
     }
 
     @Test public void testResourceToString_ExistingResourceAtRootPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-simple-utf8.bin").toURI()).length();
+        final long fileSize = TestResources.getFile("test-file-simple-utf8.bin").length();
         final String content = IOUtils.resourceToString(
-                "test-file-simple-utf8.bin",
+                "org/apache/commons/io/test-file-simple-utf8.bin",
                 StandardCharsets.UTF_8,
                 ClassLoader.getSystemClassLoader()
         );
@@ -1085,7 +1086,7 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToString_ExistingResourceAtSubPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
+        final long fileSize = TestResources.getFile("FileUtilsTestDataCR.dat").length();
         final String content = IOUtils.resourceToString("/org/apache/commons/io/FileUtilsTestDataCR.dat", StandardCharsets.UTF_8);
 
         assertNotNull(content);
@@ -1095,7 +1096,7 @@ public class IOUtilsTestCase {
     // Tests from IO-305
 
     @Test public void testResourceToString_ExistingResourceAtSubPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
+        final long fileSize = TestResources.getFile("FileUtilsTestDataCR.dat").length();
         final String content = IOUtils.resourceToString(
                 "org/apache/commons/io/FileUtilsTestDataCR.dat",
                 StandardCharsets.UTF_8,
@@ -1118,12 +1119,12 @@ public class IOUtilsTestCase {
 
     @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
     @Test public void testResourceToString_NullCharset() throws Exception {
-        IOUtils.resourceToString("/test-file-utf8.bin", null);
+        IOUtils.resourceToString("/org/apache/commons/io//test-file-utf8.bin", null);
     }
 
     @SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
     @Test public void testResourceToString_NullCharset_WithClassLoader() throws Exception {
-        IOUtils.resourceToString("test-file-utf8.bin", null, ClassLoader.getSystemClassLoader());
+        IOUtils.resourceToString("org/apache/commons/io/test-file-utf8.bin", null, ClassLoader.getSystemClassLoader());
     }
 
     @Test public void testResourceToString_NullResource() {
@@ -1135,15 +1136,15 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToURL_ExistingResourceAtRootPackage() throws Exception {
-        final URL url = IOUtils.resourceToURL("/test-file-utf8.bin");
+        final URL url = IOUtils.resourceToURL("/org/apache/commons/io/test-file-utf8.bin");
         assertNotNull(url);
         assertTrue(url.getFile().endsWith("/test-file-utf8.bin"));
     }
 
     @Test public void testResourceToURL_ExistingResourceAtRootPackage_WithClassLoader() throws Exception {
-        final URL url = IOUtils.resourceToURL("test-file-utf8.bin", ClassLoader.getSystemClassLoader());
+        final URL url = IOUtils.resourceToURL("org/apache/commons/io/test-file-utf8.bin", ClassLoader.getSystemClassLoader());
         assertNotNull(url);
-        assertTrue(url.getFile().endsWith("/test-file-utf8.bin"));
+        assertTrue(url.getFile().endsWith("/org/apache/commons/io/test-file-utf8.bin"));
     }
 
     @Test public void testResourceToURL_ExistingResourceAtSubPackage() throws Exception {
diff --git a/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java b/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
index 2afabe9..864b2e0 100644
--- a/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
@@ -273,7 +273,7 @@ public class CharSequenceReaderTest {
          * This part of the test will test that adding the fields does not break any existing
          * serialized CharSequenceReaders.
          */
-        try (ObjectInputStream ois = new ObjectInputStream(getClass().getResourceAsStream("CharSequenceReader.bin"))) {
+        try (ObjectInputStream ois = new ObjectInputStream(TestResources.getInputStream("CharSequenceReader.bin"))) {
             final CharSequenceReader reader = (CharSequenceReader) ois.readObject();
             assertEquals('F', reader.read());
             assertEquals('o', reader.read());
diff --git a/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java b/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
index b4986e9..f7f4dc8 100644
--- a/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
 
 public class RandomAccessFileInputStreamTest {
 
-    private static final String DATA_FILE = "src/test/resources/test-file-iso8859-1.bin";
+    private static final String DATA_FILE = "src/test/resources/org/apache/commons/io/test-file-iso8859-1.bin";
     private static final int DATA_FILE_LEN = 1430;
 
     private RandomAccessFile createRandomAccessFile() throws FileNotFoundException {
diff --git a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java
index fd84598..401004d 100644
--- a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java
+++ b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java
@@ -80,7 +80,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testIsoFileDefaults(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileIso = new File(this.getClass().getResource("/test-file-iso8859-1.bin").toURI());
+        final File testFileIso = TestResources.getFile("/test-file-iso8859-1.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, ISO_8859_1);
         assertFileWithShrinkingTestLines(reversedLinesFileReader);
     }
@@ -88,7 +88,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUTF8FileWindowsBreaks(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileIso = new File(this.getClass().getResource("/test-file-utf8-win-linebr.bin").toURI());
+        final File testFileIso = TestResources.getFile("/test-file-utf8-win-linebr.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8);
         assertFileWithShrinkingTestLines(reversedLinesFileReader);
     }
@@ -96,7 +96,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUTF8FileCRBreaks(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileIso = new File(this.getClass().getResource("/test-file-utf8-cr-only.bin").toURI());
+        final File testFileIso = TestResources.getFile("/test-file-utf8-cr-only.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8);
         assertFileWithShrinkingTestLines(reversedLinesFileReader);
     }
@@ -104,7 +104,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUTF8File(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileIso = new File(this.getClass().getResource("/test-file-utf8.bin").toURI());
+        final File testFileIso = TestResources.getFile("/test-file-utf8.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8);
         assertFileWithShrinkingTestLines(reversedLinesFileReader);
     }
@@ -112,7 +112,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testEmptyFile(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI());
+        final File testFileEmpty = TestResources.getFile("/test-file-empty.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileEmpty, testParamBlockSize, UTF_8);
         assertNull(reversedLinesFileReader.readLine());
     }
@@ -120,7 +120,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUTF16BEFile(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileUTF16BE = new File(this.getClass().getResource("/test-file-utf16be.bin").toURI());
+        final File testFileUTF16BE = TestResources.getFile("/test-file-utf16be.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileUTF16BE, testParamBlockSize, "UTF-16BE");
         assertFileWithShrinkingTestLines(reversedLinesFileReader);
     }
@@ -128,7 +128,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUTF16LEFile(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileUTF16LE = new File(this.getClass().getResource("/test-file-utf16le.bin").toURI());
+        final File testFileUTF16LE = TestResources.getFile("/test-file-utf16le.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileUTF16LE, testParamBlockSize, "UTF-16LE");
         assertFileWithShrinkingTestLines(reversedLinesFileReader);
     }
@@ -136,7 +136,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testShiftJISFile(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileShiftJIS = new File(this.getClass().getResource("/test-file-shiftjis.bin").toURI());
+        final File testFileShiftJIS = TestResources.getFile("/test-file-shiftjis.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileShiftJIS, testParamBlockSize, "Shift_JIS");
         assertEqualsAndNoLineBreaks(TEST_LINE_SHIFT_JIS2, reversedLinesFileReader.readLine());
         assertEqualsAndNoLineBreaks(TEST_LINE_SHIFT_JIS1, reversedLinesFileReader.readLine());
@@ -145,7 +145,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testWindows31jFile(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileWindows31J = new File(this.getClass().getResource("/test-file-windows-31j.bin").toURI());
+        final File testFileWindows31J = TestResources.getFile("/test-file-windows-31j.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileWindows31J, testParamBlockSize, "windows-31j");
         assertEqualsAndNoLineBreaks(TEST_LINE_WINDOWS_31J_2, reversedLinesFileReader.readLine());
         assertEqualsAndNoLineBreaks(TEST_LINE_WINDOWS_31J_1, reversedLinesFileReader.readLine());
@@ -154,7 +154,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testGBK(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileGBK = new File(this.getClass().getResource("/test-file-gbk.bin").toURI());
+        final File testFileGBK = TestResources.getFile("/test-file-gbk.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileGBK, testParamBlockSize, "GBK");
         assertEqualsAndNoLineBreaks(TEST_LINE_GBK_2, reversedLinesFileReader.readLine());
         assertEqualsAndNoLineBreaks(TEST_LINE_GBK_1, reversedLinesFileReader.readLine());
@@ -163,7 +163,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testxWindows949File(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFilexWindows949 = new File(this.getClass().getResource("/test-file-x-windows-949.bin").toURI());
+        final File testFilexWindows949 = TestResources.getFile("/test-file-x-windows-949.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFilexWindows949, testParamBlockSize, "x-windows-949");
         assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_949_2, reversedLinesFileReader.readLine());
         assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_949_1, reversedLinesFileReader.readLine());
@@ -172,7 +172,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testxWindows950File(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFilexWindows950 = new File(this.getClass().getResource("/test-file-x-windows-950.bin").toURI());
+        final File testFilexWindows950 = TestResources.getFile("/test-file-x-windows-950.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFilexWindows950, testParamBlockSize, "x-windows-950");
         assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_950_2, reversedLinesFileReader.readLine());
         assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_950_1, reversedLinesFileReader.readLine());
@@ -181,7 +181,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @Test
     public void testFileSizeIsExactMultipleOfBlockSize() throws URISyntaxException, IOException {
         final int blockSize = 10;
-        final File testFile20Bytes = new File(this.getClass().getResource("/test-file-20byteslength.bin").toURI());
+        final File testFile20Bytes = TestResources.getFile("/test-file-20byteslength.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize, ISO_8859_1);
         assertEqualsAndNoLineBreaks("987654321", reversedLinesFileReader.readLine());
         assertEqualsAndNoLineBreaks("123456789", reversedLinesFileReader.readLine());
@@ -190,7 +190,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUTF8FileWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileUtf8 = new File(this.getClass().getResource("/test-file-utf8-win-linebr.bin").toURI());
+        final File testFileUtf8 = TestResources.getFile("/test-file-utf8-win-linebr.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileUtf8, testParamBlockSize, UTF_8);
         assertFileWithShrinkingTestLines(reversedLinesFileReader);
     }
@@ -198,7 +198,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testIsoFileManyWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines(final int testParamBlockSize) throws URISyntaxException, IOException {
-        final File testFileIso = new File(this.getClass().getResource("/test-file-iso8859-1-shortlines-win-linebr.bin").toURI());
+        final File testFileIso = TestResources.getFile("/test-file-iso8859-1-shortlines-win-linebr.bin");
         reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, ISO_8859_1);
 
         for (int i = 3; i > 0; i--) {
@@ -212,7 +212,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUnsupportedEncodingUTF16(final int testParamBlockSize) throws URISyntaxException {
-        final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI());
+        final File testFileEmpty = TestResources.getFile("/test-file-empty.bin");
         assertThrows(UnsupportedEncodingException.class,
                 () -> new ReversedLinesFileReader(testFileEmpty, testParamBlockSize, "UTF-16").close());
     }
@@ -220,7 +220,7 @@ public class ReversedLinesFileReaderTestParamBlockSize {
     @ParameterizedTest(name = "BlockSize={0}")
     @MethodSource("blockSizes")
     public void testUnsupportedEncodingBig5(final int testParamBlockSize) throws URISyntaxException {
-        final File testFileEncodingBig5 = new File(this.getClass().getResource("/test-file-empty.bin").toURI());
+        final File testFileEncodingBig5 = TestResources.getFile("/test-file-empty.bin");
         assertThrows(UnsupportedEncodingException.class,
                 () -> new ReversedLinesFileReader(testFileEncodingBig5, testParamBlockSize, "Big5").close());
     }
diff --git a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java
index 08932be..c131e21 100644
--- a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java
+++ b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java
@@ -22,18 +22,21 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.charset.Charset;
-import java.nio.file.*;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.Stack;
 import java.util.stream.Stream;
 
-import com.google.common.jimfs.Configuration;
-import com.google.common.jimfs.Jimfs;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
 
+import com.google.common.jimfs.Configuration;
+import com.google.common.jimfs.Jimfs;
+
 /**
- * Test checks symmetric behavior with  BufferedReader
+ * Test checks symmetric behavior with BufferedReader.
  */
 public class ReversedLinesFileReaderTestParamFile {
 
@@ -65,7 +68,7 @@ public class ReversedLinesFileReaderTestParamFile {
     public void testDataIntegrityWithBufferedReader(final String fileName, final String encodingName,
         final Integer blockSize, final boolean useNonDefaultFileSystem) throws IOException, URISyntaxException {
 
-        Path filePath = Paths.get(getClass().getResource("/" + fileName).toURI());
+        Path filePath = TestResources.getPath(fileName);
         FileSystem fileSystem = null;
         if (useNonDefaultFileSystem) {
             fileSystem = Jimfs.newFileSystem(Configuration.unix());
diff --git a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java
index 912fb69..8d889d8 100644
--- a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java
+++ b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java
@@ -35,7 +35,7 @@ public class ReversedLinesFileReaderTestSimple {
     @Test
     public void testFileSizeIsExactMultipleOfBlockSize() throws URISyntaxException, IOException {
         final int blockSize = 10;
-        final File testFile20Bytes = new File(this.getClass().getResource("/test-file-20byteslength.bin").toURI());
+        final File testFile20Bytes = TestResources.getFile("/test-file-20byteslength.bin");
         try (ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize,
             "ISO-8859-1")) {
             assertEqualsAndNoLineBreaks("987654321", reversedLinesFileReader.readLine());
@@ -46,7 +46,7 @@ public class ReversedLinesFileReaderTestSimple {
     @Test
     public void testLineCount() throws URISyntaxException, IOException {
         final int blockSize = 10;
-        final File testFile20Bytes = new File(this.getClass().getResource("/test-file-20byteslength.bin").toURI());
+        final File testFile20Bytes = TestResources.getFile("/test-file-20byteslength.bin");
         try (ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize,
             "ISO-8859-1")) {
             assertThrows(IllegalArgumentException.class, () -> reversedLinesFileReader.readLines(-1));
@@ -62,7 +62,7 @@ public class ReversedLinesFileReaderTestSimple {
     @Test
     public void testToString() throws URISyntaxException, IOException {
         final int blockSize = 10;
-        final File testFile20Bytes = new File(this.getClass().getResource("/test-file-20byteslength.bin").toURI());
+        final File testFile20Bytes = TestResources.getFile("/test-file-20byteslength.bin");
         try (ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize,
             "ISO-8859-1")) {
             assertThrows(IllegalArgumentException.class, () -> reversedLinesFileReader.toString(-1));
@@ -76,14 +76,14 @@ public class ReversedLinesFileReaderTestSimple {
 
     @Test
     public void testUnsupportedEncodingUTF16() throws URISyntaxException {
-        final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI());
+        final File testFileEmpty = TestResources.getFile("/test-file-empty.bin");
         assertThrows(UnsupportedEncodingException.class,
             () -> new ReversedLinesFileReader(testFileEmpty, IOUtils.DEFAULT_BUFFER_SIZE, "UTF-16").close());
     }
 
     @Test
     public void testUnsupportedEncodingBig5() throws URISyntaxException {
-        final File testFileEncodingBig5 = new File(this.getClass().getResource("/test-file-empty.bin").toURI());
+        final File testFileEncodingBig5 = TestResources.getFile("/test-file-empty.bin");
         assertThrows(UnsupportedEncodingException.class,
             () -> new ReversedLinesFileReader(testFileEncodingBig5, IOUtils.DEFAULT_BUFFER_SIZE, "Big5").close());
     }
diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java b/src/test/java/org/apache/commons/io/input/TailerTest.java
index a77ef48..e73f1dc 100644
--- a/src/test/java/org/apache/commons/io/input/TailerTest.java
+++ b/src/test/java/org/apache/commons/io/input/TailerTest.java
@@ -126,7 +126,7 @@ public class TailerTest {
     public void testMultiByteBreak() throws Exception {
         // System.out.println("testMultiByteBreak() Default charset: " + Charset.defaultCharset().displayName());
         final long delay = 50;
-        final File origin = new File(this.getClass().getResource("/test-file-utf8.bin").toURI());
+        final File origin = TestResources.getFile("test-file-utf8.bin");
         final File file = new File(temporaryFolder, "testMultiByteBreak.txt");
         createFile(file, 0);
         final TestTailerListener listener = new TestTailerListener();
diff --git a/src/test/java/org/apache/commons/io/input/TestResources.java b/src/test/java/org/apache/commons/io/input/TestResources.java
new file mode 100644
index 0000000..1b7de8e
--- /dev/null
+++ b/src/test/java/org/apache/commons/io/input/TestResources.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Provides access to this package's test resources.
+ */
+public class TestResources {
+
+    private static final String ROOT = "/org/apache/commons/io/";
+
+    public static File getFile(final String fileName) throws URISyntaxException {
+        return new File(getURI(fileName));
+    }
+
+    public static Path getPath(final String fileName) throws URISyntaxException {
+        return Paths.get(getURI(fileName));
+    }
+
+    public static URI getURI(final String fileName) throws URISyntaxException {
+        return getURL(fileName).toURI();
+    }
+
+    public static URL getURL(final String fileName) {
+        return TestResources.class.getResource(ROOT + fileName);
+    }
+
+    public static InputStream getInputStream(final String fileName) {
+        return TestResources.class.getResourceAsStream(ROOT + fileName);
+    }
+}
diff --git a/src/test/resources/org/apache/commons/io/input/CharSequenceReader.bin b/src/test/resources/org/apache/commons/io/CharSequenceReader.bin
similarity index 100%
rename from src/test/resources/org/apache/commons/io/input/CharSequenceReader.bin
rename to src/test/resources/org/apache/commons/io/CharSequenceReader.bin
diff --git a/src/test/resources/io639-1.bin b/src/test/resources/org/apache/commons/io/io639-1.bin
similarity index 100%
rename from src/test/resources/io639-1.bin
rename to src/test/resources/org/apache/commons/io/io639-1.bin
diff --git a/src/test/resources/io639-2.bin b/src/test/resources/org/apache/commons/io/io639-2.bin
similarity index 100%
rename from src/test/resources/io639-2.bin
rename to src/test/resources/org/apache/commons/io/io639-2.bin
diff --git a/src/test/resources/io639-3.bin b/src/test/resources/org/apache/commons/io/io639-3.bin
similarity index 100%
rename from src/test/resources/io639-3.bin
rename to src/test/resources/org/apache/commons/io/io639-3.bin
diff --git a/src/test/resources/io639-4.bin b/src/test/resources/org/apache/commons/io/io639-4.bin
similarity index 100%
rename from src/test/resources/io639-4.bin
rename to src/test/resources/org/apache/commons/io/io639-4.bin
diff --git a/src/test/resources/io639-5.bin b/src/test/resources/org/apache/commons/io/io639-5.bin
similarity index 100%
rename from src/test/resources/io639-5.bin
rename to src/test/resources/org/apache/commons/io/io639-5.bin
diff --git a/src/test/resources/test-file-20byteslength.bin b/src/test/resources/org/apache/commons/io/test-file-20byteslength.bin
similarity index 100%
rename from src/test/resources/test-file-20byteslength.bin
rename to src/test/resources/org/apache/commons/io/test-file-20byteslength.bin
diff --git a/src/test/resources/test-file-empty.bin b/src/test/resources/org/apache/commons/io/test-file-empty.bin
similarity index 100%
rename from src/test/resources/test-file-empty.bin
rename to src/test/resources/org/apache/commons/io/test-file-empty.bin
diff --git a/src/test/resources/test-file-gbk.bin b/src/test/resources/org/apache/commons/io/test-file-gbk.bin
similarity index 100%
rename from src/test/resources/test-file-gbk.bin
rename to src/test/resources/org/apache/commons/io/test-file-gbk.bin
diff --git a/src/test/resources/test-file-iso8859-1-shortlines-win-linebr.bin b/src/test/resources/org/apache/commons/io/test-file-iso8859-1-shortlines-win-linebr.bin
similarity index 100%
rename from src/test/resources/test-file-iso8859-1-shortlines-win-linebr.bin
rename to src/test/resources/org/apache/commons/io/test-file-iso8859-1-shortlines-win-linebr.bin
diff --git a/src/test/resources/test-file-iso8859-1.bin b/src/test/resources/org/apache/commons/io/test-file-iso8859-1.bin
similarity index 100%
rename from src/test/resources/test-file-iso8859-1.bin
rename to src/test/resources/org/apache/commons/io/test-file-iso8859-1.bin
diff --git a/src/test/resources/test-file-shiftjis.bin b/src/test/resources/org/apache/commons/io/test-file-shiftjis.bin
similarity index 100%
rename from src/test/resources/test-file-shiftjis.bin
rename to src/test/resources/org/apache/commons/io/test-file-shiftjis.bin
diff --git a/src/test/resources/test-file-simple-utf8.bin b/src/test/resources/org/apache/commons/io/test-file-simple-utf8.bin
similarity index 100%
rename from src/test/resources/test-file-simple-utf8.bin
rename to src/test/resources/org/apache/commons/io/test-file-simple-utf8.bin
diff --git a/src/test/resources/test-file-utf16be.bin b/src/test/resources/org/apache/commons/io/test-file-utf16be.bin
similarity index 100%
rename from src/test/resources/test-file-utf16be.bin
rename to src/test/resources/org/apache/commons/io/test-file-utf16be.bin
diff --git a/src/test/resources/test-file-utf16le.bin b/src/test/resources/org/apache/commons/io/test-file-utf16le.bin
similarity index 100%
rename from src/test/resources/test-file-utf16le.bin
rename to src/test/resources/org/apache/commons/io/test-file-utf16le.bin
diff --git a/src/test/resources/test-file-utf8-cr-only.bin b/src/test/resources/org/apache/commons/io/test-file-utf8-cr-only.bin
similarity index 100%
rename from src/test/resources/test-file-utf8-cr-only.bin
rename to src/test/resources/org/apache/commons/io/test-file-utf8-cr-only.bin
diff --git a/src/test/resources/test-file-utf8-win-linebr.bin b/src/test/resources/org/apache/commons/io/test-file-utf8-win-linebr.bin
similarity index 100%
rename from src/test/resources/test-file-utf8-win-linebr.bin
rename to src/test/resources/org/apache/commons/io/test-file-utf8-win-linebr.bin
diff --git a/src/test/resources/test-file-utf8.bin b/src/test/resources/org/apache/commons/io/test-file-utf8.bin
similarity index 100%
rename from src/test/resources/test-file-utf8.bin
rename to src/test/resources/org/apache/commons/io/test-file-utf8.bin
diff --git a/src/test/resources/test-file-windows-31j.bin b/src/test/resources/org/apache/commons/io/test-file-windows-31j.bin
similarity index 100%
rename from src/test/resources/test-file-windows-31j.bin
rename to src/test/resources/org/apache/commons/io/test-file-windows-31j.bin
diff --git a/src/test/resources/test-file-x-windows-949.bin b/src/test/resources/org/apache/commons/io/test-file-x-windows-949.bin
similarity index 100%
rename from src/test/resources/test-file-x-windows-949.bin
rename to src/test/resources/org/apache/commons/io/test-file-x-windows-949.bin
diff --git a/src/test/resources/test-file-x-windows-950.bin b/src/test/resources/org/apache/commons/io/test-file-x-windows-950.bin
similarity index 100%
rename from src/test/resources/test-file-x-windows-950.bin
rename to src/test/resources/org/apache/commons/io/test-file-x-windows-950.bin