|
32 | 32 | import org.openqa.selenium.firefox.FirefoxDriver;
|
33 | 33 | import org.openqa.selenium.firefox.FirefoxOptions;
|
34 | 34 | import org.openqa.selenium.ie.InternetExplorerDriver;
|
35 |
| -import org.openqa.selenium.internal.SocketLock; |
36 | 35 | import org.openqa.selenium.net.PortProber;
|
37 | 36 | import org.openqa.selenium.opera.OperaDriver;
|
38 | 37 | import org.openqa.selenium.safari.SafariDriver;
|
@@ -149,35 +148,36 @@ private URL determineSuiteUrl(String startURL, String suiteURL) throws IOExcepti
|
149 | 148 | Path path = Paths.get(suiteURL).toAbsolutePath();
|
150 | 149 | if (Files.exists(path)) {
|
151 | 150 | // Not all drivers can read files from the disk, so we need to host the suite somewhere.
|
152 |
| - try (SocketLock lock = new SocketLock()) { |
153 |
| - server = new Server(); |
154 |
| - HttpConfiguration httpConfig = new HttpConfiguration(); |
| 151 | + server = new Server(); |
| 152 | + HttpConfiguration httpConfig = new HttpConfiguration(); |
155 | 153 |
|
156 |
| - ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); |
157 |
| - int port = PortProber.findFreePort(); |
158 |
| - http.setPort(port); |
159 |
| - http.setIdleTimeout(500000); |
160 |
| - server.setConnectors(new Connector[]{http}); |
| 154 | + ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); |
| 155 | + int port = PortProber.findFreePort(); |
| 156 | + http.setPort(port); |
| 157 | + http.setIdleTimeout(500000); |
| 158 | + server.setConnectors(new Connector[]{http}); |
161 | 159 |
|
162 |
| - ResourceHandler handler = new ResourceHandler(); |
163 |
| - handler.setDirectoriesListed(true); |
164 |
| - handler.setWelcomeFiles(new String[]{path.getFileName().toString(), "index.html"}); |
165 |
| - handler.setBaseResource(new PathResource(path.toFile().getParentFile().toPath().toRealPath())); |
| 160 | + ResourceHandler handler = new ResourceHandler(); |
| 161 | + handler.setDirectoriesListed(true); |
| 162 | + handler.setWelcomeFiles(new String[]{path.getFileName().toString(), "index.html"}); |
| 163 | + handler |
| 164 | + .setBaseResource(new PathResource(path.toFile().getParentFile().toPath().toRealPath())); |
166 | 165 |
|
167 |
| - ContextHandler context = new ContextHandler("/tests"); |
168 |
| - context.setHandler(handler); |
| 166 | + ContextHandler context = new ContextHandler("/tests"); |
| 167 | + context.setHandler(handler); |
169 | 168 |
|
170 |
| - server.setHandler(context); |
| 169 | + server.setHandler(context); |
| 170 | + try { |
171 | 171 | server.start();
|
172 |
| - |
173 |
| - PortProber.waitForPortUp(port, 15, SECONDS); |
174 |
| - |
175 |
| - URL serverUrl = server.getURI().toURL(); |
176 |
| - return new URL(serverUrl.getProtocol(), serverUrl.getHost(), serverUrl.getPort(), |
177 |
| - "/tests/"); |
178 | 172 | } catch (Exception e) {
|
179 | 173 | throw new IOException(e);
|
180 | 174 | }
|
| 175 | + |
| 176 | + PortProber.waitForPortUp(port, 15, SECONDS); |
| 177 | + |
| 178 | + URL serverUrl = server.getURI().toURL(); |
| 179 | + return new URL(serverUrl.getProtocol(), serverUrl.getHost(), serverUrl.getPort(), |
| 180 | + "/tests/"); |
181 | 181 | }
|
182 | 182 |
|
183 | 183 | // Well then, it must be a URL relative to whatever the browserUrl. Probe and find out.
|
|
0 commit comments