Skip to content

Fix the log4j-spring-cloud-config-client test harness - #4317

Open
ramanathan1504 wants to merge 3 commits into
2.xfrom
fix-spring-cloud-config-client-test-harness
Open

Fix the log4j-spring-cloud-config-client test harness #4317
ramanathan1504 wants to merge 3 commits into
2.xfrom
fix-spring-cloud-config-client-test-harness

Conversation

@ramanathan1504

Copy link
Copy Markdown
Contributor

Follow-up to @vy's request on #4252. The module has run no tests since removed junit-vintage-engine while Log4j2EventListenerTest stayed on JUnit 4.

After Restoring jave some issues: CONFIG names a file that does not exist, Boot's bundled log4j2.xml claims the LoggerContext first, and no configuration declares monitorInterval, so WatchManager.start() never subscribes to WatchEventManager.

The module has run no tests since `8d706b4b27` (2024-01-04) removed
`junit-vintage-engine` while `Log4j2EventListenerTest` stayed on JUnit 4:
Surefire selects the JUnit Platform provider, discovers nothing and reports
`Tests run: 0` with a green build.

Restoring the engine exposes three further breakages that kept the only
assertion in the module unreachable:

- `CONFIG` named `log4j-console.xml`; the resource is `log4j2-console.xml`.
- `spring-boot-starter-log4j2` is a test dependency, so Boot installs its own
  bundled `log4j2.xml` before `LoggerContextRule` can install the module's.
- Neither configuration declares `monitorInterval`, so
  `AbstractConfiguration.isConfigurationMonitoringEnabled()` is false,
  `WatchManager.start()` never runs, nothing subscribes to
  `WatchEventManager` and `publishEvent()` iterates an empty map.

`logging.config` now points Boot at the module's own configuration and the
test reads the `LoggerContext` that Boot installed, which retires the
`LoggerContextRule` and `RuleChain`. `withCleanFilesRule("target/logs")` is
dropped with them; the configuration declares a single console appender and
has never written there.

Verified: `Tests run: 1, Failures: 0` with both halves in place, and
`Failures: 1` with either `monitorInterval` or the `logging.config` property
removed. Full `verify` on the module is green through spotbugs, RAT, spotless
and bnd-baseline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant