onkar717 opened a new pull request, #986:
URL: https://github.com/apache/tomcat/pull/986
### **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**
* [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]