Skip to content

Commit

Permalink
Added 3 tests for broken symlinks.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkishalmi committed Feb 12, 2019
1 parent 1cb8a2d commit 39048d6
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,45 @@ public void testReadSymbolicLinkPath() throws IOException {
assertTrue(linkFO.readSymbolicLinkPath().endsWith("data.dat"));
}

public void testBrokenSymbolicLink1() throws IOException {
if (!checkSymlinksSupported()) {
return;
}
File dir = getWorkDir();
File data = new File(dir, "data.dat");
File link = new File(dir, "link.lnk");
Files.createSymbolicLink(link.toPath(), data.toPath());
FileObject linkFO = FileUtil.toFileObject(link);
assertNull(linkFO);
}

public void testBrokenSymbolicLink2() throws IOException {
if (!checkSymlinksSupported()) {
return;
}
File dir = getWorkDir();
File data = new File(dir, "data.dat");
File link = new File(dir, "link.lnk");
Files.createSymbolicLink(link.toPath(), data.toPath());
FileObject dirFO = FileUtil.toFileObject(dir);
FileObject[] children = dirFO.getChildren();
assertEquals(children.length, 0);
}

public void testBrokenSymbolicLink3() throws IOException {
if (!checkSymlinksSupported()) {
return;
}
File dir = getWorkDir();
File data = new File(dir, "data.dat");
File link = new File(dir, "link.lnk");
Files.createSymbolicLink(link.toPath(), data.toPath());
FileObject dirFO = FileUtil.toFileObject(dir);
dirFO.getChildren(); //Cache children
FileObject linkFO = FileUtil.toFileObject(link);
assertNull(linkFO);
}

/**
* Test getCanonicalFileObject method.
*
Expand Down

0 comments on commit 39048d6

Please sign in to comment.