Package org.springframework.web.context.request

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


    @Test
    public void testCoincidenceCaptchaWithInputValue() throws Exception {
        UserDto userDto = createUserDto();
        session.setAttribute(Constants.KAPTCHA_SESSION_KEY, GENERATED_CAPTCHA_TEXT);
        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));

        Map<String, String> errors = service.validateCaptcha(userDto, 1L);

        assertTrue(errors.isEmpty(), "Validation of captcha with valid value should not return any errors.");
    }
View Full Code Here


  protected WebRequest getRequest(RequestParameters parameters) {

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameters(parameters.asMap());

    ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(requestAttributes);

    return new ServletWebRequest(request);
  }
View Full Code Here

   * Initializes web tests. Will register a {@link MockHttpServletRequest} for the current thread.
   */
  public static void initWebTest() {

    MockHttpServletRequest request = new MockHttpServletRequest();
    ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(requestAttributes);
  }
View Full Code Here

  @Before
  public void setMockRequest() {
    MockHttpServletRequest req = new MockHttpServletRequest();
    req.addHeader("User-Agent", "Win");
    SecurityContextHolderAwareRequestWrapper reqWrapper = new SecurityContextHolderAwareRequestWrapper(req, "U");
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(reqWrapper));
  }
View Full Code Here

  @Before
  public void setMockContext() {
    MockHttpServletRequest req = new MockHttpServletRequest();
    req.addHeader("User-Agent", "Win");
    SecurityContextHolderAwareRequestWrapper reqWrapper = new SecurityContextHolderAwareRequestWrapper(req, "U");
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(reqWrapper));
  }
View Full Code Here

  @Before
  public void setUp() {

    request = new MockHttpServletRequest();
    ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(requestAttributes);
  }
View Full Code Here

  @Override
  protected void doFilterInternal(
      HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
      throws ServletException, IOException {

    ServletRequestAttributes attributes = new ServletRequestAttributes(request, response);
    initContextHolders(request, attributes);

    try {
      filterChain.doFilter(request, response);
    }
    finally {
      resetContextHolders();
      if (logger.isDebugEnabled()) {
        logger.debug("Cleared thread-bound request context: " + request);
      }
      attributes.requestCompleted();
    }
  }
View Full Code Here

  private ServletRequestAttributes newRequestAttributesWithSession;


  @Before
  public void setUp() {
    this.oldRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
    this.newRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());

    MockHttpServletRequest oldRequestWithSession = new MockHttpServletRequest();
    oldRequestWithSession.setSession(new MockHttpSession());
    this.oldRequestAttributesWithSession = new ServletRequestAttributes(oldRequestWithSession);

    MockHttpServletRequest newRequestWithSession = new MockHttpServletRequest();
    newRequestWithSession.setSession(new MockHttpSession());
    this.newRequestAttributesWithSession = new ServletRequestAttributes(newRequestWithSession);
  }
View Full Code Here

  private ServletRequestAttributes newRequestAttributesWithSession;


  @Before
  public void setUp() {
    this.oldRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
    this.newRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());

    MockHttpServletRequest oldRequestWithSession = new MockHttpServletRequest();
    oldRequestWithSession.setSession(new MockHttpSession());
    this.oldRequestAttributesWithSession = new ServletRequestAttributes(oldRequestWithSession);

    MockHttpServletRequest newRequestWithSession = new MockHttpServletRequest();
    newRequestWithSession.setSession(new MockHttpSession());
    this.newRequestAttributesWithSession = new ServletRequestAttributes(newRequestWithSession);
  }
View Full Code Here

  @SuppressWarnings("serial")
  private static class WebRequestObjectFactory implements ObjectFactory<WebRequest>, Serializable {

    @Override
    public WebRequest getObject() {
      ServletRequestAttributes requestAttr = currentRequestAttributes();
      return new ServletWebRequest(requestAttr.getRequest(), requestAttr.getResponse());
    }
View Full Code Here

TOP

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

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.