Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
xargs perl -p -i -e "s/[ \t]*$//g" {} \;
Issue: SPR-10127
This commit is contained in:
committed by
Chris Beams
parent
44a474a014
commit
1762157ad1
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
/*
|
||||
* Copyright 2002-2005 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HttpMessageConverterTests {
|
||||
assertFalse(converter.canRead(MyType.class, new MediaType("foo", "*")));
|
||||
assertFalse(converter.canRead(MyType.class, MediaType.ALL));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
AbstractHttpMessageConverter<MyType> converter = new MyHttpMessageConverter<MyType>(MEDIA_TYPE) {
|
||||
|
||||
@@ -87,7 +87,7 @@ public class StringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
// SPR-8867
|
||||
|
||||
|
||||
@Test
|
||||
public void writeOverrideRequestedContentType() throws IOException {
|
||||
Charset utf8 = Charset.forName("UTF-8");
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Jaxb2RootElementHttpMessageConverterTest {
|
||||
AopProxy proxy = proxyFactory.createAopProxy(advisedSupport);
|
||||
rootElementCglib = (RootElement) proxy.getProxy();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() throws Exception {
|
||||
assertTrue("Converter does not support reading @XmlRootElement", converter.canRead(RootElement.class, null));
|
||||
@@ -79,7 +79,7 @@ public class Jaxb2RootElementHttpMessageConverterTest {
|
||||
RootElement result = (RootElement) converter.read((Class) RootElement.class, inputMessage);
|
||||
assertEquals("Invalid result", "Hello World", result.type.s);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readXmlRootElementSubclass() throws Exception {
|
||||
|
||||
@@ -120,7 +120,7 @@ public class SourceHttpMessageConverterTests {
|
||||
assertEquals("Invalid content-length", outputMessage.getBodyAsBytes().length,
|
||||
outputMessage.getHeaders().getContentLength());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void writeSAXSource() throws Exception {
|
||||
String xml = "<root>Hello World</root>";
|
||||
|
||||
@@ -71,7 +71,7 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession with a default {@link MockServletContext}.
|
||||
*
|
||||
*
|
||||
* @see MockServletContext
|
||||
*/
|
||||
public MockHttpSession() {
|
||||
@@ -80,7 +80,7 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
*/
|
||||
public MockHttpSession(ServletContext servletContext) {
|
||||
@@ -89,7 +89,7 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
* @param id a unique identifier for this session
|
||||
*/
|
||||
@@ -222,7 +222,7 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Serialize the attributes of this session into an object that can be
|
||||
* turned into a byte array with standard Java serialization.
|
||||
*
|
||||
*
|
||||
* @return a representation of this session's serialized state
|
||||
*/
|
||||
public Serializable serializeState() {
|
||||
@@ -249,7 +249,7 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Deserialize the attributes of this session from a state object created by
|
||||
* {@link #serializeState()}.
|
||||
*
|
||||
*
|
||||
* @param state a representation of this session's serialized state
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -72,7 +72,7 @@ public class RequestAndSessionScopedBeanTests {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPutBeanInSession() throws Exception {
|
||||
String targetBeanName = "target";
|
||||
|
||||
@@ -41,16 +41,16 @@ public class RequestContextFilterTests extends TestCase {
|
||||
public void testHappyPath() throws Exception {
|
||||
testFilterInvocation(null);
|
||||
}
|
||||
|
||||
|
||||
public void testWithException() throws Exception {
|
||||
testFilterInvocation(new ServletException());
|
||||
}
|
||||
|
||||
|
||||
public void testFilterInvocation(final ServletException sex) throws Exception {
|
||||
final MockHttpServletRequest req = new MockHttpServletRequest();
|
||||
req.setAttribute("myAttr", "myValue");
|
||||
final MockHttpServletResponse resp = new MockHttpServletResponse();
|
||||
|
||||
|
||||
// Expect one invocation by the filter being tested
|
||||
class DummyFilterChain implements FilterChain {
|
||||
public int invocations = 0;
|
||||
@@ -84,7 +84,7 @@ public class RequestContextFilterTests extends TestCase {
|
||||
catch (ServletException ex) {
|
||||
assertNotNull(sex);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
RequestContextHolder.currentRequestAttributes();
|
||||
fail();
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.web.method.annotation.AbstractCookieValueMethodArgume
|
||||
|
||||
/**
|
||||
* Test fixture with {@link org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver}.
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -59,7 +59,7 @@ public class CookieValueMethodArgumentResolverTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
resolver = new TestCookieValueMethodArgumentResolver();
|
||||
|
||||
|
||||
Method method = getClass().getMethod("params", Cookie.class, String.class, String.class);
|
||||
paramNamedCookie = new MethodParameter(method, 0);
|
||||
paramNamedDefaultValueString = new MethodParameter(method, 1);
|
||||
@@ -79,7 +79,7 @@ public class CookieValueMethodArgumentResolverTests {
|
||||
@Test
|
||||
public void resolveCookieDefaultValue() throws Exception {
|
||||
Object result = resolver.resolveArgument(paramNamedDefaultValueString, null, webRequest, null);
|
||||
|
||||
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("Invalid result", "bar", result);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class CookieValueMethodArgumentResolverTests {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void params(@CookieValue("name") Cookie param1,
|
||||
@CookieValue(value = "name", defaultValue = "bar") String param2,
|
||||
String param3) {
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link ErrorsMethodArgumentResolver}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ErrorsMethodHandlerArgumentResolverTests {
|
||||
@@ -66,7 +66,7 @@ public class ErrorsMethodHandlerArgumentResolverTests {
|
||||
mavContainer.addAttribute("ignore4", "value4");
|
||||
mavContainer.addAttribute("ignore5", "value5");
|
||||
mavContainer.addAllAttributes(bindingResult.getModel());
|
||||
|
||||
|
||||
Object actual = resolver.resolveArgument(paramErrors, mavContainer, webRequest, null);
|
||||
|
||||
assertSame(actual, bindingResult);
|
||||
@@ -77,10 +77,10 @@ public class ErrorsMethodHandlerArgumentResolverTests {
|
||||
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
|
||||
mavContainer.addAllAttributes(bindingResult.getModel());
|
||||
mavContainer.addAttribute("ignore1", "value1");
|
||||
|
||||
|
||||
resolver.resolveArgument(paramErrors, mavContainer, webRequest, null);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
public void noBindingResult() throws Exception {
|
||||
resolver.resolveArgument(paramErrors, new ModelAndViewContainer(), webRequest, null);
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link ExceptionHandlerMethodResolver} tests.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ExceptionHandlerMethodResolverTests {
|
||||
@@ -83,7 +83,7 @@ public class ExceptionHandlerMethodResolverTests {
|
||||
IOException exception = new IOException();
|
||||
assertEquals("handleIOException", resolver.resolveMethod(exception).getName());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void ambiguousExceptionMapping() {
|
||||
new ExceptionHandlerMethodResolver(AmbiguousController.class);
|
||||
@@ -96,7 +96,7 @@ public class ExceptionHandlerMethodResolverTests {
|
||||
|
||||
@Controller
|
||||
static class ExceptionController {
|
||||
|
||||
|
||||
public void handle() {}
|
||||
|
||||
@ExceptionHandler(IOException.class)
|
||||
@@ -139,10 +139,10 @@ public class ExceptionHandlerMethodResolverTests {
|
||||
|
||||
@Controller
|
||||
static class NoExceptionController {
|
||||
|
||||
|
||||
@ExceptionHandler
|
||||
public void handle() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.web.method.annotation.ExpressionValueMethodArgumentRe
|
||||
|
||||
/**
|
||||
* Test fixture with {@link ExpressionValueMethodArgumentResolver}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ExpressionValueMethodArgumentResolverTests {
|
||||
@@ -57,18 +57,18 @@ public class ExpressionValueMethodArgumentResolverTests {
|
||||
GenericWebApplicationContext context = new GenericWebApplicationContext();
|
||||
context.refresh();
|
||||
resolver = new ExpressionValueMethodArgumentResolver(context.getBeanFactory());
|
||||
|
||||
|
||||
Method method = getClass().getMethod("params", int.class, String.class, String.class);
|
||||
paramSystemProperty = new MethodParameter(method, 0);
|
||||
paramContextPath = new MethodParameter(method, 1);
|
||||
paramNotSupported = new MethodParameter(method, 2);
|
||||
|
||||
webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse());
|
||||
|
||||
|
||||
// Expose request to the current thread (for SpEL expressions)
|
||||
RequestContextHolder.setRequestAttributes(webRequest);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
RequestContextHolder.resetRequestAttributes();
|
||||
@@ -86,7 +86,7 @@ public class ExpressionValueMethodArgumentResolverTests {
|
||||
System.setProperty("systemProperty", "22");
|
||||
Object value = resolver.resolveArgument(paramSystemProperty, null, webRequest, null);
|
||||
System.clearProperty("systemProperty");
|
||||
|
||||
|
||||
assertEquals("22", value);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ExpressionValueMethodArgumentResolverTests {
|
||||
public void resolveContextPath() throws Exception {
|
||||
webRequest.getNativeRequest(MockHttpServletRequest.class).setContextPath("/contextPath");
|
||||
Object value = resolver.resolveArgument(paramContextPath, null, webRequest, null);
|
||||
|
||||
|
||||
assertEquals("/contextPath", value);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,19 +53,19 @@ public class InitBinderDataBinderFactoryTests {
|
||||
private HandlerMethodArgumentResolverComposite argumentResolvers;
|
||||
|
||||
private NativeWebRequest webRequest;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
bindingInitializer = new ConfigurableWebBindingInitializer();
|
||||
argumentResolvers = new HandlerMethodArgumentResolverComposite();
|
||||
webRequest = new ServletWebRequest(new MockHttpServletRequest());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void createBinder() throws Exception {
|
||||
WebDataBinderFactory factory = createBinderFactory("initBinder", WebDataBinder.class);
|
||||
WebDataBinder dataBinder = factory.createBinder(webRequest, null, null);
|
||||
|
||||
|
||||
assertNotNull(dataBinder.getDisallowedFields());
|
||||
assertEquals("id", dataBinder.getDisallowedFields()[0]);
|
||||
}
|
||||
@@ -74,10 +74,10 @@ public class InitBinderDataBinderFactoryTests {
|
||||
public void createBinderWithGlobalInitialization() throws Exception {
|
||||
ConversionService conversionService = new DefaultFormattingConversionService();
|
||||
bindingInitializer.setConversionService(conversionService);
|
||||
|
||||
|
||||
WebDataBinderFactory factory = createBinderFactory("initBinder", WebDataBinder.class);
|
||||
WebDataBinder dataBinder = factory.createBinder(webRequest, null, null);
|
||||
|
||||
|
||||
assertSame(conversionService, dataBinder.getConversionService());
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class InitBinderDataBinderFactoryTests {
|
||||
public void createBinderWithAttrName() throws Exception {
|
||||
WebDataBinderFactory factory = createBinderFactory("initBinderWithAttributeName", WebDataBinder.class);
|
||||
WebDataBinder dataBinder = factory.createBinder(webRequest, null, "foo");
|
||||
|
||||
|
||||
assertNotNull(dataBinder.getDisallowedFields());
|
||||
assertEquals("id", dataBinder.getDisallowedFields()[0]);
|
||||
}
|
||||
@@ -94,18 +94,18 @@ public class InitBinderDataBinderFactoryTests {
|
||||
public void createBinderWithAttrNameNoMatch() throws Exception {
|
||||
WebDataBinderFactory factory = createBinderFactory("initBinderWithAttributeName", WebDataBinder.class);
|
||||
WebDataBinder dataBinder = factory.createBinder(webRequest, null, "invalidName");
|
||||
|
||||
|
||||
assertNull(dataBinder.getDisallowedFields());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void createBinderNullAttrName() throws Exception {
|
||||
WebDataBinderFactory factory = createBinderFactory("initBinderWithAttributeName", WebDataBinder.class);
|
||||
WebDataBinder dataBinder = factory.createBinder(webRequest, null, null);
|
||||
|
||||
|
||||
assertNull(dataBinder.getDisallowedFields());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
public void returnValueNotExpected() throws Exception {
|
||||
WebDataBinderFactory factory = createBinderFactory("initBinderReturnValue", WebDataBinder.class);
|
||||
@@ -123,7 +123,7 @@ public class InitBinderDataBinderFactoryTests {
|
||||
assertNotNull(dataBinder.getDisallowedFields());
|
||||
assertEquals("requestParam-22", dataBinder.getDisallowedFields()[0]);
|
||||
}
|
||||
|
||||
|
||||
private WebDataBinderFactory createBinderFactory(String methodName, Class<?>... parameterTypes)
|
||||
throws Exception {
|
||||
|
||||
@@ -134,9 +134,9 @@ public class InitBinderDataBinderFactoryTests {
|
||||
handlerMethod.setHandlerMethodArgumentResolvers(argumentResolvers);
|
||||
handlerMethod.setDataBinderFactory(new DefaultDataBinderFactory(null));
|
||||
handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
|
||||
|
||||
|
||||
return new InitBinderDataBinderFactory(Arrays.asList(handlerMethod), bindingInitializer);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InitBinderHandler {
|
||||
|
||||
@@ -145,24 +145,24 @@ public class InitBinderDataBinderFactoryTests {
|
||||
public void initBinder(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@InitBinder(value="foo")
|
||||
public void initBinderWithAttributeName(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@InitBinder
|
||||
public String initBinderReturnValue(WebDataBinder dataBinder) {
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@InitBinder
|
||||
public void initBinderTypeConversion(WebDataBinder dataBinder, @RequestParam int requestParam) {
|
||||
dataBinder.setDisallowedFields("requestParam-" + requestParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -35,15 +35,15 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link org.springframework.web.method.annotation.MapMethodProcessor}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MapMethodProcessorTests {
|
||||
|
||||
private MapMethodProcessor processor;
|
||||
|
||||
|
||||
private ModelAndViewContainer mavContainer;
|
||||
|
||||
|
||||
private MethodParameter paramMap;
|
||||
|
||||
private MethodParameter returnParamMap;
|
||||
@@ -54,8 +54,8 @@ public class MapMethodProcessorTests {
|
||||
public void setUp() throws Exception {
|
||||
processor = new MapMethodProcessor();
|
||||
mavContainer = new ModelAndViewContainer();
|
||||
|
||||
Method method = getClass().getDeclaredMethod("map", Map.class);
|
||||
|
||||
Method method = getClass().getDeclaredMethod("map", Map.class);
|
||||
paramMap = new MethodParameter(method, 0);
|
||||
returnParamMap = new MethodParameter(method, 0);
|
||||
|
||||
@@ -76,12 +76,12 @@ public class MapMethodProcessorTests {
|
||||
public void resolveArgumentValue() throws Exception {
|
||||
assertSame(mavContainer.getModel(), processor.resolveArgument(paramMap, mavContainer, webRequest, null));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void handleMapReturnValue() throws Exception {
|
||||
mavContainer.addAttribute("attr1", "value1");
|
||||
Map<String, Object> returnValue = new ModelMap("attr2", "value2");
|
||||
|
||||
|
||||
processor.handleReturnValue(returnValue , returnParamMap, mavContainer, webRequest);
|
||||
|
||||
assertEquals("value1", mavContainer.getModel().get("attr1"));
|
||||
@@ -92,5 +92,5 @@ public class MapMethodProcessorTests {
|
||||
private Map<String, Object> map(Map<String, Object> map) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -50,13 +50,13 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
/**
|
||||
* Text fixture for {@link ModelFactory} tests.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ModelFactoryTests {
|
||||
|
||||
|
||||
private Object handler = new ModelHandler();
|
||||
|
||||
|
||||
private InvocableHandlerMethod handleMethod;
|
||||
|
||||
private InvocableHandlerMethod handleSessionAttrMethod;
|
||||
@@ -77,13 +77,13 @@ public class ModelFactoryTests {
|
||||
sessionAttrsHandler = new SessionAttributesHandler(handlerType, sessionAttributeStore);
|
||||
webRequest = new ServletWebRequest(new MockHttpServletRequest());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void modelAttributeMethod() throws Exception {
|
||||
ModelFactory modelFactory = createModelFactory("modelAttr", Model.class);
|
||||
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
|
||||
modelFactory.initModel(webRequest, mavContainer, handleMethod);
|
||||
|
||||
|
||||
assertEquals(Boolean.TRUE, mavContainer.getModel().get("modelAttr"));
|
||||
}
|
||||
|
||||
@@ -114,14 +114,14 @@ public class ModelFactoryTests {
|
||||
assertTrue(mavContainer.containsAttribute("name"));
|
||||
assertNull(mavContainer.getModel().get("name"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sessionAttribute() throws Exception {
|
||||
sessionAttributeStore.storeAttribute(webRequest, "sessionAttr", "sessionAttrValue");
|
||||
|
||||
// Resolve successfully handler session attribute once
|
||||
assertTrue(sessionAttrsHandler.isHandlerSessionAttribute("sessionAttr", null));
|
||||
|
||||
|
||||
ModelFactory modelFactory = createModelFactory("modelAttr", Model.class);
|
||||
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
|
||||
modelFactory.initModel(webRequest, mavContainer, handleMethod);
|
||||
@@ -137,7 +137,7 @@ public class ModelFactoryTests {
|
||||
modelFactory.initModel(webRequest, new ModelAndViewContainer(), handleSessionAttrMethod);
|
||||
fail("Expected HttpSessionRequiredException");
|
||||
} catch (HttpSessionRequiredException e) { }
|
||||
|
||||
|
||||
sessionAttributeStore.storeAttribute(webRequest, "sessionAttr", "sessionAttrValue");
|
||||
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
|
||||
modelFactory.initModel(webRequest, mavContainer, handleSessionAttrMethod);
|
||||
@@ -151,19 +151,19 @@ public class ModelFactoryTests {
|
||||
Object attrValue = new Object();
|
||||
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
|
||||
mavContainer.addAttribute(attrName, attrValue);
|
||||
|
||||
|
||||
WebDataBinder dataBinder = new WebDataBinder(attrValue, attrName);
|
||||
WebDataBinderFactory binderFactory = createMock(WebDataBinderFactory.class);
|
||||
expect(binderFactory.createBinder(webRequest, attrValue, attrName)).andReturn(dataBinder);
|
||||
replay(binderFactory);
|
||||
|
||||
|
||||
ModelFactory modelFactory = new ModelFactory(null, binderFactory, sessionAttrsHandler);
|
||||
modelFactory.updateModel(webRequest, mavContainer);
|
||||
|
||||
assertEquals(attrValue, mavContainer.getModel().remove(attrName));
|
||||
assertSame(dataBinder.getBindingResult(), mavContainer.getModel().remove(bindingResultKey(attrName)));
|
||||
assertEquals(0, mavContainer.getModel().size());
|
||||
|
||||
|
||||
verify(binderFactory);
|
||||
}
|
||||
|
||||
@@ -171,12 +171,12 @@ public class ModelFactoryTests {
|
||||
public void updateModelSessionStatusComplete() throws Exception {
|
||||
String attrName = "sessionAttr";
|
||||
String attrValue = "sessionAttrValue";
|
||||
|
||||
|
||||
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
|
||||
mavContainer.addAttribute(attrName, attrValue);
|
||||
mavContainer.getSessionStatus().setComplete();
|
||||
sessionAttributeStore.storeAttribute(webRequest, attrName, attrValue);
|
||||
|
||||
|
||||
// Resolve successfully handler session attribute once
|
||||
assertTrue(sessionAttrsHandler.isHandlerSessionAttribute(attrName, null));
|
||||
|
||||
@@ -193,11 +193,11 @@ public class ModelFactoryTests {
|
||||
|
||||
verify(binderFactory);
|
||||
}
|
||||
|
||||
|
||||
private String bindingResultKey(String key) {
|
||||
return BindingResult.MODEL_KEY_PREFIX + key;
|
||||
}
|
||||
|
||||
|
||||
private ModelFactory createModelFactory(String methodName, Class<?>... parameterTypes) throws Exception{
|
||||
Method method = ModelHandler.class.getMethod(methodName, parameterTypes);
|
||||
|
||||
@@ -208,13 +208,13 @@ public class ModelFactoryTests {
|
||||
handlerMethod.setHandlerMethodArgumentResolvers(argResolvers);
|
||||
handlerMethod.setDataBinderFactory(null);
|
||||
handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
|
||||
|
||||
|
||||
return new ModelFactory(Arrays.asList(handlerMethod), null, sessionAttrsHandler);
|
||||
}
|
||||
|
||||
|
||||
@SessionAttributes("sessionAttr") @SuppressWarnings("unused")
|
||||
private static class ModelHandler {
|
||||
|
||||
|
||||
@ModelAttribute
|
||||
public void modelAttr(Model model) {
|
||||
model.addAttribute("modelAttr", Boolean.TRUE);
|
||||
@@ -234,7 +234,7 @@ public class ModelFactoryTests {
|
||||
public Boolean nullModelAttr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void handle() {
|
||||
}
|
||||
|
||||
|
||||
@@ -35,15 +35,15 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link org.springframework.web.method.annotation.ModelMethodProcessor}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ModelMethodProcessorTests {
|
||||
|
||||
private ModelMethodProcessor processor;
|
||||
|
||||
|
||||
private ModelAndViewContainer mavContainer;
|
||||
|
||||
|
||||
private MethodParameter paramModel;
|
||||
|
||||
private MethodParameter returnParamModel;
|
||||
@@ -54,11 +54,11 @@ public class ModelMethodProcessorTests {
|
||||
public void setUp() throws Exception {
|
||||
processor = new ModelMethodProcessor();
|
||||
mavContainer = new ModelAndViewContainer();
|
||||
|
||||
Method method = getClass().getDeclaredMethod("model", Model.class);
|
||||
|
||||
Method method = getClass().getDeclaredMethod("model", Model.class);
|
||||
paramModel = new MethodParameter(method, 0);
|
||||
returnParamModel = new MethodParameter(method, -1);
|
||||
|
||||
|
||||
webRequest = new ServletWebRequest(new MockHttpServletRequest());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ModelMethodProcessorTests {
|
||||
public void resolveArgumentValue() throws Exception {
|
||||
assertSame(mavContainer.getModel(), processor.resolveArgument(paramModel, mavContainer, webRequest, null));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void handleModelReturnValue() throws Exception {
|
||||
mavContainer.addAttribute("attr1", "value1");
|
||||
@@ -84,14 +84,14 @@ public class ModelMethodProcessorTests {
|
||||
returnValue.addAttribute("attr2", "value2");
|
||||
|
||||
processor.handleReturnValue(returnValue , returnParamModel, mavContainer, webRequest);
|
||||
|
||||
|
||||
assertEquals("value1", mavContainer.getModel().get("attr1"));
|
||||
assertEquals("value2", mavContainer.getModel().get("attr2"));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Model model(Model model) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import org.springframework.web.method.annotation.RequestHeaderMapMethodArgumentR
|
||||
|
||||
/**
|
||||
* Text fixture with {@link RequestHeaderMapMethodArgumentResolver}.
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
resolver = new RequestHeaderMapMethodArgumentResolver();
|
||||
|
||||
|
||||
Method method = getClass().getMethod("params", Map.class, MultiValueMap.class, HttpHeaders.class, Map.class);
|
||||
paramMap = new MethodParameter(method, 0);
|
||||
paramMultiValueMap = new MethodParameter(method, 1);
|
||||
@@ -108,7 +108,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
|
||||
expected.add(name, value2);
|
||||
|
||||
Object result = resolver.resolveArgument(paramMultiValueMap, null, webRequest, null);
|
||||
|
||||
|
||||
assertTrue(result instanceof MultiValueMap);
|
||||
assertEquals("Invalid result", expected, result);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
|
||||
expected.add(name, value2);
|
||||
|
||||
Object result = resolver.resolveArgument(paramHttpHeaders, null, webRequest, null);
|
||||
|
||||
|
||||
assertTrue(result instanceof HttpHeaders);
|
||||
assertEquals("Invalid result", expected, result);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.web.method.annotation.RequestHeaderMethodArgumentReso
|
||||
|
||||
/**
|
||||
* Test fixture with {@link org.springframework.web.method.annotation.RequestHeaderMethodArgumentResolver}.
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
// Expose request to the current thread (for SpEL expressions)
|
||||
RequestContextHolder.setRequestAttributes(webRequest);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
RequestContextHolder.resetRequestAttributes();
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.web.method.annotation.RequestParamMapMethodArgumentRe
|
||||
|
||||
/**
|
||||
* Test fixture with {@link RequestParamMapMethodArgumentResolver}.
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -61,7 +61,7 @@ public class RequestParamMapMethodArgumentResolverTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
resolver = new RequestParamMapMethodArgumentResolver();
|
||||
|
||||
|
||||
Method method = getClass().getMethod("params", Map.class, MultiValueMap.class, Map.class, Map.class);
|
||||
paramMap = new MethodParameter(method, 0);
|
||||
paramMultiValueMap = new MethodParameter(method, 1);
|
||||
@@ -88,7 +88,7 @@ public class RequestParamMapMethodArgumentResolverTests {
|
||||
Map<String, String> expected = Collections.singletonMap(name, value);
|
||||
|
||||
Object result = resolver.resolveArgument(paramMap, null, webRequest, null);
|
||||
|
||||
|
||||
assertTrue(result instanceof Map);
|
||||
assertEquals("Invalid result", expected, result);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class RequestParamMapMethodArgumentResolverTests {
|
||||
String value1 = "bar";
|
||||
String value2 = "baz";
|
||||
request.addParameter(name, new String[]{value1, value2});
|
||||
|
||||
|
||||
MultiValueMap<String, String> expected = new LinkedMultiValueMap<String, String>(1);
|
||||
expected.add(name, value1);
|
||||
expected.add(name, value2);
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link org.springframework.web.method.annotation.RequestParamMethodArgumentResolver}.
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -81,7 +81,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
|
||||
Method method = getClass().getMethod("params", String.class, String[].class, Map.class, MultipartFile.class,
|
||||
Map.class, String.class, MultipartFile.class, List.class, Part.class, MultipartFile.class);
|
||||
|
||||
|
||||
paramNamedDefaultValueString = new MethodParameter(method, 0);
|
||||
paramNamedStringArray = new MethodParameter(method, 1);
|
||||
paramNamedMap = new MethodParameter(method, 2);
|
||||
@@ -112,7 +112,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
assertTrue("Simple type params supported w/o annotations", resolver.supportsParameter(paramStringNotAnnot));
|
||||
assertTrue("MultipartFile parameter not supported", resolver.supportsParameter(paramMultipartFileNotAnnot));
|
||||
assertTrue("Part parameter not supported", resolver.supportsParameter(paramServlet30Part));
|
||||
|
||||
|
||||
resolver = new RequestParamMethodArgumentResolver(null, false);
|
||||
assertFalse(resolver.supportsParameter(paramStringNotAnnot));
|
||||
assertFalse(resolver.supportsParameter(paramRequestPartAnnot));
|
||||
@@ -229,7 +229,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
@Test
|
||||
public void resolveDefaultValue() throws Exception {
|
||||
Object result = resolver.resolveArgument(paramNamedDefaultValueString, null, webRequest, null);
|
||||
|
||||
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("Invalid result", "bar", result);
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
}
|
||||
|
||||
// SPR-8561
|
||||
|
||||
|
||||
@Test
|
||||
public void resolveSimpleTypeParamToNull() throws Exception {
|
||||
Object result = resolver.resolveArgument(paramStringNotAnnot, null, webRequest, null);
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link WebArgumentResolverAdapterTests}.
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ public class WebArgumentResolverAdapterTests {
|
||||
adapter = new TestWebArgumentResolverAdapter(adaptee);
|
||||
parameter = new MethodParameter(getClass().getMethod("handle", Integer.TYPE), 0);
|
||||
webRequest = new ServletWebRequest(new MockHttpServletRequest());
|
||||
|
||||
|
||||
// Expose request to the current thread (for SpEL expressions)
|
||||
RequestContextHolder.setRequestAttributes(webRequest);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class WebArgumentResolverAdapterTests {
|
||||
|
||||
public void handle(int param) {
|
||||
}
|
||||
|
||||
|
||||
private class TestWebArgumentResolverAdapter extends AbstractWebArgumentResolverAdapter {
|
||||
|
||||
public TestWebArgumentResolverAdapter(WebArgumentResolver adaptee) {
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.core.MethodParameter;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link HandlerMethodArgumentResolverComposite}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class HandlerMethodArgumentResolverCompositeTests {
|
||||
@@ -42,20 +42,20 @@ public class HandlerMethodArgumentResolverCompositeTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
resolvers = new HandlerMethodArgumentResolverComposite();
|
||||
|
||||
|
||||
Method method = getClass().getDeclaredMethod("handle", Integer.class, String.class);
|
||||
paramInt = new MethodParameter(method, 0);
|
||||
paramStr = new MethodParameter(method, 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() throws Exception {
|
||||
registerResolver(Integer.class, null);
|
||||
|
||||
|
||||
assertTrue(this.resolvers.supportsParameter(paramInt));
|
||||
assertFalse(this.resolvers.supportsParameter(paramStr));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void resolveArgument() throws Exception {
|
||||
registerResolver(Integer.class, Integer.valueOf(55));
|
||||
@@ -63,7 +63,7 @@ public class HandlerMethodArgumentResolverCompositeTests {
|
||||
|
||||
assertEquals(Integer.valueOf(55), resolvedValue);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkArgumentResolverOrder() throws Exception {
|
||||
registerResolver(Integer.class, Integer.valueOf(1));
|
||||
@@ -72,7 +72,7 @@ public class HandlerMethodArgumentResolverCompositeTests {
|
||||
|
||||
assertEquals("Didn't use the first registered resolver", Integer.valueOf(1), resolvedValue);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void noSuitableArgumentResolver() throws Exception {
|
||||
this.resolvers.resolveArgument(paramStr, null, null, null);
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.core.MethodParameter;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link HandlerMethodReturnValueHandlerComposite}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class HandlerMethodReturnValueHandlerCompositeTests {
|
||||
@@ -35,7 +35,7 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
|
||||
private HandlerMethodReturnValueHandlerComposite handlers;
|
||||
|
||||
ModelAndViewContainer mavContainer;
|
||||
|
||||
|
||||
private MethodParameter paramInt;
|
||||
|
||||
private MethodParameter paramStr;
|
||||
@@ -43,11 +43,11 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
handlers = new HandlerMethodReturnValueHandlerComposite();
|
||||
mavContainer = new ModelAndViewContainer();
|
||||
mavContainer = new ModelAndViewContainer();
|
||||
paramInt = new MethodParameter(getClass().getDeclaredMethod("handleInteger"), -1);
|
||||
paramStr = new MethodParameter(getClass().getDeclaredMethod("handleString"), -1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void supportsReturnType() throws Exception {
|
||||
registerHandler(Integer.class);
|
||||
@@ -55,12 +55,12 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
|
||||
assertTrue(this.handlers.supportsReturnType(paramInt));
|
||||
assertFalse(this.handlers.supportsReturnType(paramStr));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void handleReturnValue() throws Exception {
|
||||
StubReturnValueHandler handler = registerHandler(Integer.class);
|
||||
this.handlers.handleReturnValue(Integer.valueOf(55), paramInt, mavContainer, null);
|
||||
|
||||
|
||||
assertEquals(Integer.valueOf(55), handler.getReturnValue());
|
||||
}
|
||||
|
||||
@@ -69,28 +69,28 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
|
||||
StubReturnValueHandler h1 = registerHandler(Integer.class);
|
||||
StubReturnValueHandler h2 = registerHandler(Integer.class);
|
||||
this.handlers.handleReturnValue(Integer.valueOf(55), paramInt, mavContainer, null);
|
||||
|
||||
|
||||
assertEquals("Didn't use the 1st registered handler", Integer.valueOf(55), h1.getReturnValue());
|
||||
assertNull("Shouldn't have use the 2nd registered handler", h2.getReturnValue());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void noSuitableReturnValueHandler() throws Exception {
|
||||
registerHandler(Integer.class);
|
||||
this.handlers.handleReturnValue("value", paramStr, null, null);
|
||||
}
|
||||
|
||||
|
||||
private StubReturnValueHandler registerHandler(Class<?> returnType) {
|
||||
StubReturnValueHandler handler = new StubReturnValueHandler(returnType);
|
||||
handlers.addHandler(handler);
|
||||
return handler;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Integer handleInteger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String handleString() {
|
||||
return null;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ModelAndViewContainerTests {
|
||||
public void setup() {
|
||||
this.mavContainer = new ModelAndViewContainer();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getModel() {
|
||||
this.mavContainer.addAttribute("name", "value");
|
||||
@@ -48,13 +48,13 @@ public class ModelAndViewContainerTests {
|
||||
ModelMap redirectModel = new ModelMap("name", "redirectValue");
|
||||
this.mavContainer.setRedirectModel(redirectModel);
|
||||
this.mavContainer.addAttribute("name", "value");
|
||||
|
||||
|
||||
assertEquals("Default model should be used if not in redirect scenario",
|
||||
"value", this.mavContainer.getModel().get("name"));
|
||||
|
||||
|
||||
this.mavContainer.setRedirectModelScenario(true);
|
||||
|
||||
assertEquals("Redirect model should be used in redirect scenario",
|
||||
|
||||
assertEquals("Redirect model should be used in redirect scenario",
|
||||
"redirectValue", this.mavContainer.getModel().get("name"));
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ public class ModelAndViewContainerTests {
|
||||
public void getModelIgnoreDefaultModelOnRedirect() {
|
||||
this.mavContainer.addAttribute("name", "value");
|
||||
this.mavContainer.setRedirectModelScenario(true);
|
||||
|
||||
assertEquals("Default model should be used since no redirect model was provided",
|
||||
|
||||
assertEquals("Default model should be used since no redirect model was provided",
|
||||
1, this.mavContainer.getModel().size());
|
||||
|
||||
this.mavContainer.setIgnoreDefaultModelOnRedirect(true);
|
||||
|
||||
assertEquals("Empty model should be returned if no redirect model is available",
|
||||
|
||||
assertEquals("Empty model should be returned if no redirect model is available",
|
||||
0, this.mavContainer.getModel().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
/**
|
||||
* Supports parameters of a given type and resolves them using a stub value.
|
||||
* Also records the resolved parameter value.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class StubArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
@@ -34,7 +34,7 @@ public class StubArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
private final Class<?> parameterType;
|
||||
|
||||
private final Object stubValue;
|
||||
|
||||
|
||||
private List<MethodParameter> resolvedParameters = new ArrayList<MethodParameter>();
|
||||
|
||||
public StubArgumentResolver(Class<?> supportedParameterType, Object stubValue) {
|
||||
|
||||
@@ -20,16 +20,16 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
/**
|
||||
* Supports a fixed return value type. Records the last handled return value.
|
||||
*
|
||||
* Supports a fixed return value type. Records the last handled return value.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class StubReturnValueHandler implements HandlerMethodReturnValueHandler {
|
||||
|
||||
private final Class<?> returnType;
|
||||
|
||||
|
||||
private Object returnValue;
|
||||
|
||||
|
||||
public StubReturnValueHandler(Class<?> returnType) {
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@@ -36,19 +36,19 @@ import static org.junit.Assert.*;
|
||||
public class RequestPartServletServerHttpRequestTests {
|
||||
|
||||
private RequestPartServletServerHttpRequest request;
|
||||
|
||||
|
||||
private MockMultipartHttpServletRequest mockRequest;
|
||||
|
||||
private MockMultipartFile mockFile;
|
||||
|
||||
|
||||
@Before
|
||||
public void create() throws Exception {
|
||||
mockFile = new MockMultipartFile("part", "", "application/json" ,"Part Content".getBytes("UTF-8"));
|
||||
mockRequest = new MockMultipartHttpServletRequest();
|
||||
mockRequest.addFile(mockFile);
|
||||
request = new RequestPartServletServerHttpRequest(mockRequest, "part");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMethod() throws Exception {
|
||||
mockRequest.setMethod("POST");
|
||||
@@ -80,5 +80,5 @@ public class RequestPartServletServerHttpRequestTests {
|
||||
byte[] result = FileCopyUtils.copyToByteArray(request.getBody());
|
||||
assertArrayEquals("Invalid content returned", mockFile.getBytes(), result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Log4jWebConfigurerTests {
|
||||
public void initLoggingWithClasspathResourceAndRefreshInterval() {
|
||||
initLogging(CLASSPATH_RESOURCE, true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void initLoggingWithRelativeFilePath() {
|
||||
initLogging(RELATIVE_PATH, false);
|
||||
@@ -119,11 +119,11 @@ public class Log4jWebConfigurerTests {
|
||||
@Test
|
||||
public void testLog4jConfigListener() {
|
||||
Log4jConfigListener listener = new Log4jConfigListener();
|
||||
|
||||
|
||||
MockServletContext sc = new MockServletContext("", new FileSystemResourceLoader());
|
||||
sc.addInitParameter(Log4jWebConfigurer.CONFIG_LOCATION_PARAM, RELATIVE_PATH);
|
||||
listener.contextInitialized(new ServletContextEvent(sc));
|
||||
|
||||
|
||||
try {
|
||||
assertLogOutput();
|
||||
} finally {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2006 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -45,7 +45,7 @@ public class UriComponentsTests {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com/hotel list/Z\u00fcrich").build();
|
||||
assertEquals(new URI("http://example.com/hotel%20list/Z\u00fcrich"), uriComponents.toUri());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void expand() {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com").path("/{foo} {bar}").build();
|
||||
@@ -63,7 +63,7 @@ public class UriComponentsTests {
|
||||
public void invalidCharacters() {
|
||||
UriComponentsBuilder.fromPath("/{foo}").build(true);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidEncodedSequence() {
|
||||
UriComponentsBuilder.fromPath("/fo%2o").build(true);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class UriTemplateTests {
|
||||
URI result = template.expand(uriVariables);
|
||||
assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void expandMapEncoded() throws Exception {
|
||||
Map<String, String> uriVariables = Collections.singletonMap("hotel", "Z\u00fcrich");
|
||||
@@ -113,7 +113,7 @@ public class UriTemplateTests {
|
||||
assertFalse("UriTemplate matches", template.matches(""));
|
||||
assertFalse("UriTemplate matches", template.matches(null));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void matchesCustomRegex() throws Exception {
|
||||
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel:\\d+}");
|
||||
|
||||
@@ -29,7 +29,7 @@ public class UriUtilsTests {
|
||||
|
||||
private static final String ENC = "UTF-8";
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void encodeScheme() throws UnsupportedEncodingException {
|
||||
|
||||
Reference in New Issue
Block a user