use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class JythonScriptTemplateTests method renderViewWithModel.
private MockServerHttpResponse renderViewWithModel(String viewUrl, Map<String, Object> model) throws Exception {
ScriptTemplateView view = createViewWithUrl(viewUrl);
MockServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
view.renderInternal(model, MediaType.TEXT_HTML, exchange).block();
return exchange.getResponse();
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class NashornScriptTemplateTests method renderViewWithModel.
private MockServerHttpResponse renderViewWithModel(String viewUrl, Map<String, Object> model, Class<?> configuration) throws Exception {
ScriptTemplateView view = createViewWithUrl(viewUrl, configuration);
MockServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
view.renderInternal(model, MediaType.TEXT_HTML, exchange).block();
return exchange.getResponse();
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceHandlerRegistryTests method mapPathToLocation.
@Test
public void mapPathToLocation() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
exchange.getAttributes().put(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, "/testStylesheet.css");
ResourceWebHandler handler = getHandler("/resources/**");
handler.handle(exchange).block(Duration.ofSeconds(5));
StepVerifier.create(exchange.getResponse().getBody()).consumeNextWith(buf -> assertEquals("test stylesheet content", DataBufferTestUtils.dumpString(buf, StandardCharsets.UTF_8))).expectComplete().verify();
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceTransformerSupportTests method resolveUrlPath.
@Test
public void resolveUrlPath() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("/resources/main.css").toExchange();
String resourcePath = "/resources/bar.css";
Resource css = new ClassPathResource("test/main.css", getClass());
String actual = this.transformer.resolveUrlPath(resourcePath, exchange, css, this.transformerChain).block(Duration.ofSeconds(5));
assertEquals("/resources/bar-11e16cf79faee7ac698c805cf28248d2.css", actual);
assertEquals("/resources/bar-11e16cf79faee7ac698c805cf28248d2.css", actual);
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceWebHandlerTests method getResourceFromSubDirectory.
@Test
public void getResourceFromSubDirectory() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
setPathWithinHandlerMapping(exchange, "js/foo.js");
this.handler.handle(exchange).block(TIMEOUT);
assertEquals(MediaType.parseMediaType("text/javascript"), exchange.getResponse().getHeaders().getContentType());
assertResponseBody(exchange, "function foo() { console.log(\"hello world\"); }");
}
Aggregations