Search in sources :

Example 6 with DefaultWebSessionManager

use of org.springframework.web.server.session.DefaultWebSessionManager 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();
}
Also used : AcceptHeaderLocaleContextResolver(org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver) MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) DefaultServerWebExchange(org.springframework.web.server.adapter.DefaultServerWebExchange) ServerWebExchange(org.springframework.web.server.ServerWebExchange) DefaultServerWebExchange(org.springframework.web.server.adapter.DefaultServerWebExchange) ZeroDemandResponse(org.springframework.web.reactive.result.view.ZeroDemandResponse) HashMap(java.util.HashMap) DefaultWebSessionManager(org.springframework.web.server.session.DefaultWebSessionManager) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultWebSessionManager (org.springframework.web.server.session.DefaultWebSessionManager)6 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 ZeroDemandResponse (org.springframework.web.reactive.result.view.ZeroDemandResponse)2 ServerWebExchange (org.springframework.web.server.ServerWebExchange)2 DefaultServerWebExchange (org.springframework.web.server.adapter.DefaultServerWebExchange)2 AcceptHeaderLocaleContextResolver (org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver)2 MockServerWebExchange (org.springframework.web.testfixture.server.MockServerWebExchange)2 HashMap (java.util.HashMap)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Bean (org.springframework.context.annotation.Bean)1 MockServerHttpRequest (org.springframework.mock.http.server.reactive.MockServerHttpRequest)1 MockServerHttpResponse (org.springframework.mock.http.server.reactive.MockServerHttpResponse)1 SpringSessionWebSessionStore (org.springframework.session.web.server.session.SpringSessionWebSessionStore)1 ExtendedModelMap (org.springframework.ui.ExtendedModelMap)1 ModelMap (org.springframework.ui.ModelMap)1