model.put("foo", "bar");
model.put("I", obj);
String url = "forward-to";
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myservlet/handler.do");
request.setContextPath("/mycontext");
request.setServletPath("/myservlet");
request.setPathInfo(";mypathinfo");
request.setQueryString("?param1=value1");
InternalResourceView view = new InternalResourceView();
view.setUrl(url);
view.setServletContext(new MockServletContext() {
@Override
public int getMinorVersion() {
return 4;
}
});
MockHttpServletResponse response = new MockHttpServletResponse();
view.render(model, request, response);
assertEquals(url, response.getForwardedUrl());
Set<String> keys = model.keySet();
for (String key : keys) {
assertEquals(model.get(key), request.getAttribute(key));
}
}