Exemplo n.º 1
0
  @Test
  public void should_support_property_sets_with_auto_generated_keys() {
    new SeleneseTest(
            Selenese.builder()
                .setHtmlTestsInClasspath(
                    "create-auto-generated",
                    "/settings/PropertySetsTest/auto-generated/create.html")
                .build())
        .runOn(orchestrator);

    String[] keys = getProperty("sonar.autogenerated").split("[,]");
    assertThat(getProperty("sonar.autogenerated." + keys[0] + ".value")).isEqualTo("FIRST");
    assertThat(getProperty("sonar.autogenerated." + keys[1] + ".value")).isEqualTo("SECOND");
    assertThat(getProperty("sonar.autogenerated." + keys[2] + ".value")).isEqualTo("THIRD");

    new SeleneseTest(
            Selenese.builder()
                .setHtmlTestsInClasspath(
                    "update-auto-generated",
                    "/settings/PropertySetsTest/auto-generated/update.html")
                .build())
        .runOn(orchestrator);

    keys = getProperty("sonar.autogenerated").split("[,]");
    assertThat(getProperty("sonar.autogenerated." + keys[0] + ".value")).isEqualTo("FIRST");
    assertThat(getProperty("sonar.autogenerated." + keys[1] + ".value")).isEqualTo("THIRD");
  }
Exemplo n.º 2
0
 @Test
 public void manage_measure_filters() {
   Selenese selenese =
       Selenese.builder()
           .setHtmlTestsInClasspath(
               "manage_measure_filters",
               "/measure/suite/measure_filters/save_with_special_characters.html")
           .build();
   // Use the old runner because it fails with the new Selenium runner
   orchestrator.executeSelenese(selenese);
 }
Exemplo n.º 3
0
 @Test
 public void copy_measure_filters() {
   Selenese selenese =
       Selenese.builder()
           .setHtmlTestsInClasspath(
               "copy_measure_filters",
               "/measure/suite/measure_filters/copy_measure_filter.html",
               "/measure/suite/measure_filters/copy_uniqueness_of_name.html")
           .build();
   // Use the old runner because it fails with the new Selenium runner
   orchestrator.executeSelenese(selenese);
 }
Exemplo n.º 4
0
 @Test
 public void measure_filter_list_widget() {
   Selenese selenese =
       Selenese.builder()
           .setHtmlTestsInClasspath(
               "measure_filter_list_widget",
               "/measure/suite/measure_filters/list_widget.html",
               "/measure/suite/measure_filters/list_widget_sort.html",
               "/measure/suite/measure_filters/list_widget_warning_if_missing_filter.html")
           .build();
   // Use the old runner because it fails with the new Selenium runner
   orchestrator.executeSelenese(selenese);
 }
Exemplo n.º 5
0
 @Test
 public void display_measure_filter_as_list() {
   Selenese selenese =
       Selenese.builder()
           .setHtmlTestsInClasspath(
               "display_measure_filter_as_list",
               "/measure/suite/measure_filters/list_change_columns.html",
               "/measure/suite/measure_filters/list_delete_column.html",
               "/measure/suite/measure_filters/list_move_columns.html",
               "/measure/suite/measure_filters/list_sort_by_descending_name.html",
               "/measure/suite/measure_filters/list_sort_by_ncloc.html")
           .build();
   // Use the old runner because it fails with the new Selenium runner
   orchestrator.executeSelenese(selenese);
 }
  /** SONAR-4700 */
  @Test
  public void not_display_periods_selection_dropdown_on_first_analysis() {
    orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY);
    orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "empty");
    orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")));

    // Use old way to execute Selenium because 'assertSelectOptions' action is not supported by
    // SeleneseTest
    orchestrator.executeSelenese(
        Selenese.builder()
            .setHtmlTestsInClasspath(
                "not-display-periods-selection-dropdown-on-first-analysis",
                "/measureHistory/DifferentialPeriodsTest/not-display-periods-selection-dropdown-on-dashboard.html")
            .build());

    orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")));

    orchestrator.executeSelenese(
        Selenese.builder()
            .setHtmlTestsInClasspath(
                "display-periods-selection-dropdown-after-first-analysis",
                "/measureHistory/DifferentialPeriodsTest/display-periods-selection-dropdown-on-dashboard.html")
            .build());
  }
Exemplo n.º 7
0
  /** SONAR-4099 */
  @Test
  public void should_not_share_filter_when_user_have_no_sharing_permissions() {
    String user = "******";
    createUser(user, "User Measure Filters without sharing permission");

    try {
      // Use the old runner because it fails with the new Selenium runner
      orchestrator.executeSelenese(
          Selenese.builder()
              .setHtmlTestsInClasspath(
                  "should_not_share_filter_when_user_have_no_sharing_permissions",
                  "/measure/suite/measure_filters/should-not-share-filter-when-user-have-no-sharing-permissions.html")
              .build());
    } finally {
      deactivateUser(user);
    }
  }
Exemplo n.º 8
0
 @Test
 public void execute_measure_filters() {
   Selenese selenese =
       Selenese.builder()
           .setHtmlTestsInClasspath(
               "execution_of_measure_filters",
               "/measure/suite/measure_filters/link_from_main_header.html",
               "/measure/suite/measure_filters/initial_search_form.html",
               "/measure/suite/measure_filters/search_for_projects.html",
               "/measure/suite/measure_filters/search_for_files.html",
               // SONAR-4195
               "/measure/suite/measure_filters/search-by-key.html",
               "/measure/suite/measure_filters/search-by-name.html",
               "/measure/suite/measure_filters/empty_filter.html")
           .build();
   // Use the old runner because it fails with the new Selenium runner
   orchestrator.executeSelenese(selenese);
 }
  /** SONAR-7093 */
  @Test
  public void ensure_leak_period_defined_at_project_level_is_taken_into_account() throws Exception {
    orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY);

    // Set a global property and a project property to ensure project property is used
    setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
    setServerProperty(orchestrator, PROJECT_KEY, "sonar.timemachine.period1", "30");

    // Execute an analysis in the past to have a past snapshot without any issues
    orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "empty");
    orchestrator.executeBuild(
        SonarRunner.create(projectDir("shared/xoo-sample"))
            .setProperty("sonar.projectDate", formatDate(addDays(new Date(), -15))));

    // Second analysis -> issues will be created
    orchestrator
        .getServer()
        .restoreProfile(FileLocation.ofClasspath("/measureHistory/one-issue-per-line-profile.xml"));
    orchestrator
        .getServer()
        .associateProjectToQualityProfile(PROJECT_KEY, "xoo", "one-issue-per-line");
    orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")));

    // Third analysis -> There's no new issue from previous analysis
    orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")));

    // Project should have 17 new issues for period 1
    Resource newTechnicalDebt =
        orchestrator
            .getServer()
            .getWsClient()
            .find(ResourceQuery.createForMetrics(PROJECT_KEY, "violations").setIncludeTrends(true));
    List<Measure> measures = newTechnicalDebt.getMeasures();
    assertThat(measures.get(0).getVariation1()).isEqualTo(17);

    // Check on ui that it's possible to define leak period on project
    new SeleneseTest(
            Selenese.builder()
                .setHtmlTestsInClasspath(
                    "define-leak-period-on-project",
                    "/measureHistory/DifferentialPeriodsTest/define-leak-period-on-project.html")
                .build())
        .runOn(orchestrator);
  }
Exemplo n.º 10
0
  @Test
  public void should_support_property_sets() {
    Selenese selenese =
        Selenese.builder()
            .setHtmlTestsInClasspath(
                "property-sets",
                "/settings/PropertySetsTest/property-sets/create.html",
                "/settings/PropertySetsTest/property-sets/delete.html",
                "/settings/PropertySetsTest/property-sets/reference.html",
                "/settings/PropertySetsTest/property-sets/all_types.html")
            .build();
    // Use the old runner because it fails with the new Selenium runner
    orchestrator.executeSelenese(selenese);

    // SSF-25 Check that the password has well be setted as now it does not appears in the html
    // source code
    String sonarDemoValue = getProperty("sonar.demo");
    assertThat(getProperty("sonar.demo." + sonarDemoValue + ".password")).isEqualTo("abcde");
  }
Exemplo n.º 11
0
  @Test
  public void share_measure_filters() {
    // SONAR-4099
    String user = "******";
    createUser(user, "User Measure Filters with sharing permission", "shareDashboard");

    try {
      Selenese selenese =
          Selenese.builder()
              .setHtmlTestsInClasspath(
                  "share_measure_filters",
                  // SONAR-4469
                  "/measure/suite/measure_filters/should-unshare-filter-remove-other-filters-favourite.html")
              .build();
      // Use the old runner because it fails with the new Selenium runner
      orchestrator.executeSelenese(selenese);

    } finally {
      deactivateUser(user);
    }
  }
Exemplo n.º 12
0
 private void seleniumSuite(String suiteName, String... tests) {
   Selenese selenese = Selenese.builder().setHtmlTestsInClasspath(suiteName, tests).build();
   orchestrator.executeSelenese(selenese);
 }