Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5675

Some tests in ConvertExcelToCSVProcessorTest fail because of locale-dependent expressions

    XMLWordPrintableJSON

    Details

    • Type: Test
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.0
    • Component/s: Extensions
    • Labels:
      None

      Description

      Some tests in ConvertExcelToCSVProcessorTest fail in some locales because text in the assertions is locale-dependent.

      The problem is that DateTime expressions (such as "Sunday, January 01, 2017") are based on English and locale-dependent. When the locale of JVM is "ja_JP" for example, the tests fail as follows:

      [INFO] Running org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest
      [ERROR] Tests run: 13, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 5.32 s <<< FAILURE! - in org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest
      [ERROR] testSkipRows(org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest)  Time elapsed: 0.146 s  <<< FAILURE!
      org.junit.ComparisonFailure: 
      expected:<1234.46,12:00:00 [PM,£   123.45
      1234.5,Sunday\, January 01\, 2017,¥   123.45
      1\,234.46,1/1/17 12:00,$   1\,023.45
      1\,234.4560,12:00 PM],£   1\,023.45
      9.88E...> but was:<1234.46,12:00:00 [午後,£   123.45
      1234.5,日曜日\, 1月 01\, 2017,¥   123.45
      1\,234.46,1/1/17 12:00,$   1\,023.45
      1\,234.4560,12:00 午後],£   1\,023.45
      9.88E...>
      	at org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest.testSkipRows(ConvertExcelToCSVProcessorTest.java:153)
      
      [ERROR] testCustomDelimiters(org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest)  Time elapsed: 0.03 s  <<< FAILURE!
      org.junit.ComparisonFailure: 
      expected:<...5
      1234.46|12:00:00 [PM|£   123.45
      1234.5|Sunday, January 01, 2017|¥   123.45
      1,234.46|1/1/17 12:00|$   1,023.45
      1,234.4560|12:00 PM]|£   1,023.45
      9.88E...> but was:<...5
      1234.46|12:00:00 [午後|£   123.45
      1234.5|日曜日, 1月 01, 2017|¥   123.45
      1,234.46|1/1/17 12:00|$   1,023.45
      1,234.4560|12:00 午後]|£   1,023.45
      9.88E...>
      	at org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest.testCustomDelimiters(ConvertExcelToCSVProcessorTest.java:266)
      
      [ERROR] testQuoting(org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest)  Time elapsed: 0.029 s  <<< FAILURE!
      org.junit.ComparisonFailure: 
      expected:<...45
      1234.46,12:00:00 [PM,£   123.45
      1234.5,"Sunday, January 01, 2017",¥   123.45
      "1,234.46",1/1/17 12:00,"$   1,023.45"
      "1,234.4560",12:00 PM],"£   1,023.45"
      9.88...> but was:<...45
      1234.46,12:00:00 [午後,£   123.45
      1234.5,"日曜日, 1月 01, 2017",¥   123.45
      "1,234.46",1/1/17 12:00,"$   1,023.45"
      "1,234.4560",12:00 午後],"£   1,023.45"
      9.88...>
      	at org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest.testQuoting(ConvertExcelToCSVProcessorTest.java:125)
      
      [ERROR] testSkipRowsWithEL(org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest)  Time elapsed: 0.02 s  <<< FAILURE!
      org.junit.ComparisonFailure: 
      expected:<1234.46,12:00:00 [PM,£   123.45
      1234.5,Sunday\, January 01\, 2017,¥   123.45
      1\,234.46,1/1/17 12:00,$   1\,023.45
      1\,234.4560,12:00 PM],£   1\,023.45
      9.88E...> but was:<1234.46,12:00:00 [午後,£   123.45
      1234.5,日曜日\, 1月 01\, 2017,¥   123.45
      1\,234.46,1/1/17 12:00,$   1\,023.45
      1\,234.4560,12:00 午後],£   1\,023.45
      9.88E...>
      	at org.apache.nifi.processors.poi.ConvertExcelToCSVProcessorTest.testSkipRowsWithEL(ConvertExcelToCSVProcessorTest.java:181)
      

      To fix this, we can convert the expected DateTime strings using `DateTimeFormatter` in the assertions.

      Note that similar issues and fixes (for a different class) are here:

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kotarot Kotaro Terada
                Reporter:
                kotarot Kotaro Terada
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: