void () { String relativePath = FileUtil.toSystemDependentName("relative/path.file"); File existingDir = tempDir.getRoot(); assertEquals(relativePath, FileUtil.getRelativePath(existingDir, new File(existingDir, relativePath))); File notExistingDirOrFile = new File("not/existing/path"); assertEquals(relativePath, FileUtil.getRelativePath(notExistingDirOrFile, new File(notExistingDirOrFile, relativePath))); // FileUtil.getRelativePath(File, File) should have the same behavior then FileUtil.getRelativePath(String, String, char) File existingFile = createTestFile(existingDir, "foo.file"); assertEquals(".." + File.separatorChar + relativePath, FileUtil.getRelativePath(existingFile, new File(existingFile.getParent(), relativePath))); }