Skip to content

Improve/Refactor MBean Utilities and Add Unit Tests for Catalina MBeans#987

Open
onkar717 wants to merge 1 commit intoapache:mainfrom
onkar717:Unit-Tests-Catalina-MBeans
Open

Improve/Refactor MBean Utilities and Add Unit Tests for Catalina MBeans#987
onkar717 wants to merge 1 commit intoapache:mainfrom
onkar717:Unit-Tests-Catalina-MBeans

Conversation

@onkar717
Copy link
Copy Markdown
Contributor

Summary

This PR improves test coverage for the ssi module by adding
unit and integration tests for core classes that previously had
little to no coverage.

Motivation

During analysis of overall test coverage, the ssi module was
identified as having several untested or under-tested classes.

These classes are responsible for Server Side Includes (SSI)
processing, including expression parsing, conditional evaluation,
and servlet-based rendering, making them critical for correctness
and stability.

This PR introduces targeted tests to validate core behaviors,
edge cases, and integration scenarios across the module.

Changes

ExpressionTokenizer

Added TestExpressionTokenizer covering:

  • Token parsing and sequencing
  • Handling of quoted strings and escaping
  • Recognition of operators and special characters
  • Edge cases in expression parsing

ByteArrayServletOutputStream

Added TestByteArrayServletOutputStream covering:

  • Write operations and buffer behavior
  • Conversion to byte array
  • ServletOutputStream contract methods

SSIConditionalState

Added TestSSIConditionalState covering:

  • Default state validation
  • State transitions and flag handling

SSIStopProcessingException

Added TestSSIStopProcessingException covering:

  • Exception construction
  • Cause propagation
  • Class hierarchy validation

SSIServlet

Added TestSSIServlet covering:

  • SSI directive processing using embedded Tomcat:

    • echo
    • set
    • if/else conditional logic
    • printenv, config, and fsize directives
  • Security restrictions for WEB-INF and META-INF

  • End-to-end request handling and response generation

Testing

All tests pass locally:

ant clean test

Targeted validation was performed for each new test class with no failures.

Test results:

TestExpressionTokenizer:           Tests run: 19, Failures: 0, Errors: 0
TestByteArrayServletOutputStream:  Tests run: 5,  Failures: 0, Errors: 0
TestSSIConditionalState:           Tests run: 4,  Failures: 0, Errors: 0
TestSSIStopProcessingException:    Tests run: 3,  Failures: 0, Errors: 0
TestSSIServlet:                    Tests run: 9,  Failures: 0, Errors: 0

Coverage Impact

This PR significantly improves coverage for the ssi module,
which previously had minimal or no dedicated test coverage.

The following core classes are now covered:

  • ExpressionTokenizer
  • ByteArrayServletOutputStream
  • SSIConditionalState
  • SSIStopProcessingException
  • SSIServlet

This establishes a strong foundation for further coverage
improvements in remaining SSI-related components.

Impact

  • No functional changes
  • Test coverage improvements only

Files Changed

  • TestExpressionTokenizer.java (new)
  • TestByteArrayServletOutputStream.java (new)
  • TestSSIConditionalState.java (new)
  • TestSSIStopProcessingException.java (new)
  • TestSSIServlet.java (new)

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