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 196ab82c Test PathUtils.fileContentEquals(Path, Path) with zip files 196ab82c is described below commit 196ab82c1aabf334edcae29ccd70c998c38057f6 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Nov 10 09:29:32 2023 -0500 Test PathUtils.fileContentEquals(Path, Path) with zip files --- .../io/file/PathUtilsContentEqualsTest.java | 24 +++++++++++++++------ .../resources/org/apache/commons/io/bla-copy.zip | Bin 0 -> 666 bytes src/test/resources/org/apache/commons/io/bla.zip | Bin 0 -> 666 bytes src/test/resources/org/apache/commons/io/moby.zip | Bin 0 -> 4897 bytes 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java index 13ea17f2..b094d35e 100644 --- a/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java +++ b/src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java @@ -167,28 +167,28 @@ public class PathUtilsContentEqualsTest { assertTrue(PathUtils.fileContentEquals(path1, path2)); assertTrue(PathUtils.fileContentEquals(path2, path2)); assertTrue(PathUtils.fileContentEquals(path2, path1)); - + // Directories assertThrows(IOException.class, () -> PathUtils.fileContentEquals(temporaryFolder.toPath(), temporaryFolder.toPath())); - + // Different files final Path objFile1 = Paths.get(temporaryFolder.getAbsolutePath(), getName() + ".object"); PathUtils.copyFile(getClass().getResource("/java/lang/Object.class"), objFile1); - + final Path objFile1b = Paths.get(temporaryFolder.getAbsolutePath(), getName() + ".object2"); PathUtils.copyFile(getClass().getResource("/java/lang/Object.class"), objFile1b); - + final Path objFile2 = Paths.get(temporaryFolder.getAbsolutePath(), getName() + ".collection"); PathUtils.copyFile(getClass().getResource("/java/util/Collection.class"), objFile2); - + assertFalse(PathUtils.fileContentEquals(objFile1, objFile2)); assertFalse(PathUtils.fileContentEquals(objFile1b, objFile2)); assertTrue(PathUtils.fileContentEquals(objFile1, objFile1b)); - + assertTrue(PathUtils.fileContentEquals(objFile1, objFile1)); assertTrue(PathUtils.fileContentEquals(objFile1b, objFile1b)); assertTrue(PathUtils.fileContentEquals(objFile2, objFile2)); - + // Equal files Files.createFile(path1); Files.createFile(path2); @@ -196,4 +196,14 @@ public class PathUtilsContentEqualsTest { assertTrue(PathUtils.fileContentEquals(path1, path2)); } + @Test + public void testFileContentEqualsZip() throws Exception { + // Non-existent files + final Path path1 = Paths.get("src/test/resources/org/apache/commons/io/bla.zip"); + final Path path2 = Paths.get("src/test/resources/org/apache/commons/io/bla-copy.zip"); + final Path path3 = Paths.get("src/test/resources/org/apache/commons/io/moby.zip"); + assertTrue(PathUtils.fileContentEquals(path1, path2)); + assertFalse(PathUtils.fileContentEquals(path1, path3)); + } + } diff --git a/src/test/resources/org/apache/commons/io/bla-copy.zip b/src/test/resources/org/apache/commons/io/bla-copy.zip new file mode 100644 index 00000000..160eedc6 Binary files /dev/null and b/src/test/resources/org/apache/commons/io/bla-copy.zip differ diff --git a/src/test/resources/org/apache/commons/io/bla.zip b/src/test/resources/org/apache/commons/io/bla.zip new file mode 100644 index 00000000..160eedc6 Binary files /dev/null and b/src/test/resources/org/apache/commons/io/bla.zip differ diff --git a/src/test/resources/org/apache/commons/io/moby.zip b/src/test/resources/org/apache/commons/io/moby.zip new file mode 100644 index 00000000..ae3f9ee6 Binary files /dev/null and b/src/test/resources/org/apache/commons/io/moby.zip differ