diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java index 755b4a1889cb..aeb66214d3d2 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java @@ -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)); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java index 11478c9d5cc9..dc5a00b6e7c7 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java @@ -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));