use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testExecuteCommand.
@Test(groups = { "ut" })
public void testExecuteCommand() throws UnsupportedOperationException, IOException {
HttpRequestWithBody req = (HttpRequestWithBody) createServerMock("POST", SeleniumRobotGridConnector.NODE_TASK_SERVLET, 200, "foo");
SeleniumGridConnector connector = new SeleniumRobotGridConnector("http://localhost:4444/wd/hub");
connector.setSessionId(new SessionId("1234"));
connector.setNodeUrl("http://localhost:4321");
Assert.assertEquals(connector.executeCommand("myProcess", "arg1", "arg2"), "foo");
verify(req).queryString("arg0", "arg1");
verify(req).queryString("arg1", "arg2");
verify(req).queryString("name", "myProcess");
verify(req).queryString("action", "command");
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testIsGridActiveWithRobotGridInactive.
/**
* Check that we get false if the grid is INACTIVE
* @throws ClientProtocolException
* @throws IOException
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testIsGridActiveWithRobotGridInactive() throws ClientProtocolException, IOException {
String hubStatus = "{" + "\"http:\\u002f\\u002fnode1.company.com:5555\": {\r\n" + " \"busy\": false,\r\n" + " \"lastSessionStart\": \"2018-08-31T08:30:06Z\",\r\n" + " \"version\": \"3.14.0\",\r\n" + " \"usedTestSlots\": 0,\r\n" + " \"testSlots\": 1,\r\n" + " \"status\": \"INACTIVE\"\r\n" + " },\r\n" + " \"hub\": {\r\n" + " \"version\": \"3.14.0\",\r\n" + " \"status\": \"INACTIVE\"\r\n" + " },\r\n" + " \"success\": true\r\n" + "}";
SeleniumGridConnector connector = new SeleniumRobotGridConnector(SERVER_URL);
createServerMock("GET", SeleniumGridConnector.CONSOLE_SERVLET, 200, "some text");
createServerMock("GET", SeleniumRobotGridConnector.STATUS_SERVLET, 200, hubStatus);
Assert.assertFalse(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testIsGridActiveWithGridInError.
@Test(groups = { "ut" })
public void testIsGridActiveWithGridInError() throws ClientProtocolException, IOException {
SeleniumGridConnector connector = new SeleniumRobotGridConnector(SERVER_URL);
createServerMock("GET", SeleniumGridConnector.CONSOLE_SERVLET, 500, "some text");
Assert.assertFalse(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method testIsGridActiveWithRobotGridActiveWithoutNodes.
/**
* Check that we get false if the grid is ACTIVE and no node is present
* @throws ClientProtocolException
* @throws IOException
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testIsGridActiveWithRobotGridActiveWithoutNodes() throws ClientProtocolException, IOException {
String hubStatus = "{" + " \"hub\": {\r\n" + " \"version\": \"3.14.0\",\r\n" + " \"status\": \"ACTIVE\"\r\n" + " },\r\n" + " \"success\": true\r\n" + "}";
SeleniumGridConnector connector = new SeleniumRobotGridConnector(SERVER_URL);
createServerMock("GET", SeleniumGridConnector.CONSOLE_SERVLET, 200, "some text");
createServerMock("GET", SeleniumRobotGridConnector.STATUS_SERVLET, 200, hubStatus);
Assert.assertFalse(connector.isGridActive());
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotGridConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotGridConnector method init.
@BeforeMethod(groups = { "ut" })
private void init() throws ClientProtocolException, IOException {
PowerMockito.mockStatic(HttpClients.class);
when(HttpClients.createDefault()).thenReturn(client);
when(response.getEntity()).thenReturn(entity);
when(response.getStatusLine()).thenReturn(statusLine);
when(client.execute((HttpHost) any(), any())).thenReturn(response);
connector = new SeleniumRobotGridConnector(SERVER_URL + "/wd/hub");
connector.setNodeUrl("http://localhost:4321");
connector.setSessionId(new SessionId("1234"));
gridLogger = spy(connector.getLogger());
connector.setLogger(gridLogger);
}
Aggregations