Skip to content

Commit 196ab82

Browse files
committed
Test PathUtils.fileContentEquals(Path, Path) with zip files
1 parent 8aa0418 commit 196ab82

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/test/java/org/apache/commons/io/file/PathUtilsContentEqualsTest.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,33 +167,43 @@ public void testFileContentEquals() throws Exception {
167167
assertTrue(PathUtils.fileContentEquals(path1, path2));
168168
assertTrue(PathUtils.fileContentEquals(path2, path2));
169169
assertTrue(PathUtils.fileContentEquals(path2, path1));
170-
170+
171171
// Directories
172172
assertThrows(IOException.class, () -> PathUtils.fileContentEquals(temporaryFolder.toPath(), temporaryFolder.toPath()));
173-
173+
174174
// Different files
175175
final Path objFile1 = Paths.get(temporaryFolder.getAbsolutePath(), getName() + ".object");
176176
PathUtils.copyFile(getClass().getResource("/java/lang/Object.class"), objFile1);
177-
177+
178178
final Path objFile1b = Paths.get(temporaryFolder.getAbsolutePath(), getName() + ".object2");
179179
PathUtils.copyFile(getClass().getResource("/java/lang/Object.class"), objFile1b);
180-
180+
181181
final Path objFile2 = Paths.get(temporaryFolder.getAbsolutePath(), getName() + ".collection");
182182
PathUtils.copyFile(getClass().getResource("/java/util/Collection.class"), objFile2);
183-
183+
184184
assertFalse(PathUtils.fileContentEquals(objFile1, objFile2));
185185
assertFalse(PathUtils.fileContentEquals(objFile1b, objFile2));
186186
assertTrue(PathUtils.fileContentEquals(objFile1, objFile1b));
187-
187+
188188
assertTrue(PathUtils.fileContentEquals(objFile1, objFile1));
189189
assertTrue(PathUtils.fileContentEquals(objFile1b, objFile1b));
190190
assertTrue(PathUtils.fileContentEquals(objFile2, objFile2));
191-
191+
192192
// Equal files
193193
Files.createFile(path1);
194194
Files.createFile(path2);
195195
assertTrue(PathUtils.fileContentEquals(path1, path1));
196196
assertTrue(PathUtils.fileContentEquals(path1, path2));
197197
}
198198

199+
@Test
200+
public void testFileContentEqualsZip() throws Exception {
201+
// Non-existent files
202+
final Path path1 = Paths.get("src/test/resources/org/apache/commons/io/bla.zip");
203+
final Path path2 = Paths.get("src/test/resources/org/apache/commons/io/bla-copy.zip");
204+
final Path path3 = Paths.get("src/test/resources/org/apache/commons/io/moby.zip");
205+
assertTrue(PathUtils.fileContentEquals(path1, path2));
206+
assertFalse(PathUtils.fileContentEquals(path1, path3));
207+
}
208+
199209
}
666 Bytes
Binary file not shown.
666 Bytes
Binary file not shown.
4.78 KB
Binary file not shown.

0 commit comments

Comments
 (0)