Search in sources :

Example 1 with JettyHttpServer

use of org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer in project spring-framework by spring-projects.

the class ErrorHandlerIntegrationTests method emptyPathSegments.

// SPR-15560
@ParameterizedHttpServerTest
void emptyPathSegments(HttpServer httpServer) throws Exception {
    startServer(httpServer);
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
    URI url = new URI("http://localhost:" + port + "//");
    ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
    // 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);
}
Also used : HttpStatus(org.springframework.http.HttpStatus) RestTemplate(org.springframework.web.client.RestTemplate) URI(java.net.URI) JettyHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer)

Example 2 with JettyHttpServer

use of org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer in project spring-framework by spring-projects.

the class AbstractWebSocketIntegrationTests method arguments.

static Stream<Object[]> arguments() throws IOException {
    WebSocketClient[] clients = new WebSocketClient[] { new TomcatWebSocketClient(), new JettyWebSocketClient(), new ReactorNettyWebSocketClient(), new UndertowWebSocketClient(Xnio.getInstance().createWorker(OptionMap.EMPTY)) };
    Map<HttpServer, Class<?>> servers = new LinkedHashMap<>();
    servers.put(new TomcatHttpServer(TMP_DIR.getAbsolutePath(), WsContextListener.class), TomcatConfig.class);
    servers.put(new JettyHttpServer(), JettyConfig.class);
    servers.put(new ReactorHttpServer(), ReactorNettyConfig.class);
    servers.put(new UndertowHttpServer(), UndertowConfig.class);
    // Try each client once against each server..
    Flux<WebSocketClient> f1 = Flux.fromArray(clients).concatMap(c -> Mono.just(c).repeat(servers.size() - 1));
    Flux<Map.Entry<HttpServer, Class<?>>> f2 = Flux.fromIterable(servers.entrySet()).repeat(clients.length - 1).share();
    return Flux.zip(f1, f2.map(Map.Entry::getKey), f2.map(Map.Entry::getValue)).map(Tuple3::toArray).toStream();
}
Also used : WsContextListener(org.apache.tomcat.websocket.server.WsContextListener) ReactorHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer) ReactorNettyWebSocketClient(org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient) TomcatWebSocketClient(org.springframework.web.reactive.socket.client.TomcatWebSocketClient) UndertowHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.UndertowHttpServer) WebSocketClient(org.springframework.web.reactive.socket.client.WebSocketClient) ReactorNettyWebSocketClient(org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient) TomcatWebSocketClient(org.springframework.web.reactive.socket.client.TomcatWebSocketClient) UndertowWebSocketClient(org.springframework.web.reactive.socket.client.UndertowWebSocketClient) JettyWebSocketClient(org.springframework.web.reactive.socket.client.JettyWebSocketClient) LinkedHashMap(java.util.LinkedHashMap) JettyWebSocketClient(org.springframework.web.reactive.socket.client.JettyWebSocketClient) TomcatHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.TomcatHttpServer) ReactorHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer) HttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer) JettyHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer) UndertowHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.UndertowHttpServer) TomcatHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.TomcatHttpServer) UndertowWebSocketClient(org.springframework.web.reactive.socket.client.UndertowWebSocketClient) OptionMap(org.xnio.OptionMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) JettyHttpServer(org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer)

Aggregations

JettyHttpServer (org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer)2 URI (java.net.URI)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 WsContextListener (org.apache.tomcat.websocket.server.WsContextListener)1 HttpStatus (org.springframework.http.HttpStatus)1 RestTemplate (org.springframework.web.client.RestTemplate)1 JettyWebSocketClient (org.springframework.web.reactive.socket.client.JettyWebSocketClient)1 ReactorNettyWebSocketClient (org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient)1 TomcatWebSocketClient (org.springframework.web.reactive.socket.client.TomcatWebSocketClient)1 UndertowWebSocketClient (org.springframework.web.reactive.socket.client.UndertowWebSocketClient)1 WebSocketClient (org.springframework.web.reactive.socket.client.WebSocketClient)1 HttpServer (org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer)1 ReactorHttpServer (org.springframework.web.testfixture.http.server.reactive.bootstrap.ReactorHttpServer)1 TomcatHttpServer (org.springframework.web.testfixture.http.server.reactive.bootstrap.TomcatHttpServer)1 UndertowHttpServer (org.springframework.web.testfixture.http.server.reactive.bootstrap.UndertowHttpServer)1 OptionMap (org.xnio.OptionMap)1