You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CI fails on Linux JDK 17: Mockito state corrupted by mock(Method.class) in WinRMInvocationHandlerTest #84
Mocking core JDK reflection types breaks Mockito's own reflection internals (mockito#2026). After this mock is created, later stubbing of methods such as executeCommand(...) can fail with a NullPointerException on Method.getParameterTypes().
The InvalidUseOfMatchersException in WinRMWqlExecutorTest is a secondary effect of polluted Mockito matcher state, not a separate bug in that test.
Why it passes locally but fails in CI
Surefire test execution order is filesystem-dependent:
Environment
Typical order
Result
Windows local
WinRMCommandExecutorTest runs before WinRMInvocationHandlerTest
Pass
Linux CI
WinRMInvocationHandlerTest runs first, corrupts Mockito, then others fail
Fail
Proposed fix
WinRMInvocationHandlerTest — Remove mock(Method.class). Use a real WinRMWebService.receiveMethod and stub WIN_RM_WS.receive(...) instead of Method.invoke(...).
WinRMCommandExecutorTest — In the SMB/file-copy path, mock WinRMService (concrete class) instead of the WindowsRemoteExecutor interface, and use eq(UTF_8) instead of any(Charset.class) for consistency with the other test branch.
Acceptance criteria
mvn test passes on Linux CI with JDK 17
Tests pass regardless of Surefire execution order (e.g. -Dtest=WinRMInvocationHandlerTest,WinRMCommandExecutorTest,WinRMWqlExecutorTest)
No mocking of java.lang.reflect.Method or other core JDK reflection types in tests
Activity
Merge pull request #83 from MetricsHub/fix/junit-tests-fixes