Package org.springframework.test.web.servlet

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


  /**
   * Assert the response status code is in the 4xx range.
   */
  public ResultMatcher is4xxClientError() {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertEquals("Range for response status value " + result.getResponse().getStatus(),
            HttpStatus.Series.CLIENT_ERROR, getHttpStatusSeries(result));
      }
View Full Code Here


  /**
   * Assert the response status code is in the 5xx range.
   */
  public ResultMatcher is5xxServerError() {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertEquals("Range for response status value " + result.getResponse().getStatus(),
            HttpStatus.Series.SERVER_ERROR, getHttpStatusSeries(result));
      }
View Full Code Here

  /**
   * Assert the Servlet response error message with the given Hamcrest {@link Matcher}.
   */
  public ResultMatcher reason(final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertThat("Response status reason", result.getResponse().getErrorMessage(), matcher);
      }
    };
View Full Code Here

  /**
   * Assert the Servlet response error message.
   */
  public ResultMatcher reason(final String reason) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        assertEquals("Response status reason", reason, result.getResponse().getErrorMessage());
      }
    };
View Full Code Here

  /**
   * Match the expected response status to that of the HttpServletResponse
   */
  private ResultMatcher matcher(final HttpStatus status) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) {
        assertEquals("Status", status.value(), result.getResponse().getStatus());
      }
    };
View Full Code Here

   * Asserts the request was forwarded to the given URL.
   * This methods accepts only exact matches.
   * @param expectedUrl the exact URL expected
   */
  public static ResultMatcher forwardedUrl(final String expectedUrl) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertEquals("Forwarded URL", expectedUrl, result.getResponse().getForwardedUrl());
      }
View Full Code Here

   * @param urlPattern an AntPath expression to match against
   * @see org.springframework.util.AntPathMatcher
   * @since 4.0
   */
  public static ResultMatcher forwardedUrlPattern(final String urlPattern) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertTrue("AntPath expression", pathMatcher.isPattern(urlPattern));
        assertTrue("Forwarded URL does not match the expected URL pattern",
View Full Code Here

   * Asserts the request was redirected to the given URL.
   * This methods accepts only exact matches.
   * @param expectedUrl the exact URL expected
   */
  public static ResultMatcher redirectedUrl(final String expectedUrl) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertEquals("Redirected URL", expectedUrl, result.getResponse().getRedirectedUrl());
      }
View Full Code Here

   * @param expectedUrl an AntPath expression to match against
   * @see org.springframework.util.AntPathMatcher
   * @since 4.0
   */
  public static ResultMatcher redirectedUrlPattern(final String expectedUrl) {
    return new ResultMatcher() {

      @Override
      public void match(MvcResult result) {
        assertTrue("AntPath expression",pathMatcher.isPattern(expectedUrl));
        assertTrue("Redirected URL",
View Full Code Here

  /**
   * Assert the selected view name with the given Hamcrest {@link Matcher}.
   */
  public ResultMatcher name(final Matcher<? super String> matcher) {
    return new ResultMatcher() {
      @Override
      public void match(MvcResult result) throws Exception {
        ModelAndView mav = result.getModelAndView();
        assertTrue("No ModelAndView found", mav != null);
        assertThat("View name", mav.getViewName(), 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.