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 471e4b3697ec80b58c307132a0b41ecff4bf4aff Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Fri Jan 15 18:33:27 2021 -0500 Sort methods. --- .../org/apache/commons/io/FileUtilsTestCase.java | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java index efffbda..94ae6c6 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java @@ -1281,6 +1281,12 @@ public class FileUtilsTestCase { } @Test + public void testDelete() throws Exception { + assertEquals(testFile1, FileUtils.delete(testFile1)); + assertThrows(IOException.class, () -> FileUtils.delete(new File("does not exist.nope"))); + } + + @Test public void testDeleteDirectoryWithNonDirectory() throws Exception { try { FileUtils.deleteDirectory(testFile1); @@ -1291,12 +1297,6 @@ public class FileUtilsTestCase { } @Test - public void testDelete() throws Exception { - assertEquals(testFile1, FileUtils.delete(testFile1)); - assertThrows(IOException.class, () -> FileUtils.delete(new File("does not exist.nope"))); - } - - @Test public void testDeleteQuietlyDir() throws IOException { final File testDirectory = new File(temporaryFolder, "testDeleteQuietlyDir"); final File testFile = new File(testDirectory, "testDeleteQuietlyFile"); @@ -2169,6 +2169,32 @@ public class FileUtilsTestCase { } @Test + public void testMoveFile_CopyDelete_Failed() throws Exception { + final File destination = new File(temporaryFolder, "move3.txt"); + final File src = new File(testFile1.getAbsolutePath()) { + private static final long serialVersionUID = 1L; + + // Force delete failure + @Override + public boolean delete() { + return false; + } + + // Force renameTo to fail, as if destination is on another + // filesystem + @Override + public boolean renameTo(final File f) { + return false; + } + + }; + assertThrows(IOException.class, () -> FileUtils.moveFile(src, destination)); + // expected + assertTrue(!destination.exists(), "Check Rollback"); + assertTrue(src.exists(), "Original exists"); + } + + @Test public void testMoveFile_CopyDelete_WithFileDatePreservation() throws Exception { final File destination = new File(temporaryFolder, "move2.txt"); @@ -2194,7 +2220,7 @@ public class FileUtilsTestCase { final long delta = destLastMod - expected; assertEquals(expected, destLastMod, "Check last modified date same as input, delta " + delta); } - + @Test public void testMoveFile_CopyDelete_WithoutFileDatePreservation() throws Exception { final File destination = new File(temporaryFolder, "move2.txt"); @@ -2230,32 +2256,6 @@ public class FileUtilsTestCase { } @Test - public void testMoveFile_CopyDelete_Failed() throws Exception { - final File destination = new File(temporaryFolder, "move3.txt"); - final File src = new File(testFile1.getAbsolutePath()) { - private static final long serialVersionUID = 1L; - - // Force delete failure - @Override - public boolean delete() { - return false; - } - - // Force renameTo to fail, as if destination is on another - // filesystem - @Override - public boolean renameTo(final File f) { - return false; - } - - }; - assertThrows(IOException.class, () -> FileUtils.moveFile(src, destination)); - // expected - assertTrue(!destination.exists(), "Check Rollback"); - assertTrue(src.exists(), "Original exists"); - } - - @Test public void testMoveFile_Errors() throws Exception { assertThrows(NullPointerException.class, () -> FileUtils.moveFile(null, new File("foo"))); assertThrows(NullPointerException.class, () -> FileUtils.moveFile(new File("foo"), null));