Skip to content

Commit 02e5f12

Browse files
committed
Tests IO-872 PathUtils.directoryAndFileContentEquals doesn't work across
FileSystems. WindowsPath and ZipPath equals() methods always return false if the argument is not of the same instance as itself.
1 parent aadc8c9 commit 02e5f12

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.nio.file.Path;
3030
import java.nio.file.Paths;
3131

32+
import org.junit.jupiter.api.Disabled;
3233
import org.junit.jupiter.api.Test;
3334
import org.junit.jupiter.api.io.TempDir;
3435

@@ -100,6 +101,23 @@ public void testDirectoryAndFileContentEquals() throws Exception {
100101
}
101102
}
102103

104+
/**
105+
* Tests IO-872 PathUtils.directoryAndFileContentEquals doesn't work across FileSystems.
106+
*
107+
* @throws Exception on test failure.
108+
*/
109+
@Disabled
110+
@Test
111+
public void testDirectoryAndFileContentEqualsDifferentFileSystems() throws Exception {
112+
final Path dir1 = Paths.get("src/test/resources/dir-equals-tests");
113+
try (FileSystem fileSystem = FileSystems.newFileSystem(dir1.resolveSibling(dir1.getFileName() + ".zip"), null)) {
114+
final Path dir2 = fileSystem.getPath("/dir-equals-tests");
115+
// WindowsPath and ZipPath equals() methods always return false if the argument is not of the same instance as itself.
116+
assertTrue(PathUtils.directoryAndFileContentEquals(dir1, dir2));
117+
}
118+
}
119+
120+
103121
@Test
104122
public void testDirectoryContentEquals() throws Exception {
105123
// Non-existent files
8.76 KB
Binary file not shown.

0 commit comments

Comments
 (0)