From 51d96eced890c29e282fb2d67cdb1e67eb3b83dd Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 1 Dec 2020 13:23:13 +0100 Subject: [PATCH] Removed hardcoded port. Signed-off-by: Simone Bordet --- .../tests/proxy/WebSocketProxyTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/proxy/WebSocketProxyTest.java b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/proxy/WebSocketProxyTest.java index 3a47531d1c2..a6dec735963 100644 --- a/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/proxy/WebSocketProxyTest.java +++ b/jetty-websocket/jetty-websocket-tests/src/test/java/org/eclipse/jetty/websocket/tests/proxy/WebSocketProxyTest.java @@ -57,8 +57,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class WebSocketProxyTest { - private static final int PORT = 49998; - private Server server; private EventSocket serverSocket; private WebSocketProxy webSocketProxy; @@ -70,15 +68,8 @@ public class WebSocketProxyTest { server = new Server(); ServerConnector connector = new ServerConnector(server); - connector.setPort(PORT); server.addConnector(connector); - client = new WebSocketClient(); - client.start(); - proxyUri = URI.create("ws://localhost:" + PORT + "/proxy"); - URI echoUri = URI.create("ws://localhost:" + PORT + "/echo"); - webSocketProxy = new WebSocketProxy(client, echoUri); - ServletContextHandler contextHandler = new ServletContextHandler(); WebSocketUpgradeFilter.configure(contextHandler); serverSocket = new EchoSocket(); @@ -95,6 +86,14 @@ public class WebSocketProxyTest server.setHandler(contextHandler); server.start(); + + int port = connector.getLocalPort(); + + client = new WebSocketClient(); + client.start(); + proxyUri = URI.create("ws://localhost:" + port + "/proxy"); + URI echoUri = URI.create("ws://localhost:" + port + "/echo"); + webSocketProxy = new WebSocketProxy(client, echoUri); } @AfterEach