use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParamThreadContextNotInitialized.
/**
* Check we look at global context if thread context is not initialized
*/
@Test(groups = { "ut" })
public void testParamThreadContextNotInitialized() {
SeleniumTestsContextManager.setThreadContext(null);
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foo", new TestVariable("foo", "bar2"));
Assert.assertEquals(TestTasks.param("foo"), "bar2");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParamValuePatternThreadContextNotInitialized.
/**
* Check we look at global context if thread context is not initialized
*/
@Test(groups = { "ut" })
public void testParamValuePatternThreadContextNotInitialized() {
SeleniumTestsContextManager.setThreadContext(null);
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foobar", new TestVariable("foobar", "barbar2"));
Assert.assertEquals(TestTasks.param(null, Pattern.compile("rba")), "barbar2");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParamValuePattern.
/**
* Check we get parameters with pattern on value from the thread context
*/
@Test(groups = { "ut" })
public void testParamValuePattern() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "barbar"));
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foobar", new TestVariable("foobar", "barbar2"));
Assert.assertEquals(TestTasks.param(null, Pattern.compile("rba")), "barbar");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParam.
/**
* Check we get parameters from the thread context
*/
@Test(groups = { "ut" })
public void testParam() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foo", new TestVariable("foo", "bar"));
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foo", new TestVariable("foo", "bar2"));
Assert.assertEquals(TestTasks.param("foo"), "bar");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testRecreateExistingVariableIfReservable.
/**
* Check that if variable exists, it's updated, if we do not request it to be reservable
* @param testNGCtx
* @param xmlTest
* @throws Exception
*/
@Test(groups = { "ut" })
public void testRecreateExistingVariableIfReservable(final ITestContext testNGCtx, final XmlTest xmlTest) throws Exception {
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);
TestVariable varToReturn = new TestVariable(10, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
when(variableServer.upsertVariable(any(TestVariable.class), anyBoolean())).thenReturn(varToReturn);
ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
initThreadContext(testNGCtx, "myTest", testResult);
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("key", new TestVariable(10, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key", 2, null));
TestTasks.createOrUpdateParam("key", "value", false, 3, false);
// check upsert has been called
verify(variableServer).upsertVariable(new TestVariable(10, "key", "value", false, "key", 3, null), false);
// check configuration is updated
Assert.assertEquals(SeleniumTestsContextManager.getThreadContext().getConfiguration().get("key"), varToReturn);
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
}
}
Aggregations