Class MockMvcTester.MockMvcRequestBuilder
java.lang.Object
org.springframework.test.web.servlet.request.AbstractMockHttpServletRequestBuilder<MockMvcTester.MockMvcRequestBuilder>
org.springframework.test.web.servlet.assertj.MockMvcTester.MockMvcRequestBuilder
- All Implemented Interfaces:
org.assertj.core.api.AssertProvider<MvcTestResultAssert>, Mergeable, ConfigurableSmartRequestBuilder<MockMvcTester.MockMvcRequestBuilder>, RequestBuilder, SmartRequestBuilder
- Enclosing class:
MockMvcTester
public final class MockMvcTester.MockMvcRequestBuilder
extends AbstractMockHttpServletRequestBuilder<MockMvcTester.MockMvcRequestBuilder>
implements org.assertj.core.api.AssertProvider<MvcTestResultAssert>
A builder for
MockHttpServletRequest that supports AssertJ.- Since:
- 6.2
- Author:
- Stephane Nicoll, Brian Clozel
-
Method Summary
Modifier and TypeMethodDescriptionExecute the request and do not attempt to wait for the completion of an asynchronous request.exchange()Execute the request.Execute the request and wait at most the giventimeToWaitduration for the asynchronous request to complete.Enable file upload support using multipart.Methods inherited from class AbstractMockHttpServletRequestBuilder
accept, accept, acceptCharset, apiVersion, apiVersionInserter, buildRequest, characterEncoding, characterEncoding, content, content, contentType, contentType, contextPath, cookie, createServletRequest, flashAttr, flashAttrs, formField, formFields, header, headers, headers, ifModifiedSince, ifNoneMatch, isMergeEnabled, locale, locale, merge, param, params, pathInfo, postProcessRequest, principal, queryParam, queryParams, remoteAddress, requestAttr, secure, self, servletPath, session, sessionAttr, sessionAttrs, uri, uri, with
-
Method Details
-
multipart
Enable file upload support using multipart.- Returns:
- a
MockMvcTester.MockMultipartMvcRequestBuilderwith the settings configured thus far
-
exchange
Execute the request. If the request is processing asynchronously, wait at most the given timeout value associated with the async request, seeMockAsyncContext.setTimeout(long).For simple assertions, you can wrap this builder in
assertThatrather than calling this method explicitly:// These two examples are equivalent assertThat(mvc.get().uri("/greet")).hasStatusOk(); assertThat(mvc.get().uri("/greet").exchange()).hasStatusOk();For assertions on the original asynchronous request that might still be in progress, use
asyncExchange().- See Also:
-
exchange
Execute the request and wait at most the giventimeToWaitduration for the asynchronous request to complete. If the request is not asynchronous, thetimeToWaitis ignored.For assertions on the original asynchronous request that might still be in progress, use
asyncExchange().- See Also:
-
asyncExchange
Execute the request and do not attempt to wait for the completion of an asynchronous request. Contrary toexchange(), this returns the original result that might still be in progress. -
assertThat
- Specified by:
assertThatin interfaceorg.assertj.core.api.AssertProvider<MvcTestResultAssert>
-