Add params(MultiValueMap) to MockMvc

Issue: SPR-13801
This commit is contained in:
Rossen Stoyanchev
2015-12-16 11:51:59 -05:00
parent 5626384812
commit c8aa48faa9
2 changed files with 32 additions and 0 deletions

View File

@@ -151,6 +151,21 @@ public class MockHttpServletRequestBuilder
return this;
}
/**
* Add request parameters to the {@link MockHttpServletRequest} for example
* such as when testing a form submission. If called more than once, the new
* values are added.
* @param params the parameters to add
*/
public MockHttpServletRequestBuilder params(MultiValueMap<String, String> params) {
for (String name : params.keySet()) {
for (String value : params.get(name)) {
this.parameters.add(name, value);
}
}
return this;
}
/**
* Add a header to the request. Values are always added.
* @param name the header name