Skip to content

Commit 4f1e896

Browse files
committed
Add one second tolerance for ZIP entries when compared in tests
When ZIP file is created the last modified time is stored in MS-DOS formated date(if it's in the valid range for MS-DOS time), but when it's read the last modification time from extra field data is used. When ZIP file is created from the content of other ZIP file created with third-party tool the last modified time might differ with one second. Modify ArchiveFileComparator so two ZIP files are still considered equal if their entries' last modified time vary only by one second.
1 parent eb4d980 commit 4f1e896

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/test/java/org/codehaus/plexus/archiver/zip/ArchiveFileComparator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ private static void assertEquals( ZipFile file1, ZipArchiveEntry entry1,
9898
throws Exception
9999
{
100100
Assert.assertEquals( entry1.isDirectory(), entry2.isDirectory() );
101-
Assert.assertEquals( entry1.getLastModifiedDate().getTime(), entry2.getLastModifiedDate().getTime() );
101+
long timeDelta = entry1.getLastModifiedDate().getTime() - entry2.getLastModifiedDate().getTime();
102+
Assert.assertTrue( Math.abs( timeDelta ) <= 1000 );
102103

103104
final InputStream is1 = file1.getInputStream( entry1 );
104105
final InputStream is2 = file2.getInputStream( entry2 );

0 commit comments

Comments
 (0)