Problem with maven and mockito

Hi all,

I currently have a problem with maven and mockito. When I run tests from Idea IDE, everything works fine. When I ran them a few days (hours ?) ago, everything worked fine.
Since this morning, I get a failure when running command:

mvn test -Dtest=org.orekit.propagation.events.EventDetectorTest#testGetDetectionSettings

I get this:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.orekit.propagation.events.EventDetectorTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.375 s <<< FAILURE! - in org.orekit.propagation.events.EventDetectorTest
[ERROR] testGetDetectionSettings  Time elapsed: 0.368 s  <<< ERROR!
org.mockito.exceptions.base.MockitoException: 

Cannot call abstract real method on java object!
Calling real methods is only possible when mocking non abstract method.
  //correct example:
  when(mockOfConcreteClass.nonAbstractMethod()).thenCallRealMethod();
	at org.orekit.propagation.events.EventDetectorTest.testGetDetectionSettings(EventDetectorTest.java:489)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   EventDetectorTest.testGetDetectionSettings:489 Mockito 
Cannot call abstract r...
[INFO] 
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.233 s
[INFO] Finished at: 2024-09-17T13:08:04+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project orekit: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/luc/sources/java/orekit/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

The culprit seems to be the getDetectionSettings method, which has a default implementation in the EventDetector interface. However, the method and the test seem to have be here at least for one month, and I think I did run maven tests in the last few days without any problem. I think there was an upgrade recently of my JVM (I am running Debian), so maybe its a mockito/maven/JVM triplet that triggers the problem.

I have no clue how to solve this. It seems we cannot upgrade the mockito plugin as a comment in the pom states that the version we use is the last one to support java 8.

This is really troublesome to me just now, it arrives just at the wrong time. I am considering just adding an @Disabled annotation to this test as I really am in a hurry.

If anyone has a clue, help would be greatly appreciated.

Putting @Disabled does not help…

OK, putting @Disabled on both EventDetectorTest and FieldEventDetectorTest worked.
But this is just a temporary hack.

Hi!

Maybe the solution is to upgrade our Java version in order to use a more recent mockito version :slight_smile: