SPR-8214 Javadoc and polish

This commit is contained in:
Rossen Stoyanchev
2011-04-13 23:15:19 +00:00
parent 62d40dc7aa
commit aa065e8310
40 changed files with 466 additions and 420 deletions

View File

@@ -122,15 +122,6 @@ public class HttpEntityMethodProcessorTests {
assertFalse("non-ResponseBody return type supported", processor.supportsReturnType(intReturnValue));
}
@Test
public void usesResponseArgument() {
assertFalse("HttpEntity parameter uses response argument", processor.usesResponseArgument(httpEntityParam));
assertTrue("ResponseBody return type does not use response argument",
processor.usesResponseArgument(responseEntityReturnValue));
assertTrue("HttpEntity return type does not use response argument",
processor.usesResponseArgument(httpEntityReturnValue));
}
@Test
@SuppressWarnings("unchecked")
public void resolveArgument() throws Exception {
@@ -146,8 +137,9 @@ public class HttpEntityMethodProcessorTests {
replay(messageConverter);
HttpEntity<?> result = (HttpEntity<String>) processor.resolveArgument(httpEntityParam, mavContainer, request, null);
assertEquals("Invalid argument", expected, result.getBody());
assertTrue("The ResolveView flag shouldn't change", mavContainer.isResolveView());
assertEquals("Invalid argument", expected, result.getBody());
verify(messageConverter);
}
@@ -164,6 +156,7 @@ public class HttpEntityMethodProcessorTests {
processor.resolveArgument(httpEntityParam, mavContainer, request, null);
assertTrue("The ResolveView flag shouldn't change", mavContainer.isResolveView());
verify(messageConverter);
}

View File

@@ -52,7 +52,7 @@ public class PathVariableMethodArgumentResolverTests {
@Before
public void setUp() throws Exception {
resolver = new PathVariableMethodArgumentResolver(null);
resolver = new PathVariableMethodArgumentResolver();
Method method = getClass().getMethod("handle", String.class, String.class);
pathVarParam = new MethodParameter(method, 0);
stringParam = new MethodParameter(method, 1);
@@ -62,11 +62,6 @@ public class PathVariableMethodArgumentResolverTests {
webRequest = new ServletWebRequest(servletRequest, servletResponse);
}
@Test
public void usesResponseArgument() {
assertFalse(resolver.usesResponseArgument(null));
}
@Test
public void supportsParameter() {
assertTrue("Parameter with @PathVariable annotation", resolver.supportsParameter(pathVarParam));

View File

@@ -106,13 +106,6 @@ public class RequestResponseBodyMethodProcessorTests {
assertFalse("non-ResponseBody return type supported", processor.supportsReturnType(intReturnValue));
}
@Test
public void usesResponseArgument() {
assertFalse("RequestBody parameter uses response argument", processor.usesResponseArgument(stringParameter));
assertTrue("ResponseBody return type does not use response argument",
processor.usesResponseArgument(stringReturnValue));
}
@Test
public void resolveArgument() throws Exception {
MediaType contentType = MediaType.TEXT_PLAIN;
@@ -127,8 +120,9 @@ public class RequestResponseBodyMethodProcessorTests {
replay(messageConverter);
Object result = processor.resolveArgument(stringParameter, mavContainer, webRequest, null);
assertEquals("Invalid argument", expected, result);
assertEquals("Invalid argument", expected, result);
assertTrue("The ResolveView flag shouldn't change", mavContainer.isResolveView());
verify(messageConverter);
}
@@ -146,6 +140,7 @@ public class RequestResponseBodyMethodProcessorTests {
processor.resolveArgument(stringParameter, mavContainer, webRequest, null);
assertTrue("The ResolveView flag shouldn't change", mavContainer.isResolveView());
verify(messageConverter);
}
@@ -168,7 +163,7 @@ public class RequestResponseBodyMethodProcessorTests {
processor.handleReturnValue(returnValue, stringReturnValue, mavContainer, webRequest);
assertFalse(mavContainer.isResolveView());
assertFalse("The ResolveView flag wasn't turned off", mavContainer.isResolveView());
verify(messageConverter);
}
@@ -186,7 +181,7 @@ public class RequestResponseBodyMethodProcessorTests {
processor.handleReturnValue(returnValue, stringReturnValue, mavContainer, webRequest);
assertFalse(mavContainer.isResolveView());
assertFalse("The ResolveView flag wasn't turned off", mavContainer.isResolveView());
verify(messageConverter);
}

View File

@@ -31,7 +31,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.support.CookieValueMethodArgumentResolver;
import org.springframework.web.method.annotation.support.AbstractCookieValueMethodArgumentResolver;
import org.springframework.web.servlet.mvc.method.annotation.support.ServletCookieValueMethodArgumentResolver;
/**
@@ -39,7 +39,7 @@ import org.springframework.web.servlet.mvc.method.annotation.support.ServletCook
*/
public class ServletCookieValueMethodArgumentResolverTests {
private CookieValueMethodArgumentResolver resolver;
private ServletCookieValueMethodArgumentResolver resolver;
private MethodParameter cookieParameter;
@@ -65,11 +65,6 @@ public class ServletCookieValueMethodArgumentResolverTests {
}
@Test
public void usesResponseArgument() throws NoSuchMethodException {
assertFalse("resolver uses response argument", resolver.usesResponseArgument(null));
}
@Test
public void supportsParameter() {
assertTrue("Cookie parameter not supported", resolver.supportsParameter(cookieParameter));

View File

@@ -33,6 +33,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.method.support.ModelAndViewContainer;
import org.springframework.web.multipart.MultipartRequest;
import org.springframework.web.servlet.mvc.method.annotation.support.ServletRequestMethodArgumentResolver;
@@ -47,6 +48,8 @@ public class ServletRequestMethodArgumentResolverTests {
private Method supportedParams;
private ModelAndViewContainer mavContainer;
private ServletWebRequest webRequest;
private MockHttpServletRequest servletRequest;
@@ -57,23 +60,21 @@ public class ServletRequestMethodArgumentResolverTests {
supportedParams = getClass()
.getMethod("supportedParams", ServletRequest.class, MultipartRequest.class, HttpSession.class,
Principal.class, Locale.class, InputStream.class, Reader.class, WebRequest.class);
mavContainer = new ModelAndViewContainer();
servletRequest = new MockHttpServletRequest();
webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());
}
@Test
public void usesResponseArgument() {
assertFalse("resolver uses response argument", resolver.usesResponseArgument(null));
}
@Test
public void servletRequest() throws Exception {
MethodParameter servletRequestParameter = new MethodParameter(supportedParams, 0);
assertTrue("ServletRequest not supported", resolver.supportsParameter(servletRequestParameter));
Object result = resolver.resolveArgument(servletRequestParameter, null, webRequest, null);
boolean isSupported = resolver.supportsParameter(servletRequestParameter);
Object result = resolver.resolveArgument(servletRequestParameter, mavContainer, webRequest, null);
assertTrue("ServletRequest not supported", isSupported);
assertSame("Invalid result", servletRequest, result);
assertTrue("The ResolveView flag shouldn't change", mavContainer.isResolveView());
}
@Test
@@ -82,10 +83,12 @@ public class ServletRequestMethodArgumentResolverTests {
servletRequest.setSession(session);
MethodParameter sessionParameter = new MethodParameter(supportedParams, 2);
assertTrue("Session not supported", resolver.supportsParameter(sessionParameter));
boolean isSupported = resolver.supportsParameter(sessionParameter);
Object result = resolver.resolveArgument(sessionParameter, mavContainer, webRequest, null);
Object result = resolver.resolveArgument(sessionParameter, null, webRequest, null);
assertTrue("Session not supported", isSupported);
assertSame("Invalid result", session, result);
assertTrue("The ResolveView flag shouldn't change", mavContainer.isResolveView());
}
@Test

View File

@@ -57,11 +57,6 @@ public class ServletResponseMethodArgumentResolverTests {
webRequest = new ServletWebRequest(new MockHttpServletRequest(), servletResponse);
}
@Test
public void usesResponseArgument() {
assertTrue("resolver uses response argument", resolver.usesResponseArgument(null));
}
@Test
public void servletResponse() throws Exception {
MethodParameter servletResponseParameter = new MethodParameter(supportedParams, 0);