ramanathan1504 opened a new pull request, #4427:
URL: https://github.com/apache/logging-log4j2/pull/4427
Migrate `log4j-api-test` tests to JUnit 5
Picks up #3218 by @Realtin (with their go-ahead there): their two commits
are kept as-is, with one commit on top that finishes the job.
`log4j-api-test` has no vintage engine, so its remaining JUnit 4 tests were
never executed. `LoaderUtilSecurityManagerTest` and
`MessageFormatMessageSerializationTest` report zero tests on `2.x` today.
On top of #3218:
- **`AbstractSerializationTest` is left unchanged.** It is public API of a
published artifact. The constructor change in #3218 fails `bnd-baseline` with a
MAJOR delta. `MessageFormatMessageSerializationTest` and
`LoggerSerializationTest` are now standalone `@ParameterizedTest`s instead.
- **`SecurityManagerExtension`** gets Javadoc and `@since 2.27.0`. It aborts
the test when the JVM refuses `System.setSecurityManager` (JDK 18+), and it
restores the previous manager only if its own is still installed.
- **`LoaderUtilSecurityManagerTest`**, which hit the `StackOverflowError`
reported in #3218:
- It resolves `LoaderUtil.GET_CLASS_LOADER` before the manager is
installed. Resolving it inside `checkPermission` recursed.
- It denies `getClassLoader` only outside privileged blocks. Denying it
everywhere broke JUnit's own JUL bootstrap in `TimeoutExtension`.
- The `assertFalse(GET_CLASS_LOADER_DISABLED)` assertion is dropped. That
value is decided by the JVM `Policy` through `AccessController`, not by
`SecurityManager#checkPermission`, and it is a static `LazyBoolean`, so the
test could not control it.
`SecurityManagerTestRule` and the other JUnit 4 rules in `src/main` stay for
downstream users.
Verified:
- `./mvnw -pl log4j-api-test install` passes: 961 tests, baseline and
Spotless clean.
- `LoggerSerializationTest` runs 8 tests, the same count as before.
- On JDK 21 the security-manager tests are skipped instead of erroring.
--
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]