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.)