类 MockMvcResultMatchers

java.lang.Object
cn.taketoday.test.web.servlet.result.MockMvcResultMatchers

public abstract class MockMvcResultMatchers extends Object
Static factory methods for ResultMatcher-based result actions.

Eclipse Users

Consider adding this class as a Java editor favorite. To navigate to this setting, open the Preferences and type "favorites".

从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Brian Clozel, Sam Brannen
  • 字段详细资料

    • pathMatcher

      private static final cn.taketoday.core.AntPathMatcher pathMatcher
  • 构造器详细资料

    • MockMvcResultMatchers

      public MockMvcResultMatchers()
  • 方法详细资料

    • request

      public static RequestResultMatchers request()
      Access to request-related assertions.
    • handler

      public static HandlerResultMatchers handler()
      Access to assertions for the handler that handled the request.
    • model

      public static ModelResultMatchers model()
      Access to model-related assertions.
    • view

      public static ViewResultMatchers view()
      Access to assertions on the selected view.
    • flash

      public static FlashAttributeResultMatchers flash()
      Access to flash attribute assertions.
    • forwardedUrl

      public static ResultMatcher forwardedUrl(@Nullable String expectedUrl)
      Asserts the request was forwarded to the given URL.

      This method accepts only exact matches.

      参数:
      expectedUrl - the exact URL expected
    • forwardedUrlTemplate

      public static ResultMatcher forwardedUrlTemplate(String urlTemplate, Object... uriVars)
      Asserts the request was forwarded to the given URL template.

      This method accepts exact matches against the expanded and encoded URL template.

      参数:
      urlTemplate - a URL template; the expanded URL will be encoded
      uriVars - zero or more URI variables to populate the template
      另请参阅:
      • UriComponentsBuilder.fromUriString(String)
    • forwardedUrlPattern

      public static ResultMatcher forwardedUrlPattern(String urlPattern)
      Asserts the request was forwarded to the given URL.

      This method accepts AntPathMatcher patterns.

      参数:
      urlPattern - an Ant-style path pattern to match against
      另请参阅:
      • AntPathMatcher
    • redirectedUrl

      public static ResultMatcher redirectedUrl(String expectedUrl)
      Asserts the request was redirected to the given URL.

      This method accepts only exact matches.

      参数:
      expectedUrl - the exact URL expected
    • redirectedUrlTemplate

      public static ResultMatcher redirectedUrlTemplate(String urlTemplate, Object... uriVars)
      Asserts the request was redirected to the given URL template.

      This method accepts exact matches against the expanded and encoded URL template.

      参数:
      urlTemplate - a URL template; the expanded URL will be encoded
      uriVars - zero or more URI variables to populate the template
      另请参阅:
      • UriComponentsBuilder.fromUriString(String)
    • redirectedUrlPattern

      public static ResultMatcher redirectedUrlPattern(String urlPattern)
      Asserts the request was redirected to the given URL.

      This method accepts AntPathMatcher patterns.

      参数:
      urlPattern - an Ant-style path pattern to match against
      另请参阅:
      • AntPathMatcher
    • status

      public static StatusResultMatchers status()
      Access to response status assertions.
    • header

      public static HeaderResultMatchers header()
      Access to response header assertions.
    • content

      public static ContentResultMatchers content()
      Access to response body assertions.
    • jsonPath

      public static JsonPathResultMatchers jsonPath(String expression, Object... args)
      Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.

      The JSON path expression can be a parameterized string using formatting specifiers as defined in String.format(String, Object...).

      参数:
      expression - the JSON path expression, optionally parameterized with arguments
      args - arguments to parameterize the JSON path expression with
      另请参阅:
    • jsonPath

      public static <T> ResultMatcher jsonPath(String expression, org.hamcrest.Matcher<? super T> matcher)
      Evaluate the given JsonPath expression against the response body and assert the resulting value with the given Hamcrest Matcher.
      参数:
      expression - the JSON path expression
      matcher - a matcher for the value expected at the JSON path
      另请参阅:
    • jsonPath

      public static <T> ResultMatcher jsonPath(String expression, org.hamcrest.Matcher<? super T> matcher, Class<T> targetType)
      Evaluate the given JsonPath expression against the response body and assert the resulting value with the given Hamcrest Matcher, coercing the resulting value into the given target type before applying the matcher.

      This can be useful for matching numbers reliably — for example, to coerce an integer into a double.

      参数:
      expression - the JSON path expression
      matcher - a matcher for the value expected at the JSON path
      targetType - the target type to coerce the matching value into
      另请参阅:
    • xpath

      public static XpathResultMatchers xpath(String expression, Object... args) throws XPathExpressionException
      Access to response body assertions using an XPath expression to inspect a specific subset of the body.

      The XPath expression can be a parameterized string using formatting specifiers as defined in String.format(String, Object...).

      参数:
      expression - the XPath expression, optionally parameterized with arguments
      args - arguments to parameterize the XPath expression with
      抛出:
      XPathExpressionException
    • xpath

      public static XpathResultMatchers xpath(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
      Access to response body assertions using an XPath expression to inspect a specific subset of the body.

      The XPath expression can be a parameterized string using formatting specifiers as defined in String.format(String, Object...).

      参数:
      expression - the XPath expression, optionally parameterized with arguments
      namespaces - the namespaces referenced in the XPath expression
      args - arguments to parameterize the XPath expression with
      抛出:
      XPathExpressionException
    • cookie

      public static CookieResultMatchers cookie()
      Access to response cookie assertions.