Example usage for org.springframework.web.context.request ServletRequestAttributes ServletRequestAttributes

List of usage examples for org.springframework.web.context.request ServletRequestAttributes ServletRequestAttributes

Introduction

In this page you can find the example usage for org.springframework.web.context.request ServletRequestAttributes ServletRequestAttributes.

Prototype

public ServletRequestAttributes(HttpServletRequest request) 

Source Link

Document

Create a new ServletRequestAttributes instance for the given request.

Usage

From source file:com.nebhale.cyclinglibrary.web.json.LinkTest.java

@Before
public void setRequestContext() {
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
}

From source file:org.cloudfoundry.identity.uaa.web.ForwardAwareInternalResourceViewResolverTests.java

@Before
public void start() {
    ServletRequestAttributes attributes = new ServletRequestAttributes(request);
    LocaleContextHolder.setLocale(request.getLocale());
    RequestContextHolder.setRequestAttributes(attributes);
}

From source file:io.jmnarloch.spring.request.correlation.support.RequestCorrelationUtilsTest.java

@Before
public void setUp() throws Exception {

    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
}

From source file:ru.javaops.web.ErrorController.java

@RequestMapping(ERROR_PATH)
String error(HttpServletRequest request, Model model) {
    Map<String, Object> errorMap = errorAttributes.getErrorAttributes(new ServletRequestAttributes(request),
            false);//from  ww w  . ja  va2s . co  m
    model.addAllAttributes(errorMap);
    return "exception";
}

From source file:com.imooc.MyErrorController.java

@RequestMapping(ERROR_PATH)
String error(HttpServletRequest request, Model model) {
    Map<String, Object> errorMap = errorAttributes.getErrorAttributes(new ServletRequestAttributes(request),
            false);/*from   ww w  .j  av  a 2  s  .  c o m*/
    model.addAttribute("errors", errorMap);
    return "error";
}

From source file:com.nebhale.cyclinglibrary.web.json.AbstractJsonSerializerTest.java

@Before
public final void setRequestContext() {
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
}

From source file:com.mtgi.analytics.servlet.SpringSessionContextTest.java

@Test
public void testAuthenticated() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRemoteUser("testUser");
    ServletRequestAttributes atts = new ServletRequestAttributes(request);
    RequestContextHolder.setRequestAttributes(atts);

    assertEquals("context inherits user from request attributes", "testUser", inst.getContextUserId());
    assertEquals("context inherits session from request attributes", request.getSession().getId(),
            inst.getContextSessionId());
}

From source file:oobbit.controllers.CustomErrorController.java

/**
 * Displays the error to the user using ErrorObject.
 *
 * @param request  HttpServletRequest made by the user
 * @param response HttpServletResponse made by the server
 * @param model    Model to be included in the page
 *
 * @return template as a string/*  ww w .  j av a 2 s. co  m*/
 */
@RequestMapping(value = PATH)
public String errorPage(HttpServletRequest request, HttpServletResponse response, Model model) {
    RequestAttributes requestAttributes = new ServletRequestAttributes(request);
    model.addAttribute("error", new ErrorObject(response.getStatus(),
            errorAttributes.getErrorAttributes(requestAttributes, INCLUDE_STACKTRACE)));

    return "error";
}

From source file:cec.easyshop.storefront.security.cookie.EnhancedCookieGeneratorTest.java

@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);
    cookieGenerator.setCookieDomain("what a domain");
    cookieGenerator.setCookieMaxAge(Integer.valueOf(NEVER_EXPIRES));
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
}

From source file:com.acc.storefront.security.cookie.EnhancedCookieGeneratorTest.java

@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);
    cookieGenerator.setCookieDomain("what a domain");
    cookieGenerator.setCookieMaxAge(Integer.valueOf(NEVER_EXPIRES));

    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
}