use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParamKeyAndValuePattern.
/**
* Check we get parameters with pattern on value and key from the thread context
*/
@Test(groups = { "ut" })
public void testParamKeyAndValuePattern() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "barbar"));
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foobar", new TestVariable("foobar", "barbar2"));
Assert.assertEquals(TestTasks.param(Pattern.compile("foo"), Pattern.compile("rba")), "barbar");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParamKeyPatternDoesNotExist.
/**
* Check empty string is returned if parameter is not known
*/
@Test(groups = { "ut" })
public void testParamKeyPatternDoesNotExist() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "bar"));
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "bar_global"));
Assert.assertEquals(TestTasks.param(Pattern.compile("offo")), "");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParamKeyAndValuePatternNoKeyMatching.
/**
* Check no variable matches because of non matching key
*/
@Test(groups = { "ut" })
public void testParamKeyAndValuePatternNoKeyMatching() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "barbar"));
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foobar", new TestVariable("foobar", "barbar2"));
Assert.assertEquals(TestTasks.param(Pattern.compile("ffo"), Pattern.compile("rba")), "");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testParamKeyAndValuePatternNoValueMatching.
/**
* Check no variable matches because of non matching key
*/
@Test(groups = { "ut" })
public void testParamKeyAndValuePatternNoValueMatching() {
SeleniumTestsContextManager.getThreadContext().getConfiguration().put("foofoo", new TestVariable("foofoo", "barbar"));
SeleniumTestsContextManager.getGlobalContext().getConfiguration().put("foobar", new TestVariable("foobar", "barbar2"));
Assert.assertEquals(TestTasks.param(Pattern.compile("foo"), Pattern.compile("rbba")), "");
}
use of com.seleniumtests.core.TestVariable in project seleniumRobot by bhecquet.
the class TestTestTasks method testUpdateReservableVariableWithoutTTL.
/**
* Check error is raised when TTL is not specified ( <= 0) for a reservable variable
* @param testNGCtx
* @param xmlTest
* @throws Exception
*/
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testUpdateReservableVariableWithoutTTL(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);
TestTasks.createOrUpdateParam("key", "value", false, 0, true);
} finally {
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_ACTIVE);
System.clearProperty(SeleniumTestsContext.SELENIUMROBOTSERVER_URL);
}
}
Aggregations