You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2021/02/15 15:23:50 UTC
svn commit: r1886532 -
/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
Author: centic
Date: Mon Feb 15 15:23:49 2021
New Revision: 1886532
URL: http://svn.apache.org/viewvc?rev=1886532&view=rev
Log:
Do not fail test which compares two documents if the timestamp in the ZIP header field is different
Modified:
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1886532&r1=1886531&r2=1886532&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Mon Feb 15 15:23:49 2021
@@ -39,6 +39,7 @@ import java.util.List;
import java.util.Map;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.FormulaParseException;
@@ -1827,8 +1828,25 @@ public abstract class BaseTestBugzillaIs
out1.flush();
out2.flush();
- assertArrayEquals(out1.toByteArray(), out2.toByteArray());
+ // to avoid flaky tests if the documents are written at slightly different timestamps
+ // we clear some bytes which contain timestamps
+ assertArrayEquals(
+ removeTimestamp(out1.toByteArray()),
+ removeTimestamp(out2.toByteArray()));
}
}
}
-}
\ No newline at end of file
+
+ private byte[] removeTimestamp(byte[] bytes) {
+ if (FileMagic.valueOf(bytes) == FileMagic.OOXML) {
+ // This removes the timestamp in the header of the ZIP-Format
+ // see "Local file header" at https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
+ bytes[10] = 0;
+ bytes[11] = 0;
+ bytes[12] = 0;
+ bytes[13] = 0;
+ }
+
+ return bytes;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org