diff --git a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java index 08e75c1137fe..ad2b06067767 100644 --- a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java +++ b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java @@ -54,6 +54,7 @@ import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; @@ -615,11 +616,17 @@ public void testListFilesInRootDirectory() throws IOException { // test absolute path, relative path. for (String check : new String[]{".", "/", ""}) { Path rootPath = fs.getPath(check); - List objectNames = new ArrayList<>(); + List pathsFound = new ArrayList<>(); for (Path path : Files.newDirectoryStream(rootPath)) { - objectNames.add(path.toString()); + // The returned paths will match the absolute-ness of the root path + // (this matches the behavior of the built-in UNIX file system). + assertWithMessage("Absolute/relative for " + check + ": ") + .that(path.isAbsolute()).isEqualTo(rootPath.isAbsolute()); + // To simplify the check that we found our files, we normalize here. + pathsFound.add(path.toAbsolutePath()); } - assertWithMessage("Listing " + check + ": ").that(objectNames).containsExactly(BIG_FILE, SML_FILE); + assertWithMessage("Listing " + check + ": ").that(pathsFound).containsExactly( + fs.getPath(BIG_FILE).toAbsolutePath(), fs.getPath(SML_FILE).toAbsolutePath()); } }