Raise exception on missing request parameters
Issue: SPR-10193
This commit is contained in:
@@ -42,6 +42,7 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.UnsatisfiedServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -202,6 +203,19 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsatisfiedServletRequestParameterException() throws Exception {
|
||||
try {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/params");
|
||||
this.handlerMapping.getHandler(request);
|
||||
fail("UnsatisfiedServletRequestParameterException expected");
|
||||
}
|
||||
catch (UnsatisfiedServletRequestParameterException ex) {
|
||||
assertArrayEquals("Invalid request parameter conditions",
|
||||
new String[] { "foo=bar" }, ex.getParamConditions());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uriTemplateVariables() {
|
||||
PatternsRequestCondition patterns = new PatternsRequestCondition("/{path1}/{path2}");
|
||||
@@ -414,6 +428,11 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
return "";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/params", params="foo=bar")
|
||||
public String param() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/content", produces="application/xml")
|
||||
public String xmlContent() {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user