Fix Jetty 10+ test failure related to empty path handling

See gh-27424
This commit is contained in:
Rossen Stoyanchev
2021-09-17 12:52:41 +01:00
parent 513cc1576e
commit 853ab5d67b

View File

@@ -27,6 +27,7 @@ import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests;
import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer;
import org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer;
import static org.assertj.core.api.Assertions.assertThat;
@@ -80,7 +81,14 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
URI url = new URI("http://localhost:" + port + "//");
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
// Jetty 10+ rejects empty path segments, see https://github.com/eclipse/jetty.project/issues/6302,
// but an application can apply CompactPathRule via RewriteHandler:
// https://www.eclipse.org/jetty/documentation/jetty-11/programming_guide.php
HttpStatus expectedStatus =
(httpServer instanceof JettyHttpServer ? HttpStatus.BAD_REQUEST : HttpStatus.OK);
assertThat(response.getStatusCode()).isEqualTo(expectedStatus);
}