use of com.seleniumtests.util.osutility.OSUtilityUnix in project seleniumRobot by bhecquet.
the class TestLinuxOsUtility method testNoBrowserInstalled.
/**
* Check no error is raised when no browser is installed (issue #128)
*/
@Test(groups = { "ut" })
public void testNoBrowserInstalled() {
PowerMockito.mockStatic(OSCommand.class);
PowerMockito.mockStatic(Paths.class);
when(Paths.get("/usr/local/bin/firefox")).thenReturn(path);
when(path.toFile()).thenReturn(browserFile);
when(browserFile.exists()).thenReturn(true);
when(OSCommand.executeCommandAndWait("which firefox")).thenReturn("/usr/bin/which: no firefox in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which iceweasel")).thenReturn("/usr/bin/which: no iceweasel in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which chromium-browser")).thenReturn("/usr/bin/which: no chromium-browser in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which google-chrome")).thenReturn("/usr/bin/which: no google-chrome in (/usr/local/sbin)");
Map<BrowserType, List<BrowserInfo>> browsers = new OSUtilityUnix().discoverInstalledBrowsersWithVersion();
Assert.assertEquals(browsers.size(), 2);
Assert.assertFalse(browsers.containsKey(BrowserType.FIREFOX));
}
use of com.seleniumtests.util.osutility.OSUtilityUnix in project seleniumRobot by bhecquet.
the class TestLinuxOsUtility method testChromeSpecialBinaryInstallation.
@Test(groups = { "ut" })
public void testChromeSpecialBinaryInstallation() {
PowerMockito.mockStatic(OSCommand.class);
PowerMockito.mockStatic(Paths.class);
when(Paths.get("/usr/local/bin/google-chrome")).thenReturn(path);
when(Paths.get("/usr/local/bin/google-chrome-binary")).thenReturn(path);
when(path.toFile()).thenReturn(browserFile);
when(browserFile.exists()).thenReturn(true);
when(OSUtility.getChromeVersion("/usr/local/bin/google-chrome")).thenReturn("Google Chrome 57.0.2987.110");
when(OSUtility.getChromeVersion("/usr/local/bin/google-chrome-binary")).thenReturn("Google Chrome 66.6.6666.666");
when(OSCommand.executeCommandAndWait("which google-chrome")).thenReturn("/usr/local/bin/google-chrome");
when(OSCommand.executeCommandAndWait(new String[] { "/usr/local/bin/google-chrome", "--version" })).thenReturn("Google Chrome 57.0.2987.110");
when(OSCommand.executeCommandAndWait("which firefox")).thenReturn("/usr/bin/which: no firefox in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which iceweasel")).thenReturn("/usr/bin/which: no iceweasel in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which chromium-browser")).thenReturn("/usr/bin/which: no chromium-browser in (/usr/local/sbin)");
SeleniumTestsContextManager.getThreadContext().setAttribute(CHROME_BINARY_PATH, "/usr/local/bin/google-chrome-binary");
OSUtility.resetInstalledBrowsersWithVersion();
SeleniumTestsContextManager.getThreadContext().configureContext(Reporter.getCurrentTestResult());
Map<BrowserType, List<BrowserInfo>> browsersBinary = new OSUtilityUnix().getInstalledBrowsersWithVersion(false);
assertEquals(browsersBinary.size(), 3);
assertEquals(browsersBinary.get(BrowserType.CHROME).size(), 2);
browsersBinary.get(BrowserType.CHROME).get(0).getVersion();
}
use of com.seleniumtests.util.osutility.OSUtilityUnix in project seleniumRobot by bhecquet.
the class TestLinuxOsUtility method testChromeStandardInstallation.
@Test(groups = { "ut" })
public void testChromeStandardInstallation() {
PowerMockito.mockStatic(OSCommand.class);
PowerMockito.mockStatic(Paths.class);
when(Paths.get("/usr/local/bin/google-chrome")).thenReturn(path);
when(path.toFile()).thenReturn(browserFile);
when(browserFile.exists()).thenReturn(true);
when(OSCommand.executeCommandAndWait("which google-chrome")).thenReturn("/usr/local/bin/google-chrome");
when(OSCommand.executeCommandAndWait(new String[] { "google-chrome", "--version" })).thenReturn("Google Chrome 57.0.2987.110");
when(OSCommand.executeCommandAndWait("which firefox")).thenReturn("/usr/bin/which: no firefox in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which iceweasel")).thenReturn("/usr/bin/which: no iceweasel in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which chromium-browser")).thenReturn("/usr/bin/which: no chromium-browser in (/usr/local/sbin)");
Map<BrowserType, List<BrowserInfo>> browsers = new OSUtilityUnix().discoverInstalledBrowsersWithVersion();
assertTrue(browsers.containsKey(BrowserType.CHROME));
}
use of com.seleniumtests.util.osutility.OSUtilityUnix in project seleniumRobot by bhecquet.
the class TestLinuxOsUtility method testFirefoxStandardInstallation.
@Test(groups = { "ut" })
public void testFirefoxStandardInstallation() {
PowerMockito.mockStatic(OSCommand.class);
PowerMockito.mockStatic(Paths.class);
when(Paths.get("/usr/local/bin/firefox")).thenReturn(path);
when(path.toFile()).thenReturn(browserFile);
when(browserFile.exists()).thenReturn(true);
when(OSCommand.executeCommandAndWait("which firefox")).thenReturn("/usr/local/bin/firefox");
when(OSCommand.executeCommandAndWait("firefox --version | more")).thenReturn("Mozilla Firefox 56.0");
when(OSCommand.executeCommandAndWait("which iceweasel")).thenReturn("/usr/bin/which: no iceweasel in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which chromium-browser")).thenReturn("/usr/bin/which: no chromium-browser in (/usr/local/sbin)");
when(OSCommand.executeCommandAndWait("which google-chrome")).thenReturn("/usr/bin/which: no google-chrome in (/usr/local/sbin)");
Map<BrowserType, List<BrowserInfo>> browsers = new OSUtilityUnix().discoverInstalledBrowsersWithVersion();
assertTrue(browsers.containsKey(BrowserType.FIREFOX));
}
use of com.seleniumtests.util.osutility.OSUtilityUnix in project seleniumRobot by bhecquet.
the class TestLinuxOsUtility method testGetProcessPidByListenPort.
@Test(groups = { "ut" })
public void testGetProcessPidByListenPort() {
PowerMockito.mockStatic(OSCommand.class);
when(OSCommand.executeCommandAndWait("netstat -anp")).thenReturn("tcp 0 0 0.0.0.0:48000 0.0.0.0:* LISTEN 1421/nimbus(control\r\n" + "tcp 0 0 0.0.0.0:51239 0.0.0.0:* LISTEN 22492/nimbus(spooler\r\n" + "tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1382/zabbix_agentd\r\n" + "tcp 112 0 10.204.84.149:48624 10.204.90.112:5647 CLOSE_WAIT 1362/python\r\n" + "tcp 112 0 10.204.84.149:48836 10.204.90.112:5647 CLOSE_WAIT 1362/python\r\n" + "tcp6 0 0 10.204.84.149:39436 10.200.42.177:5555 TIME_WAIT -\r\n" + "tcp6 0 0 10.204.84.149:52030 10.200.42.184:5555 TIME_WAIT -\r\n" + "tcp6 0 0 10.204.84.149:60048 10.200.41.38:5555 TIME_WAIT -\r\n" + "udp 0 0 0.0.0.0:68 0.0.0.0:* 1301/dhclient\r\n" + "udp 0 0 0.0.0.0:111 0.0.0.0:* 939/rpcbind\r\n");
Integer processPid = new OSUtilityUnix().getProcessIdByListeningPort(51239);
Assert.assertEquals((Integer) processPid, (Integer) 22492);
}
Aggregations