Skip to content

Add unit and integration tests for SSI module (catalina/ssi)#986

Open
onkar717 wants to merge 1 commit intoapache:mainfrom
onkar717:unit-integration-tests-SSI-module
Open

Add unit and integration tests for SSI module (catalina/ssi)#986
onkar717 wants to merge 1 commit intoapache:mainfrom
onkar717:unit-integration-tests-SSI-module

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 test coverage.

Motivation

While analyzing overall test coverage, the ssi module was
identified as having multiple untested classes.

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

This PR introduces targeted tests to cover 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 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.

Core classes are now covered, including:

  • ExpressionTokenizer
  • ByteArrayServletOutputStream
  • SSIConditionalState
  • SSIStopProcessingException
  • SSIServlet

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

Impact

  • No functional changes
  • Test coverage improvement only

Files Changed

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

Notes

This PR is part of ongoing work to systematically improve test
coverage across Tomcat modules, focusing on high-impact gaps.

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