Joda date causing unit test failure on Linux

In the project joda date is used to manage dates. It works as expected on windows but surprize, tests were failing on linux. The step by step investigation and findings are listed in this blog:

1. Date stored in DB might be incorrect.

– Junit uses hsql db which is in memory database to stored and execute test. While saving date in hsql db on Linux platform there could be some. To verify, test database was externalized to use MySql 5.1 database.

– Finding is data is stored correctly.

2. Upgrade joda date to latest version

– Project is using joda 1.1 and latest 1.3. By upgrading joda lib version issue will automatically be fixed.

– Finding is while upgrading joda date there were dependencies with hibernate, due to which exceptions (no such method found) are thrown.

3. Issue with the joda date convertor

– Joda uses date convertor which deals with hibernate. The suspection was when date is retrieved and converted, one day was deduced from the expected date to be retrieved. When System date is changed to GMT 0 and the tests started running successfully since there was not date conversion to local date.

– Finding is test run successfully for when system date is changed to US dates. That means when date is GMT -ve(American) and GMT 0 tests were running successfully. On further analysis the tests were failing only with GMT + 5:30 or 5:45.

4. Fix

– while returning the target date from code base – system os and time zone can be detected and corrected date ‘plusDays(1)’ can be returned on Indian time zone (and error prone tz) for Linux boxes.

Conclusion: These tests were failing on all the Linux boxes which have GMT +5:30 and +5:45 time zone however it is running successfully on American time zone and all other time zone. The server is at US time zone, and currently local installer is not supported for linux. As a part of up gradation entire technical stack this issue would automatically get fixed.
e (and error prone tz) for linux boxes.

Conclusion: Joda is going to be offical date time with upcoming jdk . Change technical stack so that latest joda can be used to resolve this issue.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s