You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2017/10/13 22:34:24 UTC
[2/2] flink git commit: [FLINK-6615] [core] (followup) Add one more
test for FileUtils
[FLINK-6615] [core] (followup) Add one more test for FileUtils
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/47282af5
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/47282af5
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/47282af5
Branch: refs/heads/master
Commit: 47282af56697aca38a5159044b147bdeaa811a84
Parents: 90be577
Author: Stephan Ewen <se...@apache.org>
Authored: Fri Oct 13 12:15:04 2017 +0200
Committer: Stephan Ewen <se...@apache.org>
Committed: Fri Oct 13 21:07:08 2017 +0200
----------------------------------------------------------------------
.../org/apache/flink/util/FileUtilsTest.java | 27 +++++++++++++++++---
1 file changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/47282af5/flink-core/src/test/java/org/apache/flink/util/FileUtilsTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/util/FileUtilsTest.java b/flink-core/src/test/java/org/apache/flink/util/FileUtilsTest.java
index 166d24d..28bb24a 100644
--- a/flink-core/src/test/java/org/apache/flink/util/FileUtilsTest.java
+++ b/flink-core/src/test/java/org/apache/flink/util/FileUtilsTest.java
@@ -19,6 +19,7 @@
package org.apache.flink.util;
import org.apache.flink.core.testutils.CheckedThread;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -27,12 +28,15 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.AccessDeniedException;
-import java.nio.file.Files;
-import java.util.Random;
-import static org.junit.Assert.*;
-import static org.junit.Assume.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+/**
+ * Tests for the {@link FileUtils}.
+ */
public class FileUtilsTest {
@Rule
@@ -101,6 +105,21 @@ public class FileUtilsTest {
}
@Test
+ public void testDeleteDirectoryWhichIsAFile() throws Exception {
+
+ // deleting a directory that is actually a file should fails
+
+ File file = tmp.newFile();
+ try {
+ FileUtils.deleteDirectory(file);
+ fail("this should fail with an exception");
+ }
+ catch (IOException ignored) {
+ // this is what we expect
+ }
+ }
+
+ @Test
public void testDeleteDirectoryConcurrently() throws Exception {
final File parent = tmp.newFolder();