]> source.dussan.org Git - sonarqube.git/commitdiff
Remove some more potential FP
authorDavid Gageot <david@gageot.net>
Wed, 2 Sep 2015 16:34:04 +0000 (18:34 +0200)
committerDavid Gageot <david@gageot.net>
Wed, 2 Sep 2015 17:29:13 +0000 (19:29 +0200)
13 files changed:
it/it-tests/src/test/java/administration/suite/administration/ProjectAdministrationTest.java
it/it-tests/src/test/java/selenium/LazyDomElement.java
it/it-tests/src/test/java/selenium/LazyShould.java
it/it-tests/src/test/java/selenium/Retry.java
it/it-tests/src/test/java/selenium/SeleneseTest.java
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/display-alerts-history-page/should-display-alerts-correctly-history-page.html
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/project-deletion/project-deletion.html
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-impossible-because-duplicate-keys.html
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-impossible-because-no-input.html
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-impossible-because-no-match.html
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-success.html
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/project-update-keys/fine-grained-update-impossible.html
it/it-tests/src/test/resources/administration/suite/ProjectAdministrationTest/project-update-keys/fine-grained-update-success.html

index 939b2af95a538349bade4a8e531d2050937eab30..7b9b49257e56a1d8dcace9598b1719a13ff1fc48 100644 (file)
@@ -104,7 +104,7 @@ public class ProjectAdministrationTest {
    * Test updated for SONAR-3570 and SONAR-5923
    */
   @Test
-  public void project_deletion() throws Exception {
+  public void project_deletion() {
     String projectAdminUser = "project-deletion-with-admin-permission-on-project";
     SonarClient adminClient = orchestrator.getServer().adminWsClient();
     try {
@@ -117,10 +117,9 @@ public class ProjectAdministrationTest {
       adminClient.permissionClient().addPermission(
         PermissionParameters.create().user(projectAdminUser).component("sample").permission("admin"));
 
-      // Use the old runner because it fails with the new Selenium runner
-      orchestrator.executeSelenese(
+      new SeleneseTest(
         Selenese.builder().setHtmlTestsInClasspath("project-deletion", "/administration/suite/ProjectAdministrationTest/project-deletion/project-deletion.html").build()
-      );
+      ).runOn(orchestrator);
     } finally {
       adminClient.userClient().deactivate(projectAdminUser);
     }
@@ -128,7 +127,7 @@ public class ProjectAdministrationTest {
 
   // SONAR-4203
   @Test
-  public void delete_version_of_multimodule_project() throws Exception {
+  public void delete_version_of_multimodule_project() {
     GregorianCalendar today = new GregorianCalendar();
     SonarRunner build = SonarRunner.create(projectDir("shared/xoo-multi-modules-sample"))
       .setProperty("sonar.dynamicAnalysis", "false")
@@ -162,7 +161,7 @@ public class ProjectAdministrationTest {
 
   // SONAR-3326
   @Test
-  public void display_alerts_correctly_in_history_page() throws Exception {
+  public void display_alerts_correctly_in_history_page() {
     QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient();
     QualityGate qGate = qgClient.create("AlertsForHistory");
     qgClient.setDefault(qGate.id());
@@ -178,8 +177,7 @@ public class ProjectAdministrationTest {
       .setHtmlTestsInClasspath("display-alerts-history-page",
         "/administration/suite/ProjectAdministrationTest/display-alerts-history-page/should-display-alerts-correctly-history-page.html"
       ).build();
-    // Use the old runner because it fails with the new Selenium runner
-    orchestrator.executeSelenese(selenese);
+    new SeleneseTest(selenese).runOn(orchestrator);
 
     qgClient.unsetDefault();
     qgClient.destroy(qGate.id());
@@ -189,7 +187,7 @@ public class ProjectAdministrationTest {
    * SONAR-1352
    */
   @Test
-  public void display_period_alert_on_project_dashboard() throws Exception {
+  public void display_period_alert_on_project_dashboard() {
     QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient();
     QualityGate qGate = qgClient.create("AlertsForDashboard");
     qgClient.createCondition(NewCondition.create(qGate.id()).metricKey("lines").operator("LT").warningThreshold("0").errorThreshold("10")
@@ -246,8 +244,7 @@ public class ProjectAdministrationTest {
         "/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-impossible-because-no-match.html",
         "/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-success.html"
       ).build();
-    // Use the old runner because it fails with the new Selenium runner
-    orchestrator.executeSelenese(selenese);
+    new SeleneseTest(selenese).runOn(orchestrator);
   }
 
   /**
@@ -263,8 +260,7 @@ public class ProjectAdministrationTest {
         "/administration/suite/ProjectAdministrationTest/project-update-keys/fine-grained-update-impossible.html",
         "/administration/suite/ProjectAdministrationTest/project-update-keys/fine-grained-update-success.html"
       ).build();
-    // Use the old runner because it fails with the new Selenium runner
-    orchestrator.executeSelenese(selenese);
+    new SeleneseTest(selenese).runOn(orchestrator);
   }
 
   /**
index 52cb63886214de4e4df571211a86929960aad12a..1a230bd0e5ae6321865046ba4ce907b187ee40eb 100644 (file)
@@ -71,7 +71,7 @@ class LazyDomElement {
   }
 
   public LazyShould should() {
-    return new LazyShould(this, Retry._5_SECONDS, true);
+    return new LazyShould(this, Retry._30_SECONDS, true);
   }
 
   public void fill(final CharSequence text) {
index 92ddbc6bf620d17543e756dd121847d12ecc1dcd..c344ba70e2a2a250efe974a4d114d98e2df65e70 100644 (file)
@@ -99,7 +99,7 @@ class LazyShould {
 
   public LazyShould contain(final String text) {
     return verify(
-      doesOrNot("contain(") + text + ")",
+      doesOrNot("contain") + "(" + text + ")",
       new Predicate<List<WebElement>>() {
         @Override
         public boolean apply(List<WebElement> elements) {
index 1623284adf81c5ee9b75c8e26de2b2be97bd3983..cc13823546d1cd6c5c3be880dc5ce50333b503f5 100644 (file)
@@ -33,7 +33,6 @@ import static java.util.concurrent.TimeUnit.SECONDS;
 
 class Retry {
   public static final Retry _30_SECONDS = new Retry(30, SECONDS);
-  public static final Retry _5_SECONDS = new Retry(5, SECONDS);
 
   private final long timeoutInMs;
 
index f78438a80b03e35a4b399c5c959e08e8df4f5197..9d7d2bb495d4987208e5936f46f711f457ca2eda 100644 (file)
@@ -21,6 +21,7 @@ package selenium;
 
 import com.sonar.orchestrator.Orchestrator;
 import com.sonar.orchestrator.selenium.Selenese;
+import org.assertj.core.util.Strings;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -38,7 +39,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.util.Objects.requireNonNull;
 import static java.util.regex.Pattern.DOTALL;
 import static org.assertj.core.api.Assertions.assertThat;
-import static selenium.Retry._5_SECONDS;
+import static selenium.Retry._30_SECONDS;
 
 public class SeleneseTest {
   private final Selenese suite;
@@ -127,6 +128,7 @@ public class SeleneseTest {
         return this;
       case "assertTextPresent":
         assertTextPresent(param1);
+        return this;
       case "assertTextNotPresent":
         assertTextNotPresent(param1);
         return this;
@@ -134,7 +136,7 @@ public class SeleneseTest {
         assertLocation(param1);
         return this;
       case "waitForElementPresent":
-        waitForElementPresent(param1);
+        waitForElementPresent(param1, param2);
         return this;
       case "waitForVisible":
         waitForVisible(param1);
@@ -148,6 +150,7 @@ public class SeleneseTest {
         confirm(param1);
         return this;
       case "setTimeout":
+      case "pause":
         // Ignore
         return this;
     }
@@ -179,7 +182,7 @@ public class SeleneseTest {
   private LazyDomElement find(String selector) {
     selector = replacePlaceholders(selector);
 
-    if (selector.startsWith("link=")) {
+    if (selector.startsWith("link=") || selector.startsWith("Link=")) {
       return find("a").withText(selector.substring(5));
     }
 
@@ -217,7 +220,7 @@ public class SeleneseTest {
     }
 
     System.out.println(" - selectFrame(" + id + ")");
-    _5_SECONDS.execute(new Runnable() {
+    _30_SECONDS.execute(new Runnable() {
       @Override
       public void run() {
         driver.switchTo().frame(id);
@@ -325,8 +328,12 @@ public class SeleneseTest {
     find("body").should().not().contain(text);
   }
 
-  private void waitForElementPresent(String selector) {
-    find(selector).should().exist();
+  private void waitForElementPresent(String selector, String text) {
+    if (Strings.isNullOrEmpty(text)) {
+      find(selector).should().exist();
+    } else {
+      find(selector).withText(text).should().exist();
+    }
   }
 
   private void waitForVisible(String selector) {
@@ -340,7 +347,7 @@ public class SeleneseTest {
   private void confirm(final String message) {
     System.out.println(" - confirm(" + message + ")");
 
-    _5_SECONDS.execute(new Runnable() {
+    _30_SECONDS.execute(new Runnable() {
       @Override
       public void run() {
         driver.switchTo().alert().accept();
index 1845a5a031d9bfdba41974e75d244c7b501532d8..4dc4d19847255906ea9241d126409ad33ec054e7 100644 (file)
         <td>/sonar/dashboard/index/sample</td>
         <td></td>
     </tr>
+    <tr>
+        <td>click</td>
+        <td>css=#context-navigation .navbar-admin-link</td>
+        <td></td>
+    </tr>
     <tr>
         <td>waitForElementPresent</td>
         <td>link=History</td>
index 9de248da6811361b69f38af2c07171e3a53d8cb0..e424badc70ab609711627a61b64e10a8f7175c6e 100644 (file)
        <td>/sonar/dashboard/index/sample</td>
        <td></td>
 </tr>
+<tr>
+    <td>click</td>
+    <td>css=#context-navigation .navbar-admin-link</td>
+    <td></td>
+</tr>
 <tr>
        <td>waitForElementPresent</td>
        <td>link=Deletion</td>
index 7e3f7a63ec23aee4662e2edd2b803d740df96162..b58daa1a5e2753f97042552072b10c04b2a714bf 100644 (file)
@@ -39,9 +39,9 @@
        <td></td>
 </tr>
 <tr>
-       <td>waitForElementPresent</td>
-       <td>link=Update Key</td>
-       <td></td>
+    <td>click</td>
+    <td>css=#context-navigation .navbar-admin-link</td>
+    <td></td>
 </tr>
 <tr>
        <td>clickAndWait</td>
index 3f925bc2226a651d9cb682d42cc480255402c11d..e160f29814233ff080391f3a404f329a8bac64c0 100644 (file)
         <td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
         <td></td>
     </tr>
+    <tr>
+        <td>click</td>
+        <td>css=#context-navigation .navbar-admin-link</td>
+        <td></td>
+    </tr>
     <tr>
         <td>waitForElementPresent</td>
         <td>link=Update Key</td>
index 7bd340476d780991ce648cd77473b2cd31adc833..f42db7bc348e564fa86cd56b9b35fa2ffa0fc00b 100644 (file)
         <td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
         <td></td>
     </tr>
+    <tr>
+        <td>click</td>
+        <td>css=#context-navigation .navbar-admin-link</td>
+        <td></td>
+    </tr>
     <tr>
         <td>waitForElementPresent</td>
         <td>link=Update Key</td>
index 1a778ecf599fe488e22c18907922b1f92e892240..20d7fbbd72543ae83f8cd59fba2281135f7b2229 100644 (file)
        <td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
        <td></td>
 </tr>
+<tr>
+    <td>click</td>
+    <td>css=#context-navigation .navbar-admin-link</td>
+    <td></td>
+</tr>
 <tr>
        <td>waitForElementPresent</td>
        <td>link=Update Key</td>
index c4191f938b9801a316ae78f5725029e711d05b06..7bf565c8221583574adad51d52da19217381f187 100644 (file)
         <td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
         <td></td>
     </tr>
+    <tr>
+        <td>click</td>
+        <td>css=#context-navigation .navbar-admin-link</td>
+        <td></td>
+    </tr>
     <tr>
         <td>waitForElementPresent</td>
         <td>link=Update Key</td>
index aaa1d9929f3dc3196391e24100dc5e12e1a743e0..eff5373a8c6bae8bf0931642b56cad51fac0e68f 100644 (file)
         <td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
         <td></td>
     </tr>
+    <tr>
+        <td>click</td>
+        <td>css=#context-navigation .navbar-admin-link</td>
+        <td></td>
+    </tr>
     <tr>
         <td>waitForElementPresent</td>
         <td>link=Update Key</td>