Skip to content

Commit

Permalink
clean up tests a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
marschall committed Nov 19, 2023
1 parent 465dacd commit 3870736
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,27 @@ void directoryStreamRelative() throws IOException {
void directoryStreamFollowsSymlink() throws IOException {
FileSystem fileSystem = this.extension.getFileSystem();

/*
* /
* /Volumes
* /Volumes/Macintosh HD -> / (symlink)
* /abc.txt
*/
Path root = fileSystem.getRootDirectories().iterator().next();
Path volumes = Files.createDirectory(root.resolve("Volumes"));
Path hd = Files.createSymbolicLink(volumes.resolve("Macintosh HD"), root);

Path macintoshHd = Files.createSymbolicLink(volumes.resolve("Macintosh HD"), root);
Path abc = Files.createFile(root.resolve("abc.txt"));

try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(hd)) {
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(macintoshHd)) {
List<String> actual = new ArrayList<>(2);
for (Path each : directoryStream) {
actual.add(each.toRealPath().toString());
}
actual.sort(null);
List<String> expected = Arrays.asList(
volumes.toRealPath().toString(),
abc.toRealPath().toString()
);
assertEquals(expected.size(), actual.size());

Set<String> actualSet = new HashSet<>(actual);
assertEquals(actualSet.size(), actual.size());

Set<String> expectedSet = new HashSet<>(expected);
assertEquals(expectedSet, actualSet);
volumes.toRealPath().toString(),
abc.toRealPath().toString());
assertEquals(expected, actual);
}
}

Expand Down

0 comments on commit 3870736

Please sign in to comment.