Testing: is there a framework allowing embedding Tomcat to simulate request/response cycles without involving HTTP?
For automated functional testing purposes, I would like to run a servlet container from my test driver 开发者_运维问答without actually issuing HTTP requests over the network. The main goal is to test fairly elaborate conditions of servlet filtering, forwarding, and includes.
I would like a system that embeds the servlet container in a way that:
- doesn't create a separate process if possible
- doesn't cause the embedded container to listen on network ports
- allows me to issue simulated HTTP requests (through an API)
- allows me to wait for/receive responses and analyze them from Java code
I know that Tomcat can be embedded through an API and has a connector API, so I am sure that it is doable. But surely there must exist a test framework out there doing exactly this already?
(Note that I would prefer if Tomcat is used, but Jetty is another option.)
What about using Jakarta Cactus? Check out How it works and the TestCase Howto tutorial.
精彩评论