use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class FilteringWebHandlerTests method handleErrorFromFilter.
@Test
public void handleErrorFromFilter() throws Exception {
MockServerHttpRequest request = MockServerHttpRequest.get("/").build();
MockServerHttpResponse response = new MockServerHttpResponse();
TestExceptionHandler exceptionHandler = new TestExceptionHandler();
WebHttpHandlerBuilder.webHandler(new StubWebHandler()).filter(new ExceptionFilter()).exceptionHandler(exceptionHandler).build().handle(request, response).block();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
assertThat(exceptionHandler.ex).isNotNull();
assertThat(exceptionHandler.ex.getMessage()).isEqualTo("boo");
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class AcceptHeaderLocaleContextResolverTests method resolveMissingAcceptLanguageHeaderWithDefault.
@Test
public void resolveMissingAcceptLanguageHeaderWithDefault() {
this.resolver.setDefaultLocale(US);
MockServerHttpRequest request = MockServerHttpRequest.get("/").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
assertThat(this.resolver.resolveLocaleContext(exchange).getLocale()).isEqualTo(US);
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class AcceptHeaderLocaleContextResolverTests method defaultLocale.
@Test
public void defaultLocale() {
this.resolver.setDefaultLocale(JAPANESE);
MockServerHttpRequest request = MockServerHttpRequest.get("/").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
assertThat(this.resolver.resolveLocaleContext(exchange).getLocale()).isEqualTo(JAPANESE);
request = MockServerHttpRequest.get("/").acceptLanguageAsLocales(US).build();
exchange = MockServerWebExchange.from(request);
assertThat(this.resolver.resolveLocaleContext(exchange).getLocale()).isEqualTo(US);
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class AcceptHeaderLocaleContextResolverTests method resolveEmptyAcceptLanguageHeader.
@Test
public void resolveEmptyAcceptLanguageHeader() {
MockServerHttpRequest request = MockServerHttpRequest.get("/").header(HttpHeaders.ACCEPT_LANGUAGE, "").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
assertThat(this.resolver.resolveLocaleContext(exchange).getLocale()).isNull();
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class AcceptHeaderLocaleContextResolverTests method resolveEmptyAcceptLanguageHeaderWithDefault.
@Test
public void resolveEmptyAcceptLanguageHeaderWithDefault() {
this.resolver.setDefaultLocale(US);
MockServerHttpRequest request = MockServerHttpRequest.get("/").header(HttpHeaders.ACCEPT_LANGUAGE, "").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
assertThat(this.resolver.resolveLocaleContext(exchange).getLocale()).isEqualTo(US);
}
Aggregations