Consistent spelling for StandaloneMockMvcBuilder's addPlaceholderValue

master
Juergen Hoeller 8 years ago
parent 02e9477711
commit a4b6682c3e
  1. 17
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java
  2. 30
      spring-test/src/test/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilderTests.java

@ -119,7 +119,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
private Boolean removeSemicolonContent;
private Map<String, String> placeHolderValues = new HashMap<>();
private Map<String, String> placeholderValues = new HashMap<>();
/**
@ -317,9 +317,10 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
* request mappings. This method allows manually provided placeholder values so they
* can be resolved. Alternatively consider creating a test that initializes a
* {@link WebApplicationContext}.
* @since 4.2.8
*/
public StandaloneMockMvcBuilder addPlaceHolderValue(String name, String value) {
this.placeHolderValues.put(name, value);
public StandaloneMockMvcBuilder addPlaceholderValue(String name, String value) {
this.placeholderValues.put(name, value);
return this;
}
@ -364,8 +365,8 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
}
private List<ViewResolver> initViewResolvers(WebApplicationContext wac) {
this.viewResolvers = (this.viewResolvers == null) ?
Arrays.<ViewResolver>asList(new InternalResourceViewResolver()) : this.viewResolvers;
this.viewResolvers = (this.viewResolvers != null ? this.viewResolvers :
Collections.<ViewResolver>singletonList(new InternalResourceViewResolver()));
for (Object viewResolver : this.viewResolvers) {
if (viewResolver instanceof WebApplicationObjectSupport) {
((WebApplicationObjectSupport) viewResolver).setApplicationContext(wac);
@ -380,7 +381,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
public StaticRequestMappingHandlerMapping getHandlerMapping() {
StaticRequestMappingHandlerMapping handlerMapping = new StaticRequestMappingHandlerMapping();
handlerMapping.setEmbeddedValueResolver(new StaticStringValueResolver(placeHolderValues));
handlerMapping.setEmbeddedValueResolver(new StaticStringValueResolver(placeholderValues));
handlerMapping.setUseSuffixPatternMatch(useSuffixPatternMatch);
handlerMapping.setUseTrailingSlashMatch(useTrailingSlashPatternMatch);
handlerMapping.setOrder(0);
@ -440,8 +441,8 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
try {
((InitializingBean) mvcValidator).afterPropertiesSet();
}
catch (Exception e) {
throw new BeanInitializationException("Failed to initialize Validator", e);
catch (Exception ex) {
throw new BeanInitializationException("Failed to initialize Validator", ex);
}
}
return mvcValidator;

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@ -23,6 +23,8 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ser.impl.UnknownSerializer;
import org.junit.Test;
import org.springframework.http.converter.json.SpringHandlerInstantiator;
@ -36,9 +38,6 @@ import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ser.impl.UnknownSerializer;
import static org.junit.Assert.*;
/**
@ -50,12 +49,10 @@ import static org.junit.Assert.*;
*/
public class StandaloneMockMvcBuilderTests {
// SPR-10825
@Test
@Test // SPR-10825
public void placeHoldersInRequestMapping() throws Exception {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PlaceholderController());
builder.addPlaceHolderValue("sys.login.ajax", "/foo");
builder.addPlaceholderValue("sys.login.ajax", "/foo");
builder.build();
RequestMappingHandlerMapping hm = builder.wac.getBean(RequestMappingHandlerMapping.class);
@ -67,9 +64,7 @@ public class StandaloneMockMvcBuilderTests {
assertEquals("handleWithPlaceholders", ((HandlerMethod) chain.getHandler()).getMethod().getName());
}
// SPR-13637
@Test
@Test // SPR-13637
public void suffixPatternMatch() throws Exception {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PersonController());
builder.setUseSuffixPatternMatch(false);
@ -87,18 +82,15 @@ public class StandaloneMockMvcBuilderTests {
assertNull(chain);
}
// SPR-12553
@Test
@Test // SPR-12553
public void applicationContextAttribute() {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PlaceholderController());
builder.addPlaceHolderValue("sys.login.ajax", "/foo");
builder.addPlaceholderValue("sys.login.ajax", "/foo");
WebApplicationContext wac = builder.initWebAppContext();
assertEquals(wac, WebApplicationContextUtils
.getRequiredWebApplicationContext(wac.getServletContext()));
}
@Test(expected = IllegalArgumentException.class)
public void addFiltersFiltersNull() {
StandaloneMockMvcBuilder builder = MockMvcBuilders.standaloneSetup(new PersonController());
@ -123,9 +115,7 @@ public class StandaloneMockMvcBuilderTests {
builder.addFilter(new ContinueFilter(), (String) null);
}
// SPR-13375
@Test
@Test // SPR-13375
@SuppressWarnings("rawtypes")
public void springHandlerInstantiator() {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PersonController());
@ -159,6 +149,7 @@ public class StandaloneMockMvcBuilderTests {
}
}
@Controller
private static class PersonController {
@ -173,6 +164,7 @@ public class StandaloneMockMvcBuilderTests {
}
}
private class ContinueFilter extends OncePerRequestFilter {
@Override

Loading…
Cancel
Save