类 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().- 从以下版本开始:
- 3.2
- 作者:
- Keesun Baik, Rossen Stoyanchev, Sebastien Deleuze, Brian Clozel
构造器概要
构造器 限定符 构造器 说明 protectedStatusResultMatchers()Protected constructor.
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 ResultMatcheris(int status)Assert the response status code is equal to an integer value.ResultMatcheris(Matcher<Integer> matcher)Assert the response status code with the given HamcrestMatcher.ResultMatcheris1xxInformational()Assert the response status code is in the 1xx range.ResultMatcheris2xxSuccessful()Assert the response status code is in the 2xx range.ResultMatcheris3xxRedirection()Assert the response status code is in the 3xx range.ResultMatcheris4xxClientError()Assert the response status code is in the 4xx range.ResultMatcheris5xxServerError()Assert the response status code is in the 5xx range.ResultMatcherisAccepted()Assert the response status code isHttpStatus.ACCEPTED(202).ResultMatcherisAlreadyReported()Assert the response status code isHttpStatus.ALREADY_REPORTED(208).ResultMatcherisBadGateway()Assert the response status code isHttpStatus.BAD_GATEWAY(502).ResultMatcherisBadRequest()Assert the response status code isHttpStatus.BAD_REQUEST(400).ResultMatcherisBandwidthLimitExceeded()Assert the response status code isHttpStatus.BANDWIDTH_LIMIT_EXCEEDED(509).ResultMatcherisCheckpoint()Assert the response status code isHttpStatus.CHECKPOINT(103).ResultMatcherisConflict()Assert the response status code isHttpStatus.CONFLICT(409).ResultMatcherisContinue()Assert the response status code isHttpStatus.CONTINUE(100).ResultMatcherisCreated()Assert the response status code isHttpStatus.CREATED(201).ResultMatcherisDestinationLocked()已过时。matching the deprecation ofHttpStatus.DESTINATION_LOCKEDResultMatcherisExpectationFailed()Assert the response status code isHttpStatus.EXPECTATION_FAILED(417).ResultMatcherisFailedDependency()Assert the response status code isHttpStatus.FAILED_DEPENDENCY(424).ResultMatcherisForbidden()Assert the response status code isHttpStatus.FORBIDDEN(403).ResultMatcherisFound()Assert the response status code isHttpStatus.FOUND(302).ResultMatcherisGatewayTimeout()Assert the response status code isHttpStatus.GATEWAY_TIMEOUT(504).ResultMatcherisGone()Assert the response status code isHttpStatus.GONE(410).ResultMatcherisHttpVersionNotSupported()Assert the response status code isHttpStatus.HTTP_VERSION_NOT_SUPPORTED(505).ResultMatcherisIAmATeapot()Assert the response status code isHttpStatus.I_AM_A_TEAPOT(418).ResultMatcherisImUsed()Assert the response status code isHttpStatus.IM_USED(226).ResultMatcherisInsufficientSpaceOnResource()已过时。matching the deprecation ofHttpStatus.INSUFFICIENT_SPACE_ON_RESOURCEResultMatcherisInsufficientStorage()Assert the response status code isHttpStatus.INSUFFICIENT_STORAGE(507).ResultMatcherisInternalServerError()Assert the response status code isHttpStatus.INTERNAL_SERVER_ERROR(500).ResultMatcherisLengthRequired()Assert the response status code isHttpStatus.LENGTH_REQUIRED(411).ResultMatcherisLocked()Assert the response status code isHttpStatus.LOCKED(423).ResultMatcherisLoopDetected()Assert the response status code isHttpStatus.LOOP_DETECTED(508).ResultMatcherisMethodFailure()已过时。matching the deprecation ofHttpStatus.METHOD_FAILUREResultMatcherisMethodNotAllowed()Assert the response status code isHttpStatus.METHOD_NOT_ALLOWED(405).ResultMatcherisMovedPermanently()Assert the response status code isHttpStatus.MOVED_PERMANENTLY(301).ResultMatcherisMovedTemporarily()已过时。in favor ofisFound()ResultMatcherisMultipleChoices()Assert the response status code isHttpStatus.MULTIPLE_CHOICES(300).ResultMatcherisMultiStatus()Assert the response status code isHttpStatus.MULTI_STATUS(207).ResultMatcherisNetworkAuthenticationRequired()Assert the response status code isHttpStatus.NETWORK_AUTHENTICATION_REQUIRED(511).ResultMatcherisNoContent()Assert the response status code isHttpStatus.NO_CONTENT(204).ResultMatcherisNonAuthoritativeInformation()Assert the response status code isHttpStatus.NON_AUTHORITATIVE_INFORMATION(203).ResultMatcherisNotAcceptable()Assert the response status code isHttpStatus.NOT_ACCEPTABLE(406).ResultMatcherisNotExtended()Assert the response status code isHttpStatus.NOT_EXTENDED(510).ResultMatcherisNotFound()Assert the response status code isHttpStatus.NOT_FOUND(404).ResultMatcherisNotImplemented()Assert the response status code isHttpStatus.NOT_IMPLEMENTED(501).ResultMatcherisNotModified()Assert the response status code isHttpStatus.NOT_MODIFIED(304).ResultMatcherisOk()Assert the response status code isHttpStatus.OK(200).ResultMatcherisPartialContent()Assert the response status code isHttpStatus.PARTIAL_CONTENT(206).ResultMatcherisPayloadTooLarge()Assert the response status code isHttpStatus.PAYLOAD_TOO_LARGE(413).ResultMatcherisPaymentRequired()Assert the response status code isHttpStatus.PAYMENT_REQUIRED(402).ResultMatcherisPermanentRedirect()Assert the response status code isHttpStatus.PERMANENT_REDIRECT(308).ResultMatcherisPreconditionFailed()Assert the response status code isHttpStatus.PRECONDITION_FAILED(412).ResultMatcherisPreconditionRequired()Assert the response status code isHttpStatus.PRECONDITION_REQUIRED(428).ResultMatcherisProcessing()Assert the response status code isHttpStatus.PROCESSING(102).ResultMatcherisProxyAuthenticationRequired()Assert the response status code isHttpStatus.PROXY_AUTHENTICATION_REQUIRED(407).ResultMatcherisRequestedRangeNotSatisfiable()Assert the response status code isHttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE(416).ResultMatcherisRequestEntityTooLarge()已过时。matching the deprecation ofHttpStatus.REQUEST_ENTITY_TOO_LARGEResultMatcherisRequestHeaderFieldsTooLarge()Assert the response status code isHttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE(431).ResultMatcherisRequestTimeout()Assert the response status code isHttpStatus.REQUEST_TIMEOUT(408).ResultMatcherisRequestUriTooLong()已过时。matching the deprecation ofHttpStatus.REQUEST_URI_TOO_LONGResultMatcherisResetContent()Assert the response status code isHttpStatus.RESET_CONTENT(205).ResultMatcherisSeeOther()Assert the response status code isHttpStatus.SEE_OTHER(303).ResultMatcherisServiceUnavailable()Assert the response status code isHttpStatus.SERVICE_UNAVAILABLE(503).ResultMatcherisSwitchingProtocols()Assert the response status code isHttpStatus.SWITCHING_PROTOCOLS(101).ResultMatcherisTemporaryRedirect()Assert the response status code isHttpStatus.TEMPORARY_REDIRECT(307).ResultMatcherisTooManyRequests()Assert the response status code isHttpStatus.TOO_MANY_REQUESTS(429).ResultMatcherisUnauthorized()Assert the response status code isHttpStatus.UNAUTHORIZED(401).ResultMatcherisUnavailableForLegalReasons()Assert the response status code isHttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS(451).ResultMatcherisUnprocessableEntity()Assert the response status code isHttpStatus.UNPROCESSABLE_ENTITY(422).ResultMatcherisUnsupportedMediaType()Assert the response status code isHttpStatus.UNSUPPORTED_MEDIA_TYPE(415).ResultMatcherisUpgradeRequired()Assert the response status code isHttpStatus.UPGRADE_REQUIRED(426).ResultMatcherisUriTooLong()Assert the response status code isHttpStatus.REQUEST_URI_TOO_LONG(414).ResultMatcherisUseProxy()已过时。matching the deprecation ofHttpStatus.USE_PROXYResultMatcherisVariantAlsoNegotiates()Assert the response status code isHttpStatus.VARIANT_ALSO_NEGOTIATES(506).ResultMatcherreason(String reason)Assert the Servlet response error message.ResultMatcherreason(Matcher<? super String> matcher)Assert the Servlet response error message with the given HamcrestMatcher.
构造器详细资料
StatusResultMatchers
protected StatusResultMatchers()
Protected constructor. UseMockMvcResultMatchers.status().
方法详细资料
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()
已过时。in favor ofisFound()Assert the response status code isHttpStatus.MOVED_TEMPORARILY(302).- 另请参阅:
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()
已过时。matching the deprecation ofHttpStatus.USE_PROXYAssert 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).- 从以下版本开始:
- 4.1
isRequestEntityTooLarge
@Deprecated public ResultMatcher isRequestEntityTooLarge()
已过时。matching the deprecation ofHttpStatus.REQUEST_ENTITY_TOO_LARGEAssert the response status code isHttpStatus.REQUEST_ENTITY_TOO_LARGE(413).- 另请参阅:
isPayloadTooLarge()
isUriTooLong
public ResultMatcher isUriTooLong()
Assert the response status code isHttpStatus.REQUEST_URI_TOO_LONG(414).- 从以下版本开始:
- 4.1
isRequestUriTooLong
@Deprecated public ResultMatcher isRequestUriTooLong()
已过时。matching the deprecation ofHttpStatus.REQUEST_URI_TOO_LONGAssert the response status code isHttpStatus.REQUEST_URI_TOO_LONG(414).- 另请参阅:
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()
已过时。matching the deprecation ofHttpStatus.INSUFFICIENT_SPACE_ON_RESOURCEAssert the response status code isHttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE(419).
isMethodFailure
@Deprecated public ResultMatcher isMethodFailure()
已过时。matching the deprecation ofHttpStatus.METHOD_FAILUREAssert the response status code isHttpStatus.METHOD_FAILURE(420).
isDestinationLocked
@Deprecated public ResultMatcher isDestinationLocked()
已过时。matching the deprecation ofHttpStatus.DESTINATION_LOCKEDAssert 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).- 从以下版本开始:
- 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).