Solr
  1. Solr
  2. SOLR-4634

Fix test bugs in Javascript tests to work with Java 8's Mozilla-Rhino-replacement "Nashorn"

    Details

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

      Description

      the new Java 8 builds have replaced "Mozilla Rhino" JavaScript engine with "Nashorn" (http://openjdk.java.net/projects/nashorn/). The tests assume that a specific java type is returned, which is not guaranteed and Rhino-specific. Instead it should only cast to java.lang.Number and not to a specific type. The reason for the difference: Javascript is typeless, it only knows numbers, but not double/integer/...

      The other bug is not explainable to me, I think its some other problem. Il will fix the first one.

      The following tests fail, mostly with "java.lang.Integer cannot be casted to java.lang.Double":

      • org.apache.solr.update.processor.ScriptEngineTest.testEvalText
      • org.apache.solr.update.processor.ScriptEngineTest.testPut
      • org.apache.solr.update.processor.ScriptEngineTest.testEvalReader

      Those fail with some assert problem (method not found, I think the javascript is bogus):

      • org.apache.solr.update.processor.StatelessScriptUpdateProcessorFactoryTest.testSingleScript
      • org.apache.solr.update.processor.StatelessScriptUpdateProcessorFactoryTest.testMultipleScripts
      1. SOLR-4634.patch
        7 kB
        Uwe Schindler

        Activity

        Hide
        Uwe Schindler added a comment -

        This patch fixes both issues and another tye error in DIH:

        • The fix was to cast to Number and not expect a specific number type
        • In DIH there was a wrong String type expected
        • the problem with assertNotNull not found was a preexisting bug in the script: It tried to call a static method (Assert.assertNotNull) on an instance, which is not allowed by "corect" javascript. I fixed this by directly using org.junit.Assert.
        Show
        Uwe Schindler added a comment - This patch fixes both issues and another tye error in DIH: The fix was to cast to Number and not expect a specific number type In DIH there was a wrong String type expected the problem with assertNotNull not found was a preexisting bug in the script: It tried to call a static method (Assert.assertNotNull) on an instance, which is not allowed by "corect" javascript. I fixed this by directly using org.junit.Assert.
        Hide
        Uwe Schindler added a comment -

        Committed to 4.x and trunk.

        Show
        Uwe Schindler added a comment - Committed to 4.x and trunk.
        Hide
        Mark Miller added a comment -

        Thanks Uwe!

        Show
        Mark Miller added a comment - Thanks Uwe!

          People

          • Assignee:
            Uwe Schindler
            Reporter:
            Uwe Schindler
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development