From 9cf42ee58ed48a165a28156d6e73a1bddc3db925 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 27 Sep 2023 17:18:33 +0200 Subject: [PATCH] Fixes #10547 - Cannot customize Executor on WebSocketClient. Added tests after review. Signed-off-by: Simone Bordet --- .../tests/client/WebSocketClientTest.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/WebSocketClientTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/WebSocketClientTest.java index 5716c06a538c..7ad16d31cf3c 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/WebSocketClientTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/WebSocketClientTest.java @@ -53,6 +53,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -120,21 +122,23 @@ public void stopServer() throws Exception server.stop(); } - @Test - public void testCustomizeExecutorDirectly() throws Exception + @ParameterizedTest + @ValueSource(booleans = {false, true}) + public void testCustomizeExecutorDirectly(boolean startHttpClient) throws Exception { Executor executor = Executors.newFixedThreadPool(50); HttpClient httpClient = new HttpClient(); httpClient.setExecutor(executor); try { - httpClient.start(); + if (startHttpClient) + httpClient.start(); WebSocketClient webSocketClient = new WebSocketClient(httpClient); try { webSocketClient.start(); - Executor inuseExecutor = webSocketClient.getExecutor(); - assertSame(executor, inuseExecutor); + Executor wsExecutor = webSocketClient.getExecutor(); + assertSame(executor, wsExecutor); } finally {