Package org.springframework.test.web.servlet

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


  /**
   * Assert the selected view name.
   */
  public ResultMatcher name(final String expectedViewName) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        ModelAndView mav = result.getModelAndView();
        assertTrue("No ModelAndView found", mav != null);
        assertEquals("View name", expectedViewName, mav.getViewName());
View Full Code Here


  /**
   * Assert the primary value of the named response header with the given
   * Hamcrest {@link Matcher}.
   */
  public ResultMatcher string(final String name, final Matcher<? super String> matcher) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertThat("Response header " + name, result.getResponse().getHeader(name), matcher);
      }
View Full Code Here

  /**
   * Assert the primary value of the named response header as a {@link String}.
   */
  public ResultMatcher string(final String name, final String value) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertEquals("Response header " + name, value, result.getResponse().getHeader(name));
      }
View Full Code Here

  /**
   * Assert that the named response header does not exist.
   * @since 4.0
   */
  public ResultMatcher doesNotExist(final String name) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertTrue("Response should not contain header " + name, !result.getResponse().containsHeader(name));
      }
View Full Code Here

   * <p>The {@link ResultMatcher} returned by this method throws an {@link AssertionError}
   * if the response does not contain the specified header, or if the supplied
   * {@code value} does not match the primary value.
   */
  public ResultMatcher longValue(final String name, final long value) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertTrue("Response does not contain header " + name, result.getResponse().containsHeader(name));
        assertEquals("Response header " + name, value, Long.parseLong(result.getResponse().getHeader(name)));
View Full Code Here

  /**
   * Assert a flash attribute's value with the given Hamcrest {@link Matcher}.
   */
  public <T> ResultMatcher attribute(final String name, final Matcher<T> matcher) {
    return new ResultMatcher() {
      @Override
      @SuppressWarnings("unchecked")
      public void match(MvcResult result) throws Exception {
        assertThat("Flash attribute", (T) result.getFlashMap().get(name), matcher);
      }
View Full Code Here

  /**
   * Assert a flash attribute's value.
   */
  public <T> ResultMatcher attribute(final String name, final Object value) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertEquals("Flash attribute", value, result.getFlashMap().get(name));
      }
    };
View Full Code Here

  /**
   * Assert the existence of the given flash attributes.
   */
  public <T> ResultMatcher attributeExists(final String... names) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        for (String name : names) {
          assertTrue("Flash attribute [" + name + "] does not exist", result.getFlashMap().get(name) != null);
        }
View Full Code Here

  /**
   * Assert the number of flash attributes.
   */
  public <T> ResultMatcher attributeCount(final int count) {
    return new ResultMatcher() {
      @Override
      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() {
      @Override
      public void match(MvcResult result) throws Exception {
        String content = result.getResponse().getContentAsString();
        xpathHelper.assertNode(content, matcher);
      }
View Full Code Here

TOP

Related Classes of org.springframework.test.web.servlet.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.