use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse in project spring-framework by spring-projects.
the class KotlinScriptTemplateTests method renderTemplateWithEnglishLocale.
@Test
public void renderTemplateWithEnglishLocale() throws Exception {
Map<String, Object> model = new HashMap<>();
model.put("foo", "Foo");
String url = "org/springframework/web/reactive/result/view/script/kotlin/template.kts";
MockServerHttpResponse response = render(url, model, Locale.ENGLISH, ScriptTemplatingConfiguration.class);
assertThat(response.getBodyAsString().block()).isEqualTo("<html><body>\n<p>Hello Foo</p>\n</body></html>");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse in project spring-framework by spring-projects.
the class KotlinScriptTemplateTests method renderTemplateWithFrenchLocale.
@Test
public void renderTemplateWithFrenchLocale() throws Exception {
Map<String, Object> model = new HashMap<>();
model.put("foo", "Foo");
String url = "org/springframework/web/reactive/result/view/script/kotlin/template.kts";
MockServerHttpResponse response = render(url, model, Locale.FRENCH, ScriptTemplatingConfiguration.class);
assertThat(response.getBodyAsString().block()).isEqualTo("<html><body>\n<p>Bonjour Foo</p>\n</body></html>");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse in project spring-framework by spring-projects.
the class KotlinScriptTemplateTests method renderTemplateWithoutRenderFunction.
@Test
public void renderTemplateWithoutRenderFunction() throws Exception {
Map<String, Object> model = new HashMap<>();
model.put("header", "<html><body>");
model.put("hello", "Hello");
model.put("foo", "Foo");
model.put("footer", "</body></html>");
String url = "org/springframework/web/reactive/result/view/script/kotlin/eval.kts";
Class<?> configClass = ScriptTemplatingConfigurationWithoutRenderFunction.class;
MockServerHttpResponse response = render(url, model, Locale.ENGLISH, configClass);
assertThat(response.getBodyAsString().block()).isEqualTo("<html><body>\n<p>Hello Foo</p>\n</body></html>");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse in project spring-framework by spring-projects.
the class ViewResolutionResultHandlerTests method contentNegotiationWithRedirect.
// SPR-15291
@Test
public void contentNegotiationWithRedirect() {
HandlerResult handlerResult = new HandlerResult(new Object(), "redirect:/", on(Handler.class).annotNotPresent(ModelAttribute.class).resolveReturnType(String.class), this.bindingContext);
UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
viewResolver.setApplicationContext(new StaticApplicationContext());
ViewResolutionResultHandler resultHandler = resultHandler(viewResolver);
MockServerWebExchange exchange = MockServerWebExchange.from(get("/account").accept(APPLICATION_JSON));
resultHandler.handleResult(exchange, handlerResult).block(Duration.ZERO);
MockServerHttpResponse response = exchange.getResponse();
assertThat(response.getStatusCode().value()).isEqualTo(303);
assertThat(response.getHeaders().getLocation().toString()).isEqualTo("/");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse in project spring-framework by spring-projects.
the class NashornScriptTemplateTests method renderTemplateWithUrl.
// SPR-13453
@Test
public void renderTemplateWithUrl() throws Exception {
String url = "org/springframework/web/reactive/result/view/script/nashorn/template.html";
Class<?> configClass = ScriptTemplatingWithUrlConfiguration.class;
MockServerHttpResponse response = render(url, null, configClass);
assertThat(response.getBodyAsString().block()).isEqualTo(("<html><head><title>Check url parameter</title></head><body><p>" + url + "</p></body></html>"));
}
Aggregations