use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testServerWithRedirect308.
/**
* Issue #356: check we change URL if redirect 308 is encountered
*/
@Test(groups = { "ut" })
public void testServerWithRedirect308() {
// connection for HTTP
configureMockedVariableServerConnection();
// connection for HTTPS
configureMockedVariableServerConnection("https://localhost:2345");
HttpResponse<String> response = mock(HttpResponse.class);
when(response.getBody()).thenReturn("Moved Permanently");
when(response.getHeaders()).thenReturn(headers);
when(response.getStatus()).thenReturn(308);
when(responseHttps.getBody()).thenReturn("OK");
when(responseHttps.getStatus()).thenReturn(200);
when(headers.getFirst("Location")).thenReturn("https://localhost:2345");
when(getAliveRequest.asString()).thenReturn(response);
when(getAliveRequestHttps.asString()).thenReturn(responseHttps);
when(unirestInstance.get(SERVER_URL + "/variable/api/")).thenReturn(getAliveRequest);
when(Unirest.get("https://localhost:2345/variable/api/")).thenReturn(getAliveRequestHttps);
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
Assert.assertEquals(connector.getUrl(), "https://localhost:2345");
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testVariableRecreateExistingVariable.
/**
* Variable is re-created when user has changed the value of a non-custom variable
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testVariableRecreateExistingVariable() throws UnirestException {
configureMockedVariableServerConnection();
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
TestVariable existingVariable = new TestVariable(12, "key", "value", false, "key");
TestVariable variable = connector.upsertVariable(existingVariable, true);
PowerMockito.verifyStatic(Unirest.class);
Unirest.post(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
Assert.assertEquals(variable.getValue(), "value");
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testFetchVariableWithNetworkError.
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testFetchVariableWithNetworkError() throws UnirestException {
configureMockedVariableServerConnection();
HttpRequest<HttpRequest> req = createServerMock(SERVER_URL, "GET", SeleniumRobotVariableServerConnector.VARIABLE_API_URL, 200, "{}");
when(req.asString()).thenThrow(UnirestException.class);
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
Map<String, TestVariable> variables = connector.getVariables();
Assert.assertEquals(variables.get("key1").getValue(), "value1");
Assert.assertEquals(variables.get("key2").getValue(), "value2");
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testVariableUpdateExistingVariableWithServerError.
@Test(groups = { "ut" }, expectedExceptions = SeleniumRobotServerException.class)
public void testVariableUpdateExistingVariableWithServerError() throws UnirestException {
configureMockedVariableServerConnection();
createServerMock(SERVER_URL, "PATCH", String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 12), 500, "{}");
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
TestVariable existingVariable = new TestVariable(12, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
connector.upsertVariable(existingVariable, true);
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testServerNotActive.
@Test(groups = { "ut" })
public void testServerNotActive() {
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(false, SERVER_URL, "Test1", null);
Assert.assertFalse(connector.getActive());
}
Aggregations