Skip to content

Commit

Permalink
Sometimes it happens that some process is listening to `connector.get…
Browse files Browse the repository at this point in the history
…LocalPort() + 1`, making this test fail.

Now using a non-allocated privileged port from IANA, that nobody should listen to, so the test should not fail.
It is not a 100% guarantee, but perhaps better than before, especially because now a port < 1024 is used.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed May 23, 2024
1 parent 36cdc12 commit be7491e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,11 @@ public void testWebSocketConnectPortDoesNotExist() throws Exception
startServer();
startClient(clientConnector -> new ClientConnectionFactoryOverHTTP2.HTTP2(new HTTP2Client(clientConnector)));

// Port 293 is not assigned by IANA, so
// it should be impossible to connect.
int nonExistingPort = 293;
EventSocket wsEndPoint = new EventSocket();
URI uri = URI.create("ws://localhost:" + (connector.getLocalPort() + 1) + "/ws/echo");
URI uri = URI.create("ws://localhost:" + nonExistingPort + "/ws/echo");

ExecutionException failure = Assertions.assertThrows(ExecutionException.class, () ->
wsClient.connect(wsEndPoint, uri).get(5, TimeUnit.SECONDS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ public void testWebSocketConnectPortDoesNotExist() throws Exception
startServer();
startClient(clientConnector -> new ClientConnectionFactoryOverHTTP2.HTTP2(new HTTP2Client(clientConnector)));

// Port 293 is not assigned by IANA, so
// it should be impossible to connect.
int nonExistingPort = 293;
EventSocket wsEndPoint = new EventSocket();
URI uri = URI.create("ws://localhost:" + (connector.getLocalPort() + 1) + "/ws/echo");
URI uri = URI.create("ws://localhost:" + nonExistingPort + "/ws/echo");

ExecutionException failure = Assertions.assertThrows(ExecutionException.class, () ->
wsClient.connect(wsEndPoint, uri).get(5, TimeUnit.SECONDS));
Expand Down

0 comments on commit be7491e

Please sign in to comment.