@@ -47,6 +47,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
|
||||
|
||||
private MethodParameter returnParamModelAndView;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.handler = new ModelAndViewMethodReturnValueHandler();
|
||||
@@ -55,6 +56,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
|
||||
this.returnParamModelAndView = getReturnValueParam("modelAndView");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void supportsReturnType() throws Exception {
|
||||
assertTrue(handler.supportsReturnType(returnParamModelAndView));
|
||||
@@ -143,7 +145,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
|
||||
assertNotSame("RedirectAttributes should not be used if controller doesn't redirect", redirectAttributes, model);
|
||||
}
|
||||
|
||||
@Test // SPR-14045
|
||||
@Test // SPR-14045
|
||||
public void handleRedirectWithIgnoreDefaultModel() throws Exception {
|
||||
mavContainer.setIgnoreDefaultModelOnRedirect(true);
|
||||
|
||||
@@ -163,6 +165,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
|
||||
return new MethodParameter(method, -1);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
ModelAndView modelAndView() {
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,6 +50,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
||||
|
||||
private ServletWebRequest request;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mavResolvers = new ArrayList<ModelAndViewResolver>();
|
||||
@@ -58,6 +59,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
||||
request = new ServletWebRequest(new MockHttpServletRequest());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void modelAndViewResolver() throws Exception {
|
||||
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("testBeanReturnValue"), -1);
|
||||
@@ -71,7 +73,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
||||
assertFalse(mavContainer.isRequestHandled());
|
||||
}
|
||||
|
||||
@Test(expected=UnsupportedOperationException.class)
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void modelAndViewResolverUnresolved() throws Exception {
|
||||
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("intReturnValue"), -1);
|
||||
mavResolvers.add(new TestModelAndViewResolver(TestBean.class));
|
||||
@@ -88,7 +90,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
||||
assertTrue(mavContainer.getModel().isEmpty());
|
||||
}
|
||||
|
||||
@Test(expected=UnsupportedOperationException.class)
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void handleSimpleType() throws Exception {
|
||||
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("intReturnValue"), -1);
|
||||
handler.handleReturnValue(55, returnType, mavContainer, request);
|
||||
@@ -102,6 +104,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
||||
assertTrue(mavContainer.containsAttribute("testBean"));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int intReturnValue() {
|
||||
return 0;
|
||||
@@ -112,6 +115,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static class TestModelAndViewResolver implements ModelAndViewResolver {
|
||||
|
||||
private Class<?> returnValueType;
|
||||
@@ -132,4 +136,5 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user