Take the 2-minute tour ×  Im not sure how to word what I want to
do so I apologise in advance  I'm currently writing unit tests
for some legacy code as part of my job. One of these bits of
code is a (Java) HttpServlet which provides a re-direct URL.
Essentially the code looks like this:  public class Server
extends HttpServlet {   public void doGet(HttpServletRequest
request, HttpServletResponse response) {     String url =
"....";     .. // do some work to create that url  As part of my
unit test for this class I want to test that redirect URL
created. So I would do something along the lines of:   Server
server = new Server();  server.doGet(request, response);  String
url = getRedirectURL(response);  // test URL returned  What's
the best way to 'getRedirectURL' from the response?  I'm
currently using Junit and Jmock (both latest versions). I create
a Mock HttpServletRequest and I can easily create a mock
HttpServletResponse and add an expectation for the
sendRedirect(url) method IF I knew the expected format