Package org.springframework.test.web.server

Examples of org.springframework.test.web.server.ResultMatcher


   * @param xmlContent the expected XML content
   * @see MockMvcResultMatchers#xpath(String, Object...)
   * @see MockMvcResultMatchers#xpath(String, Map, Object...)
   */
  public ResultMatcher xml(final String xmlContent) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xmlHelper.assertXmlEqual(xmlContent, content);
      }
    };
View Full Code Here


   * {@link Matcher}.
   *
   * @see org.hamcrest.Matchers#hasXPath
   */
  public ResultMatcher node(final Matcher<? super Node> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xmlHelper.assertNode(content, matcher);
      }
    };
View Full Code Here

   * Hamcrest {@link Matcher}.
   *
   * @see <a href="http://code.google.com/p/xml-matchers/">xml-matchers</a>
   */
  public ResultMatcher source(final Matcher<? super Source> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xmlHelper.assertSource(content, matcher);
      }
    };
View Full Code Here

  /**
   * Assert a request attribute value with the given Hamcrest {@link Matcher}.
   */
  public <T> ResultMatcher attribute(final String name, final Matcher<T> matcher) {
    return new ResultMatcher() {
      @SuppressWarnings("unchecked")
      public void match(MvcResult result) {
        T value = (T) result.getRequest().getAttribute(name);
        MatcherAssert.assertThat("Request attribute: ", value, matcher);
      }
View Full Code Here

  /**
   * Assert a session attribute value with the given Hamcrest {@link Matcher}.
   */
  public <T> ResultMatcher sessionAttribute(final String name, final Matcher<T> matcher) {
    return new ResultMatcher() {
      @SuppressWarnings("unchecked")
      public void match(MvcResult result) {
        T value = (T) result.getRequest().getSession().getAttribute(name);
        MatcherAssert.assertThat("Request attribute: ", value, matcher);
      }
View Full Code Here

  /**
   * Asserts the request was forwarded to the given URL.
   */
  public static ResultMatcher forwardedUrl(final String expectedUrl) {
    return new ResultMatcher() {
      public void match(MvcResult result) {
        assertEquals("Forwarded URL", expectedUrl, result.getResponse().getForwardedUrl());
      }
    };
  }
View Full Code Here

  /**
   * Asserts the request was redirected to the given URL.
   */
  public static ResultMatcher redirectedUrl(final String expectedUrl) {
    return new ResultMatcher() {
      public void match(MvcResult result) {
        assertEquals("Redirected URL", expectedUrl, result.getResponse().getRedirectedUrl());
      }
    };
  }
View Full Code Here

  /**
   * Assert a cookie value with the given Hamcrest {@link Matcher}.
   */
  public ResultMatcher value(final String name, final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) {
        Cookie cookie = result.getResponse().getCookie(name);
        assertTrue("Response cookie not found: " + name, cookie != null);
        MatcherAssert.assertThat("Response cookie", cookie.getValue(), matcher);
      }
View Full Code Here

  /**
   * Assert a cookie exists. The existence check is irrespective of whether
   * max age is 0 (i.e. expired).
   */
  public ResultMatcher exists(final String name) {
    return new ResultMatcher() {
      public void match(MvcResult result) {
        Cookie cookie = result.getResponse().getCookie(name);
        assertTrue("No cookie with name: " + name, cookie != null);
      }
    };
View Full Code Here

  /**
   * Assert a cookie does not exist. Note that the existence check is
   * irrespective of whether max age is 0, i.e. expired.
   */
  public ResultMatcher doesNotExist(final String name) {
    return new ResultMatcher() {
      public void match(MvcResult result) {
        Cookie cookie = result.getResponse().getCookie(name);
        assertTrue("Unexpected cookie with name " + name, cookie == null);
      }
    };
View Full Code Here

TOP

Related Classes of org.springframework.test.web.server.ResultMatcher

Copyright © 2018 www.massapicom. 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.