Class MockMvcRequestBuilderUtils
- java.lang.Object
-
- io.florianlopes.spring.test.web.servlet.request.MockMvcRequestBuilderUtils
-
public class MockMvcRequestBuilderUtils extends Object
Custom MockMvcRequestBuilder to post an entire form to a given url. Useful to test Spring MVC form validation.- Author:
- Florian Lopes
- See Also:
MockMvcRequestBuilders
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMockMvcRequestBuilderUtils.ConfigurationConfiguration class that allows the exclusion of specific fields.static classMockMvcRequestBuilderUtils.FormRequestPostProcessorImplementation ofRequestPostProcessorthat adds form parameters to the request before execution.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MockMvcRequestBuilderUtils.FormRequestPostProcessorform(Object form)static MockMvcRequestBuilderUtils.FormRequestPostProcessorform(Object form, MockMvcRequestBuilderUtils.Configuration config)static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilderpostForm(String url, Object form)Post a form to the given url.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilderpostForm(String url, Object form, MockMvcRequestBuilderUtils.Configuration config)Post a form to the given url.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilderputForm(String url, Object form)Put a form to the given url.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilderputForm(String url, Object form, MockMvcRequestBuilderUtils.Configuration config)Put a form to the given url.static voidregisterPropertyEditor(Class type, PropertyEditor propertyEditor)Register custom property editor for a given type.
-
-
-
Method Detail
-
registerPropertyEditor
public static void registerPropertyEditor(Class type, PropertyEditor propertyEditor)
Register custom property editor for a given type.- Parameters:
type- type of the propertypropertyEditor-PropertyEditorto register
-
form
public static MockMvcRequestBuilderUtils.FormRequestPostProcessor form(Object form)
-
form
public static MockMvcRequestBuilderUtils.FormRequestPostProcessor form(Object form, MockMvcRequestBuilderUtils.Configuration config)
-
postForm
public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder postForm(String url, Object form)
Post a form to the given url. All non-null, non-static, non-final, non-transient form fields will be added as HTTP request parameters using POST method- Parameters:
url- the URL to post the form toform- form object to send using POST method- Returns:
- mockHttpServletRequestBuilder wrapped mockHttpServletRequestBuilder
-
postForm
public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder postForm(String url, Object form, MockMvcRequestBuilderUtils.Configuration config)
Post a form to the given url. All non-null, non-static, non-final form fields will be added as HTTP request parameters using POST method- Parameters:
url- the URL to post the form toform- form object to send using POST methodconfig- configuration object- Returns:
- mockHttpServletRequestBuilder wrapped mockHttpServletRequestBuilder
-
putForm
public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder putForm(String url, Object form)
Put a form to the given url. All non-null, non-static, non-final, non-transient form fields will be added as HTTP request parameters using PUT method- Parameters:
url- the URL to put the form toform- form object to send using PUT method- Returns:
- mockHttpServletRequestBuilder wrapped mockHttpServletRequestBuilder
-
putForm
public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder putForm(String url, Object form, MockMvcRequestBuilderUtils.Configuration config)
Put a form to the given url. All non-null, non-static, non-final form fields will be added as HTTP request parameters using PUT method- Parameters:
url- the URL to put the form toform- form object to send using PUT methodconfig- configuration object- Returns:
- mockHttpServletRequestBuilder wrapped mockHttpServletRequestBuilder
-
-