Sort test members
MODIFY
src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTest.java
src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTest.java
protected abstract boolean setupSymlink(final File res, final File link) throws Exception;
+ @Test
+ public void testDeleteDirectoryNullArgument() {
+ assertThrows(NullPointerException.class, () -> FileUtils.deleteDirectory(null));
+ }
+
@Test
public void testDeleteDirWithASymlinkDir() throws Exception {
@@ -250,9 +255,4 @@ public void testDeletesRegular() throws Exception {
assertEquals(0, top.list().length);
}
- @Test
- public void testDeleteDirectoryNullArgument() {
- assertThrows(NullPointerException.class, () -> FileUtils.deleteDirectory(null));
- }
-
}

MODIFY
src/test/java/org/apache/commons/io/FileUtilsTest.java
src/test/java/org/apache/commons/io/FileUtilsTest.java
@SuppressWarnings({"deprecation", "ResultOfMethodCallIgnored"}) // unit tests include tests of many deprecated methods
public class FileUtilsTest extends AbstractTempDirTest {
- private static final String UTF_8 = StandardCharsets.UTF_8.name();
-
/**
* DirectoryWalker implementation that recursively lists all files and directories.
*/
@@ -133,6 +131,8 @@ public long length() {
}
}
+ private static final String UTF_8 = StandardCharsets.UTF_8.name();
+
/** Test data. */
private static final long DATE3 = 1000000002000L;

MODIFY
src/test/java/org/apache/commons/io/IOUtilsTest.java
src/test/java/org/apache/commons/io/IOUtilsTest.java
@@ -624,25 +624,6 @@ public void testContentEqualsIgnoreEOL() throws Exception {
testSingleEOL("1235", "1234", false);
}
- public void testSingleEOL(final String s1, final String s2, final boolean ifEquals) throws IOException {
- assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
- new CharArrayReader(s1.toCharArray()),
- new CharArrayReader(s2.toCharArray())
- ), "failed at :{" + s1 + "," + s2 + "}");
- assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
- new CharArrayReader(s2.toCharArray()),
- new CharArrayReader(s1.toCharArray())
- ), "failed at :{" + s2 + "," + s1 + "}");
- assertTrue(IOUtils.contentEqualsIgnoreEOL(
- new CharArrayReader(s1.toCharArray()),
- new CharArrayReader(s1.toCharArray())
- ),"failed at :{" + s1 + "," + s1 + "}");
- assertTrue(IOUtils.contentEqualsIgnoreEOL(
- new CharArrayReader(s2.toCharArray()),
- new CharArrayReader(s2.toCharArray())
- ), "failed at :{" + s2 + "," + s2 + "}");
- }
-
@Test
public void testCopy_ByteArray_OutputStream() throws Exception {
final File destination = TestUtils.newFile(temporaryFolder, "copy8.txt");
@@ -1160,8 +1141,6 @@ public void testResourceToString_ExistingResourceAtSubPackage() throws Exception
assertEquals(fileSize, content.getBytes().length);
}
- // Tests from IO-305
-
@Test
public void testResourceToString_ExistingResourceAtSubPackage_WithClassLoader() throws Exception {
final long fileSize = TestResources.getFile("FileUtilsTestDataCR.dat").length();
@@ -1172,6 +1151,8 @@ public void testResourceToString_ExistingResourceAtSubPackage_WithClassLoader()
assertEquals(fileSize, content.getBytes().length);
}
+ // Tests from IO-305
+
@Test
public void testResourceToString_NonExistingResource() {
assertThrows(IOException.class,
@@ -1259,6 +1240,25 @@ public void testResourceToURL_Null_WithClassLoader() {
assertThrows(NullPointerException.class, () -> IOUtils.resourceToURL(null, ClassLoader.getSystemClassLoader()));
}
+ public void testSingleEOL(final String s1, final String s2, final boolean ifEquals) throws IOException {
+ assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
+ new CharArrayReader(s1.toCharArray()),
+ new CharArrayReader(s2.toCharArray())
+ ), "failed at :{" + s1 + "," + s2 + "}");
+ assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
+ new CharArrayReader(s2.toCharArray()),
+ new CharArrayReader(s1.toCharArray())
+ ), "failed at :{" + s2 + "," + s1 + "}");
+ assertTrue(IOUtils.contentEqualsIgnoreEOL(
+ new CharArrayReader(s1.toCharArray()),
+ new CharArrayReader(s1.toCharArray())
+ ),"failed at :{" + s1 + "," + s1 + "}");
+ assertTrue(IOUtils.contentEqualsIgnoreEOL(
+ new CharArrayReader(s2.toCharArray()),
+ new CharArrayReader(s2.toCharArray())
+ ), "failed at :{" + s2 + "," + s2 + "}");
+ }
+
@Test
public void testSkip_FileReader() throws Exception {
try (Reader in = Files.newBufferedReader(testFilePath)) {

MODIFY
src/test/java/org/apache/commons/io/function/IOPredicateTest.java
src/test/java/org/apache/commons/io/function/IOPredicateTest.java
@@ -91,6 +91,14 @@ public void testAsPredicate() throws IOException {
assertFalse(IS_HIDDEN.test(PATH_FIXTURE));
}
+ @Test
+ public void testFalse() throws IOException {
+ assertFalse(Constants.IO_PREDICATE_FALSE.test("A"));
+ // Make sure we keep the argument type
+ final IOPredicate<String> alwaysFalse = IOPredicate.alwaysFalse();
+ assertFalse(alwaysFalse.test("A"));
+ }
+
@Test
public void testIsEqualChecked() throws IOException {
assertThrowsChecked(() -> IOPredicate.isEqual(THROWING_EQUALS).test("B"));
@@ -147,14 +155,6 @@ public void testTestUnchecked() {
assertTrue(Constants.IO_PREDICATE_TRUE.asPredicate().test("A"));
}
- @Test
- public void testFalse() throws IOException {
- assertFalse(Constants.IO_PREDICATE_FALSE.test("A"));
- // Make sure we keep the argument type
- final IOPredicate<String> alwaysFalse = IOPredicate.alwaysFalse();
- assertFalse(alwaysFalse.test("A"));
- }
-
@Test
public void testTrue() throws IOException {
assertTrue(Constants.IO_PREDICATE_TRUE.test("A"));

MODIFY
src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
@@ -79,6 +79,11 @@ public void testLargeUTF8WithSingleByteWrite() throws IOException {
testWithSingleByteWrite(LARGE_TEST_STRING, UTF_8);
}
+ @Test
+ public void testNullCharsetDecoderWithSingleByteWrite() throws IOException {
+ testWithSingleByteWrite(TEST_STRING, (CharsetDecoder) null);
+ }
+
@Test
public void testNullCharsetNameWithSingleByteWrite() throws IOException {
testWithSingleByteWrite(TEST_STRING, (String) null);
@@ -89,11 +94,6 @@ public void testNullCharsetWithSingleByteWrite() throws IOException {
testWithSingleByteWrite(TEST_STRING, (Charset) null);
}
- @Test
- public void testNullCharsetDecoderWithSingleByteWrite() throws IOException {
- testWithSingleByteWrite(TEST_STRING, (CharsetDecoder) null);
- }
-
@Test
public void testUTF16BEWithBufferedWrite() throws IOException {
testWithBufferedWrite(TEST_STRING, UTF_16BE);

Sort test members