port = port == 0 ? PortProber.findFreePort() : port;
@Override protected void waitUntilAvailable() throws MalformedURLException { PortProber.waitForPortUp(getUrl().getPort(), 20, SECONDS); }
/** * Check the port availability * * @param port * the port to check * @param msg * the text to append to the end of the error message displayed when the port is not available. * @throws IllegalArgumentException * when the port is not available. */ void checkPort(int port, String msg) { StringBuilder message = new StringBuilder().append(" ").append(msg); String portInUseError = String.format("Port %d is already in use. Please shutdown the service " + "listening on this port or configure a different port%s.", port, message); boolean free = false; try { free = PortProber.pollPort(port); } catch (RuntimeException e) { throw new IllegalArgumentException(portInUseError, e); } finally { if (!free) { throw new IllegalArgumentException(portInUseError); } } }
Integer getDefaultValue() { return PortProber.findFreePort(); }
public BMPCLocalManager(String executablePath, String logPath) { this(executablePath, logPath, PortProber.findFreePort()); }
Integer sanitize(Object value) { checkNotNull(value); int port = Integer.valueOf(String.valueOf(value)); // 0 = random, -1 = Opera default (7001) (for use with Opera < 11.60) if (port == SERVER_RANDOM_PORT_IDENTIFIER) { port = PortProber.findFreePort(); } else if (port == SERVER_DEFAULT_PORT_IDENTIFIER) { port = SERVER_DEFAULT_PORT; } return port; } },
protected PhantomJSDriver createNewPhantomJsDriver(File phantomJsExe, Capabilities desiredCapabilities) { try { URL url = new URL("http://localhost:" + PortProber.findFreePort()); return new PhantomJSDriver(phantomJsExe, url, new File("target/phantomjs.log"), desiredCapabilities); } catch (MalformedURLException e) { throw new RuntimeException(e); } }
/** * See {@link com.github.detro.browsermobproxyclient.BMPCLocalLauncher#launch(int)} */ public static BMPCLocalManager launchOnRandomPort() { return launch(PortProber.findFreePort()); }
protected PhantomJSDriver createNewPhantomJsDriver(File phantomJsExe, Capabilities desiredCapabilities) { try { URL url = new URL("http://localhost:" + PortProber.findFreePort()); return new PhantomJSDriver(phantomJsExe, url, new File("target/phantomjs.log"), desiredCapabilities); } catch (MalformedURLException e) { throw new RuntimeException(e); } }
/** * Checks out the next available unused port. Callers should send the returned port * back to {@link #releaseUnusedPort(int)} when it's no longer being used. * * @throws NoSuchElementException if no unused port is available. */ public synchronized int checkOutUnusedPort() { if (availablePorts == null) { return PortProber.findFreePort(); } else if (availablePorts.isEmpty()) { // All available ports are checked out. throw new NoSuchElementException("No unused ports are available"); } return availablePorts.pop(); }
/** * Creates a new {@link WiniumDriverService} to manage the Winium StoreApps Driver server. * Before creating a new service, the builder will find a port for the server to listen to. * * @return The new {@link WiniumDriverService} object. */ public WiniumDriverService buildStoreAppsService() { int port = getPort(); if (port == 0) { port = PortProber.findFreePort(); } if (exe == null) { exe = findStoreAppsDriverExecutable(); } try { return new WiniumDriverService(exe, port, createArgs(), ImmutableMap.<String, String>of()); } catch (IOException e) { throw new WebDriverException(e); } }
port = port == 0 ? PortProber.findFreePort() : port;
/** * Creates a new {@link WiniumDriverService} to manage the Winium WindowsPhone Driver server. * Before creating a new service, the builder will find a port for the server to listen to. * * @return The new {@link WiniumDriverService} object. */ public WiniumDriverService buildSilverlightService() { int port = getPort(); if (port == 0) { port = PortProber.findFreePort(); } if (exe == null) { exe = findSilverlightDriverExecutable(); } try { return new WiniumDriverService(exe, port, createArgs(), ImmutableMap.<String, String>of()); } catch (IOException e) { throw new WebDriverException(e); } }
/** * Creates a new {@link WiniumDriverService} to manage the Winium Desktop Driver server. * Before creating a new service, the builder will find a port for the server to listen to. * * @return The new {@link WiniumDriverService} object. */ public WiniumDriverService buildDesktopService() { int port = getPort(); if (port == 0) { port = PortProber.findFreePort(); } if (exe == null) { exe = findDesktopDriverExecutable(); } try { return new WiniumDriverService(exe, port, createArgs(), ImmutableMap.<String, String>of()); } catch (IOException e) { throw new WebDriverException(e); } }
synchronized LocalHub getLocalServerComponent() { if (instance == null) { instance = new LocalHub(); instance.setHost(new NetworkUtils().getIpOfLoopBackIp4()); // Choose a random port for local hub. int hubPort = PortProber.findFreePort(); instance.setPort(hubPort); // Set ConfigProperty.SELENIUM_PORT so that the local nodes can register to it. Config.setConfigProperty(ConfigProperty.SELENIUM_PORT, Integer.toString(hubPort)); LauncherOptions launcherOptions = new LauncherConfiguration() .setFileDownloadCheckTimeStampOnInvocation(false).setFileDownloadCleanupOnInvocation(false); instance.setLauncher(new ThreadedLauncher(new String[] { "-role", "hub", "-port", String.valueOf(instance.getPort()), "-host", instance.getHost() }, launcherOptions)); } return instance; }
synchronized LocalNode getLocalServerComponent() { if (instance == null) { instance = new LocalNode(); instance.setHost(new NetworkUtils().getIpOfLoopBackIp4()); instance.setPort(PortProber.findFreePort()); String hubPort = Config.getConfigProperty(ConfigProperty.SELENIUM_PORT); String hub = String.format("http://%s:%s/grid/register", instance.getHost(), hubPort); setLegacyFFBootupIfRequested(); LauncherOptions launcherOptions = new LauncherConfiguration() .setFileDownloadCheckTimeStampOnInvocation(false).setFileDownloadCleanupOnInvocation(false); List<String> downloadList = determineListOfDownloadsToProcess(); instance.setLauncher(new ThreadedLauncher(new String[] { "-role", "node", "-port", String.valueOf(instance.getPort()), "-proxy", DefaultRemoteProxy.class.getName(), "-host", instance.getHost(), "-hub", hub }, launcherOptions, downloadList)); } return instance; }
int i = 100; while (!generated && (--i > 0)) { newPort = PortProber.findFreePort(); generated = firefoxPorts.add(newPort);
synchronized LocalIOSNode getLocalServerComponent() { if (instance == null) { instance = new LocalIOSNode(); instance.setHost(new NetworkUtils().getIpOfLoopBackIp4()); instance.setPort(PortProber.findFreePort()); String hubPort = Config.getConfigProperty(ConfigProperty.SELENIUM_PORT); String hub = String.format("http://%s:%s/grid/register", instance.getHost(), hubPort); String[] folder = new String[] { "", "" }; String autFolder = Config.getConfigProperty(ConfigProperty.MOBILE_APP_FOLDER); if (StringUtils.isNotEmpty(autFolder)) { folder = new String[] { "-folder", autFolder }; } ProcessLauncherOptions processOptions = new ProcessLauncherConfiguration().setContinuouslyRestart(false) .setIncludeJarsInPresentWorkingDir(false).setIncludeParentProcessClassPath(false) .setIncludeJavaSystemProperties(false).setFileDownloadCheckTimeStampOnInvocation(false) .setFileDownloadCleanupOnInvocation(false); instance.setLauncher(new IOSDriverJarSpawner(new String[] { "-port", String.valueOf(instance.getPort()), "-host", instance.getHost(), "-hub", hub, folder[0], folder[1], "-sessionTimeout", Config.getConfigProperty(ConfigProperty.MOBILE_DRIVER_SESSION_TIMEOUT) }, processOptions)); } return instance; }
instance.setPort(PortProber.findFreePort());