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;
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();
}
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
@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<org.sonarqube.ws.Issues.Issue> searchByRuleKey(String... ruleKey) throws IOException {
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;
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;
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"));
"/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
*/
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
+import util.selenium.SeleneseTest;
import static util.ItUtils.runProjectAnalysis;
// 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
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);
}
}
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
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);
}
/**
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);
}
/**
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);
}
}
case "assertLocation":
assertLocation(param1);
return this;
+ case "verifyHtmlSource":
+ verifyHtmlSource(param1);
+ return this;
case "waitForElementPresent":
waitForElementPresent(param1, param2);
return this;
case "waitForVisible":
waitForVisible(param1);
return this;
+ case "waitForXpathCount":
+ waitForXpathCount(param1, Integer.parseInt(param2));
+ return this;
case "assertValue":
case "waitForValue":
case "verifyValue":
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;
}
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 + ")");
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<String, String> entry : variables.entrySet()) {
text = text.replace("${" + entry.getKey() + "}", entry.getValue());
<td>/sessions/new</td>
<td></td>
</tr>
+<tr>
+ <td>waitForText</td>
+ <td>content</td>
+ <td>*Log In to SonarQube*</td>
+</tr>
<tr>
<td>type</td>
<td>id=login</td>
<td>commit</td>
<td></td>
</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>css=.js-user-authenticated</td>
+ <td></td>
+</tr>
<tr>
<td>open</td>
<td>/issues</td>
<td></td>
</tr>
<tr>
- <td>waitForText</td>
- <td>css=.js-issue-transition</td>
- <td>*Open*</td>
+ <td>waitForElementPresent</td>
+ <td>css=.search-navigator-workspace-list .issue</td>
+ <td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>create_event_with_special_character</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">create_event_with_special_character</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/sessions/logout</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/sessions/login</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>login</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>type</td>
- <td>password</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>commit</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>css=.js-user-authenticated</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/project/history?id=sample</td>
- <td></td>
-</tr>
- <tr>
- <td>waitForElementPresent</td>
- <td>link=Create</td>
- <td></td>
- </tr>
-<tr>
- <td>click</td>
- <td>link=Create</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>create_event_name_0</td>
- <td></td>
-</tr>
-<tr>
- <td>store</td>
- <td>évènement</td>
- <td>eventName</td>
-</tr>
-<tr>
- <td>type</td>
- <td>create_event_name_0</td>
- <td>${eventName}</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>create_save_event_0</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>infomsg</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>infomsg</td>
- <td>Event "${eventName}" was created.</td>
-</tr>
-<tr>
- <td>assertElementPresent</td>
- <td>//td[text()='${eventName}']</td>
- <td></td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>no_events_widget_on_dir</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">no_events_widget_on_package</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/widget?id=events&resource=sample</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>css=tr.event</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/widget?id=events&resource=sample%3Asrc%2Fmain%2Fxoo%2Fsample</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementNotPresent</td>
- <td>css=tr.event</td>
- <td></td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>show_events_using_filters</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">show_events_using_filters</td>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>open</td>
- <td>/sessions/logout</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/sessions/login</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>login</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>type</td>
- <td>password</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>commit</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForElementPresent</td>
- <td>css=.js-user-authenticated</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/project/history?id=sample</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>create_event_1_change</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>id=create_event_name_1</td>
- <td>Hello you</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>id=create_save_event_1</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>content</td>
- <td>*Event "Hello you" was created.*1.0-SNAPSHOT*Last*Hello you*</td>
-</tr>
-<tr>
- <td>open</td>
- <td>/widget?id=events&resource=sample</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>body</td>
- <td>*Events*</td>
-</tr>
-<tr>
- <td>waitForText</td>
- <td>block_1</td>
- <td>*Events*Version*1.0-SNAPSHOT*Other*Hello you*</td>
-</tr>
-<tr>
- <td>select</td>
- <td>id=select_category_1</td>
- <td>label=Quality Profile</td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>block_1</td>
- <td>*Version*1.0-SNAPSHOT*Other*Hello you*</td>
-</tr>
-<tr>
- <td>select</td>
- <td>id=select_category_1</td>
- <td>label=Other</td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>block_1</td>
- <td>*Version*1.0-SNAPSHOT*</td>
-</tr>
-<tr>
- <td>select</td>
- <td>id=select_category_1</td>
- <td>label=Version</td>
-</tr>
-<tr>
- <td>assertNotText</td>
- <td>block_1</td>
- <td>*Other*Hello you*</td>
-</tr>
-</tbody>
-</table>
-</body>
-</html>
<td>css=.source-line</td>
<td></td>
</tr>
- <tr>
- <td>storeHtmlSource</td>
- <td></td>
- <td></td>
- </tr>
<tr>
<td>verifyHtmlSource</td>
<td>glob:*<span class="k">package</span>*</td>
<td>css=.source-line</td>
<td></td>
</tr>
- <tr>
- <td>storeHtmlSource</td>
- <td></td>
- <td></td>
- </tr>
<tr>
<td>verifyHtmlSource</td>
<td>glob:*<span class="k">package</span>*</td>
<td>css=.source-line</td>
<td></td>
</tr>
- <tr>
- <td>storeHtmlSource</td>
- <td></td>
- <td></td>
- </tr>
<tr>
<td>verifyHtmlSource</td>
<td>glob:*<span class="k">package</span>*</td>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>ruby-rails-app</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <tbody>
- <tr>
- <td>open</td>
- <td>/fake_app/advanced</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>fake-div</td>
- <td>*This page requests database and use RoR partial*</td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>fake-div</td>
- <td>*Database connection OK*</td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>ruby-rails-app</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <tbody>
- <tr>
- <td>open</td>
- <td>/fake_app</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>fake-app</td>
- <td>Fake application</td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>helper-test</td>
- <td>message generated by helper</td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>