|
|
|
@ -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"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -50,6 +50,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { |
|
|
|
|
|
|
|
|
|
|
|
private ServletWebRequest request; |
|
|
|
private ServletWebRequest request; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
@Before |
|
|
|
public void setUp() { |
|
|
|
public void setUp() { |
|
|
|
mavResolvers = new ArrayList<ModelAndViewResolver>(); |
|
|
|
mavResolvers = new ArrayList<ModelAndViewResolver>(); |
|
|
|
@ -58,6 +59,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { |
|
|
|
request = new ServletWebRequest(new MockHttpServletRequest()); |
|
|
|
request = new ServletWebRequest(new MockHttpServletRequest()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void modelAndViewResolver() throws Exception { |
|
|
|
public void modelAndViewResolver() throws Exception { |
|
|
|
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("testBeanReturnValue"), -1); |
|
|
|
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("testBeanReturnValue"), -1); |
|
|
|
@ -71,7 +73,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { |
|
|
|
assertFalse(mavContainer.isRequestHandled()); |
|
|
|
assertFalse(mavContainer.isRequestHandled()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected=UnsupportedOperationException.class) |
|
|
|
@Test(expected = UnsupportedOperationException.class) |
|
|
|
public void modelAndViewResolverUnresolved() throws Exception { |
|
|
|
public void modelAndViewResolverUnresolved() throws Exception { |
|
|
|
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("intReturnValue"), -1); |
|
|
|
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("intReturnValue"), -1); |
|
|
|
mavResolvers.add(new TestModelAndViewResolver(TestBean.class)); |
|
|
|
mavResolvers.add(new TestModelAndViewResolver(TestBean.class)); |
|
|
|
@ -88,7 +90,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { |
|
|
|
assertTrue(mavContainer.getModel().isEmpty()); |
|
|
|
assertTrue(mavContainer.getModel().isEmpty()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected=UnsupportedOperationException.class) |
|
|
|
@Test(expected = UnsupportedOperationException.class) |
|
|
|
public void handleSimpleType() throws Exception { |
|
|
|
public void handleSimpleType() throws Exception { |
|
|
|
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("intReturnValue"), -1); |
|
|
|
MethodParameter returnType = new MethodParameter(getClass().getDeclaredMethod("intReturnValue"), -1); |
|
|
|
handler.handleReturnValue(55, returnType, mavContainer, request); |
|
|
|
handler.handleReturnValue(55, returnType, mavContainer, request); |
|
|
|
@ -102,6 +104,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { |
|
|
|
assertTrue(mavContainer.containsAttribute("testBean")); |
|
|
|
assertTrue(mavContainer.containsAttribute("testBean")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
@SuppressWarnings("unused") |
|
|
|
private int intReturnValue() { |
|
|
|
private int intReturnValue() { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
@ -112,6 +115,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class TestModelAndViewResolver implements ModelAndViewResolver { |
|
|
|
private static class TestModelAndViewResolver implements ModelAndViewResolver { |
|
|
|
|
|
|
|
|
|
|
|
private Class<?> returnValueType; |
|
|
|
private Class<?> returnValueType; |
|
|
|
@ -132,4 +136,5 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |