Skip to content

Improve test coverage for JsonErrorReportValve, JsonAccessLogValve and HealthCheckValve#981

Open
onkar717 wants to merge 1 commit intoapache:mainfrom
onkar717:JsonErrorReportValve-AccessLogValve-HealthCheckValve
Open

Improve test coverage for JsonErrorReportValve, JsonAccessLogValve and HealthCheckValve#981
onkar717 wants to merge 1 commit intoapache:mainfrom
onkar717:JsonErrorReportValve-AccessLogValve-HealthCheckValve

Conversation

@onkar717
Copy link
Copy Markdown
Contributor

@onkar717 onkar717 commented Apr 6, 2026

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:

  • 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.

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:

  • JsonErrorReportValve (93% → improved)
  • JsonAccessLogValve (97% → improved)
  • HealthCheckValve (97% → improved)

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

  • Tests added
  • Existing tests pass
  • No functional changes
  • ASF license headers included
  • Changes limited to test code only
  • Build verified with ant clean test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant