This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new 5f2b3d36 testProbeContentType behavior is OS-dependent.
5f2b3d36 is described below
commit 5f2b3d36322f754cbe3fca0cbec88532f381b8c9
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Jul 24 13:13:04 2022 -0400
testProbeContentType behavior is OS-dependent.
---
.../apache/commons/io/file/FilesUncheckTest.java | 39 ++++++++++++----------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java
b/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java
index 9346a332..9168c9e6 100644
--- a/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java
+++ b/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java
@@ -69,10 +69,10 @@ public class FilesUncheckTest {
private static final FileAttribute<?>[] EMPTY_FILE_ATTRIBUTES_ARRAY = {};
- private static final Path FILE_PATH_EMPTY =
Paths.get("src/test/resources/org/apache/commons/io/test-file-empty.bin");
-
private static final Path FILE_PATH_A =
Paths.get("src/test/resources/org/apache/commons/io/dirs-1-file-size-1/file-size-1.bin");
+ private static final Path FILE_PATH_EMPTY =
Paths.get("src/test/resources/org/apache/commons/io/test-file-empty.bin");
+
private static final Path NEW_DIR_PATH = Paths.get("target/newdir");
private static final Path NEW_FILE_PATH = Paths.get("target/file.txt");
@@ -293,18 +293,18 @@ public class FilesUncheckTest {
}
@Test
- public void testNewDirectoryStreamPathString() {
+ public void testNewDirectoryStreamPathFilterOfQsuperPath() {
Uncheck.run(() -> {
- try (final DirectoryStream<Path> directoryStream =
FilesUncheck.newDirectoryStream(TARGET_PATH, "*.xml")) {
+ try (final DirectoryStream<Path> directoryStream =
FilesUncheck.newDirectoryStream(TARGET_PATH, e -> true)) {
directoryStream.forEach(e -> assertEquals(TARGET_PATH,
e.getParent()));
}
});
}
@Test
- public void testNewDirectoryStreamPathFilterOfQsuperPath() {
+ public void testNewDirectoryStreamPathString() {
Uncheck.run(() -> {
- try (final DirectoryStream<Path> directoryStream =
FilesUncheck.newDirectoryStream(TARGET_PATH, e -> true)) {
+ try (final DirectoryStream<Path> directoryStream =
FilesUncheck.newDirectoryStream(TARGET_PATH, "*.xml")) {
directoryStream.forEach(e -> assertEquals(TARGET_PATH,
e.getParent()));
}
});
@@ -332,13 +332,18 @@ public class FilesUncheckTest {
@Test
public void testProbeContentType() {
- @SuppressWarnings("unused")
+ // Empty file:
String probeContentType =
FilesUncheck.probeContentType(FILE_PATH_EMPTY);
// Empirical: probeContentType is null on Windows
// Empirical: probeContentType is "text/plain" on Ubuntu
+ // Empirical: probeContentType is ? on macOS
+ //
+ // BOM file:
probeContentType =
FilesUncheck.probeContentType(Paths.get("src/test/resources/org/apache/commons/io/testfileBOM.xml"));
- assertTrue("text/xml".equals(probeContentType) ||
"application/xml".equals(probeContentType));
-
+ // Empirical: probeContentType is "text/plain" on Windows
+ // Empirical: probeContentType is "application/plain" on Ubuntu
+ // Empirical: probeContentType is ? on macOS
+ assertNotNull(probeContentType);
}
@Test
@@ -406,23 +411,23 @@ public class FilesUncheckTest {
}
@Test
- public void testWalkPathIntFileVisitOptionArray() {
- assertEquals(1, FilesUncheck.walk(TARGET_PATH, 0,
FileVisitOption.FOLLOW_LINKS).count());
+ public void testWalkFileTreePathFileVisitorOfQsuperPath() {
+ assertEquals(TARGET_PATH, FilesUncheck.walkFileTree(TARGET_PATH,
NoopPathVisitor.INSTANCE));
}
@Test
- public void testWalkPathFileVisitOptionArray() {
- assertTrue(0 < FilesUncheck.walk(TARGET_PATH,
FileVisitOption.FOLLOW_LINKS).count());
+ public void
testWalkFileTreePathSetOfFileVisitOptionIntFileVisitorOfQsuperPath() {
+ assertEquals(TARGET_PATH, FilesUncheck.walkFileTree(TARGET_PATH, new
HashSet<>(), 1, NoopPathVisitor.INSTANCE));
}
@Test
- public void testWalkFileTreePathFileVisitorOfQsuperPath() {
- assertEquals(TARGET_PATH, FilesUncheck.walkFileTree(TARGET_PATH,
NoopPathVisitor.INSTANCE));
+ public void testWalkPathFileVisitOptionArray() {
+ assertTrue(0 < FilesUncheck.walk(TARGET_PATH,
FileVisitOption.FOLLOW_LINKS).count());
}
@Test
- public void
testWalkFileTreePathSetOfFileVisitOptionIntFileVisitorOfQsuperPath() {
- assertEquals(TARGET_PATH, FilesUncheck.walkFileTree(TARGET_PATH, new
HashSet<>(), 1, NoopPathVisitor.INSTANCE));
+ public void testWalkPathIntFileVisitOptionArray() {
+ assertEquals(1, FilesUncheck.walk(TARGET_PATH, 0,
FileVisitOption.FOLLOW_LINKS).count());
}
@Test