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 2020/02/14 17:32:03 UTC
[flink] 02/02: [hotfix][tests] Adjust
FileUtilsTest.testDeleteSymbolicLinkDirectory() to handle unsupported
situations in Windows
This is an automated email from the ASF dual-hosted git repository.
sewen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 30b5f6173e688ea20b82226db6923db19dec29a5
Author: Stephan Ewen <se...@apache.org>
AuthorDate: Fri Feb 14 16:39:40 2020 +0100
[hotfix][tests] Adjust FileUtilsTest.testDeleteSymbolicLinkDirectory() to handle unsupported situations in Windows
---
.../src/test/java/org/apache/flink/util/FileUtilsTest.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
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 b8af6e6..4e94769 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
@@ -36,6 +36,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.MessageDigest;
@@ -57,6 +58,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
/**
@@ -209,9 +211,16 @@ public class FileUtilsTest extends TestLogger {
// creating a directory to which the test creates a symbolic link
File linkedDirectory = tmp.newFolder();
File fileInLinkedDirectory = new File(linkedDirectory, "child");
- fileInLinkedDirectory.createNewFile();
+ assertTrue(fileInLinkedDirectory.createNewFile());
+
File symbolicLink = new File(tmp.getRoot(), "symLink");
- Files.createSymbolicLink(symbolicLink.toPath(), linkedDirectory.toPath());
+ try {
+ Files.createSymbolicLink(symbolicLink.toPath(), linkedDirectory.toPath());
+ } catch (FileSystemException e) {
+ // this operation can fail under Windows due to: "A required privilege is not held by the client."
+ assumeFalse("This test does not work properly under Windows", OperatingSystem.isWindows());
+ throw e;
+ }
FileUtils.deleteDirectory(symbolicLink);
assertTrue(fileInLinkedDirectory.exists());