Skip to content

Commit

Permalink
Issue #5018 - rename ClientUpgradeRequest timeout to setTimeout
Browse files Browse the repository at this point in the history
and increase timeouts used for testing

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Jul 7, 2020
1 parent 74916c2 commit 702a48c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testWebSocketClientTimeout() throws Exception
client.setMaxIdleTimeout(timeout);
Future<Session> connect = client.connect(clientSocket, WSURI.toWebsocket(server.getURI()));

ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout + 200, TimeUnit.MILLISECONDS));
ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout * 2, TimeUnit.MILLISECONDS));
assertThat(executionException.getCause(), instanceOf(UpgradeException.class));
UpgradeException upgradeException = (UpgradeException)executionException.getCause();
assertThat(upgradeException.getCause(), instanceOf(TimeoutException.class));
Expand All @@ -112,10 +112,10 @@ public void testClientUpgradeRequestTimeout() throws Exception
EventSocket clientSocket = new EventSocket();
long timeout = 1000;
ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest();
upgradeRequest.timeout(timeout, TimeUnit.MILLISECONDS);
upgradeRequest.setTimeout(timeout, TimeUnit.MILLISECONDS);
Future<Session> connect = client.connect(clientSocket, WSURI.toWebsocket(server.getURI()), upgradeRequest);

ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout + 200, TimeUnit.MILLISECONDS));
ExecutionException executionException = assertThrows(ExecutionException.class, () -> connect.get(timeout * 2, TimeUnit.MILLISECONDS));
assertThat(executionException.getCause(), instanceOf(UpgradeException.class));
UpgradeException upgradeException = (UpgradeException)executionException.getCause();
assertThat(upgradeException.getCause(), instanceOf(TimeoutException.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,10 @@ public void setRequestURI(URI uri)
* @param timeout the total timeout for the request/response conversation of the WebSocket handshake;
* use zero or a negative value to disable the timeout
* @param unit the timeout unit
* @return this request object
*/
public ClientUpgradeRequest timeout(long timeout, TimeUnit unit)
public void setTimeout(long timeout, TimeUnit unit)
{
this.timeout = unit.toMillis(timeout);
return this;
}

/**
Expand Down

0 comments on commit 702a48c

Please sign in to comment.