use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class CssLinkResourceTransformerTests method transformNoLinks.
@Test
public void transformNoLinks() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("/static/foo.css").toExchange();
Resource expected = new ClassPathResource("test/foo.css", getClass());
StepVerifier.create(this.transformerChain.transform(exchange, expected)).consumeNextWith(resource -> assertSame(expected, resource)).expectComplete().verify();
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class HandlerResultHandlerTests method producibleMediaTypesRequestAttribute.
@Test
public void producibleMediaTypesRequestAttribute() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("/path").toExchange();
exchange.getAttributes().put(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, Collections.singleton(IMAGE_GIF));
List<MediaType> mediaTypes = Arrays.asList(IMAGE_JPEG, IMAGE_GIF, IMAGE_PNG);
MediaType actual = resultHandler.selectMediaType(exchange, () -> mediaTypes);
assertEquals(IMAGE_GIF, actual);
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class HandlerResultHandlerTests method noConcreteMediaType.
// SPR-12894
@Test
public void noConcreteMediaType() throws Exception {
List<MediaType> producible = Collections.singletonList(ALL);
MockServerWebExchange exchange = MockServerHttpRequest.get("/path").toExchange();
MediaType actual = this.resultHandler.selectMediaType(exchange, () -> producible);
assertEquals(APPLICATION_OCTET_STREAM, actual);
}
use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.
the class ResourceTransformerSupportTests method resolveUrlPathWithRelativePath.
@Test
public void resolveUrlPathWithRelativePath() throws Exception {
Resource css = new ClassPathResource("test/main.css", getClass());
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
String actual = this.transformer.resolveUrlPath("bar.css", exchange, css, this.transformerChain).block(Duration.ofSeconds(5));
assertEquals("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 getResourceNoCache.
@Test
public void getResourceNoCache() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
setPathWithinHandlerMapping(exchange, "foo.css");
this.handler.setCacheControl(CacheControl.noStore());
this.handler.handle(exchange).block(TIMEOUT);
MockServerHttpResponse response = exchange.getResponse();
assertEquals("no-store", response.getHeaders().getCacheControl());
assertTrue(response.getHeaders().containsKey("Last-Modified"));
assertEquals(response.getHeaders().getLastModified() / 1000, resourceLastModifiedDate("test/foo.css") / 1000);
assertEquals("bytes", response.getHeaders().getFirst("Accept-Ranges"));
assertEquals(1, response.getHeaders().get("Accept-Ranges").size());
}
Aggregations