gnodet opened a new pull request, #14192:
URL: https://github.com/apache/maven/pull/14192

   ## Summary
   
   Remove the Mockito javaagent from the Maven build by rewriting the one test 
that required it.
   
   ## Root Cause
   
   `DefaultClassRealmManagerTest` used 
`Mockito.mockStatic(LoggerFactory.class)` to inject a mock logger and verify 
debug message ordering. Static mocking requires ByteBuddy instrumentation, 
which on JDK 21+ cannot self-attach without an explicit 
`-javaagent:mockito-core.jar`.
   
   To supply the agent path, the build used `dependency:properties` — which 
triggers full transitive dependency resolution and sets 
`${org.mockito:mockito-core:jar}` as a property. This introduced two problems:
   1. `dependency:properties` forces full transitive resolution, creating a 
scheduling barrier in concurrent builds (all transitive reactor JARs must be 
built before the mojo can run)
   2. The whole mechanism (`dependency:properties` → property → profile 
activation → `argLine.mockito`) adds unnecessary complexity for a single test
   
   ## Fix
   
   The test was verifying two distinct things:
   - **Structural outcomes** (realm ID, parent classloader, artifact inclusion 
based on file presence) — meaningful invariants
   - **Debug message ordering** — an implementation detail, not a contract
   
   The debug message assertions (`testDebugEnabled` / `testDebugDisabled`) 
verify that different log messages are emitted depending on `isDebugEnabled()`, 
but the structural outcome (which artifacts end up in the realm) is identical 
in both cases. The `isDebugEnabled()` guard is a performance optimization, not 
a testable behavioral difference.
   
   Rewrite as a single test asserting only the structural outcomes directly 
from the `ClassRealm`. Remove:
   - `mockStatic(LoggerFactory.class)` and all Mockito static/InOrder imports
   - The `dependency:properties` plugin execution (`prepare-for-mockito-agent`)
   - The `mockito` profile and `argLine.mockito` property
   - The `argLine.mockito` placeholder from `<properties>`
   
   ## Tests
   
   The rewritten `testProjectRealmIncludesArtifactsWithFileAndExcludesOthers` 
covers all the meaningful invariants previously spread across two tests.
   
   ---
   _Hermes Agent (Claude Sonnet 4.5) on behalf of Guillaume Nodet_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to