Examples of RequestMatcher


Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Get the body of the request as a UTF-8 string and compare it to the given String.
   */
  public RequestMatcher string(final String expectedContent) {
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
        assertEquals("Request content", expectedContent, mockRequest.getBodyAsString());
      }
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Compare the body of the request to the given byte array.
   */
  public RequestMatcher bytes(final byte[] expectedContent) {
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
        assertEquals("Request content", expectedContent, mockRequest.getBodyAsBytes());
      }
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Match to any request.
   */
  public static RequestMatcher anything() {
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) throws AssertionError {
      }
    };
  }
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

   * @param matcher String matcher for the expected URI
   * @return the request matcher
   */
  public static RequestMatcher requestTo(final Matcher<String> matcher) {
    Assert.notNull(matcher, "'matcher' must not be null");
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        assertThat("Request URI", request.getURI().toString(), matcher);
      }
    };
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

   * @param expectedUri the expected URI
   * @return the request matcher
   */
  public static RequestMatcher requestTo(final String expectedUri) {
    Assert.notNull(expectedUri, "'uri' must not be null");
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        assertEquals("Request URI", expectedUri, request.getURI().toString());
      }
    };
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

   * @param method the HTTP method
   * @return the request matcher
   */
  public static RequestMatcher method(final HttpMethod method) {
    Assert.notNull(method, "'method' must not be null");
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) throws AssertionError {
        AssertionErrors.assertEquals("Unexpected HttpMethod", method, request.getMethod());
      }
    };
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

   * @param uri the expected URI
   * @return the request matcher
   */
  public static RequestMatcher requestTo(final URI uri) {
    Assert.notNull(uri, "'uri' must not be null");
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        AssertionErrors.assertEquals("Unexpected request", uri, request.getURI());
      }
    };
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Assert request header values with the given Hamcrest matcher.
   */
  @SuppressWarnings("unchecked")
  public static RequestMatcher header(final String name, final Matcher<? super String>... matchers) {
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) {
        assertHeaderValueCount(name, request.getHeaders(), matchers.length);
        for (int i = 0 ; i < matchers.length; i++) {
          assertThat("Request header", request.getHeaders().get(name).get(i), matchers[i]);
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Assert request header values.
   */
  public static RequestMatcher header(final String name, final String... expectedValues) {
    return new RequestMatcher() {
      @Override
      public void match(ClientHttpRequest request) {
        assertHeaderValueCount(name, request.getHeaders(), expectedValues.length);
        for (int i = 0 ; i < expectedValues.length; i++) {
          assertEquals("Request header + [" + name + "]",
View Full Code Here

Examples of org.springframework.ws.test.client.RequestMatcher

        template.sendBodyAndHeader("direct:sendDefault", body, "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));

    }

    private RequestMatcher doesntContains(final RequestMatcher soapHeader) {
        return new RequestMatcher() {
            public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {
                try {
                    soapHeader.match(uri, request);

                } catch (AssertionError e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.