Class StatusResultMatchers
- java.lang.Object
- org.springframework.test.web.servlet.result.StatusResultMatchers
public class StatusResultMatchers extends Object
Factory for assertions on the response status.An instance of this class is typically accessed via
MockMvcResultMatchers.status()
.- Since:
- 3.2
- Author:
- Keesun Baik, Rossen Stoyanchev, Sebastien Deleuze, Brian Clozel
Constructor Summary
Constructors Modifier Constructor Description protected
StatusResultMatchers()
Protected constructor.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ResultMatcher
is(int status)
Assert the response status code is equal to an integer value.ResultMatcher
is(Matcher<Integer> matcher)
Assert the response status code with the given HamcrestMatcher
.ResultMatcher
is1xxInformational()
Assert the response status code is in the 1xx range.ResultMatcher
is2xxSuccessful()
Assert the response status code is in the 2xx range.ResultMatcher
is3xxRedirection()
Assert the response status code is in the 3xx range.ResultMatcher
is4xxClientError()
Assert the response status code is in the 4xx range.ResultMatcher
is5xxServerError()
Assert the response status code is in the 5xx range.ResultMatcher
isAccepted()
Assert the response status code isHttpStatus.ACCEPTED
(202).ResultMatcher
isAlreadyReported()
Assert the response status code isHttpStatus.ALREADY_REPORTED
(208).ResultMatcher
isBadGateway()
Assert the response status code isHttpStatus.BAD_GATEWAY
(502).ResultMatcher
isBadRequest()
Assert the response status code isHttpStatus.BAD_REQUEST
(400).ResultMatcher
isBandwidthLimitExceeded()
Assert the response status code isHttpStatus.BANDWIDTH_LIMIT_EXCEEDED
(509).ResultMatcher
isCheckpoint()
Assert the response status code isHttpStatus.CHECKPOINT
(103).ResultMatcher
isConflict()
Assert the response status code isHttpStatus.CONFLICT
(409).ResultMatcher
isContinue()
Assert the response status code isHttpStatus.CONTINUE
(100).ResultMatcher
isCreated()
Assert the response status code isHttpStatus.CREATED
(201).ResultMatcher
isDestinationLocked()
Deprecated.matching the deprecation ofHttpStatus.DESTINATION_LOCKED
ResultMatcher
isExpectationFailed()
Assert the response status code isHttpStatus.EXPECTATION_FAILED
(417).ResultMatcher
isFailedDependency()
Assert the response status code isHttpStatus.FAILED_DEPENDENCY
(424).ResultMatcher
isForbidden()
Assert the response status code isHttpStatus.FORBIDDEN
(403).ResultMatcher
isFound()
Assert the response status code isHttpStatus.FOUND
(302).ResultMatcher
isGatewayTimeout()
Assert the response status code isHttpStatus.GATEWAY_TIMEOUT
(504).ResultMatcher
isGone()
Assert the response status code isHttpStatus.GONE
(410).ResultMatcher
isHttpVersionNotSupported()
Assert the response status code isHttpStatus.HTTP_VERSION_NOT_SUPPORTED
(505).ResultMatcher
isIAmATeapot()
Assert the response status code isHttpStatus.I_AM_A_TEAPOT
(418).ResultMatcher
isImUsed()
Assert the response status code isHttpStatus.IM_USED
(226).ResultMatcher
isInsufficientSpaceOnResource()
Deprecated.matching the deprecation ofHttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE
ResultMatcher
isInsufficientStorage()
Assert the response status code isHttpStatus.INSUFFICIENT_STORAGE
(507).ResultMatcher
isInternalServerError()
Assert the response status code isHttpStatus.INTERNAL_SERVER_ERROR
(500).ResultMatcher
isLengthRequired()
Assert the response status code isHttpStatus.LENGTH_REQUIRED
(411).ResultMatcher
isLocked()
Assert the response status code isHttpStatus.LOCKED
(423).ResultMatcher
isLoopDetected()
Assert the response status code isHttpStatus.LOOP_DETECTED
(508).ResultMatcher
isMethodFailure()
Deprecated.matching the deprecation ofHttpStatus.METHOD_FAILURE
ResultMatcher
isMethodNotAllowed()
Assert the response status code isHttpStatus.METHOD_NOT_ALLOWED
(405).ResultMatcher
isMovedPermanently()
Assert the response status code isHttpStatus.MOVED_PERMANENTLY
(301).ResultMatcher
isMovedTemporarily()
Deprecated.in favor ofisFound()
ResultMatcher
isMultipleChoices()
Assert the response status code isHttpStatus.MULTIPLE_CHOICES
(300).ResultMatcher
isMultiStatus()
Assert the response status code isHttpStatus.MULTI_STATUS
(207).ResultMatcher
isNetworkAuthenticationRequired()
Assert the response status code isHttpStatus.NETWORK_AUTHENTICATION_REQUIRED
(511).ResultMatcher
isNoContent()
Assert the response status code isHttpStatus.NO_CONTENT
(204).ResultMatcher
isNonAuthoritativeInformation()
Assert the response status code isHttpStatus.NON_AUTHORITATIVE_INFORMATION
(203).ResultMatcher
isNotAcceptable()
Assert the response status code isHttpStatus.NOT_ACCEPTABLE
(406).ResultMatcher
isNotExtended()
Assert the response status code isHttpStatus.NOT_EXTENDED
(510).ResultMatcher
isNotFound()
Assert the response status code isHttpStatus.NOT_FOUND
(404).ResultMatcher
isNotImplemented()
Assert the response status code isHttpStatus.NOT_IMPLEMENTED
(501).ResultMatcher
isNotModified()
Assert the response status code isHttpStatus.NOT_MODIFIED
(304).ResultMatcher
isOk()
Assert the response status code isHttpStatus.OK
(200).ResultMatcher
isPartialContent()
Assert the response status code isHttpStatus.PARTIAL_CONTENT
(206).ResultMatcher
isPayloadTooLarge()
Assert the response status code isHttpStatus.PAYLOAD_TOO_LARGE
(413).ResultMatcher
isPaymentRequired()
Assert the response status code isHttpStatus.PAYMENT_REQUIRED
(402).ResultMatcher
isPermanentRedirect()
Assert the response status code isHttpStatus.PERMANENT_REDIRECT
(308).ResultMatcher
isPreconditionFailed()
Assert the response status code isHttpStatus.PRECONDITION_FAILED
(412).ResultMatcher
isPreconditionRequired()
Assert the response status code isHttpStatus.PRECONDITION_REQUIRED
(428).ResultMatcher
isProcessing()
Assert the response status code isHttpStatus.PROCESSING
(102).ResultMatcher
isProxyAuthenticationRequired()
Assert the response status code isHttpStatus.PROXY_AUTHENTICATION_REQUIRED
(407).ResultMatcher
isRequestedRangeNotSatisfiable()
Assert the response status code isHttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE
(416).ResultMatcher
isRequestEntityTooLarge()
Deprecated.matching the deprecation ofHttpStatus.REQUEST_ENTITY_TOO_LARGE
ResultMatcher
isRequestHeaderFieldsTooLarge()
Assert the response status code isHttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE
(431).ResultMatcher
isRequestTimeout()
Assert the response status code isHttpStatus.REQUEST_TIMEOUT
(408).ResultMatcher
isRequestUriTooLong()
Deprecated.matching the deprecation ofHttpStatus.REQUEST_URI_TOO_LONG
ResultMatcher
isResetContent()
Assert the response status code isHttpStatus.RESET_CONTENT
(205).ResultMatcher
isSeeOther()
Assert the response status code isHttpStatus.SEE_OTHER
(303).ResultMatcher
isServiceUnavailable()
Assert the response status code isHttpStatus.SERVICE_UNAVAILABLE
(503).ResultMatcher
isSwitchingProtocols()
Assert the response status code isHttpStatus.SWITCHING_PROTOCOLS
(101).ResultMatcher
isTemporaryRedirect()
Assert the response status code isHttpStatus.TEMPORARY_REDIRECT
(307).ResultMatcher
isTooManyRequests()
Assert the response status code isHttpStatus.TOO_MANY_REQUESTS
(429).ResultMatcher
isUnauthorized()
Assert the response status code isHttpStatus.UNAUTHORIZED
(401).ResultMatcher
isUnavailableForLegalReasons()
Assert the response status code isHttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS
(451).ResultMatcher
isUnprocessableEntity()
Assert the response status code isHttpStatus.UNPROCESSABLE_ENTITY
(422).ResultMatcher
isUnsupportedMediaType()
Assert the response status code isHttpStatus.UNSUPPORTED_MEDIA_TYPE
(415).ResultMatcher
isUpgradeRequired()
Assert the response status code isHttpStatus.UPGRADE_REQUIRED
(426).ResultMatcher
isUriTooLong()
Assert the response status code isHttpStatus.REQUEST_URI_TOO_LONG
(414).ResultMatcher
isUseProxy()
Deprecated.matching the deprecation ofHttpStatus.USE_PROXY
ResultMatcher
isVariantAlsoNegotiates()
Assert the response status code isHttpStatus.VARIANT_ALSO_NEGOTIATES
(506).ResultMatcher
reason(String reason)
Assert the Servlet response error message.ResultMatcher
reason(Matcher<? super String> matcher)
Assert the Servlet response error message with the given HamcrestMatcher
.
Constructor Detail
StatusResultMatchers
protected StatusResultMatchers()
Protected constructor. UseMockMvcResultMatchers.status()
.
Method Detail
is
public ResultMatcher is(Matcher<Integer> matcher)
Assert the response status code with the given HamcrestMatcher
.
is
public ResultMatcher is(int status)
Assert the response status code is equal to an integer value.
is1xxInformational
public ResultMatcher is1xxInformational()
Assert the response status code is in the 1xx range.
is2xxSuccessful
public ResultMatcher is2xxSuccessful()
Assert the response status code is in the 2xx range.
is3xxRedirection
public ResultMatcher is3xxRedirection()
Assert the response status code is in the 3xx range.
is4xxClientError
public ResultMatcher is4xxClientError()
Assert the response status code is in the 4xx range.
is5xxServerError
public ResultMatcher is5xxServerError()
Assert the response status code is in the 5xx range.
reason
public ResultMatcher reason(Matcher<? super String> matcher)
Assert the Servlet response error message with the given HamcrestMatcher
.
reason
public ResultMatcher reason(String reason)
Assert the Servlet response error message.
isContinue
public ResultMatcher isContinue()
Assert the response status code isHttpStatus.CONTINUE
(100).
isSwitchingProtocols
public ResultMatcher isSwitchingProtocols()
Assert the response status code isHttpStatus.SWITCHING_PROTOCOLS
(101).
isProcessing
public ResultMatcher isProcessing()
Assert the response status code isHttpStatus.PROCESSING
(102).
isCheckpoint
public ResultMatcher isCheckpoint()
Assert the response status code isHttpStatus.CHECKPOINT
(103).
isOk
public ResultMatcher isOk()
Assert the response status code isHttpStatus.OK
(200).
isCreated
public ResultMatcher isCreated()
Assert the response status code isHttpStatus.CREATED
(201).
isAccepted
public ResultMatcher isAccepted()
Assert the response status code isHttpStatus.ACCEPTED
(202).
isNonAuthoritativeInformation
public ResultMatcher isNonAuthoritativeInformation()
Assert the response status code isHttpStatus.NON_AUTHORITATIVE_INFORMATION
(203).
isNoContent
public ResultMatcher isNoContent()
Assert the response status code isHttpStatus.NO_CONTENT
(204).
isResetContent
public ResultMatcher isResetContent()
Assert the response status code isHttpStatus.RESET_CONTENT
(205).
isPartialContent
public ResultMatcher isPartialContent()
Assert the response status code isHttpStatus.PARTIAL_CONTENT
(206).
isMultiStatus
public ResultMatcher isMultiStatus()
Assert the response status code isHttpStatus.MULTI_STATUS
(207).
isAlreadyReported
public ResultMatcher isAlreadyReported()
Assert the response status code isHttpStatus.ALREADY_REPORTED
(208).
isImUsed
public ResultMatcher isImUsed()
Assert the response status code isHttpStatus.IM_USED
(226).
isMultipleChoices
public ResultMatcher isMultipleChoices()
Assert the response status code isHttpStatus.MULTIPLE_CHOICES
(300).
isMovedPermanently
public ResultMatcher isMovedPermanently()
Assert the response status code isHttpStatus.MOVED_PERMANENTLY
(301).
isFound
public ResultMatcher isFound()
Assert the response status code isHttpStatus.FOUND
(302).
isMovedTemporarily
@Deprecated public ResultMatcher isMovedTemporarily()
Deprecated.in favor ofisFound()
Assert the response status code isHttpStatus.MOVED_TEMPORARILY
(302).- See Also:
isFound()
isSeeOther
public ResultMatcher isSeeOther()
Assert the response status code isHttpStatus.SEE_OTHER
(303).
isNotModified
public ResultMatcher isNotModified()
Assert the response status code isHttpStatus.NOT_MODIFIED
(304).
isUseProxy
@Deprecated public ResultMatcher isUseProxy()
Deprecated.matching the deprecation ofHttpStatus.USE_PROXY
Assert the response status code isHttpStatus.USE_PROXY
(305).
isTemporaryRedirect
public ResultMatcher isTemporaryRedirect()
Assert the response status code isHttpStatus.TEMPORARY_REDIRECT
(307).
isPermanentRedirect
public ResultMatcher isPermanentRedirect()
Assert the response status code isHttpStatus.PERMANENT_REDIRECT
(308).
isBadRequest
public ResultMatcher isBadRequest()
Assert the response status code isHttpStatus.BAD_REQUEST
(400).
isUnauthorized
public ResultMatcher isUnauthorized()
Assert the response status code isHttpStatus.UNAUTHORIZED
(401).
isPaymentRequired
public ResultMatcher isPaymentRequired()
Assert the response status code isHttpStatus.PAYMENT_REQUIRED
(402).
isForbidden
public ResultMatcher isForbidden()
Assert the response status code isHttpStatus.FORBIDDEN
(403).
isNotFound
public ResultMatcher isNotFound()
Assert the response status code isHttpStatus.NOT_FOUND
(404).
isMethodNotAllowed
public ResultMatcher isMethodNotAllowed()
Assert the response status code isHttpStatus.METHOD_NOT_ALLOWED
(405).
isNotAcceptable
public ResultMatcher isNotAcceptable()
Assert the response status code isHttpStatus.NOT_ACCEPTABLE
(406).
isProxyAuthenticationRequired
public ResultMatcher isProxyAuthenticationRequired()
Assert the response status code isHttpStatus.PROXY_AUTHENTICATION_REQUIRED
(407).
isRequestTimeout
public ResultMatcher isRequestTimeout()
Assert the response status code isHttpStatus.REQUEST_TIMEOUT
(408).
isConflict
public ResultMatcher isConflict()
Assert the response status code isHttpStatus.CONFLICT
(409).
isGone
public ResultMatcher isGone()
Assert the response status code isHttpStatus.GONE
(410).
isLengthRequired
public ResultMatcher isLengthRequired()
Assert the response status code isHttpStatus.LENGTH_REQUIRED
(411).
isPreconditionFailed
public ResultMatcher isPreconditionFailed()
Assert the response status code isHttpStatus.PRECONDITION_FAILED
(412).
isPayloadTooLarge
public ResultMatcher isPayloadTooLarge()
Assert the response status code isHttpStatus.PAYLOAD_TOO_LARGE
(413).- Since:
- 4.1
isRequestEntityTooLarge
@Deprecated public ResultMatcher isRequestEntityTooLarge()
Deprecated.matching the deprecation ofHttpStatus.REQUEST_ENTITY_TOO_LARGE
Assert the response status code isHttpStatus.REQUEST_ENTITY_TOO_LARGE
(413).- See Also:
isPayloadTooLarge()
isUriTooLong
public ResultMatcher isUriTooLong()
Assert the response status code isHttpStatus.REQUEST_URI_TOO_LONG
(414).- Since:
- 4.1
isRequestUriTooLong
@Deprecated public ResultMatcher isRequestUriTooLong()
Deprecated.matching the deprecation ofHttpStatus.REQUEST_URI_TOO_LONG
Assert the response status code isHttpStatus.REQUEST_URI_TOO_LONG
(414).- See Also:
isUriTooLong()
isUnsupportedMediaType
public ResultMatcher isUnsupportedMediaType()
Assert the response status code isHttpStatus.UNSUPPORTED_MEDIA_TYPE
(415).
isRequestedRangeNotSatisfiable
public ResultMatcher isRequestedRangeNotSatisfiable()
Assert the response status code isHttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE
(416).
isExpectationFailed
public ResultMatcher isExpectationFailed()
Assert the response status code isHttpStatus.EXPECTATION_FAILED
(417).
isIAmATeapot
public ResultMatcher isIAmATeapot()
Assert the response status code isHttpStatus.I_AM_A_TEAPOT
(418).
isInsufficientSpaceOnResource
@Deprecated public ResultMatcher isInsufficientSpaceOnResource()
Deprecated.matching the deprecation ofHttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE
Assert the response status code isHttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE
(419).
isMethodFailure
@Deprecated public ResultMatcher isMethodFailure()
Deprecated.matching the deprecation ofHttpStatus.METHOD_FAILURE
Assert the response status code isHttpStatus.METHOD_FAILURE
(420).
isDestinationLocked
@Deprecated public ResultMatcher isDestinationLocked()
Deprecated.matching the deprecation ofHttpStatus.DESTINATION_LOCKED
Assert the response status code isHttpStatus.DESTINATION_LOCKED
(421).
isUnprocessableEntity
public ResultMatcher isUnprocessableEntity()
Assert the response status code isHttpStatus.UNPROCESSABLE_ENTITY
(422).
isLocked
public ResultMatcher isLocked()
Assert the response status code isHttpStatus.LOCKED
(423).
isFailedDependency
public ResultMatcher isFailedDependency()
Assert the response status code isHttpStatus.FAILED_DEPENDENCY
(424).
isUpgradeRequired
public ResultMatcher isUpgradeRequired()
Assert the response status code isHttpStatus.UPGRADE_REQUIRED
(426).
isPreconditionRequired
public ResultMatcher isPreconditionRequired()
Assert the response status code isHttpStatus.PRECONDITION_REQUIRED
(428).
isTooManyRequests
public ResultMatcher isTooManyRequests()
Assert the response status code isHttpStatus.TOO_MANY_REQUESTS
(429).
isRequestHeaderFieldsTooLarge
public ResultMatcher isRequestHeaderFieldsTooLarge()
Assert the response status code isHttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE
(431).
isUnavailableForLegalReasons
public ResultMatcher isUnavailableForLegalReasons()
Assert the response status code isHttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS
(451).- Since:
- 4.3
isInternalServerError
public ResultMatcher isInternalServerError()
Assert the response status code isHttpStatus.INTERNAL_SERVER_ERROR
(500).
isNotImplemented
public ResultMatcher isNotImplemented()
Assert the response status code isHttpStatus.NOT_IMPLEMENTED
(501).
isBadGateway
public ResultMatcher isBadGateway()
Assert the response status code isHttpStatus.BAD_GATEWAY
(502).
isServiceUnavailable
public ResultMatcher isServiceUnavailable()
Assert the response status code isHttpStatus.SERVICE_UNAVAILABLE
(503).
isGatewayTimeout
public ResultMatcher isGatewayTimeout()
Assert the response status code isHttpStatus.GATEWAY_TIMEOUT
(504).
isHttpVersionNotSupported
public ResultMatcher isHttpVersionNotSupported()
Assert the response status code isHttpStatus.HTTP_VERSION_NOT_SUPPORTED
(505).
isVariantAlsoNegotiates
public ResultMatcher isVariantAlsoNegotiates()
Assert the response status code isHttpStatus.VARIANT_ALSO_NEGOTIATES
(506).
isInsufficientStorage
public ResultMatcher isInsufficientStorage()
Assert the response status code isHttpStatus.INSUFFICIENT_STORAGE
(507).
isLoopDetected
public ResultMatcher isLoopDetected()
Assert the response status code isHttpStatus.LOOP_DETECTED
(508).
isBandwidthLimitExceeded
public ResultMatcher isBandwidthLimitExceeded()
Assert the response status code isHttpStatus.BANDWIDTH_LIMIT_EXCEEDED
(509).
isNotExtended
public ResultMatcher isNotExtended()
Assert the response status code isHttpStatus.NOT_EXTENDED
(510).
isNetworkAuthenticationRequired
public ResultMatcher isNetworkAuthenticationRequired()
Assert the response status code isHttpStatus.NETWORK_AUTHENTICATION_REQUIRED
(511).