use of org.springframework.mock.web.server.MockServerWebExchange in project spring-boot by spring-projects.
the class FreeMarkerAutoConfigurationReactiveIntegrationTests method render.
private MockServerWebExchange render(ApplicationContext context, String viewName) {
FreeMarkerViewResolver resolver = context.getBean(FreeMarkerViewResolver.class);
Mono<View> view = resolver.resolveViewName(viewName, Locale.UK);
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path"));
view.flatMap((v) -> v.render(null, MediaType.TEXT_HTML, exchange)).block(Duration.ofSeconds(30));
return exchange;
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-boot by spring-projects.
the class MetricsWebFilterTests method filterAddsPercentileMeters.
@Test
void filterAddsPercentileMeters() {
MockServerWebExchange exchange = createTimedHandlerMethodExchange("timedPercentiles");
this.webFilter.filter(exchange, (serverWebExchange) -> exchange.getResponse().setComplete()).block(Duration.ofSeconds(30));
assertMetricsContainsTag("uri", "/projects/{project}");
assertMetricsContainsTag("status", "200");
assertThat(this.registry.get(REQUEST_METRICS_NAME_PERCENTILE).tag("phi", "0.95").gauge().value()).isNotZero();
assertThat(this.registry.get(REQUEST_METRICS_NAME_PERCENTILE).tag("phi", "0.5").gauge().value()).isNotZero();
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-boot by spring-projects.
the class MetricsWebFilterTests method disconnectedExceptionShouldProduceMetrics.
@Test
void disconnectedExceptionShouldProduceMetrics() {
MockServerWebExchange exchange = createExchange("/projects/spring-boot", "/projects/{project}");
Mono<Void> processing = this.webFilter.filter(exchange, (serverWebExchange) -> Mono.error(new EOFException("Disconnected"))).onErrorResume((t) -> {
exchange.getResponse().setRawStatusCode(500);
return exchange.getResponse().setComplete();
});
StepVerifier.create(processing).expectComplete().verify(Duration.ofSeconds(5));
assertMetricsContainsTag("uri", "/projects/{project}");
assertMetricsContainsTag("status", "500");
assertMetricsContainsTag("outcome", "UNKNOWN");
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-boot by spring-projects.
the class MetricsWebFilterTests method trailingSlashShouldNotRecordDuplicateMetrics.
@Test
void trailingSlashShouldNotRecordDuplicateMetrics() {
MockServerWebExchange exchange1 = createExchange("/projects/spring-boot", "/projects/{project}");
MockServerWebExchange exchange2 = createExchange("/projects/spring-boot", "/projects/{project}/");
this.webFilter.filter(exchange1, (serverWebExchange) -> exchange1.getResponse().setComplete()).block(Duration.ofSeconds(30));
this.webFilter.filter(exchange2, (serverWebExchange) -> exchange2.getResponse().setComplete()).block(Duration.ofSeconds(30));
assertThat(this.registry.get(REQUEST_METRICS_NAME).tag("uri", "/projects/{project}").timer().count()).isEqualTo(2);
assertThat(this.registry.get(REQUEST_METRICS_NAME).tag("status", "200").timer().count()).isEqualTo(2);
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-boot by spring-projects.
the class MetricsWebFilterTests method filterAddsExtraTags.
@Test
void filterAddsExtraTags() {
MockServerWebExchange exchange = createTimedHandlerMethodExchange("timedExtraTags");
this.webFilter.filter(exchange, (serverWebExchange) -> exchange.getResponse().setComplete()).block(Duration.ofSeconds(30));
assertMetricsContainsTag("uri", "/projects/{project}");
assertMetricsContainsTag("status", "200");
assertMetricsContainsTag("tag1", "value1");
assertMetricsContainsTag("tag2", "value2");
}
Aggregations