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 Details

  • Method Details

    • is

      public ResultMatcher is(Matcher<? super Integer> matcher)
      Assert the response status code with the given Hamcrest Matcher. Use the StatusResultMatchers.isEqualTo extension in Kotlin.
    • is

      public ResultMatcher is(int status)
      Assert the response status code is equal to an integer value. Use the StatusResultMatchers.isEqualTo extension in Kotlin.
    • 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 Hamcrest Matcher.
    • reason

      public ResultMatcher reason(String reason)
      Assert the Servlet response error message.
    • isContinue

      public ResultMatcher isContinue()
      Assert the response status code is HttpStatus.CONTINUE (100).
    • isSwitchingProtocols

      public ResultMatcher isSwitchingProtocols()
      Assert the response status code is HttpStatus.SWITCHING_PROTOCOLS (101).
    • isProcessing

      public ResultMatcher isProcessing()
      Assert the response status code is HttpStatus.PROCESSING (102).
    • isCheckpoint

      public ResultMatcher isCheckpoint()
      Assert the response status code is HttpStatus.CHECKPOINT (103).
    • isOk

      public ResultMatcher isOk()
      Assert the response status code is HttpStatus.OK (200).
    • isCreated

      public ResultMatcher isCreated()
      Assert the response status code is HttpStatus.CREATED (201).
    • isAccepted

      public ResultMatcher isAccepted()
      Assert the response status code is HttpStatus.ACCEPTED (202).
    • isNonAuthoritativeInformation

      public ResultMatcher isNonAuthoritativeInformation()
      Assert the response status code is HttpStatus.NON_AUTHORITATIVE_INFORMATION (203).
    • isNoContent

      public ResultMatcher isNoContent()
      Assert the response status code is HttpStatus.NO_CONTENT (204).
    • isResetContent

      public ResultMatcher isResetContent()
      Assert the response status code is HttpStatus.RESET_CONTENT (205).
    • isPartialContent

      public ResultMatcher isPartialContent()
      Assert the response status code is HttpStatus.PARTIAL_CONTENT (206).
    • isMultiStatus

      public ResultMatcher isMultiStatus()
      Assert the response status code is HttpStatus.MULTI_STATUS (207).
    • isAlreadyReported

      public ResultMatcher isAlreadyReported()
      Assert the response status code is HttpStatus.ALREADY_REPORTED (208).
    • isImUsed

      public ResultMatcher isImUsed()
      Assert the response status code is HttpStatus.IM_USED (226).
    • isMultipleChoices

      public ResultMatcher isMultipleChoices()
      Assert the response status code is HttpStatus.MULTIPLE_CHOICES (300).
    • isMovedPermanently

      public ResultMatcher isMovedPermanently()
      Assert the response status code is HttpStatus.MOVED_PERMANENTLY (301).
    • isFound

      public ResultMatcher isFound()
      Assert the response status code is HttpStatus.FOUND (302).
    • isMovedTemporarily

      @Deprecated public ResultMatcher isMovedTemporarily()
      Deprecated.
      in favor of isFound()
      Assert the response status code is HttpStatus.MOVED_TEMPORARILY (302).
      See Also:
    • isSeeOther

      public ResultMatcher isSeeOther()
      Assert the response status code is HttpStatus.SEE_OTHER (303).
    • isNotModified

      public ResultMatcher isNotModified()
      Assert the response status code is HttpStatus.NOT_MODIFIED (304).
    • isUseProxy

      @Deprecated public ResultMatcher isUseProxy()
      Deprecated.
      matching the deprecation of HttpStatus.USE_PROXY
      Assert the response status code is HttpStatus.USE_PROXY (305).
    • isTemporaryRedirect

      public ResultMatcher isTemporaryRedirect()
      Assert the response status code is HttpStatus.TEMPORARY_REDIRECT (307).
    • isPermanentRedirect

      public ResultMatcher isPermanentRedirect()
      Assert the response status code is HttpStatus.PERMANENT_REDIRECT (308).
    • isBadRequest

      public ResultMatcher isBadRequest()
      Assert the response status code is HttpStatus.BAD_REQUEST (400).
    • isUnauthorized

      public ResultMatcher isUnauthorized()
      Assert the response status code is HttpStatus.UNAUTHORIZED (401).
    • isPaymentRequired

      public ResultMatcher isPaymentRequired()
      Assert the response status code is HttpStatus.PAYMENT_REQUIRED (402).
    • isForbidden

      public ResultMatcher isForbidden()
      Assert the response status code is HttpStatus.FORBIDDEN (403).
    • isNotFound

      public ResultMatcher isNotFound()
      Assert the response status code is HttpStatus.NOT_FOUND (404).
    • isMethodNotAllowed

      public ResultMatcher isMethodNotAllowed()
      Assert the response status code is HttpStatus.METHOD_NOT_ALLOWED (405).
    • isNotAcceptable

      public ResultMatcher isNotAcceptable()
      Assert the response status code is HttpStatus.NOT_ACCEPTABLE (406).
    • isProxyAuthenticationRequired

      public ResultMatcher isProxyAuthenticationRequired()
      Assert the response status code is HttpStatus.PROXY_AUTHENTICATION_REQUIRED (407).
    • isRequestTimeout

      public ResultMatcher isRequestTimeout()
      Assert the response status code is HttpStatus.REQUEST_TIMEOUT (408).
    • isConflict

      public ResultMatcher isConflict()
      Assert the response status code is HttpStatus.CONFLICT (409).
    • isGone

      public ResultMatcher isGone()
      Assert the response status code is HttpStatus.GONE (410).
    • isLengthRequired

      public ResultMatcher isLengthRequired()
      Assert the response status code is HttpStatus.LENGTH_REQUIRED (411).
    • isPreconditionFailed

      public ResultMatcher isPreconditionFailed()
      Assert the response status code is HttpStatus.PRECONDITION_FAILED (412).
    • isPayloadTooLarge

      public ResultMatcher isPayloadTooLarge()
      Assert the response status code is HttpStatus.PAYLOAD_TOO_LARGE (413).
      Since:
      4.1
    • isRequestEntityTooLarge

      @Deprecated public ResultMatcher isRequestEntityTooLarge()
      Deprecated.
      matching the deprecation of HttpStatus.REQUEST_ENTITY_TOO_LARGE
      Assert the response status code is HttpStatus.REQUEST_ENTITY_TOO_LARGE (413).
      See Also:
    • isUriTooLong

      public ResultMatcher isUriTooLong()
      Assert the response status code is HttpStatus.REQUEST_URI_TOO_LONG (414).
      Since:
      4.1
    • isRequestUriTooLong

      @Deprecated public ResultMatcher isRequestUriTooLong()
      Deprecated.
      matching the deprecation of HttpStatus.REQUEST_URI_TOO_LONG
      Assert the response status code is HttpStatus.REQUEST_URI_TOO_LONG (414).
      See Also:
    • isUnsupportedMediaType

      public ResultMatcher isUnsupportedMediaType()
      Assert the response status code is HttpStatus.UNSUPPORTED_MEDIA_TYPE (415).
    • isRequestedRangeNotSatisfiable

      public ResultMatcher isRequestedRangeNotSatisfiable()
      Assert the response status code is HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE (416).
    • isExpectationFailed

      public ResultMatcher isExpectationFailed()
      Assert the response status code is HttpStatus.EXPECTATION_FAILED (417).
    • isIAmATeapot

      public ResultMatcher isIAmATeapot()
      Assert the response status code is HttpStatus.I_AM_A_TEAPOT (418).
    • isInsufficientSpaceOnResource

      @Deprecated public ResultMatcher isInsufficientSpaceOnResource()
      Deprecated.
      matching the deprecation of HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE
      Assert the response status code is HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE (419).
    • isMethodFailure

      @Deprecated public ResultMatcher isMethodFailure()
      Deprecated.
      matching the deprecation of HttpStatus.METHOD_FAILURE
      Assert the response status code is HttpStatus.METHOD_FAILURE (420).
    • isDestinationLocked

      @Deprecated public ResultMatcher isDestinationLocked()
      Deprecated.
      matching the deprecation of HttpStatus.DESTINATION_LOCKED
      Assert the response status code is HttpStatus.DESTINATION_LOCKED (421).
    • isUnprocessableEntity

      public ResultMatcher isUnprocessableEntity()
      Assert the response status code is HttpStatus.UNPROCESSABLE_ENTITY (422).
    • isLocked

      public ResultMatcher isLocked()
      Assert the response status code is HttpStatus.LOCKED (423).
    • isFailedDependency

      public ResultMatcher isFailedDependency()
      Assert the response status code is HttpStatus.FAILED_DEPENDENCY (424).
    • isTooEarly

      public ResultMatcher isTooEarly()
      Assert the response status code is HttpStatus.TOO_EARLY (425).
      Since:
      5.2
    • isUpgradeRequired

      public ResultMatcher isUpgradeRequired()
      Assert the response status code is HttpStatus.UPGRADE_REQUIRED (426).
    • isPreconditionRequired

      public ResultMatcher isPreconditionRequired()
      Assert the response status code is HttpStatus.PRECONDITION_REQUIRED (428).
    • isTooManyRequests

      public ResultMatcher isTooManyRequests()
      Assert the response status code is HttpStatus.TOO_MANY_REQUESTS (429).
    • isRequestHeaderFieldsTooLarge

      public ResultMatcher isRequestHeaderFieldsTooLarge()
      Assert the response status code is HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE (431).
    • isUnavailableForLegalReasons

      public ResultMatcher isUnavailableForLegalReasons()
      Assert the response status code is HttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS (451).
      Since:
      4.3
    • isInternalServerError

      public ResultMatcher isInternalServerError()
      Assert the response status code is HttpStatus.INTERNAL_SERVER_ERROR (500).
    • isNotImplemented

      public ResultMatcher isNotImplemented()
      Assert the response status code is HttpStatus.NOT_IMPLEMENTED (501).
    • isBadGateway

      public ResultMatcher isBadGateway()
      Assert the response status code is HttpStatus.BAD_GATEWAY (502).
    • isServiceUnavailable

      public ResultMatcher isServiceUnavailable()
      Assert the response status code is HttpStatus.SERVICE_UNAVAILABLE (503).
    • isGatewayTimeout

      public ResultMatcher isGatewayTimeout()
      Assert the response status code is HttpStatus.GATEWAY_TIMEOUT (504).
    • isHttpVersionNotSupported

      public ResultMatcher isHttpVersionNotSupported()
      Assert the response status code is HttpStatus.HTTP_VERSION_NOT_SUPPORTED (505).
    • isVariantAlsoNegotiates

      public ResultMatcher isVariantAlsoNegotiates()
      Assert the response status code is HttpStatus.VARIANT_ALSO_NEGOTIATES (506).
    • isInsufficientStorage

      public ResultMatcher isInsufficientStorage()
      Assert the response status code is HttpStatus.INSUFFICIENT_STORAGE (507).
    • isLoopDetected

      public ResultMatcher isLoopDetected()
      Assert the response status code is HttpStatus.LOOP_DETECTED (508).
    • isBandwidthLimitExceeded

      public ResultMatcher isBandwidthLimitExceeded()
      Assert the response status code is HttpStatus.BANDWIDTH_LIMIT_EXCEEDED (509).
    • isNotExtended

      public ResultMatcher isNotExtended()
      Assert the response status code is HttpStatus.NOT_EXTENDED (510).
    • isNetworkAuthenticationRequired

      public ResultMatcher isNetworkAuthenticationRequired()
      Assert the response status code is HttpStatus.NETWORK_AUTHENTICATION_REQUIRED (511).