SPR-8484 Add path variables to the model via AbstractView.render(..) rather than HandlerMethodArgumentResolver
This commit is contained in:
@@ -88,8 +88,7 @@ import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebA
|
||||
*
|
||||
* <p>If you wish to add high-level tests, consider the following other "integration"-style tests:
|
||||
* <ul>
|
||||
* <li>{@link HandlerMethodAdapterAnnotationDetectionTests}
|
||||
* <li>{@link HandlerMethodMappingAnnotationDetectionTests}
|
||||
* <li>{@link HandlerMethodAnnotationDetectionTests}
|
||||
* <li>{@link ServletHandlerMethodTests}
|
||||
* </ul>
|
||||
*
|
||||
@@ -293,7 +292,7 @@ public class RequestMappingHandlerAdapterIntegrationTests {
|
||||
@ModelAttribute OtherUser otherUser,
|
||||
Model model) throws Exception {
|
||||
|
||||
model.addAttribute("cookie", cookie).addAttribute("header", header)
|
||||
model.addAttribute("cookie", cookie).addAttribute("pathvar", pathvar).addAttribute("header", header)
|
||||
.addAttribute("systemHeader", systemHeader).addAttribute("headerMap", headerMap)
|
||||
.addAttribute("dateParam", dateParam).addAttribute("paramMap", paramMap)
|
||||
.addAttribute("paramByConvention", paramByConvention).addAttribute("value", value)
|
||||
|
||||
@@ -698,11 +698,6 @@ public class ServletHandlerMethodTests {
|
||||
assertNotNull(deserialized.session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void relativePathDispatchingController() throws Exception {
|
||||
initDispatcherServlet(MyRelativePathDispatchingController.class, null);
|
||||
|
||||
@@ -17,14 +17,19 @@
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -42,9 +47,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver;
|
||||
import org.springframework.web.servlet.mvc.annotation.UriTemplateServletAnnotationControllerTests;
|
||||
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.view.AbstractView;
|
||||
|
||||
/**
|
||||
* The origin of this test class is {@link UriTemplateServletAnnotationControllerTests} with the tests in this class
|
||||
@@ -79,6 +87,29 @@ public class UriTemplateServletHandlerMethodTests {
|
||||
assertEquals("test-42-21-other", response.getContentAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pathVarsInModel() throws Exception {
|
||||
final Map<String, Object> pathVars = new HashMap<String, Object>();
|
||||
pathVars.put("hotel", "42");
|
||||
pathVars.put("booking", 21);
|
||||
pathVars.put("other", "other");
|
||||
|
||||
WebApplicationContext wac =
|
||||
initDispatcherServlet(ViewRenderingController.class, new BeanDefinitionRegistrar() {
|
||||
public void register(GenericWebApplicationContext context) {
|
||||
RootBeanDefinition beanDef = new RootBeanDefinition(ModelValidatingViewResolver.class);
|
||||
beanDef.getConstructorArgumentValues().addGenericArgumentValue(pathVars);
|
||||
context.registerBeanDefinition("viewResolver", beanDef);
|
||||
}
|
||||
});
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels/42/bookings/21-other");
|
||||
servlet.service(request, new MockHttpServletResponse());
|
||||
|
||||
ModelValidatingViewResolver resolver = wac.getBean(ModelValidatingViewResolver.class);
|
||||
assertEquals(3, resolver.validatedAttrCount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void binding() throws Exception {
|
||||
initDispatcherServlet(BindingUriTemplateController.class, null);
|
||||
@@ -349,6 +380,17 @@ public class UriTemplateServletHandlerMethodTests {
|
||||
|
||||
}
|
||||
|
||||
@Controller
|
||||
public static class ViewRenderingController {
|
||||
|
||||
@RequestMapping("/hotels/{hotel}/bookings/{booking}-{other}")
|
||||
public void handle(@PathVariable("hotel") String hotel, @PathVariable int booking, @PathVariable String other) {
|
||||
assertEquals("Invalid path variable value", "42", hotel);
|
||||
assertEquals("Invalid path variable value", 21, booking);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Controller
|
||||
public static class BindingUriTemplateController {
|
||||
|
||||
@@ -588,18 +630,47 @@ public class UriTemplateServletHandlerMethodTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ModelValidatingViewResolver implements ViewResolver {
|
||||
|
||||
private final Map<String, Object> attrsToValidate;
|
||||
|
||||
int validatedAttrCount;
|
||||
|
||||
public ModelValidatingViewResolver(Map<String, Object> attrsToValidate) {
|
||||
this.attrsToValidate = attrsToValidate;
|
||||
}
|
||||
|
||||
public View resolveViewName(final String viewName, Locale locale) throws Exception {
|
||||
return new AbstractView () {
|
||||
public String getContentType() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
for (String key : attrsToValidate.keySet()) {
|
||||
assertTrue("Model should contain attribute named " + key, model.containsKey(key));
|
||||
assertEquals(attrsToValidate.get(key), model.get(key));
|
||||
validatedAttrCount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private interface BeanDefinitionRegistrar {
|
||||
public void register(GenericWebApplicationContext context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
|
||||
private WebApplicationContext initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
|
||||
throws ServletException {
|
||||
|
||||
|
||||
final GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
|
||||
servlet = new DispatcherServlet() {
|
||||
@Override
|
||||
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
|
||||
|
||||
Class<?> mappingType = RequestMappingHandlerMapping.class;
|
||||
@@ -625,7 +696,10 @@ public class UriTemplateServletHandlerMethodTests {
|
||||
return wac;
|
||||
}
|
||||
};
|
||||
|
||||
servlet.init(new MockServletConfig());
|
||||
|
||||
return wac;
|
||||
}
|
||||
|
||||
// @Ignore("ControllerClassNameHandlerMapping")
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.servlet.mvc.method.annotation.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -35,7 +36,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.support.PathVariableMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.View;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link PathVariableMethodArgumentResolver}.
|
||||
@@ -76,14 +77,40 @@ public class PathVariableMethodArgumentResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveStringArgument() throws Exception {
|
||||
public void resolveArgument() throws Exception {
|
||||
Map<String, String> uriTemplateVars = new HashMap<String, String>();
|
||||
uriTemplateVars.put("name", "value");
|
||||
request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars);
|
||||
|
||||
String result = (String) resolver.resolveArgument(paramNamedString, mavContainer, webRequest, null);
|
||||
assertEquals("PathVariable not resolved correctly", "value", result);
|
||||
assertEquals("PathVariable not added to the model", "value", mavContainer.getAttribute("name"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> pathVars = (Map<String, Object>) request.getAttribute(View.PATH_VARIABLES);
|
||||
assertNotNull(pathVars);
|
||||
assertEquals(1, pathVars.size());
|
||||
assertEquals("value", pathVars.get("name"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void resolveArgumentWithExistingPathVars() throws Exception {
|
||||
Map<String, String> uriTemplateVars = new HashMap<String, String>();
|
||||
uriTemplateVars.put("name", "value");
|
||||
request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars);
|
||||
|
||||
Map<String, Object> pathVars = new HashMap<String, Object>();
|
||||
uriTemplateVars.put("oldName", "oldValue");
|
||||
request.setAttribute(View.PATH_VARIABLES, uriTemplateVars);
|
||||
|
||||
String result = (String) resolver.resolveArgument(paramNamedString, mavContainer, webRequest, null);
|
||||
assertEquals("PathVariable not resolved correctly", "value", result);
|
||||
|
||||
pathVars = (Map<String, Object>) request.getAttribute(View.PATH_VARIABLES);
|
||||
assertNotNull(pathVars);
|
||||
assertEquals(2, pathVars.size());
|
||||
assertEquals("value", pathVars.get("name"));
|
||||
assertEquals("oldValue", pathVars.get("oldName"));
|
||||
}
|
||||
|
||||
@Test(expected = ServletRequestBindingException.class)
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.view;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expectLastCall;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -28,13 +32,13 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
import org.springframework.context.ApplicationContextException;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.View;
|
||||
|
||||
/**
|
||||
* Tests for AbstractView. Not called AbstractViewTests as
|
||||
@@ -45,21 +49,21 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
public class BaseViewTests extends TestCase {
|
||||
|
||||
public void testRenderWithoutStaticAttributes() throws Exception {
|
||||
MockControl mc = MockControl.createControl(WebApplicationContext.class);
|
||||
WebApplicationContext wac = (WebApplicationContext) mc.getMock();
|
||||
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
wac.getServletContext();
|
||||
mc.setReturnValue(new MockServletContext());
|
||||
mc.replay();
|
||||
expectLastCall().andReturn(new MockServletContext());
|
||||
replay(wac);
|
||||
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
TestView tv = new TestView(request, response, wac);
|
||||
TestView tv = new TestView(wac);
|
||||
|
||||
// Check superclass handles duplicate init
|
||||
tv.setApplicationContext(wac);
|
||||
tv.setApplicationContext(wac);
|
||||
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("foo", "bar");
|
||||
model.put("something", new Object());
|
||||
tv.render(model, request, response);
|
||||
@@ -68,22 +72,21 @@ public class BaseViewTests extends TestCase {
|
||||
checkContainsAll(model, tv.model);
|
||||
|
||||
assertTrue(tv.inited);
|
||||
mc.verify();
|
||||
verify(wac);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test attribute passing, NOT CSV parsing.
|
||||
*/
|
||||
public void testRenderWithStaticAttributesNoCollision() throws Exception {
|
||||
MockControl mc = MockControl.createControl(WebApplicationContext.class);
|
||||
WebApplicationContext wac = (WebApplicationContext) mc.getMock();
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
wac.getServletContext();
|
||||
mc.setReturnValue(new MockServletContext());
|
||||
mc.replay();
|
||||
expectLastCall().andReturn(new MockServletContext());
|
||||
replay(wac);
|
||||
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
TestView tv = new TestView(request, response, wac);
|
||||
TestView tv = new TestView(wac);
|
||||
|
||||
tv.setApplicationContext(wac);
|
||||
Properties p = new Properties();
|
||||
@@ -91,8 +94,8 @@ public class BaseViewTests extends TestCase {
|
||||
p.setProperty("something", "else");
|
||||
tv.setAttributes(p);
|
||||
|
||||
Map model = new HashMap();
|
||||
model.put("one", new HashMap());
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("one", new HashMap<Object, Object>());
|
||||
model.put("two", new Object());
|
||||
tv.render(model, request, response);
|
||||
|
||||
@@ -101,19 +104,52 @@ public class BaseViewTests extends TestCase {
|
||||
checkContainsAll(p, tv.model);
|
||||
|
||||
assertTrue(tv.inited);
|
||||
mc.verify();
|
||||
verify(wac);
|
||||
}
|
||||
|
||||
public void testDynamicModelOverridesStaticAttributesIfCollision() throws Exception {
|
||||
MockControl mc = MockControl.createControl(WebApplicationContext.class);
|
||||
WebApplicationContext wac = (WebApplicationContext) mc.getMock();
|
||||
|
||||
public void testPathVarsOverrideStaticAttributes() throws Exception {
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
wac.getServletContext();
|
||||
mc.setReturnValue(new MockServletContext());
|
||||
mc.replay();
|
||||
expectLastCall().andReturn(new MockServletContext());
|
||||
replay(wac);
|
||||
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
TestView tv = new TestView(request, response, wac);
|
||||
|
||||
TestView tv = new TestView(wac);
|
||||
tv.setApplicationContext(wac);
|
||||
|
||||
Properties p = new Properties();
|
||||
p.setProperty("one", "bar");
|
||||
p.setProperty("something", "else");
|
||||
tv.setAttributes(p);
|
||||
|
||||
Map<String, Object> pathVars = new HashMap<String, Object>();
|
||||
pathVars.put("one", new HashMap<Object, Object>());
|
||||
pathVars.put("two", new Object());
|
||||
request.setAttribute(View.PATH_VARIABLES, pathVars);
|
||||
|
||||
tv.render(new HashMap<String, Object>(), request, response);
|
||||
|
||||
// Check it contains all
|
||||
checkContainsAll(pathVars, tv.model);
|
||||
assertTrue(tv.model.size() == 3);
|
||||
// will have old something from properties
|
||||
assertTrue(tv.model.get("something").equals("else"));
|
||||
|
||||
assertTrue(tv.inited);
|
||||
verify(wac);
|
||||
}
|
||||
|
||||
public void testDynamicModelOverridesStaticAttributesIfCollision() throws Exception {
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
wac.getServletContext();
|
||||
expectLastCall().andReturn(new MockServletContext());
|
||||
replay(wac);
|
||||
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
TestView tv = new TestView(wac);
|
||||
|
||||
tv.setApplicationContext(wac);
|
||||
Properties p = new Properties();
|
||||
@@ -121,8 +157,8 @@ public class BaseViewTests extends TestCase {
|
||||
p.setProperty("something", "else");
|
||||
tv.setAttributes(p);
|
||||
|
||||
Map model = new HashMap();
|
||||
model.put("one", new HashMap());
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("one", new HashMap<Object, Object>());
|
||||
model.put("two", new Object());
|
||||
tv.render(model, request, response);
|
||||
|
||||
@@ -133,7 +169,40 @@ public class BaseViewTests extends TestCase {
|
||||
assertTrue(tv.model.get("something").equals("else"));
|
||||
|
||||
assertTrue(tv.inited);
|
||||
mc.verify();
|
||||
verify(wac);
|
||||
}
|
||||
|
||||
public void testDynamicModelOverridesPathVariables() throws Exception {
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
wac.getServletContext();
|
||||
expectLastCall().andReturn(new MockServletContext());
|
||||
replay(wac);
|
||||
|
||||
TestView tv = new TestView(wac);
|
||||
tv.setApplicationContext(wac);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
Map<String, Object> pathVars = new HashMap<String, Object>();
|
||||
pathVars.put("one", "bar");
|
||||
pathVars.put("something", "else");
|
||||
request.setAttribute(View.PATH_VARIABLES, pathVars);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("one", new HashMap<Object, Object>());
|
||||
model.put("two", new Object());
|
||||
|
||||
tv.render(model, request, response);
|
||||
|
||||
// Check it contains all
|
||||
checkContainsAll(model, tv.model);
|
||||
assertEquals(3, tv.model.size());
|
||||
// will have old something from path variables
|
||||
assertTrue(tv.model.get("something").equals("else"));
|
||||
|
||||
assertTrue(tv.inited);
|
||||
verify(wac);
|
||||
}
|
||||
|
||||
public void testIgnoresNullAttributes() {
|
||||
@@ -170,7 +239,7 @@ public class BaseViewTests extends TestCase {
|
||||
|
||||
public void testAttributeCSVParsingValidWithWeirdCharacters() {
|
||||
AbstractView v = new ConcreteView();
|
||||
String fooval = "owfie fue&3[][[[2 \n\n \r \t 8<>3";
|
||||
String fooval = "owfie fue&3[][[[2 \n\n \r \t 8<>3";
|
||||
// Also tests empty value
|
||||
String kingval = "";
|
||||
v.setAttributesCSV("foo=(" + fooval + "),king={" + kingval + "},f1=[we]");
|
||||
@@ -224,9 +293,10 @@ public class BaseViewTests extends TestCase {
|
||||
* @param expected
|
||||
* @param actual
|
||||
*/
|
||||
private void checkContainsAll(Map expected, Map actual) {
|
||||
Set keys = expected.keySet();
|
||||
for (Iterator iter = keys.iterator(); iter.hasNext();) {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private void checkContainsAll(Map expected, Map<String, Object> actual) {
|
||||
Set<String> keys = expected.keySet();
|
||||
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
|
||||
String key = (String) iter.next();
|
||||
//System.out.println("Checking model key " + key);
|
||||
assertTrue("Value for model key '" + key + "' must match", actual.get(key) == expected.get(key));
|
||||
@@ -239,7 +309,7 @@ public class BaseViewTests extends TestCase {
|
||||
*/
|
||||
private class ConcreteView extends AbstractView {
|
||||
// Do-nothing concrete subclass
|
||||
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
|
||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -250,21 +320,17 @@ public class BaseViewTests extends TestCase {
|
||||
* behaviour
|
||||
*/
|
||||
private class TestView extends AbstractView {
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
private WebApplicationContext wac;
|
||||
public boolean inited;
|
||||
|
||||
/** Captured model in render */
|
||||
public Map model;
|
||||
public Map<String, Object> model;
|
||||
|
||||
public TestView(HttpServletRequest request, HttpServletResponse response, WebApplicationContext wac) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
public TestView(WebApplicationContext wac) {
|
||||
this.wac = wac;
|
||||
|
||||
}
|
||||
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
|
||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// do nothing
|
||||
this.model = model;
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
package org.springframework.web.servlet.view;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expectLastCall;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
@@ -23,12 +28,12 @@ import java.util.Set;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockRequestDispatcher;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
@@ -52,7 +57,7 @@ public class InternalResourceViewTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testForward() throws Exception {
|
||||
HashMap model = new HashMap();
|
||||
HashMap<String, Object> model = new HashMap<String, Object>();
|
||||
Object obj = new Integer(1);
|
||||
model.put("foo", "bar");
|
||||
model.put("I", obj);
|
||||
@@ -77,8 +82,8 @@ public class InternalResourceViewTests extends TestCase {
|
||||
view.render(model, request, response);
|
||||
assertEquals(url, response.getForwardedUrl());
|
||||
|
||||
Set keys = model.keySet();
|
||||
for (Iterator it = keys.iterator(); it.hasNext();) {
|
||||
Set<String> keys = model.keySet();
|
||||
for (Iterator<String> it = keys.iterator(); it.hasNext();) {
|
||||
String key = (String) it.next();
|
||||
assertEquals(model.get(key), request.getAttribute(key));
|
||||
}
|
||||
@@ -91,7 +96,7 @@ public class InternalResourceViewTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testForwardWithForwardAttributesPresent() throws Exception {
|
||||
HashMap model = new HashMap();
|
||||
HashMap<String, Object> model = new HashMap<String, Object>();
|
||||
Object obj = new Integer(1);
|
||||
model.put("foo", "bar");
|
||||
model.put("I", obj);
|
||||
@@ -122,8 +127,8 @@ public class InternalResourceViewTests extends TestCase {
|
||||
view.render(model, request, response);
|
||||
assertEquals(url, response.getForwardedUrl());
|
||||
|
||||
Set keys = model.keySet();
|
||||
for (Iterator it = keys.iterator(); it.hasNext();) {
|
||||
Set<String> keys = model.keySet();
|
||||
for (Iterator<String> it = keys.iterator(); it.hasNext();) {
|
||||
String key = (String) it.next();
|
||||
assertEquals(model.get(key), request.getAttribute(key));
|
||||
}
|
||||
@@ -136,25 +141,26 @@ public class InternalResourceViewTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testAlwaysInclude() throws Exception {
|
||||
HashMap model = new HashMap();
|
||||
HashMap<String, Object> model = new HashMap<String, Object>();
|
||||
Object obj = new Integer(1);
|
||||
model.put("foo", "bar");
|
||||
model.put("I", obj);
|
||||
|
||||
String url = "forward-to";
|
||||
|
||||
MockControl reqControl = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) reqControl.getMock();
|
||||
Set keys = model.keySet();
|
||||
for (Iterator iter = keys.iterator(); iter.hasNext();) {
|
||||
HttpServletRequest request = createMock(HttpServletRequest.class);
|
||||
request.getAttribute(View.PATH_VARIABLES);
|
||||
expectLastCall().andReturn(null);
|
||||
Set<String> keys = model.keySet();
|
||||
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
|
||||
String key = (String) iter.next();
|
||||
request.setAttribute(key, model.get(key));
|
||||
reqControl.setVoidCallable(1);
|
||||
expectLastCall().times(1);
|
||||
}
|
||||
|
||||
request.getRequestDispatcher(url);
|
||||
reqControl.setReturnValue(new MockRequestDispatcher(url));
|
||||
reqControl.replay();
|
||||
expectLastCall().andReturn(new MockRequestDispatcher(url));
|
||||
replay(request);
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
InternalResourceView v = new InternalResourceView();
|
||||
@@ -164,31 +170,32 @@ public class InternalResourceViewTests extends TestCase {
|
||||
// Can now try multiple tests
|
||||
v.render(model, request, response);
|
||||
assertEquals(url, response.getIncludedUrl());
|
||||
reqControl.verify();
|
||||
verify(request);
|
||||
}
|
||||
|
||||
public void testIncludeOnAttribute() throws Exception {
|
||||
HashMap model = new HashMap();
|
||||
HashMap<String, Object> model = new HashMap<String, Object>();
|
||||
Object obj = new Integer(1);
|
||||
model.put("foo", "bar");
|
||||
model.put("I", obj);
|
||||
|
||||
String url = "forward-to";
|
||||
|
||||
MockControl reqControl = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) reqControl.getMock();
|
||||
Set keys = model.keySet();
|
||||
for (Iterator iter = keys.iterator(); iter.hasNext();) {
|
||||
HttpServletRequest request = createMock(HttpServletRequest.class);
|
||||
request.getAttribute(View.PATH_VARIABLES);
|
||||
expectLastCall().andReturn(null);
|
||||
Set<String> keys = model.keySet();
|
||||
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
|
||||
String key = (String) iter.next();
|
||||
request.setAttribute(key, model.get(key));
|
||||
reqControl.setVoidCallable(1);
|
||||
expectLastCall().times(1);
|
||||
}
|
||||
|
||||
request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE);
|
||||
reqControl.setReturnValue("somepath");
|
||||
expectLastCall().andReturn("somepath");
|
||||
request.getRequestDispatcher(url);
|
||||
reqControl.setReturnValue(new MockRequestDispatcher(url));
|
||||
reqControl.replay();
|
||||
expectLastCall().andReturn(new MockRequestDispatcher(url));
|
||||
replay(request);
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
InternalResourceView v = new InternalResourceView();
|
||||
@@ -197,31 +204,32 @@ public class InternalResourceViewTests extends TestCase {
|
||||
// Can now try multiple tests
|
||||
v.render(model, request, response);
|
||||
assertEquals(url, response.getIncludedUrl());
|
||||
reqControl.verify();
|
||||
verify(request);
|
||||
}
|
||||
|
||||
public void testIncludeOnCommitted() throws Exception {
|
||||
HashMap model = new HashMap();
|
||||
HashMap<String, Object> model = new HashMap<String, Object>();
|
||||
Object obj = new Integer(1);
|
||||
model.put("foo", "bar");
|
||||
model.put("I", obj);
|
||||
|
||||
String url = "forward-to";
|
||||
|
||||
MockControl reqControl = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) reqControl.getMock();
|
||||
Set keys = model.keySet();
|
||||
for (Iterator iter = keys.iterator(); iter.hasNext();) {
|
||||
HttpServletRequest request = createMock(HttpServletRequest.class);
|
||||
request.getAttribute(View.PATH_VARIABLES);
|
||||
expectLastCall().andReturn(null);
|
||||
Set<String> keys = model.keySet();
|
||||
for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
|
||||
String key = (String) iter.next();
|
||||
request.setAttribute(key, model.get(key));
|
||||
reqControl.setVoidCallable(1);
|
||||
expectLastCall().times(1);
|
||||
}
|
||||
|
||||
request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE);
|
||||
reqControl.setReturnValue(null);
|
||||
expectLastCall().andReturn(null);
|
||||
request.getRequestDispatcher(url);
|
||||
reqControl.setReturnValue(new MockRequestDispatcher(url));
|
||||
reqControl.replay();
|
||||
expectLastCall().andReturn(new MockRequestDispatcher(url));
|
||||
replay(request);
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
response.setCommitted(true);
|
||||
@@ -231,7 +239,7 @@ public class InternalResourceViewTests extends TestCase {
|
||||
// Can now try multiple tests
|
||||
v.render(model, request, response);
|
||||
assertEquals(url, response.getIncludedUrl());
|
||||
reqControl.verify();
|
||||
verify(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.View;
|
||||
|
||||
public class RedirectViewUriTemplateTests {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class RedirectViewUriTemplateTests {
|
||||
Map<String, String> uriTemplatVars = new HashMap<String, String>();
|
||||
uriTemplatVars.put("name1", "value1");
|
||||
uriTemplatVars.put("name2", "value2");
|
||||
request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplatVars);
|
||||
request.setAttribute(View.PATH_VARIABLES, uriTemplatVars);
|
||||
|
||||
String url = "http://url.somewhere.com";
|
||||
RedirectView redirectView = new RedirectView(url + "/{name2}");
|
||||
|
||||
@@ -74,6 +74,11 @@ public class MappingJacksonJsonViewTest {
|
||||
view = new MappingJacksonJsonView();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isExposePathVars() {
|
||||
assertEquals("Must not expose path variables", false, view.isExposePathVariables());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renderSimpleMap() throws Exception {
|
||||
|
||||
|
||||
@@ -16,10 +16,20 @@
|
||||
|
||||
package org.springframework.web.servlet.view.velocity;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expectLastCall;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -31,16 +41,14 @@ import org.apache.velocity.exception.ParseErrorException;
|
||||
import org.apache.velocity.tools.generic.DateTool;
|
||||
import org.apache.velocity.tools.generic.MathTool;
|
||||
import org.apache.velocity.tools.generic.NumberTool;
|
||||
import org.easymock.MockControl;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContextException;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||
import org.springframework.web.servlet.view.AbstractView;
|
||||
|
||||
@@ -54,13 +62,12 @@ public class VelocityViewTests {
|
||||
@Test
|
||||
public void testNoVelocityConfig() throws Exception {
|
||||
VelocityView vv = new VelocityView();
|
||||
MockControl wmc = MockControl.createControl(WebApplicationContext.class);
|
||||
WebApplicationContext wac = (WebApplicationContext) wmc.getMock();
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
wac.getBeansOfType(VelocityConfig.class, true, false);
|
||||
wmc.setReturnValue(new HashMap());
|
||||
expectLastCall().andReturn(new HashMap<String, Object>());
|
||||
wac.getParentBeanFactory();
|
||||
wmc.setReturnValue(null);
|
||||
wmc.replay();
|
||||
expectLastCall().andReturn(null);
|
||||
replay(wac);
|
||||
|
||||
vv.setUrl("anythingButNull");
|
||||
try {
|
||||
@@ -72,7 +79,7 @@ public class VelocityViewTests {
|
||||
assertTrue(ex.getMessage().contains("VelocityConfig"));
|
||||
}
|
||||
|
||||
wmc.verify();
|
||||
verify(wac);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,13 +125,12 @@ public class VelocityViewTests {
|
||||
* If it's non null it will be checked
|
||||
*/
|
||||
private void testValidTemplateName(final Exception mergeTemplateFailureException) throws Exception {
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("foo", "bar");
|
||||
|
||||
final String templateName = "test.vm";
|
||||
|
||||
MockControl wmc = MockControl.createControl(WebApplicationContext.class);
|
||||
WebApplicationContext wac = (WebApplicationContext) wmc.getMock();
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||
|
||||
@@ -135,14 +141,14 @@ public class VelocityViewTests {
|
||||
}
|
||||
};
|
||||
wac.getBeansOfType(VelocityConfig.class, true, false);
|
||||
Map configurers = new HashMap();
|
||||
Map<String, Object> configurers = new HashMap<String, Object>();
|
||||
configurers.put("velocityConfigurer", vc);
|
||||
wmc.setReturnValue(configurers);
|
||||
expectLastCall().andReturn(configurers);
|
||||
wac.getParentBeanFactory();
|
||||
wmc.setReturnValue(null);
|
||||
expectLastCall().andReturn(null);
|
||||
wac.getServletContext();
|
||||
wmc.setReturnValue(sc, 3);
|
||||
wmc.replay();
|
||||
expectLastCall().andReturn(sc).times(3);
|
||||
replay(wac);
|
||||
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
final HttpServletResponse expectedResponse = new MockHttpServletResponse();
|
||||
@@ -172,15 +178,14 @@ public class VelocityViewTests {
|
||||
assertEquals(ex, mergeTemplateFailureException);
|
||||
}
|
||||
|
||||
wmc.verify();
|
||||
verify(wac);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeepExistingContentType() throws Exception {
|
||||
final String templateName = "test.vm";
|
||||
|
||||
MockControl wmc = MockControl.createControl(WebApplicationContext.class);
|
||||
WebApplicationContext wac = (WebApplicationContext) wmc.getMock();
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||
|
||||
@@ -191,14 +196,14 @@ public class VelocityViewTests {
|
||||
}
|
||||
};
|
||||
wac.getBeansOfType(VelocityConfig.class, true, false);
|
||||
Map configurers = new HashMap();
|
||||
Map<String, Object> configurers = new HashMap<String, Object>();
|
||||
configurers.put("velocityConfigurer", vc);
|
||||
wmc.setReturnValue(configurers);
|
||||
expectLastCall().andReturn(configurers);
|
||||
wac.getParentBeanFactory();
|
||||
wmc.setReturnValue(null);
|
||||
expectLastCall().andReturn(null);
|
||||
wac.getServletContext();
|
||||
wmc.setReturnValue(sc, 3);
|
||||
wmc.replay();
|
||||
expectLastCall().andReturn(sc).times(3);
|
||||
replay(wac);
|
||||
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
final HttpServletResponse expectedResponse = new MockHttpServletResponse();
|
||||
@@ -209,16 +214,16 @@ public class VelocityViewTests {
|
||||
assertTrue(template == expectedTemplate);
|
||||
assertTrue(response == expectedResponse);
|
||||
}
|
||||
protected void exposeHelpers(Map model, HttpServletRequest request) throws Exception {
|
||||
protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request) throws Exception {
|
||||
model.put("myHelper", "myValue");
|
||||
}
|
||||
};
|
||||
|
||||
vv.setUrl(templateName);
|
||||
vv.setApplicationContext(wac);
|
||||
vv.render(new HashMap(), request, expectedResponse);
|
||||
vv.render(new HashMap<String, Object>(), request, expectedResponse);
|
||||
|
||||
wmc.verify();
|
||||
verify(wac);
|
||||
assertEquals("myContentType", expectedResponse.getContentType());
|
||||
}
|
||||
|
||||
@@ -226,12 +231,12 @@ public class VelocityViewTests {
|
||||
public void testExposeHelpers() throws Exception {
|
||||
final String templateName = "test.vm";
|
||||
|
||||
MockControl wmc = MockControl.createControl(WebApplicationContext.class);
|
||||
WebApplicationContext wac = (WebApplicationContext) wmc.getMock();
|
||||
WebApplicationContext wac = createMock(WebApplicationContext.class);
|
||||
wac.getParentBeanFactory();
|
||||
wmc.setReturnValue(null);
|
||||
expectLastCall().andReturn(null);
|
||||
wac.getServletContext();
|
||||
wmc.setReturnValue(new MockServletContext());
|
||||
expectLastCall().andReturn(new MockServletContext());
|
||||
|
||||
final Template expectedTemplate = new Template();
|
||||
VelocityConfig vc = new VelocityConfig() {
|
||||
public VelocityEngine getVelocityEngine() {
|
||||
@@ -239,19 +244,21 @@ public class VelocityViewTests {
|
||||
}
|
||||
};
|
||||
wac.getBeansOfType(VelocityConfig.class, true, false);
|
||||
Map configurers = new HashMap();
|
||||
Map<String, Object> configurers = new HashMap<String, Object>();
|
||||
configurers.put("velocityConfigurer", vc);
|
||||
wmc.setReturnValue(configurers);
|
||||
wmc.replay();
|
||||
expectLastCall().andReturn(configurers);
|
||||
replay(wac);
|
||||
|
||||
|
||||
// let it ask for locale
|
||||
MockControl reqControl = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest req = (HttpServletRequest) reqControl.getMock();
|
||||
HttpServletRequest req = createMock(HttpServletRequest.class);
|
||||
req.getAttribute(View.PATH_VARIABLES);
|
||||
expectLastCall().andReturn(null);
|
||||
req.getAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE);
|
||||
reqControl.setReturnValue(new AcceptHeaderLocaleResolver());
|
||||
expectLastCall().andReturn(new AcceptHeaderLocaleResolver());
|
||||
req.getLocale();
|
||||
reqControl.setReturnValue(Locale.CANADA);
|
||||
reqControl.replay();
|
||||
expectLastCall().andReturn(Locale.CANADA);
|
||||
replay(req);
|
||||
|
||||
final HttpServletResponse expectedResponse = new MockHttpServletResponse();
|
||||
|
||||
@@ -272,7 +279,7 @@ public class VelocityViewTests {
|
||||
assertTrue(numberTool.getLocale().equals(Locale.CANADA));
|
||||
}
|
||||
|
||||
protected void exposeHelpers(Map model, HttpServletRequest request) throws Exception {
|
||||
protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request) throws Exception {
|
||||
model.put("myHelper", "myValue");
|
||||
}
|
||||
};
|
||||
@@ -286,10 +293,10 @@ public class VelocityViewTests {
|
||||
vv.setNumberToolAttribute("numberTool");
|
||||
vv.setExposeSpringMacroHelpers(false);
|
||||
|
||||
vv.render(new HashMap(), req, expectedResponse);
|
||||
vv.render(new HashMap<String, Object>(), req, expectedResponse);
|
||||
|
||||
wmc.verify();
|
||||
reqControl.verify();
|
||||
verify(wac);
|
||||
verify(req);
|
||||
assertEquals(AbstractView.DEFAULT_CONTENT_TYPE, expectedResponse.getContentType());
|
||||
}
|
||||
|
||||
|
||||
@@ -50,12 +50,22 @@ public class MarshallingViewTests {
|
||||
assertEquals("Invalid content type", "application/xml", view.getContentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isExposePathVars() {
|
||||
assertEquals("Must not expose path variables", false, view.isExposePathVariables());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isExposePathVarsDefaultConstructor() {
|
||||
assertEquals("Must not expose path variables", false, new MarshallingView().isExposePathVariables());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renderModelKey() throws Exception {
|
||||
Object toBeMarshalled = new Object();
|
||||
String modelKey = "key";
|
||||
view.setModelKey(modelKey);
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(modelKey, toBeMarshalled);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
@@ -76,7 +86,7 @@ public class MarshallingViewTests {
|
||||
Object toBeMarshalled = new Object();
|
||||
String modelKey = "key";
|
||||
view.setModelKey("invalidKey");
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(modelKey, toBeMarshalled);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
@@ -97,7 +107,7 @@ public class MarshallingViewTests {
|
||||
@Test
|
||||
public void renderNullModelValue() throws Exception {
|
||||
String modelKey = "key";
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(modelKey, null);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
@@ -120,7 +130,7 @@ public class MarshallingViewTests {
|
||||
Object toBeMarshalled = new Object();
|
||||
String modelKey = "key";
|
||||
view.setModelKey(modelKey);
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(modelKey, toBeMarshalled);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
@@ -143,7 +153,7 @@ public class MarshallingViewTests {
|
||||
public void renderNoModelKey() throws Exception {
|
||||
Object toBeMarshalled = new Object();
|
||||
String modelKey = "key";
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(modelKey, toBeMarshalled);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
@@ -163,7 +173,7 @@ public class MarshallingViewTests {
|
||||
public void testRenderUnsupportedModel() throws Exception {
|
||||
Object toBeMarshalled = new Object();
|
||||
String modelKey = "key";
|
||||
Map model = new HashMap();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(modelKey, toBeMarshalled);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
|
||||
Reference in New Issue
Block a user