Removed Arquillian Drone and Graphene from testsuite
This commit is contained in:
parent
90b3e334ee
commit
b5a9cfc57e
28 changed files with 209 additions and 71 deletions
17
pom.xml
17
pom.xml
|
@ -243,19 +243,12 @@
|
|||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-drone-bom</artifactId>
|
||||
<version>1.2.0.Beta1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.graphene</groupId>
|
||||
<artifactId>graphene-webdriver</artifactId>
|
||||
<type>pom</type>
|
||||
<version>2.0.0.Beta1</version>
|
||||
</dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>2.26.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.keycloak.services.models.UserModel.RequiredAction;
|
|||
import org.picketlink.idm.model.sample.Realm;
|
||||
|
||||
import javax.imageio.spi.ServiceRegistry;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
|
@ -127,7 +128,7 @@ public class FormFlows {
|
|||
while (itr.hasNext()) {
|
||||
FormService provider = itr.next();
|
||||
if (provider.getId().equals("FormServiceId"))
|
||||
return Response.status(200).entity(provider.process(template, formDataBean)).build();
|
||||
return Response.status(200).type(MediaType.TEXT_HTML).entity(provider.process(template, formDataBean)).build();
|
||||
}
|
||||
|
||||
return Response.status(200).entity("form provider not found").build();
|
||||
|
|
|
@ -119,17 +119,10 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-drone-webdriver-depchain</artifactId>
|
||||
<type>pom</type>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.graphene</groupId>
|
||||
<artifactId>graphene-webdriver</artifactId>
|
||||
<type>pom</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.shrinkwrap.resolver</groupId>
|
||||
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
|
||||
|
|
|
@ -22,13 +22,15 @@
|
|||
package org.keycloak.testsuite;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.keycloak.testsuite.pages.AppPage;
|
||||
import org.keycloak.testsuite.pages.LoginPage;
|
||||
import org.keycloak.testsuite.pages.RegisterPage;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
import org.keycloak.testsuite.rule.WebRule;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
/**
|
||||
|
@ -46,11 +48,14 @@ public abstract class AbstractDroneTest {
|
|||
return Deployments.deployment();
|
||||
}
|
||||
|
||||
@Rule
|
||||
public WebRule webRule = new WebRule(this);
|
||||
|
||||
@Page
|
||||
protected AppPage appPage;
|
||||
|
||||
@Drone
|
||||
protected WebDriver browser;
|
||||
@Driver
|
||||
protected WebDriver driver;
|
||||
|
||||
@Page
|
||||
protected LoginPage loginPage;
|
||||
|
@ -64,7 +69,7 @@ public abstract class AbstractDroneTest {
|
|||
if (appPage.isCurrent()) {
|
||||
appPage.logout();
|
||||
}
|
||||
browser.manage().deleteAllCookies();
|
||||
driver.manage().deleteAllCookies();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
*/
|
||||
package org.keycloak.testsuite;
|
||||
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.keycloak.testsuite.pages.ChangePasswordPage;
|
||||
import org.keycloak.testsuite.pages.UpdateProfilePage;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
|
|
|
@ -56,7 +56,6 @@ public class LoginTest extends AbstractDroneTest {
|
|||
public void loginSuccess() {
|
||||
appPage.open();
|
||||
|
||||
Assert.assertTrue(loginPage.isCurrent());
|
||||
loginPage.login("bburke@redhat.com", "password");
|
||||
|
||||
Assert.assertTrue(appPage.isCurrent());
|
||||
|
|
|
@ -29,8 +29,6 @@ import javax.mail.MessagingException;
|
|||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
@ -42,6 +40,10 @@ import org.junit.runner.RunWith;
|
|||
import org.keycloak.testsuite.pages.AppPage;
|
||||
import org.keycloak.testsuite.pages.LoginPage;
|
||||
import org.keycloak.testsuite.pages.RegisterPage;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.keycloak.testsuite.rule.GreenMailRule;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
import org.keycloak.testsuite.rule.WebRule;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
/**
|
||||
|
@ -66,11 +68,14 @@ public class RequiredActionEmailVerificationTest {
|
|||
.addAsWebInfResource("web-properties-email-verfication.xml", "web.xml");
|
||||
}
|
||||
|
||||
@Rule
|
||||
public WebRule webRule = new WebRule(this);
|
||||
|
||||
@Page
|
||||
protected AppPage appPage;
|
||||
|
||||
@Drone
|
||||
protected WebDriver browser;
|
||||
@Driver
|
||||
protected WebDriver driver;
|
||||
|
||||
@Page
|
||||
protected LoginPage loginPage;
|
||||
|
@ -96,7 +101,7 @@ public class RequiredActionEmailVerificationTest {
|
|||
loginPage.register();
|
||||
registerPage.register("name", "email", "verifyEmail", "password", "password");
|
||||
|
||||
Assert.assertTrue(browser.getPageSource().contains("Verify email"));
|
||||
Assert.assertTrue(driver.getPageSource().contains("Verify email"));
|
||||
|
||||
MimeMessage message = greenMail.getReceivedMessages()[0];
|
||||
|
||||
|
@ -108,7 +113,7 @@ public class RequiredActionEmailVerificationTest {
|
|||
|
||||
String verificationUrl = m.group(1);
|
||||
|
||||
browser.navigate().to(verificationUrl.trim());
|
||||
driver.navigate().to(verificationUrl.trim());
|
||||
|
||||
Assert.assertTrue(appPage.isCurrent());
|
||||
Assert.assertEquals("verifyEmail", appPage.getUser());
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package org.keycloak.testsuite;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
@ -33,6 +32,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.keycloak.testsuite.pages.LoginPasswordUpdatePage;
|
||||
import org.keycloak.testsuite.pages.LoginUpdateProfilePage;
|
||||
import org.keycloak.testsuite.rule.GreenMailRule;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package org.keycloak.testsuite;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
@ -31,6 +30,8 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.keycloak.testsuite.pages.LoginPasswordUpdatePage;
|
||||
import org.keycloak.testsuite.rule.GreenMailRule;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
|
|
|
@ -24,19 +24,21 @@ package org.keycloak.testsuite;
|
|||
import java.net.MalformedURLException;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.keycloak.testsuite.pages.AppPage;
|
||||
import org.keycloak.testsuite.pages.LoginConfigTotpPage;
|
||||
import org.keycloak.testsuite.pages.LoginPage;
|
||||
import org.keycloak.testsuite.pages.RegisterPage;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
import org.keycloak.testsuite.rule.WebRule;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.picketlink.idm.credential.util.TimeBasedOTP;
|
||||
|
||||
|
@ -56,11 +58,14 @@ public class RequiredActionTotpSetupTest {
|
|||
return Deployments.deployment().addAsResource("testrealm-totp.json", "META-INF/testrealm.json");
|
||||
}
|
||||
|
||||
@Rule
|
||||
public WebRule webRule = new WebRule(this);
|
||||
|
||||
@Page
|
||||
protected AppPage appPage;
|
||||
|
||||
@Drone
|
||||
protected WebDriver browser;
|
||||
@Driver
|
||||
protected WebDriver driver;
|
||||
|
||||
@Page
|
||||
protected LoginConfigTotpPage totpPage;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package org.keycloak.testsuite;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
@ -31,6 +30,8 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.keycloak.testsuite.pages.LoginUpdateProfilePage;
|
||||
import org.keycloak.testsuite.rule.GreenMailRule;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.mail.MessagingException;
|
|||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
@ -37,6 +36,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.keycloak.testsuite.pages.LoginPasswordResetPage;
|
||||
import org.keycloak.testsuite.pages.LoginPasswordUpdatePage;
|
||||
import org.keycloak.testsuite.rule.GreenMailRule;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
|
@ -80,7 +81,7 @@ public class ResetPasswordTest extends AbstractDroneTest {
|
|||
String body = (String) message.getContent();
|
||||
String changePasswordUrl = body.split("\n")[0];
|
||||
|
||||
browser.navigate().to(changePasswordUrl.trim());
|
||||
driver.navigate().to(changePasswordUrl.trim());
|
||||
|
||||
Assert.assertTrue(updatePasswordPage.isCurrent());
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ package org.keycloak.testsuite;
|
|||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -31,6 +30,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.keycloak.testsuite.pages.LoginTotpPage;
|
||||
import org.keycloak.testsuite.pages.TotpPage;
|
||||
import org.keycloak.testsuite.rule.Page;
|
||||
import org.picketlink.idm.credential.util.TimeBasedOTP;
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,7 @@ public class TotpTest extends AbstractDroneTest {
|
|||
|
||||
totpPage.configure(totp.generate(totpPage.getTotpSecret()));
|
||||
|
||||
Assert.assertTrue(browser.getPageSource().contains("Google Authenticator enabled"));
|
||||
Assert.assertTrue(driver.getPageSource().contains("Google Authenticator enabled"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.Constants;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
@ -10,7 +10,7 @@ public class AppPage {
|
|||
|
||||
private static String PATH = Constants.APP_ROOT + "/user.jsp";
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "logout")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.Constants;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
@ -10,7 +10,7 @@ public class ChangePasswordPage {
|
|||
|
||||
private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/demo/account/password";
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "password")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.Constants;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
@ -10,7 +10,7 @@ public class LoginConfigTotpPage {
|
|||
|
||||
private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/demo/account/totp";
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "totpSecret")
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class LoginPage {
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "username")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.Constants;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
@ -10,7 +10,7 @@ public class LoginPasswordResetPage {
|
|||
|
||||
private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/demo/account/password";
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "username")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.Constants;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
@ -10,7 +10,7 @@ public class LoginPasswordUpdatePage {
|
|||
|
||||
private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/demo/account/password";
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "password-new")
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class LoginTotpPage {
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "totp")
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class LoginUpdateProfilePage {
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "firstName")
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class RegisterPage {
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "name")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.Constants;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
@ -10,7 +10,7 @@ public class TotpPage {
|
|||
|
||||
private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/demo/account/totp";
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "totpSecret")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.keycloak.testsuite.pages;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.keycloak.testsuite.Constants;
|
||||
import org.keycloak.testsuite.rule.Driver;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
@ -10,7 +10,7 @@ public class UpdateProfilePage {
|
|||
|
||||
private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/demo/account";
|
||||
|
||||
@Drone
|
||||
@Driver
|
||||
private WebDriver browser;
|
||||
|
||||
@FindBy(id = "firstName")
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package org.keycloak.testsuite.rule;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Driver {
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.keycloak.testsuite;
|
||||
package org.keycloak.testsuite.rule;
|
||||
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.net.SocketException;
|
|
@ -0,0 +1,12 @@
|
|||
package org.keycloak.testsuite.rule;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Page {
|
||||
|
||||
}
|
109
testsuite/src/test/java/org/keycloak/testsuite/rule/WebRule.java
Normal file
109
testsuite/src/test/java/org/keycloak/testsuite/rule/WebRule.java
Normal file
|
@ -0,0 +1,109 @@
|
|||
package org.keycloak.testsuite.rule;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.junit.rules.ExternalResource;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
|
||||
public class WebRule extends ExternalResource {
|
||||
|
||||
private WebDriver driver;
|
||||
private Object test;
|
||||
|
||||
public WebRule(Object test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void before() throws Throwable {
|
||||
String browser = "htmlunit";
|
||||
if (System.getProperty("browser") != null) {
|
||||
browser = System.getProperty("browser");
|
||||
}
|
||||
|
||||
if (browser.equals("htmlunit")) {
|
||||
HtmlUnitDriver d = new HtmlUnitDriver();
|
||||
d.getWebClient().setCssEnabled(false);
|
||||
driver = d;
|
||||
} else if (browser.equals("chrome")) {
|
||||
driver = new ChromeDriver();
|
||||
} else if (browser.equals("firefox")) {
|
||||
driver = new FirefoxDriver();
|
||||
} else {
|
||||
throw new RuntimeException("Unsupported browser " + browser);
|
||||
}
|
||||
|
||||
initDriver(test);
|
||||
initPages(test);
|
||||
}
|
||||
|
||||
protected void initDriver(Object o) {
|
||||
Class<?> c = o.getClass();
|
||||
while (c != null) {
|
||||
for (Field f : c.getDeclaredFields()) {
|
||||
if (f.getAnnotation(Driver.class) != null) {
|
||||
set(f, o, driver);
|
||||
}
|
||||
}
|
||||
|
||||
c = c.getSuperclass();
|
||||
}
|
||||
}
|
||||
|
||||
protected void initPages(Object o) {
|
||||
Class<?> c = o.getClass();
|
||||
while (c != null) {
|
||||
for (Field f : c.getDeclaredFields()) {
|
||||
if (f.getAnnotation(Page.class) != null) {
|
||||
set(f, o, getPage(f.getType()));
|
||||
}
|
||||
}
|
||||
|
||||
c = c.getSuperclass();
|
||||
}
|
||||
}
|
||||
|
||||
protected void set(Field f, Object o, Object v) {
|
||||
f.setAccessible(true);
|
||||
try {
|
||||
f.set(o, v);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public WebDriver getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public <T> T getPage(Class<T> pageClass) {
|
||||
try {
|
||||
T instance = pageClass.newInstance();
|
||||
initDriver(instance);
|
||||
PageFactory.initElements(driver, instance);
|
||||
return instance;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void after() {
|
||||
driver.close();
|
||||
}
|
||||
|
||||
public class HtmlUnitDriver extends org.openqa.selenium.htmlunit.HtmlUnitDriver {
|
||||
|
||||
@Override
|
||||
public WebClient getWebClient() {
|
||||
return super.getWebClient();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue