Skip to content

Commit

Permalink
Update testListFilesInRootDirectory to match reality
Browse files Browse the repository at this point in the history
In the built-in UNIX filesystem, the newDirectoryStream method
will return absolute paths if given absolute paths as input,
and relative paths if given relative paths as input.

We're now seeing this too for the NIO Cloud Storage provider
(this is a good thing), so I updated this test to reflect
this new reality.
  • Loading branch information
jean-philippe-martin committed Oct 29, 2018
1 parent f774a36 commit 0b00977
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> objectNames = new ArrayList<>();
List<Path> 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());
}
}

Expand Down

0 comments on commit 0b00977

Please sign in to comment.