use of org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver in project spring-framework by spring-projects.
the class FreeMarkerViewTests method subscribeWithoutDemand.
// gh-22754
@Test
public void subscribeWithoutDemand() {
ZeroDemandResponse response = new ZeroDemandResponse();
ServerWebExchange exchange = new DefaultServerWebExchange(MockServerHttpRequest.get("/path").build(), response, new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
FreeMarkerView view = new FreeMarkerView();
view.setApplicationContext(this.context);
view.setConfiguration(this.freeMarkerConfig);
view.setUrl("test.ftl");
ModelMap model = new ExtendedModelMap();
model.addAttribute("hello", "hi FreeMarker");
view.render(model, null, exchange).subscribe();
response.cancelWrite();
response.checkForLeaks();
}
use of org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver in project spring-framework by spring-projects.
the class DefaultWebSessionManagerTests method setUp.
@BeforeEach
void setUp() throws Exception {
given(this.createSession.save()).willReturn(Mono.empty());
given(this.createSession.getId()).willReturn("create-session-id");
given(this.updateSession.getId()).willReturn("update-session-id");
given(this.sessionStore.createWebSession()).willReturn(Mono.just(this.createSession));
given(this.sessionStore.retrieveSession(this.updateSession.getId())).willReturn(Mono.just(this.updateSession));
this.sessionManager = new DefaultWebSessionManager();
this.sessionManager.setSessionIdResolver(this.sessionIdResolver);
this.sessionManager.setSessionStore(this.sessionStore);
MockServerHttpRequest request = MockServerHttpRequest.get("/path").build();
MockServerHttpResponse response = new MockServerHttpResponse();
this.exchange = new DefaultServerWebExchange(request, response, this.sessionManager, ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
}
use of org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver in project spring-boot by spring-projects.
the class WebFluxAutoConfigurationTests method defaultLocaleContextResolver.
@Test
void defaultLocaleContextResolver() {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(LocaleContextResolver.class);
LocaleContextResolver resolver = context.getBean(LocaleContextResolver.class);
assertThat(((AcceptHeaderLocaleContextResolver) resolver).getDefaultLocale()).isNull();
});
}
use of org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver in project spring-framework by spring-projects.
the class NashornScriptTemplateTests method subscribeWithoutDemand.
// gh-22754
@Test
public void subscribeWithoutDemand() throws Exception {
ZeroDemandResponse response = new ZeroDemandResponse();
ServerWebExchange exchange = new DefaultServerWebExchange(MockServerHttpRequest.get("/path").build(), response, new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
Map<String, Object> model = new HashMap<>();
model.put("title", "Layout example");
model.put("body", "This is the body");
String viewUrl = "org/springframework/web/reactive/result/view/script/nashorn/template.html";
ScriptTemplateView view = createViewWithUrl(viewUrl, ScriptTemplatingConfiguration.class);
view.render(model, null, exchange).subscribe();
response.cancelWrite();
response.checkForLeaks();
}
use of org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver in project spring-framework by spring-projects.
the class DefaultHandlerStrategiesBuilder method defaultConfiguration.
public void defaultConfiguration() {
this.codecConfigurer.registerDefaults(true);
this.exceptionHandlers.add(new WebFluxResponseStatusExceptionHandler());
this.localeContextResolver = new AcceptHeaderLocaleContextResolver();
}
Aggregations