Polishing

This commit is contained in:
Juergen Hoeller 2016-04-08 22:52:36 +02:00
parent 67a65ea600
commit aa5c12c534
7 changed files with 29 additions and 25 deletions

View File

@ -1898,7 +1898,7 @@ public class SpelReproTests extends AbstractExpressionTests {
} }
@Test @Test
public void SPR12803() throws Exception { public void SPR12803() {
StandardEvaluationContext sec = new StandardEvaluationContext(); StandardEvaluationContext sec = new StandardEvaluationContext();
sec.setVariable("iterable", Collections.emptyList()); sec.setVariable("iterable", Collections.emptyList());
SpelExpressionParser parser = new SpelExpressionParser(); SpelExpressionParser parser = new SpelExpressionParser();
@ -1907,7 +1907,7 @@ public class SpelReproTests extends AbstractExpressionTests {
} }
@Test @Test
public void SPR12808() throws Exception { public void SPR12808() {
SpelExpressionParser parser = new SpelExpressionParser(); SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("T(org.springframework.expression.spel.SpelReproTests.DistanceEnforcer).from(#no)"); Expression expression = parser.parseExpression("T(org.springframework.expression.spel.SpelReproTests.DistanceEnforcer).from(#no)");
StandardEvaluationContext sec = new StandardEvaluationContext(); StandardEvaluationContext sec = new StandardEvaluationContext();
@ -2092,9 +2092,9 @@ public class SpelReproTests extends AbstractExpressionTests {
} }
private static enum ABC { A, B, C } private enum ABC { A, B, C }
private static enum XYZ { X, Y, Z } private enum XYZ { X, Y, Z }
public static class BooleanHolder { public static class BooleanHolder {
@ -2121,9 +2121,9 @@ public class SpelReproTests extends AbstractExpressionTests {
} }
private static interface GenericInterface<T extends Number> { private interface GenericInterface<T extends Number> {
public T getProperty(); T getProperty();
} }
@ -2148,9 +2148,9 @@ public class SpelReproTests extends AbstractExpressionTests {
} }
public static interface StaticFinal { public interface StaticFinal {
public static final String VALUE = "interfaceValue"; String VALUE = "interfaceValue";
} }
@ -2227,7 +2227,7 @@ public class SpelReproTests extends AbstractExpressionTests {
} }
@SuppressWarnings({ "rawtypes", "serial" }) @SuppressWarnings({"rawtypes", "serial"})
public static class MapWithConstant extends HashMap { public static class MapWithConstant extends HashMap {
public static final int X = 1; public static final int X = 1;

View File

@ -147,7 +147,8 @@ public class ModelAndViewContainer {
* model (redirect URL preparation). Use of this method may be needed for * model (redirect URL preparation). Use of this method may be needed for
* advanced cases when access to the "default" model is needed regardless, * advanced cases when access to the "default" model is needed regardless,
* e.g. to save model attributes specified via {@code @SessionAttributes}. * e.g. to save model attributes specified via {@code @SessionAttributes}.
* @return the default model, never {@code null} * @return the default model (never {@code null})
* @since 4.1.4
*/ */
public ModelMap getDefaultModel() { public ModelMap getDefaultModel() {
return this.defaultModel; return this.defaultModel;

View File

@ -64,9 +64,7 @@ public class ServletServerHttpRequestTests {
assertEquals("Invalid uri", uri, request.getURI()); assertEquals("Invalid uri", uri, request.getURI());
} }
// SPR-13876 @Test // SPR-13876
@Test
public void getUriWithEncoding() throws Exception { public void getUriWithEncoding() throws Exception {
URI uri = new URI("https://example.com/%E4%B8%AD%E6%96%87" + URI uri = new URI("https://example.com/%E4%B8%AD%E6%96%87" +
"?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework"); "?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework");

View File

@ -29,7 +29,7 @@ import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.context.request.ServletWebRequest;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
@ -196,9 +196,7 @@ public class InvocableHandlerMethodTests {
} }
} }
// SPR-13917 @Test // SPR-13917
@Test
public void invocationErrorMessage() throws Exception { public void invocationErrorMessage() throws Exception {
HandlerMethodArgumentResolverComposite composite = new HandlerMethodArgumentResolverComposite(); HandlerMethodArgumentResolverComposite composite = new HandlerMethodArgumentResolverComposite();
composite.addResolver(new StubArgumentResolver(double.class, null)); composite.addResolver(new StubArgumentResolver(double.class, null));

View File

@ -16,13 +16,12 @@
package org.springframework.web.method.support; package org.springframework.web.method.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import static org.junit.Assert.*;
/** /**
* Test fixture for {@link ModelAndViewContainer}. * Test fixture for {@link ModelAndViewContainer}.
@ -76,7 +75,7 @@ public class ModelAndViewContainerTests {
assertTrue(this.mavContainer.getModel().isEmpty()); assertTrue(this.mavContainer.getModel().isEmpty());
} }
@Test // SPR-14045 @Test // SPR-14045
public void ignoreDefaultModelAndWithoutRedirectModel() { public void ignoreDefaultModelAndWithoutRedirectModel() {
this.mavContainer.setIgnoreDefaultModelOnRedirect(true); this.mavContainer.setIgnoreDefaultModelOnRedirect(true);
this.mavContainer.setRedirectModelScenario(true); this.mavContainer.setRedirectModelScenario(true);

View File

@ -47,6 +47,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
private MethodParameter returnParamModelAndView; private MethodParameter returnParamModelAndView;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
this.handler = new ModelAndViewMethodReturnValueHandler(); this.handler = new ModelAndViewMethodReturnValueHandler();
@ -55,6 +56,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
this.returnParamModelAndView = getReturnValueParam("modelAndView"); this.returnParamModelAndView = getReturnValueParam("modelAndView");
} }
@Test @Test
public void supportsReturnType() throws Exception { public void supportsReturnType() throws Exception {
assertTrue(handler.supportsReturnType(returnParamModelAndView)); assertTrue(handler.supportsReturnType(returnParamModelAndView));
@ -143,7 +145,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
assertNotSame("RedirectAttributes should not be used if controller doesn't redirect", redirectAttributes, model); assertNotSame("RedirectAttributes should not be used if controller doesn't redirect", redirectAttributes, model);
} }
@Test // SPR-14045 @Test // SPR-14045
public void handleRedirectWithIgnoreDefaultModel() throws Exception { public void handleRedirectWithIgnoreDefaultModel() throws Exception {
mavContainer.setIgnoreDefaultModelOnRedirect(true); mavContainer.setIgnoreDefaultModelOnRedirect(true);
@ -163,6 +165,7 @@ public class ModelAndViewMethodReturnValueHandlerTests {
return new MethodParameter(method, -1); return new MethodParameter(method, -1);
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
ModelAndView modelAndView() { ModelAndView modelAndView() {
return null; return null;

View File

@ -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 {
} }
} }
} }
} }