Skip to content

Improve test coverage for AccessLogValve and PersistentValve#979

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

Improve test coverage for AccessLogValve and PersistentValve#979
onkar717 wants to merge 1 commit intoapache:mainfrom
onkar717:AccessLogValve-PersistentValve

Conversation

@onkar717
Copy link
Copy Markdown
Contributor

@onkar717 onkar717 commented Apr 5, 2026

Summary

This PR improves test coverage for AccessLogValve and PersistentValve by
adding tests for currently uncovered functionality related to file I/O,
log rotation, configuration handling and request filtering.

Motivation

While reviewing valve test coverage, AccessLogValve-specific logic such as
file writing, rotation, encoding handling and maxDays cleanup was found to
have little or no direct coverage. Similarly, several configuration and
filter-related paths in PersistentValve were not exercised.

This PR focuses on improving coverage for these implementation-specific
code paths.

Changes

AccessLogValve

Added new test class:

TestAccessLogValveFile

Coverage improvements include:

  • File log writing behavior
  • Log rotation logic
  • Rotation with custom filenames
  • renameOnRotate behavior
  • maxDays log cleanup
  • Buffered vs unbuffered writes
  • File existence checks
  • Encoding configuration
  • Property getters/setters
  • Lifecycle start/stop behavior

PersistentValve

Extended existing:

TestPersistentValve

Added coverage for:

  • Request filtering behavior
  • Filter configuration handling
  • Session stale detection logic
  • Semaphore configuration properties
  • Filtered request invocation path
  • Null context handling

Testing

All tests pass locally:

ant clean test

Targeted testing also performed with:

ant test -Dtest.name=org.apache.catalina.valves.*

Coverage verified using:

ant test -Dtest.coverage=true

Coverage Notes

Some AccessLogValve error handling paths (for example OS-level file
deletion failures or IOException during file creation) are difficult
to reliably reproduce in unit tests.

This PR aims to cover all realistically testable execution paths while
improving overall instruction coverage significantly.

Impact

No functional changes.

Test coverage improvement only.

Future Work

Additional opportunities may exist to improve coverage in other Valve
implementations and configuration parsing components.

Checklist

  • Tests added
  • Existing tests pass
  • No functional changes
  • ASF license headers added
  • Clean build (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