Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-11606

Mockito does not work with newer Java versions -> disable tests automatically when no working Mockito

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.2, master (8.0)
    • Component/s: Tests
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:

      Description

      When running Solr's tests with Java versions that are not supported by the Mockito mocking library, it fails with an error message.

      We should disable the tests, if the underlying Mockito version does not allow to mock classes, because the Java version is too new. There is already and issue open at ByteBuddy that is the root cause: https://github.com/raphw/byte-buddy/issues/370 and https://github.com/mockito/mockito/issues/1243

      The idea here is to use ByteBuddy's ClassFileVersion class to check if mocking is supported. This adds a new method to SolrTestCaseJ4: assumeWorkingMockito()

      Tests that use the Mockito library should add this assume to their tests, to disable them if the mocking is not supported. Instead of using a Java version test, we do this with ByteBuddy, because this is more dynamic (if we update Mockito so it works with newer Java versions, it is automatically working).

      At the same time, we should update Mockito/ByteBuddy ASAP when a new version is available.

      1. SOLR-11606.patch
        20 kB
        Uwe Schindler
      2. SOLR-11606.patch
        22 kB
        Uwe Schindler

        Activity

        Hide
        thetaphi Uwe Schindler added a comment -

        Here is the patch. I will commit this after running tests with Java 10.

        Show
        thetaphi Uwe Schindler added a comment - Here is the patch. I will commit this after running tests with Java 10.
        Hide
        thetaphi Uwe Schindler added a comment -

        New patch, that also verifies that every test source file that uses Mockito at least contains a call to assumeWorkingMockito().

        Show
        thetaphi Uwe Schindler added a comment - New patch, that also verifies that every test source file that uses Mockito at least contains a call to assumeWorkingMockito() .
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 3ab1a07662db324be9cdb76a5acfcbc2cbbd85cf in lucene-solr's branch refs/heads/master from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3ab1a07 ]

        SOLR-11606: Disable tests automatically if Mockito does not work with Java runtime (Java 10)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 3ab1a07662db324be9cdb76a5acfcbc2cbbd85cf in lucene-solr's branch refs/heads/master from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3ab1a07 ] SOLR-11606 : Disable tests automatically if Mockito does not work with Java runtime (Java 10)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit c4a113ab9e3041deace6a5c85f5aa228a91151b5 in lucene-solr's branch refs/heads/branch_7x from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=c4a113a ]

        SOLR-11606: Disable tests automatically if Mockito does not work with Java runtime (Java 10)

        Show
        jira-bot ASF subversion and git services added a comment - Commit c4a113ab9e3041deace6a5c85f5aa228a91151b5 in lucene-solr's branch refs/heads/branch_7x from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=c4a113a ] SOLR-11606 : Disable tests automatically if Mockito does not work with Java runtime (Java 10)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 610efa79258910c7cf5025a0dbe73bc53f278785 in lucene-solr's branch refs/heads/master from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=610efa7 ]

        SOLR-11606: Add missing assumeWorkingMockito()

        Show
        jira-bot ASF subversion and git services added a comment - Commit 610efa79258910c7cf5025a0dbe73bc53f278785 in lucene-solr's branch refs/heads/master from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=610efa7 ] SOLR-11606 : Add missing assumeWorkingMockito()
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1af62a6ed0a1b1b0a2a93fd2756e004bcb24ea6b in lucene-solr's branch refs/heads/branch_7x from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=1af62a6 ]

        SOLR-11606: Add missing assumeWorkingMockito()

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1af62a6ed0a1b1b0a2a93fd2756e004bcb24ea6b in lucene-solr's branch refs/heads/branch_7x from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=1af62a6 ] SOLR-11606 : Add missing assumeWorkingMockito()

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development