Package org.springframework.test.web.server

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


  /**
   * Assert the number of flash attributes.
   */
  public <T> ResultMatcher attributeCount(final int count) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        assertEquals("FlashMap size", count, result.getFlashMap().size());
      }
    };
  }
View Full Code Here


  /**
   * Evaluate the XPath and assert the {@link Node} content found with the
   * given Hamcrest {@link Matcher}.
   */
  public ResultMatcher node(final Matcher<? super Node> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xpathHelper.assertNode(content, matcher);
      }
    };
View Full Code Here

  /**
   * Evaluate the XPath and assert the number of nodes found with the given
   * Hamcrest {@link Matcher}.
   */
  public ResultMatcher nodeCount(final Matcher<Integer> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xpathHelper.assertNodeCount(content, matcher);
      }
    };
View Full Code Here

  /**
   * Apply the XPath and assert the {@link String} value found with the given
   * Hamcrest {@link Matcher}.
   */
  public ResultMatcher string(final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xpathHelper.assertString(content, matcher);
      }
    };
View Full Code Here

  /**
   * Evaluate the XPath and assert the {@link Double} value found with the
   * given Hamcrest {@link Matcher}.
   */
  public ResultMatcher number(final Matcher<? super Double> matcher) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xpathHelper.assertNumber(content, matcher);
      }
    };
View Full Code Here

  /**
   * Evaluate the XPath and assert the {@link Boolean} value found.
   */
  public ResultMatcher booleanValue(final Boolean value) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xpathHelper.assertBoolean(content, value);
      }
    };
View Full Code Here

  /**
   * Assert a model 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) throws Exception {
        ModelAndView mav = result.getModelAndView();
        assertTrue("No ModelAndView found", mav != null);
        MatcherAssert.assertThat("Model attribute '" + name + "'", (T) mav.getModel().get(name), matcher);
View Full Code Here

  /**
   * Assert the given model attributes exist.
   */
  public ResultMatcher attributeExists(final String... names) {
    return new ResultMatcher() {
      public void match(MvcResult result) throws Exception {
        assertTrue("No ModelAndView found", result.getModelAndView() != null);
        for (String name : names) {
          attribute(name, Matchers.notNullValue()).match(result);
        }
View Full Code Here

  /**
   * Assert the given model attribute(s) have errors.
   */
  public ResultMatcher attributeHasErrors(final String... names) {
    return new ResultMatcher() {
      public void match(MvcResult mvcResult) throws Exception {
        ModelAndView mav = getModelAndView(mvcResult);
        for (String name : names) {
          BindingResult result = getBindingResult(mav, name);
          assertTrue("No errors for attribute: " + name, result.hasErrors());
View Full Code Here

  /**
   * Assert the given model attribute(s) do not have errors.
   */
  public ResultMatcher attributeHasNoErrors(final String... names) {
    return new ResultMatcher() {
      public void match(MvcResult mvcResult) throws Exception {
        ModelAndView mav = getModelAndView(mvcResult);
        for (String name : names) {
          BindingResult result = getBindingResult(mav, name);
          assertTrue("No errors for attribute: " + name, !result.hasErrors());
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.