legend-pure icon indicating copy to clipboard operation
legend-pure copied to clipboard

TestPureDate.java fails on Java 11.0.9

Open ghost opened this issue 4 years ago • 0 comments

Bug Report

In Java 11.0.9 the use of timezone "CST" no longer works causing the test on line 55 of TestPureDate.java to fail:

https://github.com/finos/legend-pure/blob/f98651e4c3e0f76e41905c3f63aebb8eb4ec40b1/legend-pure-m4/src/test/java/org/finos/legend/pure/m4/primitives/TestPureDate.java#L55

Tests run: 13, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.388 sec <<< FAILURE! - in org.finos.legend.pure.m4.coreinstance.primitive.date.TestPureDate
testFormatWithTimeZoneShift(org.finos.legend.pure.m4.coreinstance.primitive.date.TestPureDate)  Time elapsed: 0.029 sec  <<< FAILURE!

This should instead be

Assert.assertEquals("2013-12-31 19:01:01.070 GMT-06:00", date.format("[CST]yyyy-MM-dd HH:mm:ss.SSS z"));

Steps to Reproduce:

  1. Using Java 11.0.9
  2. run mvn -Dtest=TestPureDate test
  3. The test on line 55 fails
  4. Using Java 11.0.7
  5. run mvn -Dtest=TestPureDate test
  6. The test on line 55 passes

Expected Result:

The test should pass consistently on 11.0.7 and 11.0.9

Actual Result:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.finos.legend.pure.m4.coreinstance.primitive.date.TestPureDate
Tests run: 13, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.388 sec <<< FAILURE! - in org.finos.legend.pure.m4.coreinstance.primitive.date.TestPureDate
testFormatWithTimeZoneShift(org.finos.legend.pure.m4.coreinstance.primitive.date.TestPureDate)  Time elapsed: 0.029 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<...-12-31 19:01:01.070 [CST]> but was:<...-12-31 19:01:01.070 [GMT-06:00]>
        at org.junit.Assert.assertEquals(Assert.java:117)
        at org.junit.Assert.assertEquals(Assert.java:146)
        at org.finos.legend.pure.m4.coreinstance.primitive.date.TestPureDate.testFormatWithTimeZoneShift(TestPureDate.java:55)

Results :

Failed tests:
  TestPureDate.testFormatWithTimeZoneShift:55 expected:<...-12-31 19:01:01.070 [CST]> but was:<...-12-31 19:01:01.070 [GMT-06:00]>

Environment:

Version: master after commit f98651e OS: Ubuntu 18.04.5 LTS and Windows 10 (baremetal) Java: 11.0.7 and 11.0.9

Additional Context:

As this issue is version specific I believe it needs a deeper dive into the use of java.util.TimeZone across the project. In this case used on line 255 of DateFormat.java

https://github.com/finos/legend-pure/blob/66fbd19bab3d358ccbf957a913cd7b6b13a65b92/legend-pure-m4/src/main/java/org/finos/legend/pure/m4/coreinstance/primitive/date/DateFormat.java#L255

I am happy to open a PR to resolve across the board; let me know if you would like me to proceed

Ref: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/TimeZone.html

ghost avatar Nov 13 '20 15:11 ghost