From d869ab28231f697f6956067544e13cd18e519b51 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Thu, 23 Jun 2016 15:48:18 +0200 Subject: [PATCH] Add retry to testPostEncryptedLoginLogout --- .../src/test/java/org/keycloak/testsuite/Retry.java | 8 ++++++-- .../testsuite/keycloaksaml/SamlAdapterTestStrategy.java | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/Retry.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/Retry.java index 441dcac02a..673d4fbb70 100644 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/Retry.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/Retry.java @@ -22,7 +22,7 @@ package org.keycloak.testsuite; */ public class Retry { - public static void execute(Runnable runnable, int retry, long interval) throws InterruptedException { + public static void execute(Runnable runnable, int retry, long interval) { while (true) { try { runnable.run(); @@ -30,7 +30,11 @@ public class Retry { } catch (RuntimeException e) { retry--; if (retry > 0) { - Thread.sleep(interval); + try { + Thread.sleep(interval); + } catch (InterruptedException ie) { + throw new RuntimeException(ie); + } } else { throw e; } diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/keycloaksaml/SamlAdapterTestStrategy.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/keycloaksaml/SamlAdapterTestStrategy.java index 6bbfeabd62..9589fe95d0 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/keycloaksaml/SamlAdapterTestStrategy.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/keycloaksaml/SamlAdapterTestStrategy.java @@ -44,6 +44,7 @@ import org.keycloak.saml.common.constants.JBossSAMLURIConstants; import org.keycloak.saml.processing.core.saml.v2.constants.X500SAMLProfileConstants; import org.keycloak.services.managers.RealmManager; import org.keycloak.testsuite.KeycloakServer; +import org.keycloak.testsuite.Retry; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.rule.AbstractKeycloakRule; import org.keycloak.testsuite.rule.ErrorServlet; @@ -503,7 +504,12 @@ public class SamlAdapterTestStrategy extends ExternalResource { driver.navigate().to(APP_SERVER_BASE_URL + "/sales-post-enc/"); assertAtLoginPagePostBinding(); loginPage.login("bburke", "password"); - assertEquals(driver.getCurrentUrl(), APP_SERVER_BASE_URL + "/sales-post-enc/"); + Retry.execute(new Runnable() { + @Override + public void run() { + assertEquals(driver.getCurrentUrl(), APP_SERVER_BASE_URL + "/sales-post-enc/"); + } + }, 10, 100); Assert.assertTrue(driver.getPageSource().contains("bburke")); driver.navigate().to(APP_SERVER_BASE_URL + "/sales-post-enc?GLO=true"); checkLoggedOut(APP_SERVER_BASE_URL + "/sales-post-enc/", true);