[ 
https://issues.apache.org/jira/browse/DRILL-5717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16215504#comment-16215504
 ] 

ASF GitHub Bot commented on DRILL-5717:
---------------------------------------

Github user vvysotskyi commented on the issue:

    https://github.com/apache/drill/pull/904
  
    @weijietong thanks for the explanation of your problem. I was able to 
reproduce it, but also I found working solution. This mock works correctly. The 
problem appears when unit test is run with other tests: 
[DateTimeZone](https://github.com/JodaOrg/joda-time/blob/ba95735daf79d00ce0928f30701d691f5e029d81/src/main/java/org/joda/time/DateTimeZone.java)
 class contains static field 
[cDefault](https://github.com/JodaOrg/joda-time/blob/ba95735daf79d00ce0928f30701d691f5e029d81/src/main/java/org/joda/time/DateTimeZone.java#L128)
 which is used to receive timezone in `testToDateForTimeStamp()` and in other 
tests. When timezone does not set to this field, but method 
[getDefault()](https://github.com/JodaOrg/joda-time/blob/ba95735daf79d00ce0928f30701d691f5e029d81/src/main/java/org/joda/time/DateTimeZone.java#L149)
 is called, value is taken from `System.getProperty()`. 
    When the first test that calls this method does not have a mock, it sets a 
real value of timezone from `System.getProperty()`. Therefore our test uses a 
unmocked value from `cDefault`. 
    
    So lets mock `DateTimeZone.getDefault()` method:
    ```
        new MockUp<DateTimeZone>() {
          @Mock
          public DateTimeZone getDefault() {
            return DateTimeZone.UTC;
          }
        };
    ```


> change some date time unit cases with specific timezone or Local
> ----------------------------------------------------------------
>
>                 Key: DRILL-5717
>                 URL: https://issues.apache.org/jira/browse/DRILL-5717
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Tools, Build & Test
>    Affects Versions: 1.9.0, 1.11.0
>            Reporter: weijie.tong
>
> Some date time test cases like  JodaDateValidatorTest  is not Local 
> independent .This will cause other Local's users's test phase to fail. We 
> should let these test cases to be Local env independent.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to