onkar717 opened a new pull request, #987:
URL: https://github.com/apache/tomcat/pull/987

   ### **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:
   
   ```bash
   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**
   
   * [x] Tests added
   * [x] Existing tests pass
   * [x] No functional changes
   * [x] ASF license headers included
   * [x] Changes limited to test code only
   * [x] Build verified with `ant clean test`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to