use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext3 method testVariablesAreGetOnlyOnce.
/**
* Check that if we request variable configuration several times, seleniumRobot
* server is called only once to avoid problems with variable reservation
*
* @param testNGCtx
* @param xmlTest
* @throws Exception
*/
@Test(groups = { "ut" })
public void testVariablesAreGetOnlyOnce(final ITestContext testNGCtx, final XmlTest xmlTest) throws Exception {
Map<String, TestVariable> variables = new HashMap<>();
variables.put("key", new TestVariable("key", "val1"));
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:1234");
PowerMockito.whenNew(SeleniumRobotVariableServerConnector.class).withArguments(eq(true), eq("http://localhost:1234"), anyString(), eq(null)).thenReturn(variableServer);
when(variableServer.isAlive()).thenReturn(true);
when(variableServer.getVariables(0)).thenReturn(variables);
ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
initThreadContext(testNGCtx, "myTest", testResult);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
// do a second parameter retrieving
seleniumTestsCtx.setTestConfiguration();
Assert.assertEquals(seleniumTestsCtx.getConfiguration().get("key").getValue(), "val1");
verify(variableServer).getVariables(0);
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
}
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext3 method testVariablesAreGetOnlyOnceWithContextCopy.
/**
* Check that when copying context, it's possible to prevent it to retrieve
* variables from server
*
* @param testNGCtx
* @param xmlTest
* @throws Exception
*/
@Test(groups = { "ut" })
public void testVariablesAreGetOnlyOnceWithContextCopy(final ITestContext testNGCtx, final XmlTest xmlTest) throws Exception {
Map<String, TestVariable> variables = new HashMap<>();
variables.put("key", new TestVariable("key", "val1"));
try {
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE, "true");
System.setProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL, "http://localhost:1234");
PowerMockito.whenNew(SeleniumRobotVariableServerConnector.class).withArguments(eq(true), eq("http://localhost:1234"), anyString(), eq(null)).thenReturn(variableServer);
when(variableServer.isAlive()).thenReturn(true);
when(variableServer.getVariables(0)).thenReturn(variables);
ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
initThreadContext(testNGCtx, "myTest", testResult);
SeleniumTestsContext seleniumTestsCtx = SeleniumTestsContextManager.getThreadContext();
// do a parameter retrieving for copied context
SeleniumTestsContext seleniumTestsCtx2 = new SeleniumTestsContext(seleniumTestsCtx, false);
seleniumTestsCtx2.configureContext(testResult);
// check that variables are kept even if variable server has not been re-called
Assert.assertEquals(seleniumTestsCtx2.getConfiguration().get("key").getValue(), "val1");
// only one call, done by first context init, further retrieving is forbidden
verify(variableServer).getVariables(0);
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
}
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testBugtrackerPasswordFromVariable.
@Test(groups = "ut context")
public void testBugtrackerPasswordFromVariable(final ITestContext testNGCtx, final XmlTest xmlTest) {
initThreadContext(testNGCtx);
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("bugtrackerPassword", new TestVariable("bugtrackerPassword", "pwd"));
Assert.assertEquals(SeleniumTestsContextManager.getThreadContext().getBugtrackerPassword(), "pwd");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testBugtrackerProjectFromVariable.
@Test(groups = "ut context")
public void testBugtrackerProjectFromVariable(final ITestContext testNGCtx, final XmlTest xmlTest) {
initThreadContext(testNGCtx);
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("bugtrackerProject", new TestVariable("bugtrackerProject", "project"));
Assert.assertEquals(SeleniumTestsContextManager.getThreadContext().getBugtrackerProject(), "project");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestSeleniumTestContext method testBugtrackerUserFromVariable.
@Test(groups = "ut context")
public void testBugtrackerUserFromVariable(final ITestContext testNGCtx, final XmlTest xmlTest) {
initThreadContext(testNGCtx);
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("bugtrackerUser", new TestVariable("bugtrackerUser", "user"));
Assert.assertEquals(SeleniumTestsContextManager.getThreadContext().getBugtrackerUser(), "user");
}
Aggregations