This PR improves test coverage for JsonErrorReportValve,
JsonAccessLogValve and HealthCheckValve by adding tests for previously
uncovered execution paths and configuration behavior.
Motivation
While reviewing Valve test coverage, a few remaining uncovered branches
were identified in these classes, primarily related to property handling,
pattern parsing and edge case behavior. This PR adds targeted tests to
exercise those paths and improve overall reliability.
Changes
JsonErrorReportValve
Extended existing TestJsonErrorReportValve with additional tests covering:
Throwable handling when message is null
Inherited setProperty/getProperty behavior
showReport and showServerInfo configuration handling
JsonAccessLogValve
Added new test class TestJsonAccessLogValve covering:
Default JSON log pattern behavior
Common and combined log patterns
Request/response header pattern handling
Cookie and session attribute pattern handling
createLogElements() behavior validation
HealthCheckValve
Extended TestHealthCheckValve to cover:
Property getters and setters
Custom health check path configuration
Container availability check configuration
Testing
All tests pass locally:
ant clean test
Targeted validation performed for the modified tests with no failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves test coverage for JsonErrorReportValve,
JsonAccessLogValve and HealthCheckValve by adding tests for previously
uncovered execution paths and configuration behavior.
Motivation
While reviewing Valve test coverage, a few remaining uncovered branches
were identified in these classes, primarily related to property handling,
pattern parsing and edge case behavior. This PR adds targeted tests to
exercise those paths and improve overall reliability.
Changes
JsonErrorReportValve
Extended existing TestJsonErrorReportValve with additional tests covering:
JsonAccessLogValve
Added new test class TestJsonAccessLogValve covering:
HealthCheckValve
Extended TestHealthCheckValve to cover:
Testing
All tests pass locally:
ant clean test
Targeted validation performed for the modified tests with no failures.
Test results:
TestJsonErrorReportValve: Tests run: 13, Failures: 0, Errors: 0
TestJsonAccessLogValve: Tests run: 6, Failures: 0, Errors: 0
TestHealthCheckValve: Tests run: 4, Failures: 0, Errors: 0
Coverage Impact
This PR increases coverage for:
All realistically testable execution paths are now covered.
Impact
No functional changes.
Test coverage improvement only.
Files Changed
TestJsonErrorReportValve.java (modified)
TestJsonAccessLogValve.java (new)
TestHealthCheckValve.java (modified)
Notes
This PR is part of ongoing work to systematically improve Valve test
coverage across Tomcat.
Checklist