From 3870736a30195d333ed8d111cc097d813c619490 Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sun, 19 Nov 2023 18:23:28 +0100 Subject: [PATCH] clean up tests a bit --- .../MemoryDirectoryStreamTest.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/test/java/com/github/marschall/memoryfilesystem/MemoryDirectoryStreamTest.java b/src/test/java/com/github/marschall/memoryfilesystem/MemoryDirectoryStreamTest.java index 8a88227..026d160 100644 --- a/src/test/java/com/github/marschall/memoryfilesystem/MemoryDirectoryStreamTest.java +++ b/src/test/java/com/github/marschall/memoryfilesystem/MemoryDirectoryStreamTest.java @@ -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 directoryStream = Files.newDirectoryStream(hd)) { + try (DirectoryStream directoryStream = Files.newDirectoryStream(macintoshHd)) { List actual = new ArrayList<>(2); for (Path each : directoryStream) { actual.add(each.toRealPath().toString()); } + actual.sort(null); List expected = Arrays.asList( - volumes.toRealPath().toString(), - abc.toRealPath().toString() - ); - assertEquals(expected.size(), actual.size()); - - Set actualSet = new HashSet<>(actual); - assertEquals(actualSet.size(), actual.size()); - - Set expectedSet = new HashSet<>(expected); - assertEquals(expectedSet, actualSet); + volumes.toRealPath().toString(), + abc.toRealPath().toString()); + assertEquals(expected, actual); } }