diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-11-23 00:06:51 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-11-28 12:22:39 +0100 |
commit | 19f395b89f54e4c0d7ae48582a3cf16fc24112a0 (patch) | |
tree | b3fa2ce18173ec73019fae9632b2490aff850959 | |
parent | 8317bd274770995c0981f03afa287c4d99123004 (diff) | |
download | sonarqube-19f395b89f54e4c0d7ae48582a3cf16fc24112a0.tar.gz sonarqube-19f395b89f54e4c0d7ae48582a3cf16fc24112a0.zip |
Simplify launch of Selenese tests
34 files changed, 287 insertions, 386 deletions
diff --git a/it/it-tests/src/test/java/it/administration/UsersPageTest.java b/it/it-tests/src/test/java/it/administration/UsersPageTest.java index 54b5e60b3cc..b89f0301662 100644 --- a/it/it-tests/src/test/java/it/administration/UsersPageTest.java +++ b/it/it-tests/src/test/java/it/administration/UsersPageTest.java @@ -20,11 +20,11 @@ package it.administration; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; +import util.selenium.Selenese; import it.Category1Suite; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; + public class UsersPageTest { @@ -33,17 +33,11 @@ public class UsersPageTest { @Test public void generate_and_revoke_user_token() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("generate_and_revoke_user_token", - "/administration/UsersPageTest/generate_and_revoke_user_token.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + Selenese.runSelenese(orchestrator, "/administration/UsersPageTest/generate_and_revoke_user_token.html"); } @Test public void admin_should_change_its_own_password() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("admin_should_change_its_own_password", - "/administration/UsersPageTest/admin_should_change_its_own_password.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + Selenese.runSelenese(orchestrator, "/administration/UsersPageTest/admin_should_change_its_own_password.html"); } } diff --git a/it/it-tests/src/test/java/it/authorisation/PermissionTemplatesPageTest.java b/it/it-tests/src/test/java/it/authorisation/PermissionTemplatesPageTest.java index 965ea125b61..7b3c405988a 100644 --- a/it/it-tests/src/test/java/it/authorisation/PermissionTemplatesPageTest.java +++ b/it/it-tests/src/test/java/it/authorisation/PermissionTemplatesPageTest.java @@ -20,11 +20,11 @@ package it.authorisation; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; + +import static util.selenium.Selenese.runSelenese; public class PermissionTemplatesPageTest { @@ -33,18 +33,13 @@ public class PermissionTemplatesPageTest { @Test public void should_display_page() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_display_page", + runSelenese(orchestrator, "/authorisation/PermissionTemplatesPageTest/should_display_page.html", - "/authorisation/PermissionTemplatesPageTest/should_create.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/authorisation/PermissionTemplatesPageTest/should_create.html"); } @Test public void should_manage_project_creators() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_manage_project_creators", - "/authorisation/PermissionTemplatesPageTest/should_manage_project_creators.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/authorisation/PermissionTemplatesPageTest/should_manage_project_creators.html"); } } diff --git a/it/it-tests/src/test/java/it/authorisation/ProvisioningPermissionTest.java b/it/it-tests/src/test/java/it/authorisation/ProvisioningPermissionTest.java index 93181867fa3..231edba99be 100644 --- a/it/it-tests/src/test/java/it/authorisation/ProvisioningPermissionTest.java +++ b/it/it-tests/src/test/java/it/authorisation/ProvisioningPermissionTest.java @@ -20,7 +20,6 @@ package it.authorisation; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -37,11 +36,11 @@ import org.sonarqube.ws.client.permission.AddUserWsRequest; import org.sonarqube.ws.client.permission.PermissionsService; import org.sonarqube.ws.client.permission.RemoveGroupWsRequest; import org.sonarqube.ws.client.permission.RemoveUserWsRequest; -import util.selenium.SeleneseTest; import util.user.UserRule; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.newAdminWsClient; +import static util.selenium.Selenese.runSelenese; public class ProvisioningPermissionTest { @@ -97,8 +96,7 @@ public class ProvisioningPermissionTest { */ @Test public void should_not_be_able_to_provision_project() { - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("should-not-be-able-to-provision-project", - "/authorisation/ProvisioningPermissionTest/should-not-be-able-to-provision-project.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/authorisation/ProvisioningPermissionTest/should-not-be-able-to-provision-project.html"); } /** @@ -107,8 +105,7 @@ public class ProvisioningPermissionTest { */ @Test public void should_be_able_to_provision_project() { - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("should-be-able-to-provision-project", - "/authorisation/ProvisioningPermissionTest/should-be-able-to-provision-project.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/authorisation/ProvisioningPermissionTest/should-be-able-to-provision-project.html"); } /** diff --git a/it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java b/it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java index befe2c242a2..0e06125ff40 100644 --- a/it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java +++ b/it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java @@ -20,7 +20,6 @@ package it.authorisation; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -32,6 +31,7 @@ import util.user.UserRule; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.runProjectAnalysis; +import static util.selenium.Selenese.runSelenese; /** * SONAR-4210 @@ -44,7 +44,7 @@ public class QualityProfileAdminPermissionTest { @ClassRule public static UserRule userRule = UserRule.from(orchestrator); - static PermissionsService permissionsWsClient; + private static PermissionsService permissionsWsClient; @BeforeClass public static void init() { @@ -64,12 +64,11 @@ public class QualityProfileAdminPermissionTest { userRule.createUser("profileadm", "papwd"); permissionsWsClient.addUser(new AddUserWsRequest().setLogin("profileadm").setPermission("profileadmin")); - orchestrator.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("administrate-profiles", + runSelenese(orchestrator, // Verify normal user is not allowed to do any modification "/authorisation/QualityProfileAdminPermissionTest/normal-user.html", // Verify profile admin is allowed to do modifications - "/authorisation/QualityProfileAdminPermissionTest/profile-admin.html" - ).build()); + "/authorisation/QualityProfileAdminPermissionTest/profile-admin.html"); } } diff --git a/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsOnRemoveFileTest.java b/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsOnRemoveFileTest.java index 45741d2a18e..3c063cb4a37 100644 --- a/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsOnRemoveFileTest.java +++ b/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsOnRemoveFileTest.java @@ -21,18 +21,17 @@ package it.duplication; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.locator.FileLocation; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import org.apache.commons.io.IOUtils; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.sonar.wsclient.services.ResourceQuery; -import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; import static util.ItUtils.runProjectAnalysis; +import static util.selenium.Selenese.runSelenese; public class CrossProjectDuplicationsOnRemoveFileTest { @@ -75,11 +74,8 @@ public class CrossProjectDuplicationsOnRemoveFileTest { @Test public void display_message_in_viewer_when_duplications_with_deleted_files_are_found() throws Exception { // TODO stas, please replace this IT by a medium test - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("duplications-on-deleted-project", - "/duplication/CrossProjectDuplicationsOnRemoveFileTest/duplications-with-deleted-project.html") - .build()) - .runOn(orchestrator); + runSelenese(orchestrator, + "/duplication/CrossProjectDuplicationsOnRemoveFileTest/duplications-with-deleted-project.html"); } private static void analyzeProject(String projectKey, String path) { diff --git a/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsTest.java b/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsTest.java index 29c666d0433..88702941d78 100644 --- a/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsTest.java +++ b/it/it-tests/src/test/java/it/duplication/CrossProjectDuplicationsTest.java @@ -22,7 +22,6 @@ package it.duplication; import com.google.common.collect.ObjectArrays; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.locator.FileLocation; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import java.util.List; import org.apache.commons.io.IOUtils; @@ -34,12 +33,12 @@ import org.sonar.wsclient.issue.Issue; import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.services.Resource; import org.sonar.wsclient.services.ResourceQuery; -import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; import static util.ItUtils.runProjectAnalysis; import static util.ItUtils.setServerProperty; +import static util.selenium.Selenese.runSelenese; public class CrossProjectDuplicationsTest { @@ -127,11 +126,7 @@ public class CrossProjectDuplicationsTest { @Test public void verify_viewer() { - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("duplications-viewer", - "/duplication/CrossProjectDuplicationsTest/cross-project-duplications-viewer.html") - .build()) - .runOn(orchestrator); + runSelenese(orchestrator, "/duplication/CrossProjectDuplicationsTest/cross-project-duplications-viewer.html"); } private static void analyzeProject(String projectKey, String path, String... additionalProperties) { diff --git a/it/it-tests/src/test/java/it/duplication/DuplicationsTest.java b/it/it-tests/src/test/java/it/duplication/DuplicationsTest.java index 7858b83fd0e..18e2d20d498 100644 --- a/it/it-tests/src/test/java/it/duplication/DuplicationsTest.java +++ b/it/it-tests/src/test/java/it/duplication/DuplicationsTest.java @@ -22,7 +22,6 @@ package it.duplication; import com.google.common.collect.ObjectArrays; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.locator.FileLocation; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import java.util.List; import org.apache.commons.io.IOUtils; @@ -34,7 +33,6 @@ import org.sonar.wsclient.issue.Issue; import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.services.Resource; import org.sonar.wsclient.services.ResourceQuery; -import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; diff --git a/it/it-tests/src/test/java/it/i18n/I18nTest.java b/it/it-tests/src/test/java/it/i18n/I18nTest.java index 58b2b509f3d..f286aca1c72 100644 --- a/it/it-tests/src/test/java/it/i18n/I18nTest.java +++ b/it/it-tests/src/test/java/it/i18n/I18nTest.java @@ -21,15 +21,14 @@ package it.i18n; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.Before; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class I18nTest { @@ -51,13 +50,12 @@ public class I18nTest { public void test_localization() { orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("ui-i18n", + runSelenese(orchestrator, "/i18n/default-locale-is-english.html", "/i18n/french-locale.html", "/i18n/french-pack.html", "/i18n/locale-with-france-country.html", - "/i18n/locale-with-swiss-country.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/i18n/locale-with-swiss-country.html"); } } diff --git a/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java b/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java index efdd3c28bf6..666909345a9 100644 --- a/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java +++ b/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java @@ -20,7 +20,6 @@ package it.issue; import com.sonar.orchestrator.locator.FileLocation; -import com.sonar.orchestrator.selenium.Selenese; import java.util.Iterator; import javax.mail.internet.MimeMessage; import org.junit.AfterClass; @@ -35,13 +34,13 @@ import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.issue.Issues; import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; -import util.selenium.SeleneseTest; import util.user.UserRule; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.resetEmailSettings; import static util.ItUtils.runProjectAnalysis; import static util.ItUtils.setServerProperty; +import static util.selenium.Selenese.runSelenese; public class IssueNotificationsTest extends AbstractIssueTest { @@ -71,11 +70,9 @@ public class IssueNotificationsTest extends AbstractIssueTest { // 1. Check that SMTP server was turned on and able to send test email // 2. Create user, which will receive notifications for new violations - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("issue-notifications", - "/issue/IssueNotificationsTest/email_configuration.html", - "/issue/IssueNotificationsTest/user_notifications_settings.html").build() - ).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, + "/issue/IssueNotificationsTest/email_configuration.html", + "/issue/IssueNotificationsTest/user_notifications_settings.html"); // We need to wait until all notifications will be delivered waitUntilAllNotificationsAreDelivered(); diff --git a/it/it-tests/src/test/java/it/issue/IssueSearchTest.java b/it/it-tests/src/test/java/it/issue/IssueSearchTest.java index 7611e5fa5dc..56e562bd2aa 100644 --- a/it/it-tests/src/test/java/it/issue/IssueSearchTest.java +++ b/it/it-tests/src/test/java/it/issue/IssueSearchTest.java @@ -21,7 +21,6 @@ package it.issue; import com.google.common.collect.Iterables; import com.sonar.orchestrator.locator.FileLocation; -import com.sonar.orchestrator.selenium.Selenese; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Collection; @@ -29,7 +28,7 @@ import java.util.Date; import java.util.List; import org.apache.commons.lang.time.DateUtils; import org.assertj.core.api.Fail; -import org.junit.After; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.sonar.wsclient.base.HttpException; @@ -40,7 +39,6 @@ import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.issue.Issues; import org.sonarqube.ws.Common; import org.sonarqube.ws.client.issue.SearchWsRequest; -import util.selenium.SeleneseTest; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -52,6 +50,7 @@ import static util.ItUtils.runProjectAnalysis; import static util.ItUtils.setServerProperty; import static util.ItUtils.toDate; import static util.ItUtils.verifyHttpException; +import static util.selenium.Selenese.runSelenese; public class IssueSearchTest extends AbstractIssueTest { @@ -83,9 +82,9 @@ public class IssueSearchTest extends AbstractIssueTest { adminIssueClient().doTransition(searchRandomIssue().key(), "resolve"); } - @After + @Before public void resetProperties() throws Exception { - setServerProperty(ORCHESTRATOR, "sonar.forceAuthentication", null); + setServerProperty(ORCHESTRATOR, "sonar.forceAuthentication", "false"); } @Test @@ -281,9 +280,7 @@ public class IssueSearchTest extends AbstractIssueTest { public void redirect_to_search_url_after_wrong_login() { // Force user authentication to check login on the issues search page setServerProperty(ORCHESTRATOR, "sonar.forceAuthentication", "true"); - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("redirect_to_search_url_after_wrong_login", - "/issue/IssueSearchTest/redirect_to_search_url_after_wrong_login.html" // SONAR-5659 - ).build()).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, "/issue/IssueSearchTest/redirect_to_search_url_after_wrong_login.html"); } @Test @@ -313,9 +310,7 @@ public class IssueSearchTest extends AbstractIssueTest { @Test public void bulk_change() { - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("bulk_change", - "/issue/IssueSearchTest/bulk_change.html" - ).build()).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, "/issue/IssueSearchTest/bulk_change.html"); } private List<org.sonarqube.ws.Issues.Issue> searchByRuleKey(String... ruleKey) throws IOException { diff --git a/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java b/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java index c7e849c441d..223b96cf4e8 100644 --- a/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java +++ b/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java @@ -21,7 +21,6 @@ package it.measure; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.Before; import org.junit.ClassRule; @@ -29,11 +28,11 @@ import org.junit.Ignore; import org.junit.Test; import pageobjects.Navigation; import pageobjects.ProjectDashboardPage; -import util.selenium.SeleneseTest; import static com.codeborne.selenide.Condition.hasText; import static com.codeborne.selenide.Condition.text; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class ProjectDashboardTest { @@ -49,10 +48,7 @@ public class ProjectDashboardTest { public void after_first_analysis() throws Exception { executeBuild("shared/xoo-sample", "project-for-overview", "Project For Overview"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("after_first_analysis", - "/measure/ProjectDashboardTest/test_project_overview_after_first_analysis.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/measure/ProjectDashboardTest/test_project_overview_after_first_analysis.html"); } @Test diff --git a/it/it-tests/src/test/java/it/measure/ProjectMeasuresPageTest.java b/it/it-tests/src/test/java/it/measure/ProjectMeasuresPageTest.java index 461ed496c7c..77058755bc0 100644 --- a/it/it-tests/src/test/java/it/measure/ProjectMeasuresPageTest.java +++ b/it/it-tests/src/test/java/it/measure/ProjectMeasuresPageTest.java @@ -21,14 +21,13 @@ package it.measure; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class ProjectMeasuresPageTest { @@ -55,26 +54,17 @@ public class ProjectMeasuresPageTest { @Test public void should_display_measures_page() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_display_measures_page", - "/measure/ProjectMeasuresPageTest/should_display_measures_page.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/measure/ProjectMeasuresPageTest/should_display_measures_page.html"); } @Test public void should_drilldown_on_list_view() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_drilldown_on_list_view", - "/measure/ProjectMeasuresPageTest/should_drilldown_on_list_view.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/measure/ProjectMeasuresPageTest/should_drilldown_on_list_view.html"); } @Test public void should_drilldown_on_tree_view() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_drilldown_on_tree_view", - "/measure/ProjectMeasuresPageTest/should_drilldown_on_tree_view.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/measure/ProjectMeasuresPageTest/should_drilldown_on_tree_view.html"); } } diff --git a/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java b/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java index 0d66bab19a2..23cc9c98748 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/BackgroundTasksTest.java @@ -21,7 +21,6 @@ package it.projectAdministration; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -30,10 +29,10 @@ import org.junit.Test; import pageobjects.BackgroundTaskItem; import pageobjects.BackgroundTasksPage; import pageobjects.Navigation; -import util.selenium.SeleneseTest; import static com.codeborne.selenide.CollectionCondition.sizeGreaterThan; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class BackgroundTasksTest { @@ -51,10 +50,8 @@ public class BackgroundTasksTest { @Test public void should_not_display_failing_and_search_and_filter_elements_on_project_level_page() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_not_display_failing_and_search_and_filter_elements_on_project_level_page", - "/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html" - ).build(); - new SeleneseTest(selenese).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, + "/projectAdministration/BackgroundTasksTest/should_not_display_failing_and_search_and_filter_elements_on_project_level_page.html"); } @Test diff --git a/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java b/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java index d407b659bf7..0a548c26358 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/BulkDeletionTest.java @@ -21,14 +21,13 @@ package it.projectAdministration; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class BulkDeletionTest { @@ -50,18 +49,14 @@ public class BulkDeletionTest { executeBuild("cameleon-2", "Foo-Application"); executeBuild("cameleon-3", "Bar-Sonar-Plugin"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("project-bulk-deletion-on-selected-project", - "/projectAdministration/BulkDeletionTest/bulk-delete-filter-projects.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/projectAdministration/BulkDeletionTest/bulk-delete-filter-projects.html"); } private void executeBuild(String projectKey, String projectName) { orchestrator.executeBuild( SonarScanner.create(projectDir("shared/xoo-sample")) .setProjectKey(projectKey) - .setProjectName(projectName) - ); + .setProjectName(projectName)); } } diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java index 5026725cbc8..4b81dfcf670 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java @@ -21,7 +21,6 @@ package it.projectAdministration; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import java.io.UnsupportedEncodingException; import java.sql.SQLException; @@ -39,10 +38,10 @@ import org.sonar.wsclient.services.ResourceQuery; import org.sonar.wsclient.user.UserParameters; import pageobjects.Navigation; import pageobjects.settings.SettingsPage; -import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class ProjectAdministrationTest { private static final String DELETE_WS_ENDPOINT = "api/projects/bulk_delete"; @@ -120,9 +119,7 @@ public class ProjectAdministrationTest { "projectKey", "sample", "permission", "admin"); - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("project-deletion", "/projectAdministration/ProjectAdministrationTest/project-deletion/project-deletion.html").build()) - .runOn(orchestrator); + runSelenese(orchestrator, "/projectAdministration/ProjectAdministrationTest/project-deletion/project-deletion.html"); } finally { wsClient.userClient().deactivate(projectAdminUser); } @@ -145,19 +142,11 @@ public class ProjectAdministrationTest { // There are 7 modules assertThat(count("events where category='Version'")).as("Different number of events").isEqualTo(1); - Selenese selenese = Selenese.builder() - .setHtmlTestsInClasspath("modify_version_of_multimodule_project", - "/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-modify-version.html") - .build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-modify-version.html"); assertThat(count("events where category='Version'")).as("Different number of events").isEqualTo(2); - selenese = Selenese.builder() - .setHtmlTestsInClasspath("delete_version_of_multimodule_project", - "/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-delete-version.html") - .build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-delete-version.html"); assertThat(count("events where category='Version'")).as("Different number of events").isEqualTo(1); } diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java index 479f03e5766..de24c1485d7 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java @@ -21,13 +21,12 @@ package it.projectAdministration; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class ProjectPermissionsTest { @@ -39,10 +38,7 @@ public class ProjectPermissionsTest { executeBuild("project-permissions-project", "Test Project"); executeBuild("project-permissions-project-2", "Another Test Project"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("project_permissions_page_shows_only_single_project", - "/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html"); } private void executeBuild(String projectKey, String projectName) { diff --git a/it/it-tests/src/test/java/it/projectComparison/ProjectComparisonTest.java b/it/it-tests/src/test/java/it/projectComparison/ProjectComparisonTest.java index b848b190618..392c18cf56a 100644 --- a/it/it-tests/src/test/java/it/projectComparison/ProjectComparisonTest.java +++ b/it/it-tests/src/test/java/it/projectComparison/ProjectComparisonTest.java @@ -21,15 +21,14 @@ package it.projectComparison; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class ProjectComparisonTest { @@ -41,22 +40,19 @@ public class ProjectComparisonTest { orchestrator.executeBuild( SonarScanner.create(projectDir("shared/xoo-sample")) .setProjectKey("project-comparison-test-project") - .setProjectName("ProjectComparisonTest Project") - ); + .setProjectName("ProjectComparisonTest Project")); } @Test @Ignore("need to find a way to type into invisible input fields") public void test_project_comparison_service() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_project_comparison_service", + runSelenese(orchestrator, "/projectComparison/ProjectComparisonTest/should-display-basic-set-of-metrics.html", "/projectComparison/ProjectComparisonTest/should-add-projects.html", "/projectComparison/ProjectComparisonTest/should-move-and-remove-projects.html", "/projectComparison/ProjectComparisonTest/should-add-metrics.html", "/projectComparison/ProjectComparisonTest/should-not-add-differential-metrics.html", - "/projectComparison/ProjectComparisonTest/should-move-and-remove-metrics.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/projectComparison/ProjectComparisonTest/should-move-and-remove-metrics.html"); } } diff --git a/it/it-tests/src/test/java/it/projectEvent/EventTest.java b/it/it-tests/src/test/java/it/projectEvent/EventTest.java index 963d0b9da2c..aae1fab6eed 100644 --- a/it/it-tests/src/test/java/it/projectEvent/EventTest.java +++ b/it/it-tests/src/test/java/it/projectEvent/EventTest.java @@ -33,11 +33,10 @@ import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsConnector; import org.sonarqube.ws.client.WsResponse; import util.ItUtils; -import com.sonar.orchestrator.selenium.Selenese; -import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class EventTest { @@ -74,9 +73,7 @@ public class EventTest { public void delete_standard_event() { executeAnalysis(); - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("delete-event", - "/projectEvent/EventTest/create_delete_standard_event.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/projectEvent/EventTest/create_delete_standard_event.html"); } /** diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java index 08b3ce7c598..ef7357c753d 100644 --- a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java +++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java @@ -21,7 +21,6 @@ package it.qualityGate; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import java.util.Iterator; import javax.mail.internet.MimeMessage; @@ -41,12 +40,12 @@ import org.sonar.wsclient.services.ResourceQuery; import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; import util.ItUtils; -import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; import static util.ItUtils.resetEmailSettings; import static util.ItUtils.setServerProperty; +import static util.selenium.Selenese.runSelenese; public class QualityGateNotificationTest { @@ -90,12 +89,9 @@ public class QualityGateNotificationTest { // Create user, who will receive notifications for new violations orchestrator.getServer().adminWsClient().post("api/users/create", "login", "tester", "name", "Tester", "email", "tester@example.org", "password", "tester"); - Selenese selenese = Selenese - .builder() - .setHtmlTestsInClasspath("notifications", - "/qualityGate/notifications/email_configuration.html", - "/qualityGate/notifications/activate_notification_channels.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, + "/qualityGate/notifications/email_configuration.html", + "/qualityGate/notifications/activate_notification_channels.html"); // Create quality gate with conditions on variations QualityGate simple = qgClient().create("SimpleWithDifferential"); diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java index e5c086800d4..503bc19c535 100644 --- a/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java +++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java @@ -21,7 +21,6 @@ package it.qualityGate; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import javax.annotation.Nullable; import org.junit.AfterClass; @@ -35,10 +34,10 @@ import org.sonar.wsclient.qualitygate.QualityGateClient; import org.sonar.wsclient.qualitygate.QualityGateCondition; import org.sonar.wsclient.qualitygate.UpdateCondition; import util.ItUtils; -import util.selenium.SeleneseTest; import static util.ItUtils.projectDir; import static util.ItUtils.setServerProperty; +import static util.selenium.Selenese.runSelenese; public class QualityGateUiTest { @@ -82,10 +81,7 @@ public class QualityGateUiTest { qgClient.updateCondition(UpdateCondition.create(lowThresholds.id()).metricKey("lines").operator("GT").warningThreshold("5000").errorThreshold("5000")); scanSampleWithDate("2012-01-02"); - new SeleneseTest(Selenese.builder() - .setHtmlTestsInClasspath("display-alerts-history-page", - "/qualityGate/QualityGateUiTest/should-display-alerts-correctly-history-page.html" - ).build()).runOn(orchestrator); + runSelenese(orchestrator, "/qualityGate/QualityGateUiTest/should-display-alerts-correctly-history-page.html"); qgClient.unsetDefault(); qgClient.destroy(qGate.id()); @@ -93,10 +89,7 @@ public class QualityGateUiTest { @Test public void should_display_quality_gates_page() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_display_quality_gates_page", - "/qualityGate/QualityGateUiTest/should_display_quality_gates_page.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/qualityGate/QualityGateUiTest/should_display_quality_gates_page.html"); } private void scanSampleWithDate(String date) { diff --git a/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesPageTest.java b/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesPageTest.java index cd182dfe47d..a1789732d26 100644 --- a/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesPageTest.java +++ b/it/it-tests/src/test/java/it/qualityProfile/QualityProfilesPageTest.java @@ -22,7 +22,6 @@ package it.qualityProfile; import com.codeborne.selenide.Condition; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import org.junit.After; import org.junit.Before; @@ -33,11 +32,11 @@ import org.junit.Test; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import pageobjects.Navigation; -import util.selenium.SeleneseTest; import static com.codeborne.selenide.Selenide.$; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class QualityProfilesPageTest { @@ -68,23 +67,19 @@ public class QualityProfilesPageTest { @Test public void testHomePage() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_home_page", + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_display_list.html", "/qualityProfile/QualityProfilesPageTest/should_open_from_list.html", - "/qualityProfile/QualityProfilesPageTest/should_filter_by_language.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/qualityProfile/QualityProfilesPageTest/should_filter_by_language.html"); } @Test public void testProfilePage() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_profile_page", + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_display_profile_rules.html", "/qualityProfile/QualityProfilesPageTest/should_display_profile_inheritance.html", "/qualityProfile/QualityProfilesPageTest/should_display_profile_projects.html", - "/qualityProfile/QualityProfilesPageTest/should_display_profile_exporters.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/qualityProfile/QualityProfilesPageTest/should_display_profile_exporters.html"); } @Test @@ -96,70 +91,48 @@ public class QualityProfilesPageTest { @Test public void testProfileChangelog() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_profile_changelog", - "/qualityProfile/QualityProfilesPageTest/should_display_changelog.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, + "/qualityProfile/QualityProfilesPageTest/should_display_changelog.html"); } @Ignore("find a way to know profile key inside selenium tests") @Test public void testComparison() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_comparison", - "/qualityProfile/QualityProfilesPageTest/should_compare.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_compare.html"); } @Test public void testCreation() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_creation", - "/qualityProfile/QualityProfilesPageTest/should_create.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_create.html"); } @Test public void testDeletion() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_deletion", - "/qualityProfile/QualityProfilesPageTest/should_delete.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_delete.html"); } @Test public void testCopying() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_copying", - "/qualityProfile/QualityProfilesPageTest/should_copy.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_copy.html"); } @Test public void testRenaming() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_renaming", - "/qualityProfile/QualityProfilesPageTest/should_rename.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_rename.html"); } @Test public void testSettingDefault() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_setting_default", - "/qualityProfile/QualityProfilesPageTest/should_set_default.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_set_default.html"); } @Test public void testRestoration() throws Exception { deleteProfile("xoo", "empty"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_restoration", + runSelenese(orchestrator, "/qualityProfile/QualityProfilesPageTest/should_restore.html", - "/qualityProfile/QualityProfilesPageTest/should_restore_built_in.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/qualityProfile/QualityProfilesPageTest/should_restore_built_in.html"); } private static void createProfile(String language, String name) { @@ -197,7 +170,7 @@ public class QualityProfilesPageTest { } private static void setDefault(String language, String name) { - adminWsClient.wsConnector().call( + adminWsClient.wsConnector().call( new PostRequest("api/qualityprofiles/set_default") .setParam("language", language) .setParam("profileName", name)); diff --git a/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java b/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java index 0c67af41e8b..71695dabe36 100644 --- a/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java +++ b/it/it-tests/src/test/java/it/serverSystem/ServerSystemTest.java @@ -21,7 +21,6 @@ package it.serverSystem; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import java.io.File; import java.io.IOException; @@ -48,11 +47,11 @@ import org.sonarqube.ws.client.WsResponse; import pageobjects.Navigation; import pageobjects.ServerIdPage; import util.ItUtils; -import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static util.ItUtils.newAdminWsClient; +import static util.selenium.Selenese.runSelenese; public class ServerSystemTest { @@ -105,9 +104,7 @@ public class ServerSystemTest { @Test public void display_system_info() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("server-administration", - "/serverSystem/ServerSystemTest/system_info.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/serverSystem/ServerSystemTest/system_info.html"); } @Test @@ -149,9 +146,7 @@ public class ServerSystemTest { @Test public void display_warnings_when_using_h2() { if (orchestrator.getConfiguration().getString("sonar.jdbc.dialect").equals("h2")) { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("derby-warnings", - "/serverSystem/ServerSystemTest/derby-warning.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/serverSystem/ServerSystemTest/derby-warning.html"); } } @@ -160,9 +155,7 @@ public class ServerSystemTest { */ @Test public void hide_jdbc_settings_to_non_admin() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("jdbc-settings", - "/serverSystem/ServerSystemTest/hide-jdbc-settings.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/serverSystem/ServerSystemTest/hide-jdbc-settings.html"); } @Test @@ -196,9 +189,7 @@ public class ServerSystemTest { orchestrator.executeBuild(SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")) .setProperty("sonar.projectKey", "myproject.jsp")); // Access dashboard - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("url_ending_by_jsp", - "/serverSystem/ServerSystemTest/url_ending_by_jsp.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/serverSystem/ServerSystemTest/url_ending_by_jsp.html"); } /** diff --git a/it/it-tests/src/test/java/it/sourceCode/EncodingTest.java b/it/it-tests/src/test/java/it/sourceCode/EncodingTest.java index a47d68f8983..433359055b3 100644 --- a/it/it-tests/src/test/java/it/sourceCode/EncodingTest.java +++ b/it/it-tests/src/test/java/it/sourceCode/EncodingTest.java @@ -20,14 +20,13 @@ package it.sourceCode; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.runProjectAnalysis; +import static util.selenium.Selenese.runSelenese; public class EncodingTest { @@ -43,9 +42,6 @@ public class EncodingTest { public void support_japanese_charset() { runProjectAnalysis(orchestrator, "sourceCode/japanese-charset", "sonar.sourceEncoding", "Shift_JIS"); - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("java-japanese-charset", - "/sourceCode/EncodingTest/japanese_sources.html" - ).build()).runOn(orchestrator); + runSelenese(orchestrator, "/sourceCode/EncodingTest/japanese_sources.html"); } } diff --git a/it/it-tests/src/test/java/it/sourceCode/HighlightingTest.java b/it/it-tests/src/test/java/it/sourceCode/HighlightingTest.java index 6a1f48f3c10..d11bd8b764d 100644 --- a/it/it-tests/src/test/java/it/sourceCode/HighlightingTest.java +++ b/it/it-tests/src/test/java/it/sourceCode/HighlightingTest.java @@ -20,14 +20,13 @@ package it.sourceCode; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.runProjectAnalysis; +import static util.selenium.Selenese.runSelenese; public class HighlightingTest { @@ -43,13 +42,11 @@ public class HighlightingTest { public void highlight_source_code_and_symbols_usage() throws Exception { runProjectAnalysis(orchestrator, "highlighting/xoo-sample-with-highlighting-v2"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("highlight_source_code_and_symbols_usage", + runSelenese(orchestrator, // SONAR-3893 & SONAR-4247 "/sourceCode/HighlightingTest/syntax-highlighting.html", // SONAR-4249 & SONAR-4250 - "/sourceCode/HighlightingTest/symbol-usages-highlighting.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/sourceCode/HighlightingTest/symbol-usages-highlighting.html"); } // Check that E/S index is updated when file content is unchanged but plugin generates different syntax/symbol highlighting @@ -57,15 +54,12 @@ public class HighlightingTest { public void update_highlighting_even_when_code_unchanged() throws Exception { runProjectAnalysis(orchestrator, "highlighting/xoo-sample-with-highlighting-v1"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("syntax-highlighting-v1", - "/sourceCode/HighlightingTest/syntax-highlighting-v1.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/sourceCode/HighlightingTest/syntax-highlighting-v1.html"); runProjectAnalysis(orchestrator, "highlighting/xoo-sample-with-highlighting-v2"); - selenese = Selenese.builder().setHtmlTestsInClasspath("syntax-highlighting-v2", + runSelenese(orchestrator, "/sourceCode/HighlightingTest/syntax-highlighting-v2.html", - "/sourceCode/HighlightingTest/symbol-usages-highlighting.html").build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/sourceCode/HighlightingTest/symbol-usages-highlighting.html"); } } diff --git a/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java b/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java index 7135aa77f30..bd97b30be4b 100644 --- a/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java +++ b/it/it-tests/src/test/java/it/sourceCode/ProjectCodeTest.java @@ -21,13 +21,12 @@ package it.sourceCode; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class ProjectCodeTest { @@ -38,22 +37,17 @@ public class ProjectCodeTest { public void test_project_code_page() throws Exception { executeBuild("shared/xoo-sample", "project-for-code", "Project For Code"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("test_project_code_page", + runSelenese(orchestrator, "/sourceCode/ProjectCodeTest/test_project_code_page.html", "/sourceCode/ProjectCodeTest/search.html", - "/sourceCode/ProjectCodeTest/permalink.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + "/sourceCode/ProjectCodeTest/permalink.html"); } @Test public void code_page_should_expand_root_dir() throws Exception { executeBuild("shared/xoo-sample-with-root-dir", "project-for-code-root-dir", "Project For Code"); - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("code_page_should_expand_root_dir", - "/sourceCode/ProjectCodeTest/code_page_should_expand_root_dir.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/sourceCode/ProjectCodeTest/code_page_should_expand_root_dir.html"); } private void executeBuild(String projectLocation, String projectKey, String projectName) { diff --git a/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java b/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java index 258f2251b65..2645493bfed 100644 --- a/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java +++ b/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java @@ -20,12 +20,13 @@ package it.uiExtension; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; -import util.selenium.SeleneseTest; + +import static util.selenium.Selenese.runSelenese; + public class UiExtensionsTest { @@ -40,9 +41,7 @@ public class UiExtensionsTest { @Test public void test_static_files() { - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("ui-static-files", - "/uiExtension/UiExtensionsTest/static-files.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/uiExtension/UiExtensionsTest/static-files.html"); } /** @@ -50,9 +49,7 @@ public class UiExtensionsTest { */ @Test public void test_page_decoration() { - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("ui-page-decoration", - "/uiExtension/UiExtensionsTest/page-decoration.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/uiExtension/UiExtensionsTest/page-decoration.html"); } /** @@ -60,9 +57,7 @@ public class UiExtensionsTest { */ @Test public void test_resource_configuration_extension() { - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("resource-configuration-extension", - "/uiExtension/UiExtensionsTest/resource-configuration-extension.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/uiExtension/UiExtensionsTest/resource-configuration-extension.html"); } } diff --git a/it/it-tests/src/test/java/it/updateCenter/UpdateCenterTest.java b/it/it-tests/src/test/java/it/updateCenter/UpdateCenterTest.java index 1e732af823e..3e90c1420e1 100644 --- a/it/it-tests/src/test/java/it/updateCenter/UpdateCenterTest.java +++ b/it/it-tests/src/test/java/it/updateCenter/UpdateCenterTest.java @@ -20,7 +20,6 @@ package it.updateCenter; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import java.util.List; import org.apache.commons.lang.StringUtils; import org.junit.After; @@ -33,11 +32,11 @@ import org.sonar.wsclient.Sonar; import org.sonar.wsclient.connectors.HttpClient4Connector; import org.sonar.wsclient.services.Plugin; import org.sonar.wsclient.services.UpdateCenterQuery; -import util.selenium.SeleneseTest; import util.user.UserRule; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.pluginArtifact; +import static util.selenium.Selenese.runSelenese; /** * This class start its own orchestrator @@ -78,10 +77,7 @@ public class UpdateCenterTest { @Test public void test_console() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("server-update-center", - "/updateCenter/installed-plugins.html") - .build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/updateCenter/installed-plugins.html"); } private Plugin findPlugin(List<Plugin> plugins, String pluginKey) { diff --git a/it/it-tests/src/test/java/it/user/BaseIdentityProviderTest.java b/it/it-tests/src/test/java/it/user/BaseIdentityProviderTest.java index c5408415336..127ab3dd7d8 100644 --- a/it/it-tests/src/test/java/it/user/BaseIdentityProviderTest.java +++ b/it/it-tests/src/test/java/it/user/BaseIdentityProviderTest.java @@ -22,7 +22,6 @@ package it.user; import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import java.io.File; import org.apache.commons.io.FileUtils; @@ -32,7 +31,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsClient; -import util.selenium.SeleneseTest; import util.user.UserRule; import util.user.Users; @@ -41,6 +39,7 @@ import static org.assertj.guava.api.Assertions.assertThat; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.resetSettings; import static util.ItUtils.setServerProperty; +import static util.selenium.Selenese.runSelenese; /** * TODO : Add missing ITs @@ -104,8 +103,7 @@ public class BaseIdentityProviderTest { enablePlugin(); setUserCreatedByAuthPlugin(USER_LOGIN, USER_PROVIDER_ID, USER_NAME, USER_EMAIL); - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("authenticate_through_ui", - "/user/BaseIdentityProviderTest/authenticate_user.html").build()).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, "/user/BaseIdentityProviderTest/authenticate_user.html"); userRule.verifyUserExists(USER_LOGIN, USER_NAME, USER_EMAIL); } @@ -116,8 +114,7 @@ public class BaseIdentityProviderTest { // As this property is null, the plugin will throw an exception setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.user", null); - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("display_unauthorized_page_when_authentication_failed", - "/user/BaseIdentityProviderTest/display_unauthorized_page_when_authentication_failed.html").build()).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, "/user/BaseIdentityProviderTest/display_unauthorized_page_when_authentication_failed.html"); userRule.verifyUserDoesNotExist(USER_LOGIN); } @@ -128,8 +125,7 @@ public class BaseIdentityProviderTest { setUserCreatedByAuthPlugin(USER_LOGIN, USER_PROVIDER_ID, USER_NAME, USER_EMAIL); setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.allowsUsersToSignUp", "false"); - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("fail_to_authenticate_when_not_allowed_to_sign_up", - "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html").build()).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html"); userRule.verifyUserDoesNotExist(USER_LOGIN); } @@ -190,8 +186,7 @@ public class BaseIdentityProviderTest { setUserCreatedByAuthPlugin(USER_LOGIN, USER_PROVIDER_ID, USER_NAME, USER_EMAIL); setServerProperty(ORCHESTRATOR, "sonar.auth.fake-base-id-provider.throwUnauthorizedMessage", "true"); - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("fail_to_authenticate_when_not_allowed_to_sign_up", - "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html").build()).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, "/user/BaseIdentityProviderTest/fail_to_authenticate_when_not_allowed_to_sign_up.html"); File logFile = ORCHESTRATOR.getServer().getWebLogs(); assertThat(FileUtils.readFileToString(logFile)).doesNotContain("A functional error has happened"); diff --git a/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java b/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java index 2befdda21ee..6fd62d03581 100644 --- a/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java +++ b/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java @@ -23,7 +23,6 @@ import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.BuildResult; import com.sonar.orchestrator.build.SonarScanner; import com.sonar.orchestrator.locator.FileLocation; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import java.io.IOException; import java.util.UUID; @@ -46,7 +45,6 @@ import org.sonarqube.ws.client.usertoken.GenerateWsRequest; import org.sonarqube.ws.client.usertoken.RevokeWsRequest; import org.sonarqube.ws.client.usertoken.SearchWsRequest; import org.sonarqube.ws.client.usertoken.UserTokensService; -import util.selenium.SeleneseTest; import util.user.UserRule; import static java.lang.String.format; @@ -54,6 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; import static util.ItUtils.setServerProperty; +import static util.selenium.Selenese.runSelenese; public class LocalAuthenticationTest { @@ -196,9 +195,7 @@ public class LocalAuthenticationTest { public void allow_users_to_sign_up() throws IOException { setServerProperty(ORCHESTRATOR, "sonar.allowUsersToSignUp", "true"); - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("allow_users_to_sign_up", - "/user/LocalAuthenticationTest/allow_users_to_sign_up.html").build()).runOn(ORCHESTRATOR); + runSelenese(ORCHESTRATOR, "/user/LocalAuthenticationTest/allow_users_to_sign_up.html"); // This check is failing because signup doesn't refresh the users ES index ! // Will be fixed by SONAR-7308 @@ -207,7 +204,7 @@ public class LocalAuthenticationTest { @Test public void authentication_through_ui() { - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("authentication", + runSelenese(ORCHESTRATOR, "/user/LocalAuthenticationTest/login_successful.html", "/user/LocalAuthenticationTest/login_wrong_password.html", "/user/LocalAuthenticationTest/should_not_be_unlogged_when_going_to_login_page.html", @@ -216,13 +213,13 @@ public class LocalAuthenticationTest { "/user/LocalAuthenticationTest/redirect_to_original_url_after_direct_login.html", "/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html", // SONAR-2009 - "/user/LocalAuthenticationTest/redirect_to_original_url_after_indirect_login.html").build()).runOn(ORCHESTRATOR); + "/user/LocalAuthenticationTest/redirect_to_original_url_after_indirect_login.html"); setServerProperty(ORCHESTRATOR, "sonar.forceAuthentication", "true"); - new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("force-authentication", + runSelenese(ORCHESTRATOR, // SONAR-3473 - "/user/LocalAuthenticationTest/force-authentication.html").build()).runOn(ORCHESTRATOR); + "/user/LocalAuthenticationTest/force-authentication.html"); } @Test diff --git a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java index d21ea961fb5..01140a1b116 100644 --- a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java +++ b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java @@ -21,7 +21,6 @@ package it.user; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import org.junit.After; import org.junit.Before; @@ -32,10 +31,10 @@ import org.junit.Test; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import pageobjects.Navigation; -import util.selenium.SeleneseTest; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; +import static util.selenium.Selenese.runSelenese; public class MyAccountPageTest { @@ -64,36 +63,24 @@ public class MyAccountPageTest { @Test public void should_display_user_details() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_display_user_details", - "/user/MyAccountPageTest/should_display_user_details.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/user/MyAccountPageTest/should_display_user_details.html"); } @Test public void should_change_password() throws Exception { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_change_password", - "/user/MyAccountPageTest/should_change_password.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/user/MyAccountPageTest/should_change_password.html"); } @Test public void should_display_projects() throws Exception { // first, try on empty instance - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_display_projects", - "/user/MyAccountPageTest/should_display_no_projects.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/user/MyAccountPageTest/should_display_no_projects.html"); // then, analyze a project analyzeProject("sample"); grantAdminPermission("account-user", "sample"); - selenese = Selenese.builder().setHtmlTestsInClasspath("should_display_projects", - "/user/MyAccountPageTest/should_display_projects.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); + runSelenese(orchestrator, "/user/MyAccountPageTest/should_display_projects.html"); } private static void createUser(String login, String name, String email) { diff --git a/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java b/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java index b6a99034d6d..f5f8f1f5793 100644 --- a/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java +++ b/it/it-tests/src/test/java/it/user/RealmAuthenticationTest.java @@ -22,7 +22,6 @@ package it.user; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import java.util.Map; import java.util.Objects; import javax.annotation.CheckForNull; @@ -47,7 +46,6 @@ import org.sonarqube.ws.client.HttpConnector; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.WsResponse; -import util.selenium.SeleneseTest; import util.user.UserRule; import static java.net.HttpURLConnection.HTTP_OK; @@ -56,6 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static util.ItUtils.pluginArtifact; import static util.ItUtils.setServerProperty; +import static util.selenium.Selenese.runSelenese; /** * Test REALM authentication. @@ -115,16 +114,10 @@ public class RealmAuthenticationTest { // Then assertThat(loginAttempt(username, password)).isEqualTo(AUTHORIZED); // with external details and groups - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("external-user-details", - "/user/ExternalAuthenticationTest/external-user-details.html") - .build()).runOn(orchestrator); + runSelenese(orchestrator, "/user/ExternalAuthenticationTest/external-user-details.html"); // SONAR-4462 - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("system-info", - "/user/ExternalAuthenticationTest/system-info.html") - .build()).runOn(orchestrator); + runSelenese(orchestrator, "/user/ExternalAuthenticationTest/system-info.html"); } /** @@ -147,10 +140,7 @@ public class RealmAuthenticationTest { assertThat(loginAttempt(username, password)).isEqualTo(AUTHORIZED); // with external details and groups // TODO replace by WS ? Or with new Selenese utils - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("external-user-details", - "/user/ExternalAuthenticationTest/external-user-details.html") - .build()).runOn(orchestrator); + runSelenese(orchestrator, "/user/ExternalAuthenticationTest/external-user-details.html"); // Now update user details users.put(username + ".name", "Tester2 Testerovich"); @@ -159,9 +149,7 @@ public class RealmAuthenticationTest { // Then assertThat(loginAttempt(username, password)).isEqualTo(AUTHORIZED); // with external details and groups updated - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("external-user-details2", - "/user/ExternalAuthenticationTest/external-user-details2.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/user/ExternalAuthenticationTest/external-user-details2.html"); } /** @@ -259,9 +247,7 @@ public class RealmAuthenticationTest { // Given clean Sonar installation and no users in external system // Let's create and delete the user "tester" in Sonar DB - new SeleneseTest( - Selenese.builder().setHtmlTestsInClasspath("external-user-create-and-delete-user", - "/user/ExternalAuthenticationTest/create-and-delete-user.html").build()).runOn(orchestrator); + runSelenese(orchestrator, "/user/ExternalAuthenticationTest/create-and-delete-user.html"); // And now update the security with the user that was deleted String login = USER_LOGIN; diff --git a/it/it-tests/src/test/java/util/selenium/Selenese.java b/it/it-tests/src/test/java/util/selenium/Selenese.java new file mode 100644 index 00000000000..2e441581803 --- /dev/null +++ b/it/it-tests/src/test/java/util/selenium/Selenese.java @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package util.selenium; + +import com.sonar.orchestrator.Orchestrator; +import java.io.File; +import javax.annotation.Nullable; +import org.apache.commons.io.FileUtils; + +/** + * Selenium HTML tests, generally written with Selenium IDE + */ +public final class Selenese { + + private File[] htmlTests; + + public Selenese(Builder builder) { + this.htmlTests = builder.htmlTests; + } + + public File[] getHtmlTests() { + return htmlTests; + } + + public static void runSelenese(Orchestrator orchestrator, String... htmlFiles) { + Selenese selenese = new Builder() + .setHtmlTests(htmlFiles) + .build(); + new SeleneseRunner().runOn(selenese, orchestrator); + } + + private static final class Builder { + private File[] htmlTests; + + private Builder() { + } + + public Builder setHtmlTests(File... htmlTests) { + this.htmlTests = htmlTests; + return this; + } + + public Builder setHtmlTests(String... htmlTestPaths) { + this.htmlTests = new File[htmlTestPaths.length]; + for (int index = 0; index < htmlTestPaths.length; index++) { + htmlTests[index] = FileUtils.toFile(getClass().getResource(htmlTestPaths[index])); + } + return this; + } + + public Selenese build() { + if (htmlTests == null || htmlTests.length == 0) { + throw new IllegalArgumentException("HTML suite or tests are missing"); + } + for (File htmlTest : htmlTests) { + checkPresence(htmlTest); + } + return new Selenese(this); + } + + private static void checkPresence(@Nullable File file) { + if (file == null || !file.isFile() || !file.exists()) { + throw new IllegalArgumentException("HTML file does not exist: " + file); + } + } + } +} diff --git a/it/it-tests/src/test/java/util/selenium/SeleneseTest.java b/it/it-tests/src/test/java/util/selenium/SeleneseRunner.java index 81866e86cc7..8819a510293 100644 --- a/it/it-tests/src/test/java/util/selenium/SeleneseTest.java +++ b/it/it-tests/src/test/java/util/selenium/SeleneseRunner.java @@ -20,7 +20,6 @@ package util.selenium; import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.selenium.Selenese; import java.io.File; import java.io.IOException; import java.net.URI; @@ -46,26 +45,21 @@ import static java.util.regex.Pattern.DOTALL; import static org.assertj.core.api.Assertions.assertThat; import static util.selenium.Retry._30_SECONDS; -public class SeleneseTest { - private final Selenese suite; +class SeleneseRunner { private Map<String, String> variables; private String baseUrl; private SeleniumDriver driver; - public SeleneseTest(Selenese suite) { - this.suite = suite; - } - - public void runOn(Orchestrator orchestrator) { + void runOn(Selenese selenese, Orchestrator orchestrator) { this.variables = new HashMap<>(); this.baseUrl = orchestrator.getServer().getUrl(); this.driver = Browser.FIREFOX.getDriverForThread(); driver.manage().deleteAllCookies(); - driver.manage().window().setSize(new Dimension(1280,1024)); + driver.manage().window().setSize(new Dimension(1280, 1024)); - for (File file : suite.getHtmlTests()) { + for (File file : selenese.getHtmlTests()) { System.out.println(); System.out.println("============ " + file.getName() + " ============"); Document doc = parse(file); @@ -103,7 +97,7 @@ public class SeleneseTest { } } - public SeleneseTest action(String action, String param1, String param2) { + public SeleneseRunner action(String action, String param1, String param2) { switch (action) { case "open": open(param1); diff --git a/it/it-tests/src/test/resources/issue/IssueSearchTest/redirect_to_search_url_after_wrong_login.html b/it/it-tests/src/test/resources/issue/IssueSearchTest/redirect_to_search_url_after_wrong_login.html index a45e560851b..791967ed6ea 100644 --- a/it/it-tests/src/test/resources/issue/IssueSearchTest/redirect_to_search_url_after_wrong_login.html +++ b/it/it-tests/src/test/resources/issue/IssueSearchTest/redirect_to_search_url_after_wrong_login.html @@ -8,66 +8,76 @@ <table cellpadding="1" cellspacing="1" border="1"> <tbody> <tr> - <td>open</td> - <td>/sessions/logout</td> - <td></td> -</tr> -<tr> - <td>open</td> - <td>/issues#resolved=true|statuses=OPEN</td> - <td></td> -</tr> -<tr> - <td>assertLocation</td> - <td>*/sessions/new*</td> - <td></td> -</tr> -<tr> - <td>assertElementPresent</td> - <td>login_form</td> - <td></td> -</tr> -<tr> - <td>type</td> - <td>id=login</td> - <td>wrong login</td> -</tr> -<tr> - <td>type</td> - <td>id=password</td> - <td>wrong password</td> -</tr> -<tr> - <td>click</td> - <td>commit</td> - <td></td> -</tr> -<tr> - <td>waitForText</td> - <td>css=.alert</td> - <td>*Authentication failed*</td> -</tr> -<tr> - <td>type</td> - <td>id=login</td> - <td>admin</td> -</tr> -<tr> - <td>type</td> - <td>id=password</td> - <td>admin</td> -</tr> -<tr> - <td>clickAndWait</td> - <td>commit</td> - <td></td> -</tr> -<tr> - <td>assertLocation</td> - <td>*#resolved=true|statuses=OPEN*</td> - <td></td> -</tr> -</tbody> + <td>open</td> + <td>/sessions/logout</td> + <td></td> + </tr> + <tr> + <td>open</td> + <td>/issues#resolved=true|statuses=OPEN</td> + <td></td> + </tr> + <tr> + <td>waitForText</td> + <td>content</td> + <td>*Log In to SonarQube*</td> + </tr> + <tr> + <td>waitForElementPresent</td> + <td>id=login</td> + <td></td> + </tr> + <tr> + <td>type</td> + <td>id=password</td> + <td>wrongpassword</td> + </tr> + <tr> + <td>type</td> + <td>id=login</td> + <td>wronglogin</td> + </tr> + <tr> + <td>type</td> + <td>id=password</td> + <td>wrongpassword</td> + </tr> + <tr> + <td>clickAndWait</td> + <td>commit</td> + <td></td> + </tr> + <tr> + <td>waitForText</td> + <td>css=.alert</td> + <td>*Authentication failed*</td> + </tr> + <tr> + <td>waitForElementPresent</td> + <td>id=login</td> + <td></td> + </tr> + <tr> + <td>type</td> + <td>id=login</td> + <td>admin</td> + </tr> + <tr> + <td>type</td> + <td>id=password</td> + <td>admin</td> + </tr> + <tr> + <td>clickAndWait</td> + <td>commit</td> + <td></td> + </tr> + <tr> + <td>assertLocation</td> + <td>*#resolved=true|statuses=OPEN*</td> + <td></td> + </tr> + </tbody> </table> </body> </html> |