Skip to content

Remove Mockito: replace mock-based tests with fakes and FakeWsmanServer - #132

Merged
bertysentry merged 1 commit into
mainfrom
119-remove-mockito-replace-mock-based-tests-with-fakes
Jul 27, 2026
Merged

Remove Mockito: replace mock-based tests with fakes and FakeWsmanServer#132
bertysentry merged 1 commit into
mainfrom
119-remove-mockito-replace-mock-based-tests-with-fakes

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Closes #119.

What

Removes org.mockito:mockito-inline (deprecated, breaks on recent JDKs) and rewrites the last three mock-based test files as end-to-end tests against the in-process FakeWsmanServer.

Test rewrites

Test Before After
WinRMWqlExecutorTest mockStatic(WinRMExecutorFactory) + interface mock End to end: executeWql → factory → LightWinRMServiceWsmanClientFakeWsmanServer, real NTLMv2 handshake and message encryption; also pins the query sent on the wire
WinRMCommandExecutorTest mockStatic + ScriptedWindowsRemoteExecutor behind a mocked factory End to end for both paths: no-copy (code-page query + command + shell delete on close, ×3 file-list variants) and file-copy (the full in-shell transfer sequence: MKDIR, digest probe, chunked echo, certutil decode, publish, then CMD.EXE /C (...) with the content-addressed remote name)
WinRmCliTest.decodesCommandOutputUsingTheRemoteWindowsCodePage mock(LightWinRMService) + mockStatic(WindowsRemoteProcessUtils) End to end: the fake server reports CodeSet 1251 and serves windows-1251 stdout bytes; the test proves the CLI queries the code page and decodes with it

Test infrastructure

  • FakeWsmanServer is now public (usable from the wql, command, and cli test packages).
  • New FakeWsmanResponses helper: the canned SOAP response bodies (enumeration results, shell lifecycle, faults) and whole-exchange enqueue helpers, shared with WsmanProtocolTest (whose private duplicates are gone).

JDK 25 build support (acceptance criterion of #119)

With Mockito gone, the remaining JDK 25 blockers were the quality tools crashing on the JDK 25 class library ("Unsupported class file major version 69"):

  • maven-pmd-plugin 3.26.0 → 3.28.0 (PMD 7.7.0 → 7.17.0). PMD 7.7.0's failed type resolution also produced a false-positive UnusedPrivateMethod on LightWinRMService.executeWithTimeout.
  • spotbugs-maven-plugin 4.9.3.0 → 4.10.3.0, gate and site report pinned to the same version.

Verification

  • mvn clean verify site green on JDK 17 (CI) and JDK 25 (default): 83 tests, 0 checkstyle/PMD/CPD/SpotBugs findings — the JDK pin for local builds can be dropped.
  • mvn dependency:tree: no mockito, byte-buddy, or objenesis; test scope is JUnit only.
  • No org.mockito import remains anywhere in the repository.

🤖 Generated with Claude Code

…t FakeWsmanServer

The last three Mockito test files were forced into mockStatic by static factory
methods. They now run the real stack instead: WinRMWqlExecutor and
WinRMCommandExecutor go through WinRMExecutorFactory -> LightWinRMService ->
WsmanClient -> FakeWsmanServer (genuine NTLMv2 handshake and message
encryption), and the CLI code-page test scripts the CodeSet query on the fake
server rather than mocking the charset lookup.

FakeWsmanServer is now public and the canned SOAP response bodies are shared in
the new FakeWsmanResponses helper, also used by WsmanProtocolTest.

mockito-inline 5.2.0 (deprecated, incompatible with recent JDKs) leaves the
dependency tree along with byte-buddy and objenesis. maven-pmd-plugin (3.28.0,
PMD 7.17.0) and spotbugs-maven-plugin (4.10.3.0) are upgraded because the
previous versions crashed on the JDK 25 class library ("Unsupported class file
major version 69"); gate and site report stay on the same versions.

mvn clean verify site is green on JDK 17 and JDK 25: the JDK pin for local
builds is gone.

Closes #119

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bertysentry
bertysentry merged commit ac522f5 into main Jul 27, 2026
5 checks passed
@bertysentry
bertysentry deleted the 119-remove-mockito-replace-mock-based-tests-with-fakes branch July 27, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Mockito: replace mock-based tests with fakes and FakeWsmanServer

1 participant