test for VfsUtil.findRelativeFile(uri, base) appcode/144.918 clion/144.917
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Sat, 7 Nov 2015 09:44:00 +0000 (12:44 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Sat, 7 Nov 2015 09:44:00 +0000 (12:44 +0300)
platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilTest.java

index c90c85bd5b3dfd0b175305a89d034c1c0b865068..0a39b739c20845c230f678bd6553b062c336e614 100644 (file)
@@ -113,6 +113,25 @@ public class VfsUtilTest extends PlatformTestCase {
     assertEquals("test text", content);
   }
 
+  public void testFindRelativeFile() throws Exception {
+    final VirtualFile root = VirtualFileManager.getInstance().findFileByUrl("temp:///");
+    assertNotNull(root);
+    VirtualFile file = VfsUtilCore.findRelativeFile(root.getUrl(), null);
+    assertEquals(root, file);
+
+    File ioTestDataDir = new File(PathManagerEx.getTestDataPath());
+    VirtualFile testDataDir = LocalFileSystem.getInstance().findFileByIoFile(ioTestDataDir);
+    assertNotNull(testDataDir);
+    assertEquals(testDataDir, VfsUtilCore.findRelativeFile(VfsUtilCore.convertFromUrl(ioTestDataDir.toURI().toURL()), null));
+    assertEquals(testDataDir, VfsUtilCore.findRelativeFile(ioTestDataDir.getAbsolutePath(), null));
+
+    File ioVfsDir = new File(ioTestDataDir, "vfs");
+    VirtualFile vfsDir = LocalFileSystem.getInstance().findFileByIoFile(ioVfsDir);
+    assertNotNull(vfsDir);
+    assertEquals(vfsDir, VfsUtilCore.findRelativeFile(ioVfsDir.getAbsolutePath(), null));
+    assertEquals(vfsDir, VfsUtilCore.findRelativeFile("vfs", testDataDir));
+  }
+
   public void testRelativePath() throws Exception {
     final File root = new File(PathManagerEx.getTestDataPath());
     final File testRoot = new File(new File(root, "vfs"), "relativePath");