Bug 64179 - [PATCH] Fix TestCellFormat.testApplyObjectDate() fail in different time zone
Summary: [PATCH] Fix TestCellFormat.testApplyObjectDate() fail in different time zone
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-26 12:55 UTC by Hyeonmin Park
Modified: 2020-03-07 15:35 UTC (History)
1 user (show)



Attachments
It's a zip archive which includes diff result(diff.txt), the screenshot of the failed test(fail.png), the screenshot of the resolved test(fix.png). (224.29 KB, application/x-zip-compressed)
2020-02-26 12:55 UTC, Hyeonmin Park
Details
Patch to set time zone of SimpleDateTime instance to pass the testcase in any time zone (787 bytes, patch)
2020-02-26 13:42 UTC, Hyeonmin Park
Details | Diff
The test really fails in a few time zone. I'm in Asia/Seoul(UTC+9). (109.48 KB, image/png)
2020-02-26 13:44 UTC, Hyeonmin Park
Details
Updated original patch to match convention of instance name (790 bytes, patch)
2020-02-26 13:46 UTC, Hyeonmin Park
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hyeonmin Park 2020-02-26 12:55:29 UTC
Created attachment 37045 [details]
It's a zip archive which includes diff result(diff.txt), the screenshot of the failed test(fail.png), the screenshot of the resolved test(fix.png).

Due to the time zone, the test `TextCellFormat.testApplyObjectDate()` fails in my machine. I'm in Asia/Seoul(UTC+9) zone.

> > Task :main:test
> 
> expected:<1/1[1]/2012> but was:<1/1[0]/2012>
> Expected :1/11/2012
> Actual   :1/10/2012
> 
> org.junit.ComparisonFailure: expected:<1/1[1]/2012> but was:<1/1[0]/2012>
> 	at org.junit.Assert.assertEquals(Assert.java:117)
> 	at org.junit.Assert.assertEquals(Assert.java:146)
> 	at org.apache.poi.ss.format.TestCellFormat.testApplyObjectDate(TestCellFormat.java:856)
> 	...

As `TestCellFormat.setTimeZone()` sets the user time zone to CET before tests, I changed to SimpleDateFormat instance have set time zone CET also.

The attached file is a zip archive which includes diff result(diff.txt), the screenshot of the failed test(fail.png), the screenshot of the resolved test(fix.png).
Comment 1 PJ Fanning 2020-02-26 13:02:33 UTC
Comment on attachment 37045 [details]
It's a zip archive which includes diff result(diff.txt), the screenshot of the failed test(fail.png), the screenshot of the resolved test(fix.png).

This 'fix' looks wrong to me.

The test passes reliably for me and and in your CI build.
Comment 2 Hyeonmin Park 2020-02-26 13:14:03 UTC
(In reply to PJ Fanning from comment #1)
> Comment on attachment 37045 [details]
> It's a zip archive which includes diff result(diff.txt), the screenshot of
> the failed test(fail.png), the screenshot of the resolved test(fix.png).
> 
> This 'fix' looks wrong to me.
> 
> The test passes reliably for me and and in your CI build.

The test surely fails in a few time zone. Try to change your machine time zone to Asia/Seoul and test again.
Comment 3 Hyeonmin Park 2020-02-26 13:42:03 UTC
Created attachment 37046 [details]
Patch to set time zone of SimpleDateTime instance to pass the testcase in any time zone
Comment 4 Hyeonmin Park 2020-02-26 13:44:39 UTC
Created attachment 37047 [details]
The test really fails in a few time zone. I'm in Asia/Seoul(UTC+9).
Comment 5 Hyeonmin Park 2020-02-26 13:46:46 UTC
Created attachment 37048 [details]
Updated original patch to match convention of instance name
Comment 6 Dominik Stadler 2020-03-07 15:35:50 UTC
Applied via r1874949, thanks for the Patch.