Fix TokensTest

(cherry picked from commit 32e6bb0)
This commit is contained in:
Vaclav Muzikar 2016-02-16 13:33:30 +01:00
parent 02851989b3
commit c34aa5763d

View file

@ -36,8 +36,8 @@ public class TokensTest extends AbstractRealmTest {
@Page @Page
private TokenSettings tokenSettingsPage; private TokenSettings tokenSettingsPage;
private static final int TIMEOUT = 4; private static final int TIMEOUT = 1;
private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS; private static final TimeUnit TIME_UNIT = TimeUnit.MINUTES;
@Before @Before
public void beforeTokensTest() { public void beforeTokensTest() {
@ -52,7 +52,7 @@ public class TokensTest extends AbstractRealmTest {
tokenSettingsPage.form().save(); tokenSettingsPage.form().save();
loginToTestRealmConsoleAs(testUser); loginToTestRealmConsoleAs(testUser);
TIME_UNIT.sleep(TIMEOUT + 2); waitForTimeout(TIMEOUT + 2);
driver.navigate().refresh(); driver.navigate().refresh();
@ -66,16 +66,22 @@ public class TokensTest extends AbstractRealmTest {
tokenSettingsPage.form().save(); tokenSettingsPage.form().save();
loginToTestRealmConsoleAs(testUser); loginToTestRealmConsoleAs(testUser);
TIME_UNIT.sleep(TIMEOUT / 2); waitForTimeout(TIMEOUT / 2);
driver.navigate().refresh(); driver.navigate().refresh();
assertCurrentUrlStartsWith(testRealmAdminConsolePage); // assert still logged in (within lifespan) assertCurrentUrlStartsWith(testRealmAdminConsolePage); // assert still logged in (within lifespan)
TIME_UNIT.sleep(TIMEOUT / 2 + 2); waitForTimeout(TIMEOUT / 2 + 2);
driver.navigate().refresh(); driver.navigate().refresh();
log.debug(driver.getCurrentUrl()); log.debug(driver.getCurrentUrl());
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage); // assert logged out (lifespan exceeded) assertCurrentUrlStartsWithLoginUrlOf(testRealmPage); // assert logged out (lifespan exceeded)
} }
private void waitForTimeout (int timeout) throws InterruptedException {
log.info("Wait for timeout: " + timeout + " " + TIME_UNIT);
TIME_UNIT.sleep(timeout);
log.info("Timeout reached");
}
} }