Package | Description |
---|---|
org.springframework.test.web.servlet |
Contains server-side support for testing Spring MVC applications.
|
org.springframework.test.web.servlet.result |
Contains built-in
ResultMatcher and ResultHandler implementations. |
org.springframework.test.web.servlet.setup |
Contains built-in
MockMvcBuilder implementations. |
Modifier and Type | Method and Description |
---|---|
ResultActions |
ResultActions.andExpect(ResultMatcher matcher)
Provide an expectation.
|
Modifier and Type | Method and Description |
---|---|
protected MockMvc |
MockMvcBuilderSupport.createMockMvc(javax.servlet.Filter[] filters,
MockServletConfig servletConfig,
WebApplicationContext webAppContext,
RequestBuilder defaultRequestBuilder,
List<ResultMatcher> globalResultMatchers,
List<ResultHandler> globalResultHandlers,
Boolean dispatchOptions) |
Modifier and Type | Method and Description |
---|---|
ResultMatcher |
RequestResultMatchers.asyncNotStarted()
Assert that asynchronous processing was not start.
|
<T> ResultMatcher |
RequestResultMatchers.asyncResult(org.hamcrest.Matcher<T> matcher)
Assert the result from asynchronous processing with the given matcher.
|
<T> ResultMatcher |
RequestResultMatchers.asyncResult(Object expectedResult)
Assert the result from asynchronous processing.
|
ResultMatcher |
RequestResultMatchers.asyncStarted()
Assert a request attribute value with the given Hamcrest
Matcher . |
<T> ResultMatcher |
FlashAttributeResultMatchers.attribute(String name,
org.hamcrest.Matcher<T> matcher)
Assert a flash attribute's value with the given Hamcrest
Matcher . |
<T> ResultMatcher |
RequestResultMatchers.attribute(String name,
org.hamcrest.Matcher<T> matcher)
Assert a request attribute value with the given Hamcrest
Matcher . |
<T> ResultMatcher |
ModelResultMatchers.attribute(String name,
org.hamcrest.Matcher<T> matcher)
Assert a model attribute value with the given Hamcrest
Matcher . |
ResultMatcher |
ModelResultMatchers.attribute(String name,
Object value)
Assert a model attribute value.
|
<T> ResultMatcher |
FlashAttributeResultMatchers.attribute(String name,
Object value)
Assert a flash attribute's value.
|
<T> ResultMatcher |
RequestResultMatchers.attribute(String name,
Object expectedValue)
Assert a request attribute value.
|
<T> ResultMatcher |
FlashAttributeResultMatchers.attributeCount(int count)
Assert the number of flash attributes.
|
ResultMatcher |
ModelResultMatchers.attributeDoesNotExist(String... names)
Assert the given model attributes do not exist
|
ResultMatcher |
ModelResultMatchers.attributeErrorCount(String name,
int expectedCount)
Assert the given model attribute(s) have errors.
|
ResultMatcher |
ModelResultMatchers.attributeExists(String... names)
Assert the given model attributes exist.
|
<T> ResultMatcher |
FlashAttributeResultMatchers.attributeExists(String... names)
Assert the existence of the given flash attributes.
|
ResultMatcher |
ModelResultMatchers.attributeHasErrors(String... names)
Assert the given model attribute(s) have errors.
|
ResultMatcher |
ModelResultMatchers.attributeHasFieldErrors(String name,
String... fieldNames)
Assert the given model attribute field(s) have errors.
|
ResultMatcher |
ModelResultMatchers.attributeHasNoErrors(String... names)
Assert the given model attribute(s) do not have errors.
|
ResultMatcher |
XpathResultMatchers.booleanValue(Boolean value)
Evaluate the XPath and assert the
Boolean value found. |
ResultMatcher |
ContentResultMatchers.bytes(byte[] expectedContent)
Assert the response body content as a byte array.
|
ResultMatcher |
CookieResultMatchers.comment(String name,
org.hamcrest.Matcher<? super String> matcher)
Assert a cookie's comment with a Hamcrest
Matcher . |
ResultMatcher |
CookieResultMatchers.comment(String name,
String comment)
Assert a cookie's comment value.
|
ResultMatcher |
ContentResultMatchers.contentType(MediaType contentType)
Assert the ServletResponse content type after parsing it as a MediaType.
|
ResultMatcher |
ContentResultMatchers.contentType(String contentType)
Assert the ServletResponse content type.
|
ResultMatcher |
ContentResultMatchers.contentTypeCompatibleWith(MediaType contentType)
Assert the ServletResponse content type is compatible with the given
content type as defined by
MediaType.isCompatibleWith(MediaType) . |
ResultMatcher |
ContentResultMatchers.contentTypeCompatibleWith(String contentType)
Assert the ServletResponse content type is compatible with the given
content type as defined by
MediaType.isCompatibleWith(MediaType) . |
ResultMatcher |
XpathResultMatchers.doesNotExist()
Evaluate the XPath and assert that content doesn't exist.
|
ResultMatcher |
JsonPathResultMatchers.doesNotExist()
Evaluate the JSON path and assert not content was found.
|
ResultMatcher |
CookieResultMatchers.doesNotExist(String name)
Assert a cookie does not exist.
|
ResultMatcher |
CookieResultMatchers.domain(String name,
org.hamcrest.Matcher<? super String> matcher)
Assert a cookie's domain with a Hamcrest
Matcher . |
ResultMatcher |
CookieResultMatchers.domain(String name,
String domain)
Assert a cookie's domain value.
|
ResultMatcher |
ContentResultMatchers.encoding(String characterEncoding)
Assert the character encoding in the ServletResponse.
|
<T> ResultMatcher |
ModelResultMatchers.errorCount(int expectedCount)
Assert the total number of errors in the model.
|
ResultMatcher |
XpathResultMatchers.exists()
Evaluate the XPath and assert that content exists.
|
ResultMatcher |
JsonPathResultMatchers.exists()
Evaluate the JSONPath and assert that content exists.
|
ResultMatcher |
CookieResultMatchers.exists(String name)
Assert a cookie exists.
|
static ResultMatcher |
MockMvcResultMatchers.forwardedUrl(String expectedUrl)
Asserts the request was forwarded to the given URL.
|
ResultMatcher |
HandlerResultMatchers.handlerType(Class<?> type)
Assert the type of the handler that processed the request.
|
<T> ResultMatcher |
ModelResultMatchers.hasErrors()
Assert the model has errors.
|
<T> ResultMatcher |
ModelResultMatchers.hasNoErrors()
Assert the model has no errors.
|
ResultMatcher |
StatusResultMatchers.is(int status)
Assert the response status code is equal to an integer value.
|
ResultMatcher |
StatusResultMatchers.is(org.hamcrest.Matcher<Integer> matcher)
Assert the response status code with the given Hamcrest
Matcher . |
ResultMatcher |
StatusResultMatchers.isAccepted()
Assert the response status code is
HttpStatus.ACCEPTED (202). |
ResultMatcher |
StatusResultMatchers.isAlreadyReported()
Assert the response status code is
HttpStatus.ALREADY_REPORTED (208). |
ResultMatcher |
JsonPathResultMatchers.isArray()
Evluate the JSON path and assert the content found is an array.
|
ResultMatcher |
StatusResultMatchers.isBadGateway()
Assert the response status code is
HttpStatus.BAD_GATEWAY (502). |
ResultMatcher |
StatusResultMatchers.isBadRequest()
Assert the response status code is
HttpStatus.BAD_REQUEST (400). |
ResultMatcher |
StatusResultMatchers.isBandwidthLimitExceeded()
Assert the response status code is
HttpStatus.BANDWIDTH_LIMIT_EXCEEDED (509). |
ResultMatcher |
StatusResultMatchers.isCheckpoint()
Assert the response status code is
HttpStatus.CHECKPOINT (103). |
ResultMatcher |
StatusResultMatchers.isConflict()
Assert the response status code is
HttpStatus.CONFLICT (409). |
ResultMatcher |
StatusResultMatchers.isContinue()
Assert the response status code is
HttpStatus.CONTINUE (100). |
ResultMatcher |
StatusResultMatchers.isCreated()
Assert the response status code is
HttpStatus.CREATED (201). |
ResultMatcher |
StatusResultMatchers.isDestinationLocked()
Deprecated.
matching the deprecation of HttpStatus.DESTINATION_LOCKED
|
ResultMatcher |
StatusResultMatchers.isExpectationFailed()
Assert the response status code is
HttpStatus.EXPECTATION_FAILED (417). |
ResultMatcher |
StatusResultMatchers.isFailedDependency()
Assert the response status code is
HttpStatus.FAILED_DEPENDENCY (424). |
ResultMatcher |
StatusResultMatchers.isForbidden()
Assert the response status code is
HttpStatus.FORBIDDEN (403). |
ResultMatcher |
StatusResultMatchers.isFound()
Assert the response status code is
HttpStatus.FOUND (302). |
ResultMatcher |
StatusResultMatchers.isGatewayTimeout()
Assert the response status code is
HttpStatus.GATEWAY_TIMEOUT (504). |
ResultMatcher |
StatusResultMatchers.isGone()
Assert the response status code is
HttpStatus.GONE (410). |
ResultMatcher |
StatusResultMatchers.isHttpVersionNotSupported()
Assert the response status code is
HttpStatus.HTTP_VERSION_NOT_SUPPORTED (505). |
ResultMatcher |
StatusResultMatchers.isIAmATeapot()
Assert the response status code is
HttpStatus.I_AM_A_TEAPOT (418). |
ResultMatcher |
StatusResultMatchers.isImUsed()
Assert the response status code is
HttpStatus.IM_USED (226). |
ResultMatcher |
StatusResultMatchers.isInsufficientSpaceOnResource()
Deprecated.
matching the deprecation of HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE
|
ResultMatcher |
StatusResultMatchers.isInsufficientStorage()
Assert the response status code is
HttpStatus.INSUFFICIENT_STORAGE (507). |
ResultMatcher |
StatusResultMatchers.isInternalServerError()
Assert the response status code is
HttpStatus.INTERNAL_SERVER_ERROR (500). |
ResultMatcher |
StatusResultMatchers.isLengthRequired()
Assert the response status code is
HttpStatus.LENGTH_REQUIRED (411). |
ResultMatcher |
StatusResultMatchers.isLocked()
Assert the response status code is
HttpStatus.LOCKED (423). |
ResultMatcher |
StatusResultMatchers.isLoopDetected()
Assert the response status code is
HttpStatus.LOOP_DETECTED (508). |
ResultMatcher |
StatusResultMatchers.isMethodFailure()
Deprecated.
matching the deprecation of HttpStatus.METHOD_FAILURE
|
ResultMatcher |
StatusResultMatchers.isMethodNotAllowed()
Assert the response status code is
HttpStatus.METHOD_NOT_ALLOWED (405). |
ResultMatcher |
StatusResultMatchers.isMovedPermanently()
Assert the response status code is
HttpStatus.MOVED_PERMANENTLY (301). |
ResultMatcher |
StatusResultMatchers.isMovedTemporarily()
Assert the response status code is
HttpStatus.MOVED_TEMPORARILY (302). |
ResultMatcher |
StatusResultMatchers.isMultipleChoices()
Assert the response status code is
HttpStatus.MULTIPLE_CHOICES (300). |
ResultMatcher |
StatusResultMatchers.isMultiStatus()
Assert the response status code is
HttpStatus.MULTI_STATUS (207). |
ResultMatcher |
StatusResultMatchers.isNetworkAuthenticationRequired()
Assert the response status code is
HttpStatus.NETWORK_AUTHENTICATION_REQUIRED (511). |
ResultMatcher |
StatusResultMatchers.isNoContent()
Assert the response status code is
HttpStatus.NO_CONTENT (204). |
ResultMatcher |
StatusResultMatchers.isNonAuthoritativeInformation()
Assert the response status code is
HttpStatus.NON_AUTHORITATIVE_INFORMATION (203). |
ResultMatcher |
StatusResultMatchers.isNotAcceptable()
Assert the response status code is
HttpStatus.NOT_ACCEPTABLE (406). |
ResultMatcher |
StatusResultMatchers.isNotExtended()
Assert the response status code is
HttpStatus.NOT_EXTENDED (510). |
ResultMatcher |
StatusResultMatchers.isNotFound()
Assert the response status code is
HttpStatus.NOT_FOUND (404). |
ResultMatcher |
StatusResultMatchers.isNotImplemented()
Assert the response status code is
HttpStatus.NOT_IMPLEMENTED (501). |
ResultMatcher |
StatusResultMatchers.isNotModified()
Assert the response status code is
HttpStatus.NOT_MODIFIED (304). |
ResultMatcher |
StatusResultMatchers.isOk()
Assert the response status code is
HttpStatus.OK (200). |
ResultMatcher |
StatusResultMatchers.isPartialContent()
Assert the response status code is
HttpStatus.PARTIAL_CONTENT (206). |
ResultMatcher |
StatusResultMatchers.isPaymentRequired()
Assert the response status code is
HttpStatus.PAYMENT_REQUIRED (402). |
ResultMatcher |
StatusResultMatchers.isPreconditionFailed()
Assert the response status code is
HttpStatus.PRECONDITION_FAILED (412). |
ResultMatcher |
StatusResultMatchers.isPreconditionRequired()
Assert the response status code is
HttpStatus.PRECONDITION_REQUIRED (428). |
ResultMatcher |
StatusResultMatchers.isProcessing()
Assert the response status code is
HttpStatus.PROCESSING (102). |
ResultMatcher |
StatusResultMatchers.isProxyAuthenticationRequired()
Assert the response status code is
HttpStatus.PROXY_AUTHENTICATION_REQUIRED (407). |
ResultMatcher |
StatusResultMatchers.isRequestedRangeNotSatisfiable()
Assert the response status code is
HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE (416). |
ResultMatcher |
StatusResultMatchers.isRequestEntityTooLarge()
Assert the response status code is
HttpStatus.REQUEST_ENTITY_TOO_LARGE (413). |
ResultMatcher |
StatusResultMatchers.isRequestHeaderFieldsTooLarge()
Assert the response status code is
HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE (431). |
ResultMatcher |
StatusResultMatchers.isRequestTimeout()
Assert the response status code is
HttpStatus.REQUEST_TIMEOUT (408). |
ResultMatcher |
StatusResultMatchers.isRequestUriTooLong()
Assert the response status code is
HttpStatus.REQUEST_URI_TOO_LONG (414). |
ResultMatcher |
StatusResultMatchers.isResetContent()
Assert the response status code is
HttpStatus.RESET_CONTENT (205). |
ResultMatcher |
StatusResultMatchers.isResumeIncomplete()
Assert the response status code is
HttpStatus.RESUME_INCOMPLETE (308). |
ResultMatcher |
StatusResultMatchers.isSeeOther()
Assert the response status code is
HttpStatus.SEE_OTHER (303). |
ResultMatcher |
StatusResultMatchers.isServiceUnavailable()
Assert the response status code is
HttpStatus.SERVICE_UNAVAILABLE (503). |
ResultMatcher |
StatusResultMatchers.isSwitchingProtocols()
Assert the response status code is
HttpStatus.SWITCHING_PROTOCOLS (101). |
ResultMatcher |
StatusResultMatchers.isTemporaryRedirect()
Assert the response status code is
HttpStatus.TEMPORARY_REDIRECT (307). |
ResultMatcher |
StatusResultMatchers.isTooManyRequests()
Assert the response status code is
HttpStatus.TOO_MANY_REQUESTS (429). |
ResultMatcher |
StatusResultMatchers.isUnauthorized()
Assert the response status code is
HttpStatus.UNAUTHORIZED (401). |
ResultMatcher |
StatusResultMatchers.isUnprocessableEntity()
Assert the response status code is
HttpStatus.UNPROCESSABLE_ENTITY (422). |
ResultMatcher |
StatusResultMatchers.isUnsupportedMediaType()
Assert the response status code is
HttpStatus.UNSUPPORTED_MEDIA_TYPE (415). |
ResultMatcher |
StatusResultMatchers.isUpgradeRequired()
Assert the response status code is
HttpStatus.UPGRADE_REQUIRED (426). |
ResultMatcher |
StatusResultMatchers.isUseProxy()
Assert the response status code is
HttpStatus.USE_PROXY (305). |
ResultMatcher |
StatusResultMatchers.isVariantAlsoNegotiates()
Assert the response status code is
HttpStatus.VARIANT_ALSO_NEGOTIATES (506). |
static <T> ResultMatcher |
MockMvcResultMatchers.jsonPath(String expression,
org.hamcrest.Matcher<T> matcher)
Access to response body assertions using a JSONPath expression to
inspect a specific subset of the body and a Hamcrest match for asserting
the value found at the JSON path.
|
ResultMatcher |
HeaderResultMatchers.longValue(String name,
long value)
Assert the primary value of a response header as a
Long . |
ResultMatcher |
CookieResultMatchers.maxAge(String name,
int maxAge)
Assert a cookie's maxAge value.
|
ResultMatcher |
CookieResultMatchers.maxAge(String name,
org.hamcrest.Matcher<? super Integer> matcher)
Assert a cookie's maxAge with a Hamcrest
Matcher . |
ResultMatcher |
HandlerResultMatchers.method(Method method)
Assert the controller method that processed the request.
|
ResultMatcher |
HandlerResultMatchers.methodName(org.hamcrest.Matcher<? super String> matcher)
Assert the name of the controller method that processed the request with
the given Hamcrest
Matcher . |
ResultMatcher |
HandlerResultMatchers.methodName(String name)
Assert the name of the controller method that processed the request.
|
ResultMatcher |
ViewResultMatchers.name(org.hamcrest.Matcher<? super String> matcher)
Assert the selected view name with the given Hamcrest
Matcher . |
ResultMatcher |
ViewResultMatchers.name(String expectedViewName)
Assert the selected view name.
|
ResultMatcher |
XpathResultMatchers.node(org.hamcrest.Matcher<? super Node> matcher)
Evaluate the XPath and assert the
Node content found with the
given Hamcrest Matcher . |
ResultMatcher |
ContentResultMatchers.node(org.hamcrest.Matcher<? super Node> matcher)
Parse the response content as
Node and apply the given Hamcrest
Matcher . |
ResultMatcher |
XpathResultMatchers.nodeCount(int expectedCount)
Evaluate the XPath and assert the number of nodes found.
|
ResultMatcher |
XpathResultMatchers.nodeCount(org.hamcrest.Matcher<Integer> matcher)
Evaluate the XPath and assert the number of nodes found with the given
Hamcrest
Matcher . |
ResultMatcher |
XpathResultMatchers.number(Double expectedValue)
Evaluate the XPath and assert the
Double value found. |
ResultMatcher |
XpathResultMatchers.number(org.hamcrest.Matcher<? super Double> matcher)
Evaluate the XPath and assert the
Double value found with the
given Hamcrest Matcher . |
ResultMatcher |
CookieResultMatchers.path(String name,
org.hamcrest.Matcher<? super String> matcher)
Assert a cookie path with a Hamcrest
Matcher . |
ResultMatcher |
CookieResultMatchers.path(String name,
String path) |
ResultMatcher |
StatusResultMatchers.reason(org.hamcrest.Matcher<? super String> matcher)
Assert the Servlet response error message with the given Hamcrest
Matcher . |
ResultMatcher |
StatusResultMatchers.reason(String reason)
Assert the Servlet response error message.
|
static ResultMatcher |
MockMvcResultMatchers.redirectedUrl(String expectedUrl)
Asserts the request was redirected to the given URL.
|
ResultMatcher |
CookieResultMatchers.secure(String name,
boolean secure)
Assert whether the cookie must be sent over a secure protocol or not.
|
<T> ResultMatcher |
RequestResultMatchers.sessionAttribute(String name,
org.hamcrest.Matcher<T> matcher)
Assert a session attribute value with the given Hamcrest
Matcher . |
<T> ResultMatcher |
RequestResultMatchers.sessionAttribute(String name,
Object value)
Assert a session attribute value..
|
<T> ResultMatcher |
ModelResultMatchers.size(int size)
Assert the number of model attributes.
|
ResultMatcher |
ContentResultMatchers.source(org.hamcrest.Matcher<? super Source> matcher)
Parse the response content as
DOMSource and apply the given
Hamcrest Matcher . |
ResultMatcher |
XpathResultMatchers.string(org.hamcrest.Matcher<? super String> matcher)
Apply the XPath and assert the
String value found with the given
Hamcrest Matcher . |
ResultMatcher |
ContentResultMatchers.string(org.hamcrest.Matcher<? super String> matcher)
Assert the response body content with a Hamcrest
Matcher . |
ResultMatcher |
XpathResultMatchers.string(String expectedValue)
Apply the XPath and assert the
String value found. |
ResultMatcher |
ContentResultMatchers.string(String expectedContent)
Assert the response body content as a String.
|
ResultMatcher |
HeaderResultMatchers.string(String name,
org.hamcrest.Matcher<? super String> matcher)
Assert a response header with the given Hamcrest
Matcher . |
ResultMatcher |
HeaderResultMatchers.string(String name,
String value)
Assert the primary value of a response header as a
String . |
<T> ResultMatcher |
JsonPathResultMatchers.value(org.hamcrest.Matcher<T> matcher)
Evaluate the JSONPath and assert the value of the content found with the
given Hamcrest
Matcher . |
ResultMatcher |
JsonPathResultMatchers.value(Object expectedValue)
Evaluate the JSONPath and assert the value of the content found.
|
ResultMatcher |
CookieResultMatchers.value(String name,
org.hamcrest.Matcher<? super String> matcher)
Assert a cookie value with the given Hamcrest
Matcher . |
ResultMatcher |
CookieResultMatchers.value(String name,
String expectedValue)
Assert a cookie value.
|
ResultMatcher |
CookieResultMatchers.version(String name,
int version)
Assert a cookie's version value.
|
ResultMatcher |
CookieResultMatchers.version(String name,
org.hamcrest.Matcher<? super Integer> matcher)
Assert a cookie's version with a Hamcrest
Matcher |
ResultMatcher |
ContentResultMatchers.xml(String xmlContent)
Parse the response content and the given string as XML and assert the two
are "similar" - i.e.
|
Modifier and Type | Method and Description |
---|---|
<T extends Self> |
DefaultMockMvcBuilder.alwaysExpect(ResultMatcher resultMatcher)
Define a global expectation that should always be applied to
every response.
|
Copyright © 2015. All rights reserved.