Bug 64179

Summary: [PATCH] Fix TestCellFormat.testApplyObjectDate() fail in different time zone
Product: POI Reporter: Hyeonmin Park <hyeonmin.park>
Component: SS CommonAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: hyeonmin.park
Priority: P2    
Version: 4.1.2-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
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).
Patch to set time zone of SimpleDateTime instance to pass the testcase in any time zone
The test really fails in a few time zone. I'm in Asia/Seoul(UTC+9).
Updated original patch to match convention of instance name

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.