I am unittesting (with the help of Cactus framework) my servlet which contains the line RequestDispatcher.forward(..). In short, I need to manually instantiates my servlet and calls its doGet() with the request/response provided by the framework and verify the required attributes are put in the request when the servlet returns.
However, that comes to the question of what RequestDispatcher.forward() would do to my execution flow. Normally, we're not expected to put in any code after forward(). But in unit testing, our verification would be placed after the servlet call. I checked the API & servlet spec. There is nothing about the execution flow after forward() call. Can anyone clarify on this? Thanks a lot.
I think this goes beyong the scope of unit testing. It is the container's responsability to leave the request parameters after the forward. If you want to check that parameters are in the request, do it before the forward.