From c0b24c8891e6a8224b28e0df3af8058de8a06e7b Mon Sep 17 00:00:00 2001 From: Eric Hartmann Date: Fri, 10 Nov 2017 12:08:15 +0100 Subject: [PATCH] Remove useless ignored tests --- .../org/sonarqube/tests/Category1Suite.java | 5 - .../org/sonarqube/tests/Category4Suite.java | 5 - .../org/sonarqube/tests/Category5Suite.java | 2 - .../sonarqube/tests/dbCleaner/PurgeTest.java | 398 ------------------ .../org/sonarqube/tests/i18n/I18nTest.java | 61 --- .../tests/projectEvent/EventTest.java | 97 ----- .../settings/ElasticsearchSettingsTest.java | 59 --- 7 files changed, 627 deletions(-) delete mode 100644 tests/src/test/java/org/sonarqube/tests/dbCleaner/PurgeTest.java delete mode 100644 tests/src/test/java/org/sonarqube/tests/i18n/I18nTest.java delete mode 100644 tests/src/test/java/org/sonarqube/tests/projectEvent/EventTest.java delete mode 100644 tests/src/test/java/org/sonarqube/tests/settings/ElasticsearchSettingsTest.java diff --git a/tests/src/test/java/org/sonarqube/tests/Category1Suite.java b/tests/src/test/java/org/sonarqube/tests/Category1Suite.java index 836bd9807aa..8b0c9724871 100644 --- a/tests/src/test/java/org/sonarqube/tests/Category1Suite.java +++ b/tests/src/test/java/org/sonarqube/tests/Category1Suite.java @@ -30,10 +30,8 @@ import org.sonarqube.tests.authorisation.ProvisioningPermissionTest; import org.sonarqube.tests.authorisation.QualityProfileAdminPermissionTest; import org.sonarqube.tests.complexity.ComplexityMeasuresTest; import org.sonarqube.tests.customMeasure.CustomMeasuresTest; -import org.sonarqube.tests.i18n.I18nTest; import org.sonarqube.tests.measure.DifferentialPeriodsTest; import org.sonarqube.tests.measure.MeasuresWsTest; -import org.sonarqube.tests.measure.ProjectDashboardTest; import org.sonarqube.tests.measure.ProjectMeasuresPageTest; import org.sonarqube.tests.measure.SincePreviousVersionHistoryTest; import org.sonarqube.tests.measure.SinceXDaysHistoryTest; @@ -75,8 +73,6 @@ import static util.ItUtils.xooPlugin; EmailsTest.class, PropertySetsTest.class, SettingsTest.class, - // i18n - I18nTest.class, // quality gate QualityGateTest.class, QualityGateUiTest.class, @@ -92,7 +88,6 @@ import static util.ItUtils.xooPlugin; CustomMeasuresTest.class, // measure ProjectMeasuresPageTest.class, - ProjectDashboardTest.class, ProjectsPageTest.class, MeasuresWsTest.class, // measure history diff --git a/tests/src/test/java/org/sonarqube/tests/Category4Suite.java b/tests/src/test/java/org/sonarqube/tests/Category4Suite.java index f8f0e52c1bb..6bec598e4c9 100644 --- a/tests/src/test/java/org/sonarqube/tests/Category4Suite.java +++ b/tests/src/test/java/org/sonarqube/tests/Category4Suite.java @@ -29,9 +29,7 @@ import org.sonarqube.tests.ce.CeTempDirTest; import org.sonarqube.tests.ce.CeWsTest; import org.sonarqube.tests.component.ComponentsWsTest; import org.sonarqube.tests.component.ProjectsWsTest; -import org.sonarqube.tests.dbCleaner.PurgeTest; import org.sonarqube.tests.user.RootUserInStandaloneModeTest; -import org.sonarqube.tests.projectEvent.EventTest; import org.sonarqube.tests.projectEvent.ProjectActivityPageTest; import org.sonarqube.tests.qualityProfile.QualityProfilesUiTest; import org.sonarqube.tests.serverSystem.HttpHeadersTest; @@ -77,9 +75,6 @@ import static util.ItUtils.xooPlugin; FileExclusionsTest.class, IssueExclusionsTest.class, // db cleaner - PurgeTest.class, - // project event - EventTest.class, ProjectActivityPageTest.class, // http HttpHeadersTest.class, diff --git a/tests/src/test/java/org/sonarqube/tests/Category5Suite.java b/tests/src/test/java/org/sonarqube/tests/Category5Suite.java index e2a7d70a964..85125797af0 100644 --- a/tests/src/test/java/org/sonarqube/tests/Category5Suite.java +++ b/tests/src/test/java/org/sonarqube/tests/Category5Suite.java @@ -32,7 +32,6 @@ import org.sonarqube.tests.rule.RuleEsResilienceTest; import org.sonarqube.tests.serverSystem.RestartTest; import org.sonarqube.tests.serverSystem.ServerSystemRestartingOrchestrator; import org.sonarqube.tests.serverSystem.SystemStateTest; -import org.sonarqube.tests.settings.ElasticsearchSettingsTest; import org.sonarqube.tests.settings.SettingsTestRestartingOrchestrator; import org.sonarqube.tests.startup.StartupIndexationTest; import org.sonarqube.tests.telemetry.TelemetryOptOutTest; @@ -73,7 +72,6 @@ import org.sonarqube.tests.user.UserEsResilienceTest; IssueCreationDatePluginChangedTest.class, // elasticsearch - ElasticsearchSettingsTest.class, StartupIndexationTest.class, SystemPasscodeTest.class }) diff --git a/tests/src/test/java/org/sonarqube/tests/dbCleaner/PurgeTest.java b/tests/src/test/java/org/sonarqube/tests/dbCleaner/PurgeTest.java deleted file mode 100644 index c2bedf5426b..00000000000 --- a/tests/src/test/java/org/sonarqube/tests/dbCleaner/PurgeTest.java +++ /dev/null @@ -1,398 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info 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 org.sonarqube.tests.dbCleaner; - -import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.build.BuildResult; -import com.sonar.orchestrator.build.SonarScanner; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang.time.DateFormatUtils; -import org.apache.commons.lang.time.DateUtils; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; -import org.sonarqube.tests.Category4Suite; -import org.sonarqube.qa.util.Tester; -import org.sonarqube.ws.ProjectAnalyses; -import org.sonarqube.ws.WsMeasures; -import org.sonarqube.ws.WsMeasures.SearchHistoryResponse.HistoryValue; -import org.sonarqube.ws.client.measure.SearchHistoryRequest; -import org.sonarqube.ws.client.projectanalysis.SearchRequest; -import util.ItUtils; - -import static java.util.Collections.singletonList; -import static org.apache.commons.lang.time.DateUtils.addDays; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static util.ItUtils.formatDate; -import static util.ItUtils.newAdminWsClient; -import static util.ItUtils.restoreProfile; -import static util.ItUtils.runProjectAnalysis; -import static util.ItUtils.setServerProperty; -import static util.ItUtils.toDatetime; - -@Ignore -public class PurgeTest { - - private static final String COUNT_FILE_MEASURES = "project_measures pm, projects p where p.uuid = pm.component_uuid and p.scope='FIL'"; - private static final String COUNT_DIR_MEASURES = "project_measures pm, projects p where p.uuid = pm.component_uuid and p.scope='DIR'"; - private static final String PROJECT_KEY = "com.sonarsource.it.samples:multi-modules-sample"; - private static final String PROJECT_SAMPLE_PATH = "dbCleaner/xoo-multi-modules-sample"; - - private static final String ONE_DAY_AGO = DateFormatUtils.ISO_DATE_FORMAT.format(addDays(new Date(), -1)); - private static final String TWO_DAYS_AGO = DateFormatUtils.ISO_DATE_FORMAT.format(addDays(new Date(), -2)); - - @ClassRule - public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; - @Rule - public Tester tester = new Tester(orchestrator); - @Rule - public ErrorCollector collector = new ErrorCollector(); - - @Before - public void deleteProjectData() { - orchestrator.resetData(); - - orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY); - - restoreProfile(orchestrator, getClass().getResource("/dbCleaner/one-issue-per-line-profile.xml")); - } - - @Test - public void test_evolution_of_number_of_rows_when_scanning_two_times_the_same_project() { - Date today = new Date(); - Date yesterday = DateUtils.addDays(today, -1); - - scan(PROJECT_SAMPLE_PATH, DateFormatUtils.ISO_DATE_FORMAT.format(yesterday)); - - // count components - collector.checkThat("Wrong number of projects", count("projects where qualifier in ('TRK','BRC')"), equalTo(7)); - collector.checkThat("Wrong number of directories", count("projects where qualifier in ('DIR')"), equalTo(4)); - collector.checkThat("Wrong number of files", count("projects where qualifier in ('FIL')"), equalTo(4)); - collector.checkThat("Wrong number of unit test files", count("projects where qualifier in ('UTS')"), equalTo(0)); - - int measuresOnTrk = 45; - int measuresOnBrc = 222; - int measuresOnDir = 141; - int measuresOnFil = 69; - - // count measures  - assertMeasuresCountForQualifier("TRK", measuresOnTrk); - assertMeasuresCountForQualifier("BRC", measuresOnBrc); - assertMeasuresCountForQualifier("DIR", measuresOnDir); - assertMeasuresCountForQualifier("FIL", measuresOnFil); - - // No new_* metrics measure should be recorded the first time - collector.checkThat( - "Wrong number of measure of new_ metrics", - count("project_measures, metrics where metrics.id = project_measures.metric_id and metrics.name like 'new_%'"), - equalTo(0)); - - int expectedMeasures = measuresOnTrk + measuresOnBrc + measuresOnDir + measuresOnFil; - collector.checkThat("Wrong number of measures", count("project_measures"), equalTo(expectedMeasures)); - collector.checkThat("Wrong number of measure data", count("project_measures where measure_data is not null"), equalTo(0)); - - // count other tables that are constant between 2 scans - int expectedIssues = 52; - - collector.checkThat("Wrong number of issues", count("issues"), equalTo(expectedIssues)); - - // must be a different date, else a single snapshot is kept per day - scan(PROJECT_SAMPLE_PATH, DateFormatUtils.ISO_DATE_FORMAT.format(today)); - - int newMeasuresOnTrk = 58; - int newMeasuresOnBrc = 304; - int newMeasuresOnDir = 56; - int newMeasuresOnFil = 0; - - assertMeasuresCountForQualifier("TRK", measuresOnTrk + newMeasuresOnTrk); - assertMeasuresCountForQualifier("BRC", measuresOnBrc + newMeasuresOnBrc); - assertMeasuresCountForQualifier("DIR", measuresOnDir + newMeasuresOnDir); - assertMeasuresCountForQualifier("FIL", measuresOnFil + newMeasuresOnFil); - - // Measures on new_* metrics should be recorded - collector.checkThat( - "Wrong number of measure of new_ metrics", - count("project_measures, metrics where metrics.id = project_measures.metric_id and metrics.name like 'new_%'"), - equalTo(154)); - - // added measures relate to project and new_* metrics - expectedMeasures += newMeasuresOnTrk + newMeasuresOnBrc + newMeasuresOnDir + newMeasuresOnFil; - collector.checkThat("Wrong number of measures after second analysis", count("project_measures"), equalTo(expectedMeasures)); - collector.checkThat("Wrong number of measure data", count("project_measures where measure_data is not null"), equalTo(0)); - collector.checkThat("Wrong number of issues", count("issues"), equalTo(expectedIssues)); - } - - /** - * SONAR-3378 - */ - @Test - public void should_keep_all_snapshots_the_first_day() { - // analyse once - scan(PROJECT_SAMPLE_PATH); - // analyse twice - scan(PROJECT_SAMPLE_PATH); - // and check we have 2 snapshots - assertThat(count("snapshots s where s.component_uuid=(select p.uuid from projects p where p.kee='com.sonarsource.it.samples:multi-modules-sample')")).isEqualTo(2); - } - - /** - * SONAR-2807 & SONAR-3378 & SONAR-4710 - */ - @Test - public void should_keep_only_one_snapshot_per_day() { - scan(PROJECT_SAMPLE_PATH); - - int snapshotsCount = count("snapshots"); - int measuresCount = count("project_measures"); - // Using the "sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay" property set to '0' is the way - // to keep only 1 snapshot per day - setServerProperty(orchestrator, "sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay", "0"); - scan(PROJECT_SAMPLE_PATH); - assertThat(count("snapshots")).as("Different number of snapshots").isEqualTo(snapshotsCount); - - int measureOnNewMetrics = count("project_measures, metrics where metrics.id = project_measures.metric_id and metrics.name like 'new_%'"); - // Number of measures should be the same as previous, with the measures on new metrics - assertThat(count("project_measures")).as("Different number of measures").isEqualTo(measuresCount + measureOnNewMetrics); - } - - /** - * SONAR-7175 - */ - @Test - public void keep_latest_snapshot() { - // Keep all snapshots from last 4 weeks - setServerProperty(orchestrator, "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek", "4"); - - Date oneWeekAgo = addDays(new Date(), -7); - - // Execute an analysis wednesday last week - Calendar lastWednesday = Calendar.getInstance(); - lastWednesday.setTime(oneWeekAgo); - lastWednesday.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); - String lastWednesdayFormatted = formatDate(lastWednesday.getTime()); - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", lastWednesdayFormatted); - - // Execute an analysis thursday last week - Calendar lastThursday = Calendar.getInstance(); - lastThursday.setTime(oneWeekAgo); - lastThursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); - String lastThursdayFormatted = formatDate(lastThursday.getTime()); - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", lastThursdayFormatted); - - // Now only keep 1 snapshot per week - setServerProperty(orchestrator, "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek", "0"); - - // Execute an analysis today to execute the purge of previous weeks snapshots - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH); - - // Check that only analysis from last thursday is kept (as it's the last one from previous week) - WsMeasures.SearchHistoryResponse response = newAdminWsClient(orchestrator).measures().searchHistory(SearchHistoryRequest.builder() - .setComponent(PROJECT_KEY) - .setMetrics(singletonList("ncloc")) - .build()); - assertThat(response.getMeasuresCount()).isEqualTo(1); - assertThat(response.getMeasuresList().get(0).getHistoryList()).extracting(HistoryValue::getDate).doesNotContain(lastWednesdayFormatted, lastThursdayFormatted); - } - - @Test - public void keep_only_analyses_with_a_version() { - tester.settings().setGlobalSettings("sonar.dbcleaner.weeksBeforeKeepingOnlyAnalysesWithVersion", "1"); - - Date now = new Date(); - String heightDaysAgo = formatDate(addDays(now, -8)); - String nineDaysAgo = formatDate(addDays(now, -9)); - - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", nineDaysAgo, "sonar.projectVersion", "V1"); - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", heightDaysAgo); - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH); - - ProjectAnalyses.SearchResponse result = tester.wsClient().projectAnalysis().search(SearchRequest.builder().setProject(PROJECT_KEY).build()); - - assertThat(result.getAnalysesList()).extracting(a -> formatDate(toDatetime(a.getDate()))) - .contains(nineDaysAgo, formatDate(now)) - .doesNotContain(heightDaysAgo); - } - - /** - * SONAR-3120 - */ - @Test - public void should_delete_removed_modules() { - scan("dbCleaner/modules/before"); - assertExists("com.sonarsource.it.samples:multi-modules-sample:module_b"); - assertExists("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1"); - - // we want the previous snapshot to be purged - setServerProperty(orchestrator, "sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay", "0"); - - scan("dbCleaner/modules/after"); - assertDisabled("com.sonarsource.it.samples:multi-modules-sample:module_b"); - assertDisabled("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1"); - assertExists("com.sonarsource.it.samples:multi-modules-sample:module_c:module_c1"); - } - - /** - * SONAR-3120 - */ - @Test - public void should_delete_removed_files() { - String fileKey = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo"; - scan("dbCleaner/files/before"); - assertExists(fileKey); - - scan("dbCleaner/files/after"); - assertDisabled(fileKey); - assertExists("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/NewHelloA1.xoo"); - } - - /** - * SONAR-2754 - */ - @Test - public void should_delete_historical_data_of_directories_by_default() { - scan(PROJECT_SAMPLE_PATH, TWO_DAYS_AGO); - - int fileMeasures = count(COUNT_FILE_MEASURES); - int dirMeasures = count(COUNT_DIR_MEASURES); - - scan(PROJECT_SAMPLE_PATH, ONE_DAY_AGO); - - // second analysis with new_* metrics - assertThat(count(COUNT_FILE_MEASURES)).isLessThan(2 * fileMeasures); - assertThat(count(COUNT_DIR_MEASURES)).isLessThan(2 * dirMeasures); - } - - /** - * SONAR-2754 - */ - @Test - public void should_not_delete_historical_data_of_directories() { - scan(PROJECT_SAMPLE_PATH, TWO_DAYS_AGO); - - int fileMeasures = count(COUNT_FILE_MEASURES); - int dirMeasures = count(COUNT_DIR_MEASURES); - - setServerProperty(orchestrator, "sonar.dbcleaner.cleanDirectory", "false"); - - scan(PROJECT_SAMPLE_PATH, ONE_DAY_AGO); - - // second analysis as NEW_* metrics - assertThat(count(COUNT_FILE_MEASURES)).isLessThan(2 * fileMeasures); - assertThat(count(COUNT_DIR_MEASURES)).isGreaterThan(2 * dirMeasures); - } - - /** - * SONAR-2061 - */ - @Test - public void should_delete_historical_data_of_flagged_metrics() { - scan(PROJECT_SAMPLE_PATH, TWO_DAYS_AGO); - - // historical data of complexity_in_classes is supposed to be deleted (see CoreMetrics) - String selectNcloc = "project_measures where metric_id in (select id from metrics where name='ncloc')"; - String selectComplexityInClasses = "project_measures where metric_id in (select id from metrics where name='complexity_in_classes')"; - int nclocCount = count(selectNcloc); - int complexitInClassesCount = count(selectComplexityInClasses); - - scan(PROJECT_SAMPLE_PATH, ONE_DAY_AGO); - assertThat(count(selectNcloc)).isGreaterThan(nclocCount); - assertThat(count(selectComplexityInClasses)).isEqualTo(complexitInClassesCount); - } - - private void assertDisabled(String key) { - assertThat(enabledStatusOfComponent(key)).isFalse(); - } - - private void assertExists(String key) { - assertThat(enabledStatusOfComponent(key)).isTrue(); - } - - private Boolean enabledStatusOfComponent(String key) { - return orchestrator.getDatabase().executeSql("select enabled from projects p where p.kee='" + key + "'") - .stream() - .findFirst() - .map(PurgeTest::toBoolean) - .orElse(null); - } - - private static Boolean toBoolean(Map s) { - String value = s.get("ENABLED"); - if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("t") || value.equals("1")) { - return true; - } - if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("f") || value.equals("0")) { - return false; - } - throw new IllegalArgumentException("Unsupported value can not be converted to boolean " + value); - } - - private BuildResult scan(String path, String date) { - return scan(path, "sonar.projectDate", date); - } - - private BuildResult scan(String path, String... extraProperties) { - SonarScanner runner = configureRunner(path, extraProperties); - return orchestrator.executeBuild(runner); - } - - private SonarScanner configureRunner(String projectPath, String... props) { - orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "one-issue-per-line-profile"); - return SonarScanner.create(ItUtils.projectDir(projectPath)).setProperties(props); - } - - private int count(String condition) { - return orchestrator.getDatabase().countSql("select count(1) from " + condition); - } - - private void assertMeasuresCountForQualifier(String qualifier, int count) { - int result = countMeasures(qualifier); - if (result != count) { - logMeasures("GOT", qualifier); - } - collector.checkThat("Wrong number of measures for qualifier " + qualifier, result, equalTo(count)); - } - - private int countMeasures(String qualifier) { - String sql = "SELECT count(1) FROM project_measures pm, projects p, metrics m where p.uuid=pm.component_uuid and pm.metric_id=m.id and p.qualifier='" + qualifier + "'"; - return orchestrator.getDatabase().countSql(sql); - } - - private void logMeasures(String title, String qualifier) { - String sql = "SELECT m.name as metricName, pm.value as value, pm.text_value as textValue, pm.variation_value_1, pm.variation_value_2, pm.variation_value_3 " - + - "FROM project_measures pm, projects p, metrics m " + - "WHERE pm.component_uuid=p.uuid and pm.metric_id=m.id and p.qualifier='" - + qualifier + "'"; - List> rows = orchestrator.getDatabase().executeSql(sql); - - System.out.println("---- " + title + " - measures on qualifier " + qualifier); - for (Map row : rows) { - System.out.println(" " + row); - } - } - -} diff --git a/tests/src/test/java/org/sonarqube/tests/i18n/I18nTest.java b/tests/src/test/java/org/sonarqube/tests/i18n/I18nTest.java deleted file mode 100644 index 29b3580e0eb..00000000000 --- a/tests/src/test/java/org/sonarqube/tests/i18n/I18nTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info 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 org.sonarqube.tests.i18n; - -import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.Category1Suite; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Test; - -import static util.ItUtils.projectDir; -import static util.selenium.Selenese.runSelenese; - -public class I18nTest { - - @ClassRule - public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; - - @Before - public void cleanDatabase() { - orchestrator.resetData(); - } - - /** - * TODO This test should use a fake widget that display a fake metric with decimals instead of using provided metric - * Ignored because there is not a good idea to force a display language by GET parameter - * The displayed language is based on browser/system locale - */ - @Test - @Ignore - public void test_localization() { - orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); - - 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"); - } - -} diff --git a/tests/src/test/java/org/sonarqube/tests/projectEvent/EventTest.java b/tests/src/test/java/org/sonarqube/tests/projectEvent/EventTest.java deleted file mode 100644 index 4941929515c..00000000000 --- a/tests/src/test/java/org/sonarqube/tests/projectEvent/EventTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info 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 org.sonarqube.tests.projectEvent; - -import com.google.common.collect.Lists; -import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.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.PostRequest; -import org.sonarqube.ws.client.WsConnector; -import org.sonarqube.ws.client.WsResponse; -import util.ItUtils; - -import static org.assertj.core.api.Assertions.assertThat; -import static util.ItUtils.projectDir; - -@Ignore("refactor using wsClient") -public class EventTest { - - @ClassRule - public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; - - @Before - public void setUp() throws Exception { - orchestrator.resetData(); - } - - @Test - public void old_ws_events_does_not_allow_creating_events_on_modules() { - SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-multi-modules-sample")); - orchestrator.executeBuild(sampleProject); - - WsConnector wsConnector = ItUtils.newAdminWsClient(orchestrator).wsConnector(); - WsResponse response = wsConnector.call(newCreateEventRequest("com.sonarsource.it.samples:multi-modules-sample", "bar")); - assertThat(response.code()) - .isEqualTo(200); - - assertThat(wsConnector.call(newCreateEventRequest("com.sonarsource.it.samples:multi-modules-sample:module_a", "bar")).code()) - .isEqualTo(400); - } - - private static PostRequest newCreateEventRequest(String componentKey, String eventName) { - return new PostRequest("/api/events") - .setParam("resource", componentKey) - .setParam("name", eventName) - .setParam("category", "Foo"); - } - - /** - * SONAR-3308 - */ - @Test - public void keep_only_one_event_per_version_in_project_history() throws Exception { - // first analyse the 1.0-SNAPSHOT version - executeAnalysis(); - // then analyse the 1.0 version - executeAnalysis("sonar.projectVersion", "1.0"); - // and do this all over again - executeAnalysis(); - executeAnalysis("sonar.projectVersion", "1.0"); - - // there should be only 1 "0.1-SNAPSHOT" event and only 1 "0.1" event - List events = orchestrator.getServer().getWsClient().findAll(new EventQuery().setResourceKey("sample")); - assertThat(events.size()).isEqualTo(2); - List eventNames = Lists.newArrayList(events.get(0).getName(), events.get(1).getName()); - assertThat(eventNames).contains("1.0", "1.0-SNAPSHOT"); - } - - private static void executeAnalysis(String... properties) { - SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample")).setProperties(properties); - orchestrator.executeBuild(sampleProject); - } -} diff --git a/tests/src/test/java/org/sonarqube/tests/settings/ElasticsearchSettingsTest.java b/tests/src/test/java/org/sonarqube/tests/settings/ElasticsearchSettingsTest.java deleted file mode 100644 index 7a2bb9eec16..00000000000 --- a/tests/src/test/java/org/sonarqube/tests/settings/ElasticsearchSettingsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info 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 org.sonarqube.tests.settings; - -import com.sonar.orchestrator.Orchestrator; -import com.sonar.orchestrator.http.HttpClient; -import com.sonar.orchestrator.http.HttpResponse; -import java.net.InetAddress; -import okhttp3.HttpUrl; -import org.junit.Test; -import org.sonar.process.NetworkUtilsImpl; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ElasticsearchSettingsTest { - - @Test - public void set_http_port_through_sonar_properties() throws Exception { - int port = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress()); - Orchestrator orchestrator = Orchestrator - .builderEnv() - .setServerProperty("sonar.search.httpPort", "" + port) - .setServerProperty("sonar.search.host", InetAddress.getLoopbackAddress().getHostAddress()) - .build(); - - orchestrator.start(); - - try { - HttpClient httpClient = new HttpClient.Builder().build(); - HttpUrl url = new HttpUrl.Builder() - .scheme("http") - .host(InetAddress.getLoopbackAddress().getHostAddress()) - .port(port) - .addEncodedPathSegments("_cluster/state") - .build(); - HttpResponse response = httpClient.newCall(url).execute(); - assertThat(response.isSuccessful()).isTrue(); - } finally { - orchestrator.stop(); - } - } -} -- 2.39.5