Skip to content

Commit

Permalink
Fixes #10547 - Cannot customize Executor on WebSocketClient.
Browse files Browse the repository at this point in the history
Added tests after review.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Sep 27, 2023
1 parent c79afd8 commit 9cf42ee
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 9cf42ee

Please sign in to comment.