MockRestRequestMatchers (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.test.web.client.match

## Class MockRestRequestMatchers

- java.lang.Object
- - org.springframework.test.web.client.match.MockRestRequestMatchers

-     public abstract class MockRestRequestMatchers
      extends Object

  Static, factory methods for `RequestMatcher` classes. Typically used to provide input for `MockRestServiceServer.expect(RequestMatcher)`.

  Eclipse users: consider adding this class as a Java editor favorite. To navigate, open the Preferences and type "favorites".

  Since:
    3.2
  Author:
    Craig Walls, Rossen Stoyanchev

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static RequestMatcher` | `anything()` Match to any request.
    `static ContentRequestMatchers` | `content()` Access to request body matchers.
    `static RequestMatcher` | `header(String name, org.hamcrest.Matcher<? super String>... matchers)` Assert request header values with the given Hamcrest matcher.
    `static RequestMatcher` | `header(String name, String... expectedValues)` Assert request header values.
    `static <T> RequestMatcher` | `jsonPath(String expression, org.hamcrest.Matcher<T> matcher)` Access to request body matchers 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 JsonPathRequestMatchers` | `jsonPath(String expression, Object... args)` Access to request body matchers using a JSONPath expression to inspect a specific subset of the body.
    `static RequestMatcher` | `method(HttpMethod method)` Assert the `HttpMethod` of the request.
    `static RequestMatcher` | `requestTo(org.hamcrest.Matcher<String> matcher)` Assert the request URI string with the given matcher.
    `static RequestMatcher` | `requestTo(String expectedUri)` Assert the request URI string.
    `static RequestMatcher` | `requestTo(URI uri)` Expect a request to the given URI.
    `static XpathRequestMatchers` | `xpath(String expression, Map<String,String> namespaces, Object... args)` Access to response body matchers using an XPath to inspect a specific subset of the body.
    `static XpathRequestMatchers` | `xpath(String expression, Object... args)` Access to request body matchers 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

    - #### anything

          public static RequestMatcher anything()

      Match to any request.

    - #### requestTo

          public static RequestMatcher requestTo(org.hamcrest.Matcher<String> matcher)

      Assert the request URI string with the given matcher.
      Parameters:
        `matcher` - String matcher for the expected URI
      Returns:
        the request matcher

    - #### requestTo

          public static RequestMatcher requestTo(String expectedUri)

      Assert the request URI string.
      Parameters:
        `expectedUri` - the expected URI
      Returns:
        the request matcher

    - #### method

          public static RequestMatcher method(HttpMethod method)

      Assert the `HttpMethod` of the request.
      Parameters:
        `method` - the HTTP method
      Returns:
        the request matcher

    - #### requestTo

          public static RequestMatcher requestTo(URI uri)

      Expect a request to the given URI.
      Parameters:
        `uri` - the expected URI
      Returns:
        the request matcher

    - #### header

          public static RequestMatcher header(String name,
                              org.hamcrest.Matcher<? super String>... matchers)

      Assert request header values with the given Hamcrest matcher.

    - #### header

          public static RequestMatcher header(String name,
                              String... expectedValues)

      Assert request header values.

    - #### content

          public static ContentRequestMatchers content()

      Access to request body matchers.

    - #### jsonPath

          public static JsonPathRequestMatchers jsonPath(String expression,
                                         Object... args)

      Access to request body matchers 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> RequestMatcher jsonPath(String expression,
                                    org.hamcrest.Matcher<T> matcher)

      Access to request body matchers 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 XpathRequestMatchers xpath(String expression,
                                   Object... args)
                                            throws XPathExpressionException

      Access to request body matchers 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 XpathRequestMatchers xpath(String expression,
                                   Map<String,String> namespaces,
                                   Object... args)
                                            throws XPathExpressionException

      Access to response body matchers 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`