use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class SessionScope method remove.
@Override
@Nullable
public Object remove(String name) {
RequestContext context = RequestContextHolder.getRequired();
WebSession session = getSession(context);
if (session != null) {
Object sessionMutex = WebUtils.getSessionMutex(session);
synchronized (sessionMutex) {
return remove(session, name);
}
}
return null;
}
use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class ServletTestExecutionListenerTests method assertRequestAttributesExist.
private RequestContext assertRequestAttributesExist() {
RequestContext requestAttributes = RequestContextHolder.get();
assertThat(requestAttributes).as("request attributes should exist").isNotNull();
return requestAttributes;
}
use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class ServletTestExecutionListenerTests method assertSetUpOutsideOfStelAttributeDoesNotExist.
private void assertSetUpOutsideOfStelAttributeDoesNotExist() {
RequestContext requestAttributes = assertRequestAttributesExist();
Object setUpOutsideOfStel = requestAttributes.getAttribute(SET_UP_OUTSIDE_OF_STEL);
assertThat(setUpOutsideOfStel).as(SET_UP_OUTSIDE_OF_STEL + " should NOT exist as a request attribute").isNull();
}
use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class ServletTestExecutionListenerTests method assertSetUpOutsideOfStelAttributeExists.
private void assertSetUpOutsideOfStelAttributeExists() {
RequestContext requestAttributes = assertRequestAttributesExist();
Object setUpOutsideOfStel = requestAttributes.getAttribute(SET_UP_OUTSIDE_OF_STEL);
assertThat(setUpOutsideOfStel).as(SET_UP_OUTSIDE_OF_STEL + " should exist as a request attribute").isNotNull();
}
use of cn.taketoday.web.RequestContext in project today-framework by TAKETODAY.
the class CorsFilterTests method validActualRequest.
@Test
public void validActualRequest() throws ServletException, IOException {
MockHttpServletRequest request = new MockHttpServletRequest(HttpMethod.GET.name(), "/test.html");
request.addHeader(HttpHeaders.ORIGIN, "https://domain2.com");
request.addHeader("header2", "foo");
MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain filterChain = (filterRequest, filterResponse) -> {
final RequestContext context = ServletUtils.getRequestContext(request, response);
assertThat(response.getHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN)).isEqualTo("https://domain2.com");
final String header = response.getHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS);
assertThat(header).isEqualTo("header3, header4");
};
filter.doFilter(request, response, filterChain);
}
Aggregations