RequestCycle requestCycle = mock(RequestCycle.class);
ThreadContext.setRequestCycle(requestCycle);
when(requestCycle.getUrlRenderer()).thenReturn(renderer);
HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
when(httpServletResponse.encodeURL(Matchers.eq(url))).thenReturn(url + ";foo");
ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
assertEquals(url + ";foo", webResponse.encodeURL(url));
}