Java 21 was released Sep 19, 2023. We would like the most used plugins to be compiled and tested with Java 21.

      The acceptance test harness and plugin bill of materials tests are already passing with Java 21. This is a further step to improve plugin readiness for use with Java 21 and for development with Java 21.

      This plugin uses Powermock for its tests.
      I've made a few updates to get the plugins to compile with JDK21 in my fork.

      Unfortunately, I still get a lot of these errors:

      [ERROR] hudson.plugins.buildblocker.BlockingJobsMonitorUnitTest.testCheckAllNodesForRunningBuildReturnsBlockedMatrixProject -- Time elapsed: 0 s <<< ERROR!
      java.lang.NoSuchMethodError: 'org.mockito.stubbing.Answer org.mockito.Answers.get()'
              at org.powermock.api.extension.listener.AnnotationEnabler.standardInject(AnnotationEnabler.java:85)
              at org.powermock.api.extension.listener.AnnotationEnabler.beforeTestMethod(AnnotationEnabler.java:55)
              at org.powermock.tests.utils.impl.PowerMockTestNotifierImpl.notifyBeforeTestMethod(PowerMockTestNotifierImpl.java:82)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:308)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:298)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:218)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:160)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:134)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:136)
              at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:117)
              at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)
              at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
      
      

      Would it be possible to migrate this plugin to Mockito only, instead of Powermock?
      See https://github.com/powermock/powermock/issues/1109#issuecomment-1379680257 "You want to hear, but we upgraded Mockito to 4.0.0 and stopped using PowerMock altogether because Mockito allows to mock static methods since 3.4.0, which was the only reason we used PowerMock."

      Is that the case with this plugin?

      I tried the OpenRewrite recipe, but it failed with another error.

      Could basil please have a quick look?

      Thanks.

          [JENKINS-72250] Can't test with Java 21 because of Powermock

          Basil Crow added a comment -

          I have attached an example of how to migrate this plugin from PowerMock to Mockito.

          Basil Crow added a comment - I have attached an example of how to migrate this plugin from PowerMock to Mockito.

          Basil Crow added a comment -

          Any update on this ticket?

          Basil Crow added a comment - Any update on this ticket?

          Andique added a comment -

          I've modernized the plugin and implemented the rewrite to Mockito, however the tests in BlockingJobMonitorTest class are waiting for more than 180seconds and failing because of the JenkinsRule default settings. I'm working on rewriting the tests to reduce the wait time

          Andique added a comment - I've modernized the plugin and implemented the rewrite to Mockito, however the tests in BlockingJobMonitorTest class are waiting for more than 180seconds and failing because of the JenkinsRule default settings. I'm working on rewriting the tests to reduce the wait time

          Basil Crow added a comment -

          It might be helpful to create a draft PR with the existing progress.

          Basil Crow added a comment - It might be helpful to create a draft PR with the existing progress.

          Andique added a comment -

          I've created the PR. Thanks 

          Andique added a comment - I've created the PR. Thanks 

          Basil Crow added a comment -

          nnamdi_q Why does https://github.com/jenkinsci/build-blocker-plugin/pull/21 contain anything other than a verbatim copy of the attached patch? Your PR contains a number of unrelated changes, while the attached patch contains the minimal number of changes necessary to refresh the plugin.

          Basil Crow added a comment - nnamdi_q Why does https://github.com/jenkinsci/build-blocker-plugin/pull/21 contain anything other than a verbatim copy of the attached patch ? Your PR contains a number of unrelated changes, while the attached patch contains the minimal number of changes necessary to refresh the plugin.

          Andique added a comment -

          I made changes relating to BlockingJobMonitorTest because all the tests relating to freestyle jobs were timing out. I'll revert the changes and push to PR21 for your advice.

          Andique added a comment - I made changes relating to BlockingJobMonitorTest because all the tests relating to freestyle jobs were timing out. I'll revert the changes and push to PR21 for your advice.

          Basil Crow added a comment -

          Basil Crow added a comment - https://github.com/jenkinsci/build-blocker-plugin/commit/e42caa361e30baf4906e04cda6926a33201913d7

            nnamdi_q Andique
            poddingue Bruno Verachten
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: