use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class UrlFilenameViewControllerTests method withFilenamePlusExtension.
@PathPatternsParameterizedTest
void withFilenamePlusExtension(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/index.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("index");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class UrlFilenameViewControllerTests method multiLevelWithMapping.
@PathPatternsParameterizedTest
void multiLevelWithMapping(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/cvs/commit.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("cvs/commit");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class SessionLocaleResolverTests method testResolveLocale.
@Test
public void testResolveLocale() {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
RequestContext context = new ServletRequestContext(webApplicationContext, request, response);
RequestContextUtils.getRequiredSession(context).setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, Locale.GERMAN);
SessionLocaleResolver resolver = new SessionLocaleResolver();
assertThat(resolver.resolveLocale(context)).isEqualTo(Locale.GERMAN);
}
use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class SessionLocaleResolverTests method testResolveLocaleWithoutSessionAndDefaultLocale.
@Test
public void testResolveLocaleWithoutSessionAndDefaultLocale() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.addPreferredLocale(Locale.TAIWAN);
RequestContext context = new ServletRequestContext(webApplicationContext, request, null);
SessionLocaleResolver resolver = new SessionLocaleResolver();
resolver.setDefaultLocale(Locale.GERMAN);
assertThat(resolver.resolveLocale(context)).isEqualTo(Locale.GERMAN);
}
use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.
the class SessionScope method get.
@Override
public Object get(String name, Supplier<?> objectFactory) {
RequestContext context = RequestContextHolder.getRequired();
WebSession session = getSession(context);
Object sessionMutex = WebUtils.getSessionMutex(session);
synchronized (sessionMutex) {
return get(session, name, objectFactory);
}
}
Aggregations