|
59 | 59 | import java.nio.file.AccessMode;
|
60 | 60 | import java.nio.file.DirectoryStream;
|
61 | 61 | import java.nio.file.Files;
|
| 62 | +import java.nio.file.LinkOption; |
62 | 63 | import java.nio.file.NoSuchFileException;
|
63 | 64 | import java.nio.file.NotDirectoryException;
|
64 | 65 | import java.nio.file.OpenOption;
|
|
83 | 84 | import static org.graalvm.python.embedding.utils.VirtualFileSystem.HostIO.READ_WRITE;
|
84 | 85 | import static org.junit.Assert.assertEquals;
|
85 | 86 | import static org.junit.Assert.assertFalse;
|
| 87 | +import static org.junit.Assert.assertNotNull; |
86 | 88 | import static org.junit.Assert.assertTrue;
|
87 | 89 | import static org.junit.Assert.fail;
|
88 | 90 |
|
@@ -901,9 +903,22 @@ public void copy() throws Exception {
|
901 | 903 |
|
902 | 904 | Path realFSPath5 = realFSPath.getParent().resolve("fromvfs2");
|
903 | 905 | assertFalse(Files.exists(realFSPath5));
|
904 |
| - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("file1"), Path.of("../" + realFSPath5.toString()))); |
905 |
| - assertTrue(Files.exists(realFSPath5)); |
906 |
| - newByteChannelRealFS(rwHostIOVFS, realFSPath5, "text1"); |
| 906 | + // NoSuchFileException: no such file or directory: '/test_mount_point/does-no-exist' |
| 907 | + checkException(NoSuchFileException.class, () -> rwHostIOVFS.copy(VFS_ROOT_PATH.resolve("does-no-exist"), realFSPath5)); |
| 908 | + assertFalse(Files.exists(realFSPath5)); |
| 909 | + |
| 910 | + Path realFSPath6 = realFSPath.getParent().resolve("fromvfs3"); |
| 911 | + assertFalse(Files.exists(realFSPath6)); |
| 912 | + // SecurityException: Operation is not allowed for: realFSPath |
| 913 | + checkException(SecurityException.class, () -> rHostIOVFS.copy(VFS_ROOT_PATH.resolve("file1"), realFSPath6)); |
| 914 | + assertFalse(Files.exists(realFSPath6)); |
| 915 | + |
| 916 | + Path realFSPath7 = realFSPath.getParent().resolve("fromvfs3"); |
| 917 | + assertFalse(Files.exists(realFSPath7)); |
| 918 | + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("file1"), Path.of("../" + realFSPath7.toString()))); |
| 919 | + assertTrue(Files.exists(realFSPath7)); |
| 920 | + newByteChannelRealFS(rwHostIOVFS, realFSPath7, "text1"); |
| 921 | + |
907 | 922 | }
|
908 | 923 |
|
909 | 924 | @Test
|
|
0 commit comments