From 8317bd274770995c0981f03afa287c4d99123004 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 22 Nov 2016 23:44:54 +0100 Subject: [PATCH] Stop using the Selenese impl provided by Orchestrator --- .../test/java/it/issue/IssueSearchTest.java | 11 +- .../test/java/it/projectEvent/EventTest.java | 28 +---- .../java/it/sourceCode/HighlightingTest.java | 7 +- .../java/it/uiExtension/UiExtensionsTest.java | 43 +------ .../test/java/util/selenium/SeleneseTest.java | 16 ++- .../issue/IssueSearchTest/bulk_change.html | 16 ++- .../create_event_with_special_character.html | 99 --------------- .../EventTest/no_events_widget_on_dir.html | 39 ------ .../EventTest/show_events_using_filters.html | 119 ------------------ .../syntax-highlighting-v1.html | 5 - .../syntax-highlighting-v2.html | 5 - .../HighlightingTest/syntax-highlighting.html | 5 - .../ruby-rails-app-advanced.html | 29 ----- .../UiExtensionsTest/ruby-rails-app.html | 29 ----- 14 files changed, 42 insertions(+), 409 deletions(-) delete mode 100644 it/it-tests/src/test/resources/projectEvent/EventTest/create_event_with_special_character.html delete mode 100644 it/it-tests/src/test/resources/projectEvent/EventTest/no_events_widget_on_dir.html delete mode 100644 it/it-tests/src/test/resources/projectEvent/EventTest/show_events_using_filters.html delete mode 100644 it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app-advanced.html delete mode 100644 it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app.html 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 a18d05fdf44..7611e5fa5dc 100644 --- a/it/it-tests/src/test/java/it/issue/IssueSearchTest.java +++ b/it/it-tests/src/test/java/it/issue/IssueSearchTest.java @@ -40,6 +40,7 @@ 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; @@ -105,7 +106,7 @@ public class IssueSearchTest extends AbstractIssueTest { public void search_issues_by_components() { assertThat( search(IssueQuery.create().components("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo")).list()) - .hasSize(34); + .hasSize(34); assertThat(search(IssueQuery.create().components("unknown")).list()).isEmpty(); } @@ -280,9 +281,9 @@ 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"); - ORCHESTRATOR.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("redirect_to_search_url_after_wrong_login", + 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()); + ).build()).runOn(ORCHESTRATOR); } @Test @@ -312,9 +313,9 @@ public class IssueSearchTest extends AbstractIssueTest { @Test public void bulk_change() { - ORCHESTRATOR.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("bulk_change", + new SeleneseTest(Selenese.builder().setHtmlTestsInClasspath("bulk_change", "/issue/IssueSearchTest/bulk_change.html" - ).build()); + ).build()).runOn(ORCHESTRATOR); } private List searchByRuleKey(String... ruleKey) throws IOException { 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 9a421a9999b..963d0b9da2c 100644 --- a/it/it-tests/src/test/java/it/projectEvent/EventTest.java +++ b/it/it-tests/src/test/java/it/projectEvent/EventTest.java @@ -22,12 +22,10 @@ package it.projectEvent; import com.google.common.collect.Lists; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; import java.util.List; import org.junit.Before; import org.junit.ClassRule; -import org.junit.Ignore; import org.junit.Test; import org.sonar.wsclient.services.Event; import org.sonar.wsclient.services.EventQuery; @@ -35,6 +33,7 @@ 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; @@ -50,18 +49,6 @@ public class EventTest { orchestrator.resetData(); } - @Test - @Ignore("Too many false-positives") - public void configuration_of_event() { - executeAnalysis(); - - orchestrator.executeSelenese( - Selenese.builder().setHtmlTestsInClasspath("events", - "/projectEvent/EventTest/create_event_with_special_character.html", - "/projectEvent/EventTest/no_events_widget_on_dir.html") - .build()); - } - @Test public void old_ws_events_does_not_allow_creating_events_on_modules() { SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-multi-modules-sample")); @@ -92,19 +79,6 @@ public class EventTest { "/projectEvent/EventTest/create_delete_standard_event.html").build()).runOn(orchestrator); } - @Test - @Ignore("Too many false-positives") - public void event_widget() { - // first build, in the past - executeAnalysis("sonar.projectDate", "2016-01-01"); - // Second build, today - executeAnalysis(); - - orchestrator.executeSelenese( - Selenese.builder().setHtmlTestsInClasspath("event-widget", - "/projectEvent/EventTest/show_events_using_filters.html").build()); - } - /** * SONAR-3308 */ 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 44eef089527..6a1f48f3c10 100644 --- a/it/it-tests/src/test/java/it/sourceCode/HighlightingTest.java +++ b/it/it-tests/src/test/java/it/sourceCode/HighlightingTest.java @@ -25,6 +25,7 @@ import it.Category1Suite; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; +import util.selenium.SeleneseTest; import static util.ItUtils.runProjectAnalysis; @@ -48,7 +49,7 @@ public class HighlightingTest { // SONAR-4249 & SONAR-4250 "/sourceCode/HighlightingTest/symbol-usages-highlighting.html" ).build(); - orchestrator.executeSelenese(selenese); + new SeleneseTest(selenese).runOn(orchestrator); } // Check that E/S index is updated when file content is unchanged but plugin generates different syntax/symbol highlighting @@ -58,13 +59,13 @@ public class HighlightingTest { Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("syntax-highlighting-v1", "/sourceCode/HighlightingTest/syntax-highlighting-v1.html").build(); - orchestrator.executeSelenese(selenese); + new SeleneseTest(selenese).runOn(orchestrator); runProjectAnalysis(orchestrator, "highlighting/xoo-sample-with-highlighting-v2"); selenese = Selenese.builder().setHtmlTestsInClasspath("syntax-highlighting-v2", "/sourceCode/HighlightingTest/syntax-highlighting-v2.html", "/sourceCode/HighlightingTest/symbol-usages-highlighting.html").build(); - orchestrator.executeSelenese(selenese); + new SeleneseTest(selenese).runOn(orchestrator); } } 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 7aca814487a..258f2251b65 100644 --- a/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java +++ b/it/it-tests/src/test/java/it/uiExtension/UiExtensionsTest.java @@ -22,18 +22,11 @@ package it.uiExtension; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.selenium.Selenese; import it.Category4Suite; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.util.EntityUtils; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import util.selenium.SeleneseTest; -import static org.assertj.core.api.Assertions.assertThat; - public class UiExtensionsTest { @ClassRule @@ -49,26 +42,7 @@ public class UiExtensionsTest { public void test_static_files() { new SeleneseTest( Selenese.builder().setHtmlTestsInClasspath("ui-static-files", - "/uiExtension/UiExtensionsTest/static-files.html" - ).build()).runOn(orchestrator); - } - - /** - * SONAR-3555 - */ - @Test - public void content_type_of_static_files_is_set() throws Exception { - HttpClient httpclient = new DefaultHttpClient(); - try { - HttpGet get = new HttpGet(orchestrator.getServer().getUrl() + "/static/uiextensionsplugin/cute.jpg"); - HttpResponse response = httpclient.execute(get); - assertThat(response.getLastHeader("Content-Type").getValue()).isEqualTo("image/jpeg"); - - EntityUtils.consume(response.getEntity()); - - } finally { - httpclient.getConnectionManager().shutdown(); - } + "/uiExtension/UiExtensionsTest/static-files.html").build()).runOn(orchestrator); } /** @@ -78,17 +52,7 @@ public class UiExtensionsTest { public void test_page_decoration() { new SeleneseTest( Selenese.builder().setHtmlTestsInClasspath("ui-page-decoration", - "/uiExtension/UiExtensionsTest/page-decoration.html" - ).build()).runOn(orchestrator); - } - - @Test - public void test_ruby_extensions() { - Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("ui-ruby-extensions", - "/uiExtension/UiExtensionsTest/ruby-rails-app.html", - "/uiExtension/UiExtensionsTest/ruby-rails-app-advanced.html" - ).build(); - orchestrator.executeSelenese(selenese); + "/uiExtension/UiExtensionsTest/page-decoration.html").build()).runOn(orchestrator); } /** @@ -98,8 +62,7 @@ public class UiExtensionsTest { public void test_resource_configuration_extension() { new SeleneseTest( Selenese.builder().setHtmlTestsInClasspath("resource-configuration-extension", - "/uiExtension/UiExtensionsTest/resource-configuration-extension.html" - ).build()).runOn(orchestrator); + "/uiExtension/UiExtensionsTest/resource-configuration-extension.html").build()).runOn(orchestrator); } } diff --git a/it/it-tests/src/test/java/util/selenium/SeleneseTest.java b/it/it-tests/src/test/java/util/selenium/SeleneseTest.java index bf84e6416d7..81866e86cc7 100644 --- a/it/it-tests/src/test/java/util/selenium/SeleneseTest.java +++ b/it/it-tests/src/test/java/util/selenium/SeleneseTest.java @@ -159,6 +159,9 @@ public class SeleneseTest { case "assertLocation": assertLocation(param1); return this; + case "verifyHtmlSource": + verifyHtmlSource(param1); + return this; case "waitForElementPresent": waitForElementPresent(param1, param2); return this; @@ -168,6 +171,9 @@ public class SeleneseTest { case "waitForVisible": waitForVisible(param1); return this; + case "waitForXpathCount": + waitForXpathCount(param1, Integer.parseInt(param2)); + return this; case "assertValue": case "waitForValue": case "verifyValue": @@ -198,7 +204,7 @@ public class SeleneseTest { url = replacePlaceholders(url); - URI uri = URI.create(url.replace(" ", "%20")); + URI uri = URI.create(url.replace(" ", "%20").replace("|", "%7C")); if (!uri.isAbsolute()) { url = baseUrl + url; } @@ -407,6 +413,10 @@ public class SeleneseTest { find(selector).should().contain(text); } + private void waitForXpathCount(String selector, int expectedCount) { + assertThat(find(selector).stream().size()).isEqualTo(expectedCount); + } + private void confirm(final String message) { System.out.println(" - confirm(" + message + ")"); @@ -422,6 +432,10 @@ public class SeleneseTest { assertThat(driver.getCurrentUrl()).matches(glob(urlPattern)); } + private void verifyHtmlSource(String expect) { + assertThat(driver.getPageSource()).matches(glob(expect)); + } + private String replacePlaceholders(String text) { for (Map.Entry entry : variables.entrySet()) { text = text.replace("${" + entry.getKey() + "}", entry.getValue()); diff --git a/it/it-tests/src/test/resources/issue/IssueSearchTest/bulk_change.html b/it/it-tests/src/test/resources/issue/IssueSearchTest/bulk_change.html index 5b8a928627b..c390c02d105 100644 --- a/it/it-tests/src/test/resources/issue/IssueSearchTest/bulk_change.html +++ b/it/it-tests/src/test/resources/issue/IssueSearchTest/bulk_change.html @@ -17,6 +17,11 @@ /sessions/new + + waitForText + content + *Log In to SonarQube* + type id=login @@ -32,15 +37,20 @@ commit + + waitForElementPresent + css=.js-user-authenticated + + open /issues - waitForText - css=.js-issue-transition - *Open* + waitForElementPresent + css=.search-navigator-workspace-list .issue + waitForElementPresent diff --git a/it/it-tests/src/test/resources/projectEvent/EventTest/create_event_with_special_character.html b/it/it-tests/src/test/resources/projectEvent/EventTest/create_event_with_special_character.html deleted file mode 100644 index c191a260a07..00000000000 --- a/it/it-tests/src/test/resources/projectEvent/EventTest/create_event_with_special_character.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - create_event_with_special_character - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
create_event_with_special_character
open/sessions/logout
open/sessions/login
typeloginadmin
typepasswordadmin
clickAndWaitcommit
waitForElementPresentcss=.js-user-authenticated
open/project/history?id=sample
waitForElementPresentlink=Create
clicklink=Create
waitForElementPresentcreate_event_name_0
storeévènementeventName
typecreate_event_name_0${eventName}
clickAndWaitcreate_save_event_0
waitForElementPresentinfomsg
waitForTextinfomsgEvent "${eventName}" was created.
assertElementPresent//td[text()='${eventName}']
- - diff --git a/it/it-tests/src/test/resources/projectEvent/EventTest/no_events_widget_on_dir.html b/it/it-tests/src/test/resources/projectEvent/EventTest/no_events_widget_on_dir.html deleted file mode 100644 index 86cfc862d09..00000000000 --- a/it/it-tests/src/test/resources/projectEvent/EventTest/no_events_widget_on_dir.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - no_events_widget_on_dir - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
no_events_widget_on_package
open/widget?id=events&resource=sample
waitForElementPresentcss=tr.event
open/widget?id=events&resource=sample%3Asrc%2Fmain%2Fxoo%2Fsample
waitForElementNotPresentcss=tr.event
- - diff --git a/it/it-tests/src/test/resources/projectEvent/EventTest/show_events_using_filters.html b/it/it-tests/src/test/resources/projectEvent/EventTest/show_events_using_filters.html deleted file mode 100644 index ca90b8077fc..00000000000 --- a/it/it-tests/src/test/resources/projectEvent/EventTest/show_events_using_filters.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - show_events_using_filters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
show_events_using_filters
open/sessions/logout
open/sessions/login
typeloginadmin
typepasswordadmin
clickAndWaitcommit
waitForElementPresentcss=.js-user-authenticated
open/project/history?id=sample
clickcreate_event_1_change
typeid=create_event_name_1Hello you
clickAndWaitid=create_save_event_1
waitForTextcontent*Event "Hello you" was created.*1.0-SNAPSHOT*Last*Hello you*
open/widget?id=events&resource=sample
waitForTextbody*Events*
waitForTextblock_1*Events*Version*1.0-SNAPSHOT*Other*Hello you*
selectid=select_category_1label=Quality Profile
assertNotTextblock_1*Version*1.0-SNAPSHOT*Other*Hello you*
selectid=select_category_1label=Other
assertNotTextblock_1*Version*1.0-SNAPSHOT*
selectid=select_category_1label=Version
assertNotTextblock_1*Other*Hello you*
- - diff --git a/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v1.html b/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v1.html index 368c3bdf58e..7a1e36cf816 100644 --- a/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v1.html +++ b/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v1.html @@ -23,11 +23,6 @@ css=.source-line - - storeHtmlSource - - - verifyHtmlSource glob:*<span class="k">package</span>* diff --git a/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v2.html b/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v2.html index 57c535a10d3..7f473dd9e43 100644 --- a/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v2.html +++ b/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting-v2.html @@ -23,11 +23,6 @@ css=.source-line - - storeHtmlSource - - - verifyHtmlSource glob:*<span class="k">package</span>* diff --git a/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting.html b/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting.html index 24d0ac63903..53e4602a978 100644 --- a/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting.html +++ b/it/it-tests/src/test/resources/sourceCode/HighlightingTest/syntax-highlighting.html @@ -23,11 +23,6 @@ css=.source-line - - storeHtmlSource - - - verifyHtmlSource glob:*<span class="k">package</span>* diff --git a/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app-advanced.html b/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app-advanced.html deleted file mode 100644 index 0553d3d36d6..00000000000 --- a/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app-advanced.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ruby-rails-app - - - - - - - - - - - - - - - - - - - - -
open/fake_app/advanced
waitForTextfake-div*This page requests database and use RoR partial*
waitForTextfake-div*Database connection OK*
- - diff --git a/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app.html b/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app.html deleted file mode 100644 index c6500b13121..00000000000 --- a/it/it-tests/src/test/resources/uiExtension/UiExtensionsTest/ruby-rails-app.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ruby-rails-app - - - - - - - - - - - - - - - - - - - - -
open/fake_app
waitForTextfake-appFake application
waitForTexthelper-testmessage generated by helper
- - -- 2.39.5