org.springframework.test.web.servlet.result

## Class MockMvcResultMatchers

- java.lang.Object
- - org.springframework.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, open the Preferences and type "favorites".

Since:
  3.2
Author:
  Rossen Stoyanchev

### Method Summary

Methods
`static ContentResultMatchers` `content()` Access to response body assertions.
`static CookieResultMatchers` `cookie()` Access to response cookie assertions.
`static FlashAttributeResultMatchers` `flash()` Access to flash attribute assertions.
`static ResultMatcher` `forwardedUrl(String expectedUrl)` Asserts the request was forwarded to the given URL.
`static HandlerResultMatchers` `handler()` Access to assertions for the handler that handled the request.
`static HeaderResultMatchers` `header()` Access to response header assertions.
`static <T> ResultMatcher` `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.
`static JsonPathResultMatchers` `jsonPath(String expression, Object... args)` Access to response body assertions using a JSONPath expression to inspect a specific subset of the body.
`static ModelResultMatchers` `model()` Access to model-related assertions.
`static ResultMatcher` `redirectedUrl(String expectedUrl)` Asserts the request was redirected to the given URL.
`static RequestResultMatchers` `request()` Access to request-related assertions.
`static StatusResultMatchers` `status()` Access to response status assertions.
`static ViewResultMatchers` `view()` Access to assertions on the selected view.
`static XpathResultMatchers` `xpath(String expression, Map<String,String> namespaces, Object... args)` Access to response body assertions using an XPath to inspect a specific subset of the body.
`static XpathResultMatchers` `xpath(String expression, Object... args)` Access to response body assertions using an XPath to inspect a specific subset of the body.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### 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(String expectedUrl)

Asserts the request was forwarded to the given URL.

#### redirectedUrl

    public static ResultMatcher redirectedUrl(String expectedUrl)

Asserts the request was redirected to the given URL.

#### 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...)`.

Parameters:
  `expression` - the JSON path optionally parameterized with arguments
  `args` - arguments to parameterize the JSON path expression with

#### jsonPath

    public static <T> ResultMatcher 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.

Parameters:
  `expression` - the JSON path expression
  `matcher` - a matcher for the value expected at the JSON path

#### xpath

    public static XpathResultMatchers xpath(String expression,
                            Object... args)
                                     throws XPathExpressionException

Access to response body assertions using an XPath 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...)`.

Parameters:
  `expression` - the XPath optionally parameterized with arguments
  `args` - arguments to parameterize the XPath expression with
Throws:
  `XPathExpressionException`

#### xpath

    public static XpathResultMatchers xpath(String expression,
                            Map<String,String> namespaces,
                            Object... args)
                                     throws XPathExpressionException

Access to response body assertions using an XPath 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...)`.

Parameters:
  `expression` - the XPath optionally parameterized with arguments
  `namespaces` - namespaces referenced in the XPath expression
  `args` - arguments to parameterize the XPath expression with
Throws:
  `XPathExpressionException`

#### cookie

    public static CookieResultMatchers cookie()

Access to response cookie assertions.