Package org.springframework.test.web.server

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


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


  /**
   * Assert a cookie path with a Hamcrest {@link Matcher}.
   */
  public ResultMatcher path(final String name, final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        Cookie cookie = result.getResponse().getCookie(name);
        MatcherAssert.assertThat("Response cookie path", cookie.getPath(), matcher);
      }
    };
View Full Code Here

  /**
   * Assert a cookie's domain with a Hamcrest {@link Matcher}.
   */
  public ResultMatcher domain(final String name, final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        Cookie cookie = result.getResponse().getCookie(name);
        MatcherAssert.assertThat("Response cookie domain", cookie.getDomain(), matcher);
      }
    };
View Full Code Here

  /**
   * Assert a cookie's comment with a Hamcrest {@link Matcher}.
   */
  public ResultMatcher comment(final String name, final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        Cookie cookie = result.getResponse().getCookie(name);
        MatcherAssert.assertThat("Response cookie comment", cookie.getComment(), matcher);
      }
    };
View Full Code Here

  /**
   * Assert a cookie's version with a Hamcrest {@link Matcher}
   */
  public ResultMatcher version(final String name, final Matcher<? super Integer> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        Cookie cookie = result.getResponse().getCookie(name);
        MatcherAssert.assertThat("Response cookie version", cookie.getVersion(), matcher);
      }
    };
View Full Code Here

  /**
   * Assert whether the cookie must be sent over a secure protocol or not.
   */
  public ResultMatcher secure(final String name, final boolean secure) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        Cookie cookie = result.getResponse().getCookie(name);
        assertEquals("Response cookie secure", secure, cookie.getSecure());
      }
    };
View Full Code Here

  /**
   * Evaluate the JSONPath and assert the value of the content found with the
   * given Hamcrest {@code Matcher}.
   */
  public <T> ResultMatcher value(final Matcher<T> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        jsonPathHelper.assertValue(content, matcher);
      }
    };
View Full Code Here

  /**
   * Evaluate the JSONPath and assert that content exists.
   */
  public ResultMatcher exists() {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        jsonPathHelper.exists(content);
      }
    };
View Full Code Here

  /**
   * Evaluate the JSON path and assert not content was found.
   */
  public ResultMatcher doesNotExist() {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        jsonPathHelper.doesNotExist(content);
      }
    };
View Full Code Here

      response.setStatus(status.value());

      String methodName = statusToMethodName(status);
      Method method = StatusResultMatchers.class.getMethod(methodName);
      try {
        ResultMatcher matcher = (ResultMatcher) ReflectionUtils.invokeMethod(method, resultMatchers);
        try {
          MvcResult mvcResult = new StubMvcResult(new MockHttpServletRequest(), null, null, null, null, null, response);
          matcher.match(mvcResult);
        }
        catch (AssertionError error) {
          failures.add(error);
        }
      }
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.