Package org.springframework.web.context.request

Examples of org.springframework.web.context.request.ServletWebRequest


    assertSupportedAndResult(parameter, pageable, TestUtils.getWebRequest());
  }

  protected void assertSupportedAndResult(MethodParameter parameter, Pageable pageable, HttpServletRequest request)
      throws Exception {
    assertSupportedAndResult(parameter, pageable, new ServletWebRequest(request));
  }
View Full Code Here


  public void returnsNullIfFallbackIsNullAndNoParametersGiven() throws Exception {

    PageableHandlerMethodArgumentResolver resolver = getResolver();
    resolver.setFallbackPageable(null);

    assertSupportedAndResult(supportedMethodParameter, null, new ServletWebRequest(new MockHttpServletRequest()),
        resolver);
  }
View Full Code Here

    resolver.setFallbackPageable(null);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("page", "20");

    assertThat(resolver.resolveArgument(supportedMethodParameter, null, new ServletWebRequest(request), null),
        is(nullValue()));
  }
View Full Code Here

    resolver.setFallbackPageable(null);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("size", "10");

    assertThat(resolver.resolveArgument(supportedMethodParameter, null, new ServletWebRequest(request), null),
        is(nullValue()));
  }
View Full Code Here

* @author Oliver Gierke
*/
class TestUtils {

  public static NativeWebRequest getWebRequest() {
    return new ServletWebRequest(new MockHttpServletRequest());
  }
View Full Code Here

    MethodParameter parameter = TestUtils.getParameterOfMethod(getControllerClass(), "unsupportedMethod", String.class);
    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
    Sort fallbackSort = new Sort(Direction.ASC, "ID");
    resolver.setFallbackSort(fallbackSort);

    Sort sort = resolver.resolveArgument(parameter, null, new ServletWebRequest(new MockHttpServletRequest()), null);
    assertThat(sort, is(fallbackSort));
  }
View Full Code Here

  public void fallbackToDefaultDefaultSort() throws Exception {

    MethodParameter parameter = TestUtils.getParameterOfMethod(getControllerClass(), "unsupportedMethod", String.class);
    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();

    Sort sort = resolver.resolveArgument(parameter, null, new ServletWebRequest(new MockHttpServletRequest()), null);
    assertThat(sort, is(nullValue()));
  }
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("sort", (String) null);

    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
    Sort result = resolver.resolveArgument(parameter, null, new ServletWebRequest(request), null);
    assertThat(result, is(nullValue()));
  }
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("sort", SORT_3);

    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
    Sort result = resolver.resolveArgument(parameter, null, new ServletWebRequest(request), null);
    assertThat(result, is(new Sort(Direction.ASC, "firstname", "lastname")));
  }
View Full Code Here

  }

  private static Sort resolveSort(HttpServletRequest request, MethodParameter parameter) throws Exception {

    SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
    return resolver.resolveArgument(parameter, null, new ServletWebRequest(request), null);
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.context.request.ServletWebRequest

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.