Skip to content

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

Description

@bertysentry

Goal

Remove Mockito (org.mockito:mockito-inline:5.2.0, test scope) from the project and replace the remaining mock-based tests with hand-rolled fakes and end-to-end tests against the existing FakeWsmanServer.

Why

  • JDK 25 incompatibility: Mockito''s inline mock maker (byte-buddy agent) breaks on recent JDKs; today the project must be built with JDK 17 solely because of the Mockito-based tests.
  • Deprecated artifact: mockito-inline was merged into mockito-core in Mockito 5.3 — the current dependency is a dead end regardless.
  • Testing style: 13 of 17 test files already test without mocks, using FakeWsmanServer (an in-process WSMan fake speaking genuine NTLMv2) or plain fakes. The 4 Mockito files are leftovers, all forced into mockStatic by static factory methods (WinRMExecutorFactory.createInstance, SmbTempShare.createInstance, WindowsRemoteProcessUtils.getWindowsEncodingCharset).

Plan (file by file)

Test file Mockito usage Replacement
SmbTempShareTest 4x mockStatic + mocks of smbj Connection/Session/DiskShare Deleted by #117 — the replacement file-copy tests run against FakeWsmanServer or a hand-rolled WindowsRemoteExecutor fake
WinRMWqlExecutorTest mockStatic(WinRMExecutorFactory) + interface mock Rewrite end-to-end against FakeWsmanServer (factory -> LightWinRMService -> WsmanClient -> fake server); also covers factory wiring
WinRMCommandExecutorTest 3x mockStatic + interface mocks No-copy path: end-to-end against FakeWsmanServer. File-copy path: after #117, also through the fake server
WinRmCliTest 1 test (decodesCommandOutputUsingTheRemoteWindowsCodePage) uses mock/mockStatic; the rest already uses a hand-rolled FakeRemote Small injectable seam for the charset lookup, or script the codepage query on FakeWsmanServer

Sequencing

Blocked by #117 (remove smbj): doing this first would mean reworking the SMB mocks for nothing, since SmbTempShareTest and the file-copy path of WinRMCommandExecutorTest are rewritten there anyway.

Acceptance criteria

  • No org.mockito dependency in pom.xml; mockito-inline, byte-buddy, byte-buddy-agent, and objenesis gone from mvn dependency:tree.
  • No org.mockito import anywhere in src/test.
  • mvn verify green on JDK 17 and the current default JDK (25) — the JDK pin for builds can be dropped.
  • Test coverage of the converted tests is equal or better (the FakeWsmanServer end-to-end versions additionally verify factory wiring and real NTLM framing).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions