aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-migration
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-02-15 18:18:27 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-02-17 13:31:49 +0100
commit9824b94f16109305b4847a611379029695823427 (patch)
tree85b339103ce4c56df78e3e26f21117da7fb04976 /server/sonar-db-migration
parent0d3be9943570cf5bfb7fbb72fdfe5a6fcb2798c0 (diff)
downloadsonarqube-9824b94f16109305b4847a611379029695823427.tar.gz
sonarqube-9824b94f16109305b4847a611379029695823427.zip
split sonar-db into server/sonar-db-core and server/sonar-db-dao
Diffstat (limited to 'server/sonar-db-migration')
-rw-r--r--server/sonar-db-migration/pom.xml4
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/AutoDbMigration.java110
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java57
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImpl.java18
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/UpsertImpl.java5
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java3
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationH2Test.java54
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java145
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SelectExecutorTest.java19
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SqlExecutorTest.java9
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest.java36
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java11
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplTest.java7
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderDbTesterTest.java8
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java10
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java7
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java7
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java33
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java7
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java8
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java9
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java15
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java8
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java16
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java23
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java27
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java13
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidImplTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java10
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java12
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java5
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java51
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SelectExecutorTest/users_table.sql4
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SqlExecutorTest/users_table.sql5
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest/schema_migration.sql4
121 files changed, 407 insertions, 779 deletions
diff --git a/server/sonar-db-migration/pom.xml b/server/sonar-db-migration/pom.xml
index d0e39a588cd..14d0b4f4c78 100644
--- a/server/sonar-db-migration/pom.xml
+++ b/server/sonar-db-migration/pom.xml
@@ -20,7 +20,7 @@
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>sonar-db</artifactId>
+ <artifactId>sonar-db-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
@@ -36,7 +36,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>sonar-db</artifactId>
+ <artifactId>sonar-db-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/AutoDbMigration.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/AutoDbMigration.java
deleted file mode 100644
index 40f297bfeea..00000000000
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/AutoDbMigration.java
+++ /dev/null
@@ -1,110 +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.sonar.server.platform.db.migration;
-
-import com.google.common.annotations.VisibleForTesting;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import org.apache.commons.dbutils.DbUtils;
-import org.apache.ibatis.session.SqlSession;
-import org.picocontainer.Startable;
-import org.sonar.api.platform.ServerUpgradeStatus;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.db.DbClient;
-import org.sonar.db.DdlUtils;
-import org.sonar.db.dialect.Dialect;
-import org.sonar.db.dialect.H2;
-import org.sonar.server.platform.db.migration.engine.MigrationEngine;
-
-/**
- * FIXME fix this class to remove use of DdlUtils.createSchema
- */
-public class AutoDbMigration implements Startable {
- private final ServerUpgradeStatus serverUpgradeStatus;
- private final DbClient dbClient;
- private final MigrationEngine migrationEngine;
-
- public AutoDbMigration(ServerUpgradeStatus serverUpgradeStatus, DbClient dbClient, MigrationEngine migrationEngine) {
- this.serverUpgradeStatus = serverUpgradeStatus;
- this.dbClient = dbClient;
- this.migrationEngine = migrationEngine;
- }
-
- @Override
- public void start() {
- if (!serverUpgradeStatus.isFreshInstall()) {
- return;
- }
-
- Loggers.get(getClass()).info("Automatically perform DB migration on fresh install");
- Dialect dialect = dbClient.getDatabase().getDialect();
- if (H2.ID.equals(dialect.getId())) {
- installH2();
- } else {
- migrationEngine.execute();
- }
- }
-
- @VisibleForTesting
- void installH2() {
- Connection connection = null;
- try (SqlSession session = dbClient.openSession(false)) {
- connection = session.getConnection();
- createH2Schema(connection, dbClient.getDatabase().getDialect().getId());
- } finally {
- DbUtils.closeQuietly(connection);
- }
- }
-
- @VisibleForTesting
- protected void createH2Schema(Connection connection, String dialectId) {
- DdlUtils.createSchema(connection, dialectId, false);
- hackFixForProjectMeasureTreeQueries(connection);
- }
-
- /**
- * see SONAR-8586
- */
- private static void hackFixForProjectMeasureTreeQueries(Connection connection) {
- int metricId = 1;
- try (PreparedStatement preparedStatement = connection.prepareStatement("insert into PROJECT_MEASURES (METRIC_ID,COMPONENT_UUID,ANALYSIS_UUID) values (?,?,?);")) {
- for (int i = 1; i < 1000; i++) {
- preparedStatement.setInt(1, metricId);
- preparedStatement.setString(2, "foo_" + i);
- preparedStatement.setString(3, "bar_" + i);
- preparedStatement.addBatch();
- if (i % 250 == 0) {
- preparedStatement.executeBatch();
- connection.commit();
- }
- }
- preparedStatement.executeBatch();
- connection.commit();
- } catch (SQLException e) {
- throw new RuntimeException("Failed to insert fake rows into table PROJECT_MEASURES", e);
- }
- }
-
- @Override
- public void stop() {
- // nothing to do
- }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java
index 405024c50ac..f36134be0d7 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java
@@ -21,28 +21,33 @@ package org.sonar.server.platform.db.migration.history;
import com.google.common.base.Throwables;
import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.Collections;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import java.util.Optional;
+import org.sonar.db.Database;
import org.sonar.db.DatabaseUtils;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.schemamigration.SchemaMigrationMapper;
import org.sonar.server.platform.db.migration.step.RegisteredMigrationStep;
import static com.google.common.base.Preconditions.checkState;
+import static org.sonar.core.util.stream.Collectors.toList;
public class MigrationHistoryImpl implements MigrationHistory {
- private final DbClient dbClient;
+ private static final String SCHEMA_MIGRATIONS_TABLE = "schema_migrations";
- public MigrationHistoryImpl(DbClient dbClient) {
- this.dbClient = dbClient;
+ private final Database database;
+
+ public MigrationHistoryImpl(Database database) {
+ this.database = database;
}
@Override
public void start() {
- try (Connection connection = dbClient.getDatabase().getDataSource().getConnection()) {
+ try (Connection connection = database.getDataSource().getConnection()) {
checkState(DatabaseUtils.tableExists(MigrationHistoryTable.NAME, connection), "Migration history table is missing");
} catch (SQLException e) {
Throwables.propagate(e);
@@ -56,26 +61,44 @@ public class MigrationHistoryImpl implements MigrationHistory {
@Override
public Optional<Long> getLastMigrationNumber() {
- try (DbSession dbSession = dbClient.openSession(false)) {
- List<Integer> versions = getMapper(dbSession).selectVersions();
+ try (Connection connection = database.getDataSource().getConnection()) {
+ List<Long> versions = selectVersions(connection);
if (!versions.isEmpty()) {
- Collections.sort(versions);
- return Optional.of(versions.get(versions.size() - 1).longValue());
+ return Optional.of(versions.get(versions.size() - 1));
}
return Optional.empty();
+ } catch (SQLException e) {
+ throw new IllegalStateException("Failed to read content of table " + SCHEMA_MIGRATIONS_TABLE, e);
}
}
@Override
public void done(RegisteredMigrationStep dbMigration) {
- try (DbSession dbSession = dbClient.openSession(false)) {
- getMapper(dbSession).insert(String.valueOf(dbMigration.getMigrationNumber()));
- dbSession.commit();
+ long migrationNumber = dbMigration.getMigrationNumber();
+ try (Connection connection = database.getDataSource().getConnection();
+ PreparedStatement statement = connection.prepareStatement("insert into schema_migrations(version) values (?)")) {
+
+ statement.setString(1, String.valueOf(migrationNumber));
+ statement.execute();
+ if (!connection.getAutoCommit()) {
+ connection.commit();
+ }
+ } catch (SQLException e) {
+ throw new IllegalStateException(String.format("Failed to insert row with value %s in table %s", migrationNumber, SCHEMA_MIGRATIONS_TABLE), e);
}
}
- private static SchemaMigrationMapper getMapper(DbSession dbSession) {
- return dbSession.getMapper(SchemaMigrationMapper.class);
+ private static List<Long> selectVersions(Connection connection) throws SQLException {
+ try (Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery("select version from " + SCHEMA_MIGRATIONS_TABLE)) {
+ List<Long> res = new ArrayList<>();
+ while (resultSet.next()) {
+ res.add(resultSet.getLong(1));
+ }
+ return res.stream()
+ .sorted(Comparator.naturalOrder())
+ .collect(toList());
+ }
}
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImpl.java
index efb63266460..0b6815e9a9b 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImpl.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImpl.java
@@ -24,23 +24,23 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.db.Database;
import org.sonar.db.DatabaseUtils;
-import org.sonar.db.DbClient;
-import org.sonar.server.platform.db.migration.sql.CreateTableBuilder;
import org.sonar.server.platform.db.migration.def.VarcharColumnDef;
+import org.sonar.server.platform.db.migration.sql.CreateTableBuilder;
public class MigrationHistoryTableImpl implements MigrationHistoryTable {
private static final String VERSION_COLUMN_NAME = "version";
- private final DbClient dbClient;
+ private final Database database;
- public MigrationHistoryTableImpl(DbClient dbClient) {
- this.dbClient = dbClient;
+ public MigrationHistoryTableImpl(Database database) {
+ this.database = database;
}
@Override
public void start() {
- try (Connection connection = createDdlConnection(dbClient)) {
+ try (Connection connection = createDdlConnection(database)) {
if (!DatabaseUtils.tableExists(NAME, connection)) {
createTable(connection);
}
@@ -50,7 +50,7 @@ public class MigrationHistoryTableImpl implements MigrationHistoryTable {
}
private void createTable(Connection connection) throws SQLException {
- List<String> sqls = new CreateTableBuilder(dbClient.getDatabase().getDialect(), NAME)
+ List<String> sqls = new CreateTableBuilder(database.getDialect(), NAME)
.addColumn(VarcharColumnDef.newVarcharColumnDefBuilder().setColumnName(VERSION_COLUMN_NAME).setIsNullable(false).setLimit(255).build())
.build();
@@ -60,8 +60,8 @@ public class MigrationHistoryTableImpl implements MigrationHistoryTable {
}
}
- private static Connection createDdlConnection(DbClient dbClient) throws SQLException {
- Connection res = dbClient.getDatabase().getDataSource().getConnection();
+ private static Connection createDdlConnection(Database database) throws SQLException {
+ Connection res = database.getDataSource().getConnection();
res.setAutoCommit(false);
return res;
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/UpsertImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/UpsertImpl.java
index 2a609a9eb34..df1a04ad9e2 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/UpsertImpl.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/UpsertImpl.java
@@ -22,10 +22,11 @@ package org.sonar.server.platform.db.migration.step;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-import org.sonar.db.BatchSession;
public class UpsertImpl extends BaseSqlStatement<Upsert> implements Upsert {
+ private static final int MAX_BATCH_SIZE = 250;
+
private long batchCount = 0L;
private UpsertImpl(PreparedStatement pstmt) {
@@ -37,7 +38,7 @@ public class UpsertImpl extends BaseSqlStatement<Upsert> implements Upsert {
pstmt.addBatch();
pstmt.clearParameters();
batchCount++;
- if (batchCount % BatchSession.MAX_BATCH_SIZE == 0L) {
+ if (batchCount % MAX_BATCH_SIZE == 0L) {
pstmt.executeBatch();
pstmt.getConnection().commit();
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java
index 1dc13cbea47..adf74030c27 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueue.java
@@ -21,7 +21,6 @@ package org.sonar.server.platform.db.migration.version.v61;
import java.sql.SQLException;
import org.sonar.db.Database;
-import org.sonar.db.ce.CeTaskTypes;
import org.sonar.server.platform.db.migration.step.DataChange;
/**
@@ -40,7 +39,7 @@ public class DeleteReportsFromCeQueue extends DataChange {
public void execute(Context context) throws SQLException {
context
.prepareUpsert("delete from ce_queue where task_type=?")
- .setString(1, CeTaskTypes.REPORT)
+ .setString(1, "REPORT")
.execute()
.commit();
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationH2Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationH2Test.java
deleted file mode 100644
index f085a3ca1c9..00000000000
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationH2Test.java
+++ /dev/null
@@ -1,54 +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.sonar.server.platform.db.migration;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.platform.ServerUpgradeStatus;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbTester;
-import org.sonar.server.platform.db.migration.engine.MigrationEngine;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-public class AutoDbMigrationH2Test {
- @Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AutoDbMigrationH2Test.class, "schema_migrations.sql");
-
- private DbClient dbClient = dbTester.getDbClient();
- private ServerUpgradeStatus serverUpgradeStatus = mock(ServerUpgradeStatus.class);
- private MigrationEngine migrationEngine = mock(MigrationEngine.class);
-
- private AutoDbMigration underTest = new AutoDbMigration(serverUpgradeStatus, dbClient, migrationEngine);
-
- @Test
- public void start_creates_fake_rows_in_project_measures_to_fix_sql_plan_of_measure_tree_queries() {
- when(serverUpgradeStatus.isFreshInstall()).thenReturn(true);
-
- underTest.start();
-
- verifyNoMoreInteractions(migrationEngine);
- assertThat(dbTester.countRowsOfTable("project_measures")).isEqualTo(999);
- }
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java
deleted file mode 100644
index b8e24b0cf32..00000000000
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java
+++ /dev/null
@@ -1,145 +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.sonar.server.platform.db.migration;
-
-import java.sql.Connection;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-import org.sonar.api.platform.ServerUpgradeStatus;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.dialect.Dialect;
-import org.sonar.db.dialect.H2;
-import org.sonar.db.dialect.MsSql;
-import org.sonar.db.dialect.MySql;
-import org.sonar.db.dialect.Oracle;
-import org.sonar.db.dialect.PostgreSql;
-import org.sonar.server.platform.db.migration.engine.MigrationEngine;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-public class AutoDbMigrationTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
- @Rule
- public LogTester logTester = new LogTester();
-
- private DbClient dbClient = mock(DbClient.class, Mockito.RETURNS_DEEP_STUBS);
- private ServerUpgradeStatus serverUpgradeStatus = mock(ServerUpgradeStatus.class);
- private MigrationEngine migrationEngine = mock(MigrationEngine.class);
- private AutoDbMigration underTest = new AutoDbMigration(serverUpgradeStatus, dbClient, migrationEngine);
-
- private AutoDbMigration noRealH2Creation = spy(new AutoDbMigration(serverUpgradeStatus, dbClient, migrationEngine) {
- @Override
- protected void createH2Schema(Connection connection, String dialectId) {
- // do nothing
- }
- });
-
- @Test
- public void start_creates_schema_on_h2_if_fresh_install() {
- mockDialect(new H2());
- mockDbClientOpenSession();
- mockFreshInstall(true);
-
- noRealH2Creation.start();
-
- verify(noRealH2Creation).installH2();
- verifyInfoLog();
- }
-
- @Test
- public void start_runs_MigrationEngine_on_mysql_if_fresh_install() {
- start_runs_MigrationEngine_for_dialect_if_fresh_install(new MySql());
- }
-
- @Test
- public void start_runs_MigrationEngine_on_postgre_if_fresh_install() {
- start_runs_MigrationEngine_for_dialect_if_fresh_install(new PostgreSql());
- }
-
- @Test
- public void start_runs_MigrationEngine_on_Oracle_if_fresh_install() {
- start_runs_MigrationEngine_for_dialect_if_fresh_install(new Oracle());
- }
-
- @Test
- public void start_runs_MigrationEngine_on_MsSQL_if_fresh_install() {
- start_runs_MigrationEngine_for_dialect_if_fresh_install(new MsSql());
- }
-
- private void start_runs_MigrationEngine_for_dialect_if_fresh_install(Dialect dialect) {
- mockDialect(dialect);
- mockFreshInstall(true);
-
- underTest.start();
-
- verify(migrationEngine).execute();
- verifyInfoLog();
- }
-
- @Test
- public void start_does_nothing_if_not_fresh_install() {
- mockFreshInstall(false);
-
- noRealH2Creation.start();
-
- verify(noRealH2Creation).start();
- verifyNoMoreInteractions(noRealH2Creation);
- verifyZeroInteractions(migrationEngine);
- assertThat(logTester.logs()).isEmpty();
- }
-
- @Test
- public void stop_has_no_effect() {
- underTest.stop();
- }
-
- private void mockFreshInstall(boolean value) {
- when(serverUpgradeStatus.isFreshInstall()).thenReturn(value);
- }
-
- private void mockDialect(Dialect dialect) {
- when(dbClient.getDatabase().getDialect()).thenReturn(dialect);
- }
-
- private void mockDbClientOpenSession() {
- Connection connection = mock(Connection.class);
- DbSession session = mock(DbSession.class);
- when(session.getConnection()).thenReturn(connection);
- when(dbClient.openSession(false)).thenReturn(session);
- }
-
- private void verifyInfoLog() {
- assertThat(logTester.logs()).hasSize(1);
- assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly("Automatically perform DB migration on fresh install");
- }
-
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SelectExecutorTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SelectExecutorTest.java
index f40af4e77a2..1c2499b5db8 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SelectExecutorTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SelectExecutorTest.java
@@ -23,26 +23,21 @@ import java.sql.Connection;
import java.util.List;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
-import org.sonar.db.user.UserDto;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
public class SelectExecutorTest {
@Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(SelectExecutorTest.class, "users_table.sql");
SqlExecutor underTest = new SqlExecutor();
@Test
public void testExecuteQuery() throws Exception {
- DbSession session = dbTester.getSession();
- dbTester.getDbClient().userDao().insert(session, new UserDto().setLogin("him").setName("Him"));
- dbTester.getDbClient().userDao().insert(session, new UserDto().setLogin("her").setName("Her"));
- session.commit();
+ insertUser("him", "Him");
+ insertUser("her", "Her");
try (Connection connection = dbTester.openConnection()) {
List<String[]> rows = underTest.select(connection, "select login, name from users order by login", new SqlExecutor.StringsConverter(2));
@@ -53,4 +48,10 @@ public class SelectExecutorTest {
assertThat(rows.get(1)[1]).isEqualTo("Him");
}
}
+
+ private void insertUser(String login, String name) {
+ dbTester.executeInsert("users",
+ "LOGIN", login,
+ "NAME", name);
+ }
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SqlExecutorTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SqlExecutorTest.java
index d4e0e4b5515..2d8c6c40286 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SqlExecutorTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/charset/SqlExecutorTest.java
@@ -25,8 +25,7 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import org.sonar.db.dialect.H2;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,10 +38,10 @@ public class SqlExecutorTest {
private static final String USERS_DB_TABLE = "users";
private static final String IS_ROOT_DB_COLUMN = "is_root";
- SqlExecutor underTest = new SqlExecutor();
+ private SqlExecutor underTest = new SqlExecutor();
@Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(SqlExecutorTest.class, "users_table.sql");
@Before
public void disableIfNotH2() {
@@ -58,7 +57,7 @@ public class SqlExecutorTest {
dbTester.executeInsert(USERS_DB_TABLE, LOGIN_DB_COLUMN, "login2", NAME_DB_COLUMN, "name two", IS_ROOT_DB_COLUMN, false);
try (Connection connection = dbTester.openConnection()) {
- List<String[]> users = underTest.select(connection, "select " + LOGIN_DB_COLUMN + ", " + NAME_DB_COLUMN + " from users order by id", new SqlExecutor.StringsConverter(
+ List<String[]> users = underTest.select(connection, "select " + LOGIN_DB_COLUMN + ", " + NAME_DB_COLUMN + " from users order by login", new SqlExecutor.StringsConverter(
2));
assertThat(users).hasSize(2);
assertThat(users.get(0)[0]).isEqualTo("login1");
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest.java
index 5c7e030684c..8bd51f1dc70 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest.java
@@ -19,14 +19,14 @@
*/
package org.sonar.server.platform.db.migration.history;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.util.Arrays;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
-import org.sonar.db.schemamigration.SchemaMigrationMapper;
+import org.sonar.db.CoreDbTester;
import org.sonar.server.platform.db.migration.step.MigrationStep;
import org.sonar.server.platform.db.migration.step.RegisteredMigrationStep;
@@ -34,14 +34,11 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MigrationHistoryImplTest {
@Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrationHistoryImplTest.class, "schema_migration.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private DbSession session = dbTester.getSession();
- private SchemaMigrationMapper schemaMigrationMapper = session.getMapper(SchemaMigrationMapper.class);
-
- private MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.getDbClient());
+ private MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.database());
@Test
public void start_does_not_fail_if_table_history_exists() {
@@ -54,8 +51,8 @@ public class MigrationHistoryImplTest {
}
@Test
- public void getLastMigrationNumber_returns_last_version_assuming_version_are_only_number() {
- insert("12", "5", "30", "8");
+ public void getLastMigrationNumber_returns_last_version_assuming_version_are_only_number() throws SQLException {
+ insert(12, 5, 30, 8);
assertThat(underTest.getLastMigrationNumber()).contains(30L);
}
@@ -74,8 +71,19 @@ public class MigrationHistoryImplTest {
assertThat(underTest.getLastMigrationNumber()).contains(12L);
}
- private void insert(String... versions) {
- Arrays.stream(versions).forEach(version -> schemaMigrationMapper.insert(version));
- session.commit();
+ private void insert(int... versions) throws SQLException {
+ try (Connection connection = dbTester.database().getDataSource().getConnection()) {
+ Arrays.stream(versions).forEach(version -> insert(connection, version));
+ }
+ }
+
+ private void insert(Connection connection, long version) {
+ try (PreparedStatement statement = connection.prepareStatement("insert into schema_migrations(version) values (?)")) {
+ statement.setString(1, String.valueOf(version));
+ statement.execute();
+ connection.commit();
+ } catch (SQLException e) {
+ throw new IllegalStateException(String.format("Failed to insert row with value %s", version), e);
+ }
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java
index 17d635849ec..51eaac93a1b 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplTest.java
@@ -26,9 +26,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,11 +34,11 @@ public class MigrationHistoryTableImplTest {
private static final String TABLE_SCHEMA_MIGRATIONS = "schema_migrations";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, MigrationHistoryTableImplTest.class, "empty.sql");
+ public CoreDbTester dbTester = CoreDbTester.createEmpty();
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private MigrationHistoryTableImpl underTest = new MigrationHistoryTableImpl(dbTester.getDbClient());
+ private MigrationHistoryTableImpl underTest = new MigrationHistoryTableImpl(dbTester.database());
@Test
public void start_creates_table_on_empty_schema() {
@@ -60,8 +58,7 @@ public class MigrationHistoryTableImplTest {
}
private void executeDdl(String sql) throws SQLException {
- try (DbSession dbSession = dbTester.getDbClient().openSession(false);
- Connection connection = dbSession.getConnection()) {
+ try (Connection connection = dbTester.database().getDataSource().getConnection()) {
connection.setAutoCommit(false);
try (Statement statement = connection.createStatement()) {
statement.execute(sql);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplTest.java
index 9f18d4b9ae6..704aed52c20 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplTest.java
@@ -23,16 +23,15 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class NoTableMigrationHistoryImplTest {
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, NoTableMigrationHistoryImplTest.class, "empty.sql");
+ public CoreDbTester dbTester = CoreDbTester.createEmpty();
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.getDbClient());
+ private MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.database());
@Test
public void start_fails_with_ISE_if_table_history_does_not_exist() throws SQLException {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderDbTesterTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderDbTesterTest.java
index 18db8f2b330..34464caa089 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderDbTesterTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderDbTesterTest.java
@@ -22,8 +22,7 @@ package org.sonar.server.platform.db.migration.sql;
import java.util.Map;
import org.junit.ClassRule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import org.sonar.db.dialect.Dialect;
import org.sonar.server.platform.db.migration.def.TinyIntColumnDef;
import org.sonar.server.platform.db.migration.def.VarcharColumnDef;
@@ -40,9 +39,9 @@ import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.Colu
public class CreateTableBuilderDbTesterTest {
@ClassRule
- public static final DbTester dbTester = DbTester.create(System2.INSTANCE);
+ public static final CoreDbTester dbTester = CoreDbTester.createEmpty();
- private Dialect dialect = dbTester.getDbClient().getDatabase().getDialect();
+ private Dialect dialect = dbTester.database().getDialect();
private static int tableNameGenerator = 0;
@Test
@@ -117,7 +116,6 @@ public class CreateTableBuilderDbTesterTest {
private void verifyAutoIncrementIsWorking(String tableName) {
dbTester.executeInsert(tableName, "val", "toto");
- dbTester.commit();
Map<String, Object> row = dbTester.selectFirst("select id as \"id\", val as \"val\" from " + tableName);
assertThat(row.get("id")).isNotNull();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java
index 9e4c382bce9..be0fbc774ec 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/DataChangeTest.java
@@ -27,9 +27,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.BatchSession;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import org.sonar.server.platform.db.migration.step.Select.Row;
import org.sonar.server.platform.db.migration.step.Select.RowReader;
@@ -39,8 +37,10 @@ import static org.junit.Assert.fail;
public class DataChangeTest {
+ private static final int MAX_BATCH_SIZE = 250;
+
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DataChangeTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DataChangeTest.class, "schema.sql");
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -261,7 +261,7 @@ public class DataChangeTest {
public void mass_batch_insert() throws Exception {
db.executeUpdateSql("truncate table persons");
- final int count = BatchSession.MAX_BATCH_SIZE + 10;
+ final int count = MAX_BATCH_SIZE + 10;
new DataChange(db.database()) {
@Override
public void execute(Context context) throws SQLException {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java
index 85d4e9582b9..e804fc9d8bc 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/CreateInitialSchemaTest.java
@@ -26,15 +26,14 @@ import java.util.List;
import java.util.Locale;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
public class CreateInitialSchemaTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateInitialSchemaTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateInitialSchemaTest.class, "empty.sql");
private CreateInitialSchema underTest = new CreateInitialSchema(dbTester.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java
index d208b72aee6..444aae7628c 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java
@@ -27,7 +27,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.core.util.stream.Collectors;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -43,7 +43,7 @@ public class PopulateInitialSchemaTest {
private System2 system2 = mock(System2.class);
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateInitialSchemaTest.class, "v56.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateInitialSchemaTest.class, "v56.sql");
private PopulateInitialSchema underTest = new PopulateInitialSchema(db.database(), system2);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java
index 7a4f83775d0..ace075b2ddb 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v561/UpdateUsersExternalIdentityWhenEmptyTest.java
@@ -26,7 +26,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -38,7 +38,7 @@ public class UpdateUsersExternalIdentityWhenEmptyTest {
private static final long NOW = 1_500_000_000_000L;
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, UpdateUsersExternalIdentityWhenEmptyTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(UpdateUsersExternalIdentityWhenEmptyTest.class, "schema.sql");
private System2 system = mock(System2.class);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java
index e63ed3e243a..8aca0619cda 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class AddAnalysisUuidColumnToCeActivityTest {
private static final long A_DATE = 123_456L;
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddAnalysisUuidColumnToCeActivityTest.class, "old_ce_activity.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidColumnToCeActivityTest.class, "old_ce_activity.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -61,7 +60,6 @@ public class AddAnalysisUuidColumnToCeActivityTest {
"updated_at", valueOf(A_DATE),
"submitted_at", valueOf(A_DATE));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java
index 1dde66f1b19..c0876b15925 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class AddAnalysisUuidColumnToEventsTest {
private static final String TABLE_EVENTS = "events";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddAnalysisUuidColumnToEventsTest.class, "events_before_6-0.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidColumnToEventsTest.class, "events_before_6-0.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -56,7 +55,6 @@ public class AddAnalysisUuidColumnToEventsTest {
"EVENT_DATE", valueOf(1 + 100),
"CREATED_AT", valueOf(1 + 300));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java
index d356eea8f9e..8e1a028c451 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class AddAnalysisUuidColumnToMeasuresTest {
private static final String TABLE = "project_measures";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddAnalysisUuidColumnToMeasuresTest.class, "old_measures.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidColumnToMeasuresTest.class, "old_measures.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -57,7 +56,6 @@ public class AddAnalysisUuidColumnToMeasuresTest {
"snapshot_id", valueOf(i + 100),
"component_uuid", valueOf(i + 1_000));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java
index 3fe71b99154..1d6f3b864a3 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class AddBColumnsToProjectsTest {
private static final String TABLE = "projects";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddBColumnsToProjectsTest.class, "old_projects.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddBColumnsToProjectsTest.class, "old_projects.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -57,7 +56,6 @@ public class AddBColumnsToProjectsTest {
"root_uuid", valueOf(i + 20),
"uuid_path", valueOf(i + 30));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java
index 01ff5290f5d..fd93547b46e 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest {
private static final String TABLE = "duplications_index";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.class,
"duplications_index_5.6.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -61,7 +60,6 @@ public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest {
"START_LINE", "3",
"END_LINE", "4");
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java
index 6f22036d593..6c37bbd6685 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java
@@ -24,15 +24,14 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
public class AddComponentUuidColumnToMeasuresTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidColumnToMeasuresTest.class, "project_measures_5.6.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddComponentUuidColumnToMeasuresTest.class, "project_measures_5.6.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -54,7 +53,6 @@ public class AddComponentUuidColumnToMeasuresTest {
"VALUE", valueOf(i),
"SNAPSHOT_ID", valueOf(i));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java
index ccf7961f504..5d793787feb 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class AddComponentUuidColumnsToSnapshotsTest {
private static final String SNAPSHOTS_TABLE = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidColumnsToSnapshotsTest.class, "old_snapshots.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddComponentUuidColumnsToSnapshotsTest.class, "old_snapshots.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -55,7 +54,6 @@ public class AddComponentUuidColumnsToSnapshotsTest {
"PROJECT_ID", valueOf(i),
"ISLAST", "TRUE");
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java
index a955f7b3ead..f053a78cfcd 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java
@@ -24,13 +24,12 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddLastUsedColumnToRulesProfilesTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddLastUsedColumnToRulesProfilesTest.class, "rules_profiles.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddLastUsedColumnToRulesProfilesTest.class, "rules_profiles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -53,7 +52,6 @@ public class AddLastUsedColumnToRulesProfilesTest {
"kee", "" + i,
"rules_updated_at", "2016-06-21");
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java
index 653e341418b..a58aa19cdf9 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java
@@ -24,13 +24,12 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddProfileKeyToActivitiesTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddProfileKeyToActivitiesTest.class, "activities.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddProfileKeyToActivitiesTest.class, "activities.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -51,7 +50,6 @@ public class AddProfileKeyToActivitiesTest {
"log_key", "LOG_KEY_" + i,
"user_login", "login");
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java
index 6bcbb6a55e6..8fbf323ce8b 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java
@@ -24,13 +24,12 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddUserUpdatedAtToRulesProfilesTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUserUpdatedAtToRulesProfilesTest.class, "rules_profiles.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddUserUpdatedAtToRulesProfilesTest.class, "rules_profiles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -54,7 +53,6 @@ public class AddUserUpdatedAtToRulesProfilesTest {
"rules_updated_at", "2016-06-21",
"last_used", "123456789");
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java
index bdb72b09a4d..38122d82113 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java
@@ -24,14 +24,13 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
public class AddUuidColumnToSnapshotsTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUuidColumnToSnapshotsTest.class, "old_snapshots.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToSnapshotsTest.class, "old_snapshots.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -53,7 +52,6 @@ public class AddUuidColumnToSnapshotsTest {
"root_component_uuid", valueOf(i + 10),
"QUALIFIER", (i % 2 == 0 ? "FIL" : "TRK"));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java
index 214ae911c31..9d86963b1a0 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java
@@ -24,15 +24,14 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddUuidColumnsToProjectsTest {
private static final String PROJECTS_TABLE = "projects";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUuidColumnsToProjectsTest.class, "old_projects.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnsToProjectsTest.class, "old_projects.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -53,7 +52,6 @@ public class AddUuidColumnsToProjectsTest {
"KEE", "key_" + i,
"ENABLED", "true");
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java
index 17816b08860..f295c2c087d 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java
@@ -24,15 +24,14 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
public class AddUuidColumnsToResourceIndexTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUuidColumnsToResourceIndexTest.class, "old_resourceindex.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnsToResourceIndexTest.class, "old_resourceindex.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -57,7 +56,6 @@ public class AddUuidColumnsToResourceIndexTest {
"ROOT_PROJECT_ID", valueOf(i + 20),
"QUALIFIER", (i % 2 == 0 ? "FILE" : "PROJECT"));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java
index c59095431b5..a45427b4987 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java
@@ -24,8 +24,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +34,7 @@ public class CleanEventsWithoutAnalysisUuidTest {
private static final String TABLE_EVENTS = "events";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanEventsWithoutAnalysisUuidTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(CleanEventsWithoutAnalysisUuidTest.class,
"in_progress_events.sql");
private CleanEventsWithoutAnalysisUuid underTest = new CleanEventsWithoutAnalysisUuid(db.database());
@@ -53,7 +52,6 @@ public class CleanEventsWithoutAnalysisUuidTest {
insertEvent(2, false, true);
insertEvent(3, false, false);
insertEvent(4, true, true);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java
index e5ae0f24504..19876d0a41b 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java
@@ -24,8 +24,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +34,7 @@ public class CleanEventsWithoutSnapshotIdTest {
private static final String TABLE_EVENTS = "events";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanEventsWithoutSnapshotIdTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(CleanEventsWithoutSnapshotIdTest.class,
"in_progress_events.sql");
private CleanEventsWithoutSnapshotId underTest = new CleanEventsWithoutSnapshotId(db.database());
@@ -53,7 +52,6 @@ public class CleanEventsWithoutSnapshotIdTest {
insertEvent(2, false);
insertEvent(3, false);
insertEvent(4, true);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java
index daf8f2b97b3..662a18056f3 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java
@@ -25,8 +25,7 @@ import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,7 +35,7 @@ public class CleanMeasuresWithNullAnalysisUuidTest {
private static final String TABLE_MEASURES = "project_measures";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanMeasuresWithNullAnalysisUuidTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(CleanMeasuresWithNullAnalysisUuidTest.class,
"in_progress_measures.sql");
private CleanMeasuresWithNullAnalysisUuid underTest = new CleanMeasuresWithNullAnalysisUuid(db.database());
@@ -53,7 +52,6 @@ public class CleanMeasuresWithNullAnalysisUuidTest {
insertMeasure(1, "U1");
insertMeasure(2, "U1");
insertMeasure(3, null);
- db.commit();
underTest.execute();
@@ -64,7 +62,6 @@ public class CleanMeasuresWithNullAnalysisUuidTest {
public void migration_is_reentrant() throws SQLException {
insertMeasure(1, "U1");
insertMeasure(2, null);
- db.commit();
underTest.execute();
assertThat(idsOfRows()).containsOnly(1L);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java
index 805ba6f8372..deb0c92097d 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java
@@ -24,8 +24,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class CleanOrphanRowsInResourceIndexTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanOrphanRowsInResourceIndexTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInResourceIndexTest.class,
"in_progress_resourceindex.sql");
private CleanOrphanRowsInResourceIndex underTest = new CleanOrphanRowsInResourceIndex(db.database());
@@ -52,7 +51,6 @@ public class CleanOrphanRowsInResourceIndexTest {
insertResourceIndex(3, true, false);
insertResourceIndex(4, false, true);
insertResourceIndex(5, true, true);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java
index ee0371706ee..f5ed42b4ee9 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java
@@ -24,8 +24,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +34,7 @@ public class CleanOrphanRowsInSnapshotsTest {
private static final String SNAPSHOTS_TABLE = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanOrphanRowsInSnapshotsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(CleanOrphanRowsInSnapshotsTest.class,
"in_progress_snapshots_and_children_tables.sql");
private CleanOrphanRowsInSnapshots underTest = new CleanOrphanRowsInSnapshots(db.database());
@@ -54,7 +53,6 @@ public class CleanOrphanRowsInSnapshotsTest {
insertSnapshots(3, true, false);
insertSnapshots(4, false, true);
insertSnapshots(5, true, true);
- db.commit();
underTest.execute();
@@ -84,7 +82,6 @@ public class CleanOrphanRowsInSnapshotsTest {
insertEvents(1);
insertEvents(2);
insertEvents(3);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java
index a8806fad419..e729f210997 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java
@@ -28,8 +28,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -42,7 +41,7 @@ public class CleanUsurperRootComponentsTest {
"user_roles", "properties", "widgets", "projects");
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanUsurperRootComponentsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(CleanUsurperRootComponentsTest.class,
"complete_schema.sql");
private CleanUsurperRootComponents underTest = new CleanUsurperRootComponents(db.database());
@@ -183,7 +182,7 @@ public class CleanUsurperRootComponentsTest {
"INDEX_IN_FILE", valueOf(0),
"START_LINE", valueOf(0),
"END_LINE", valueOf(0));
- db.commit();
+
}
private void insertProjectMeasures(String componentUuid, Long snapshotId) {
@@ -192,7 +191,7 @@ public class CleanUsurperRootComponentsTest {
"METRIC_ID", valueOf(123L),
"COMPONENT_UUID", componentUuid,
"SNAPSHOT_ID", valueOf(snapshotId));
- db.commit();
+
}
private void insertCeActivity(String componentUuid, Long snapshotId) {
@@ -208,7 +207,7 @@ public class CleanUsurperRootComponentsTest {
"SUBMITTED_AT", valueOf(121L),
"CREATED_AT", valueOf(122L),
"UPDATED_AT", valueOf(123L));
- db.commit();
+
}
private void insertEvent(String componentUuid, Long snapshotId) {
@@ -218,7 +217,7 @@ public class CleanUsurperRootComponentsTest {
"COMPONENT_UUID", componentUuid,
"CREATED_AT", valueOf(122L),
"EVENT_DATE", valueOf(123L));
- db.commit();
+
}
private Long insertSnapshot(String componentUuid, String rootComponentUuid) {
@@ -228,7 +227,7 @@ public class CleanUsurperRootComponentsTest {
"ID", valueOf(id),
"COMPONENT_UUID", componentUuid,
"ROOT_COMPONENT_UUID", rootComponentUuid);
- db.commit();
+
return id;
}
@@ -237,7 +236,7 @@ public class CleanUsurperRootComponentsTest {
"project_links",
"COMPONENT_UUID", componentUuid,
"HREF", dontCare());
- db.commit();
+
}
private void insertIssue(@Nullable String componentUuid, @Nullable String projectUuid) {
@@ -247,7 +246,7 @@ public class CleanUsurperRootComponentsTest {
"PROJECT_UUID", projectUuid == null ? dontCare() : projectUuid,
"KEE", "kee_" + componentUuid + projectUuid,
"MANUAL_SEVERITY", valueOf(true));
- db.commit();
+
}
private void insertFileSource(@Nullable String fileUuid, @Nullable String projectUuid) {
@@ -257,7 +256,7 @@ public class CleanUsurperRootComponentsTest {
"PROJECT_UUID", projectUuid == null ? dontCare() : projectUuid,
"CREATED_AT", valueOf(122L),
"UPDATED_AT", valueOf(123L));
- db.commit();
+
}
private void insertGroupRole(long componentId) {
@@ -265,7 +264,7 @@ public class CleanUsurperRootComponentsTest {
"group_roles",
"RESOURCE_ID", valueOf(componentId),
"ROLE", dontCare());
- db.commit();
+
}
private void insertUserRole(long componentId) {
@@ -273,14 +272,14 @@ public class CleanUsurperRootComponentsTest {
"user_roles",
"RESOURCE_ID", valueOf(componentId),
"ROLE", dontCare());
- db.commit();
+
}
private void insertProperties(long componentId) {
db.executeInsert(
"properties",
"RESOURCE_ID", valueOf(componentId));
- db.commit();
+
}
private void insertWidget(long componentId) {
@@ -289,7 +288,7 @@ public class CleanUsurperRootComponentsTest {
"DASHBOARD_ID", valueOf(95),
"WIDGET_KEY", dontCare(),
"RESOURCE_ID", valueOf(componentId));
- db.commit();
+
}
private long idGenerator = 0;
@@ -314,7 +313,7 @@ public class CleanUsurperRootComponentsTest {
"PROJECT_UUID", projectUuid,
"SCOPE", scope,
"QUALIFIER", qualifier);
- db.commit();
+
return uuid;
}
@@ -328,7 +327,7 @@ public class CleanUsurperRootComponentsTest {
"root_component_uuid", dontCare(),
"scope", scope,
"qualifier", qualifier);
- db.commit();
+
return id;
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java
index e70804bea18..e946a3a66f6 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java
@@ -23,8 +23,7 @@ import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ public class CreatePermTemplatesCharacteristicsTest {
private static final String TABLE_NAME = "perm_tpl_characteristics";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreatePermTemplatesCharacteristicsTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreatePermTemplatesCharacteristicsTest.class, "empty.sql");
private CreatePermTemplatesCharacteristics underTest = new CreatePermTemplatesCharacteristics(dbTester.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java
index b5f51492da3..52616348249 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java
@@ -31,9 +31,8 @@ public class DbVersion60Test {
@Test
public void verify_supports_components() {
assertThat(underTest.getSupportComponents()).containsExactly(
- FixProjectUuidOfDeveloperProjects.class,
- CleanUsurperRootComponents.class
- );
+ FixProjectUuidOfDeveloperProjects.class,
+ CleanUsurperRootComponents.class);
}
@Test
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java
index 98ecd3125a4..055372f66b4 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java
@@ -24,8 +24,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class DeleteOrphanMeasuresWithoutComponentTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeleteOrphanMeasuresWithoutComponentTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(DeleteOrphanMeasuresWithoutComponentTest.class,
"in_progress_project_measures.sql");
private DeleteOrphanMeasuresWithoutComponent underTest = new DeleteOrphanMeasuresWithoutComponent(db.database());
@@ -51,7 +50,6 @@ public class DeleteOrphanMeasuresWithoutComponentTest {
insertMeasure(2, false);
insertMeasure(3, false);
insertMeasure(4, true);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java
index b247a981fce..0a2a76a4a32 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java
@@ -24,8 +24,7 @@ import java.util.List;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +34,7 @@ public class DropTreesOfSnapshotsTest {
private static final String SNAPSHOTS_TABLE = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropTreesOfSnapshotsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(DropTreesOfSnapshotsTest.class,
"in_progress_snapshots.sql");
private DropTreesOfSnapshots underTest = new DropTreesOfSnapshots(db.database());
@@ -54,7 +53,6 @@ public class DropTreesOfSnapshotsTest {
insertSnapshot(3L, 1);
insertSnapshot(4L, 0);
insertSnapshot(5L, 3);
- db.commit();
underTest.execute();
@@ -65,7 +63,6 @@ public class DropTreesOfSnapshotsTest {
public void migration_is_reentrant() throws SQLException {
insertSnapshot(1L, 0);
insertSnapshot(2L, 2);
- db.commit();
underTest.execute();
verifySnapshots(1L);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java
index 0b02154824d..a769bb4a344 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java
@@ -24,8 +24,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,7 +39,7 @@ public class FixProjectUuidOfDeveloperProjectsTest {
private static final String DEV2_IN_PROJECT_UUID = "U5";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, FixProjectUuidOfDeveloperProjectsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(FixProjectUuidOfDeveloperProjectsTest.class,
"projects_5.6.sql");
private FixProjectUuidOfDeveloperProjects underTest = new FixProjectUuidOfDeveloperProjects(db.database());
@@ -88,7 +87,6 @@ public class FixProjectUuidOfDeveloperProjectsTest {
Long personId = insert(DEVELOPER_UUID, "DEV", null, DEVELOPER_UUID);
insert(DEV1_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID);
insert(DEV2_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID);
- db.commit();
}
private void verifyProjectUuid(String uuid, @Nullable String expectedProjectUuid) {
@@ -103,7 +101,7 @@ public class FixProjectUuidOfDeveloperProjectsTest {
"PERSON_ID", personId == null ? null : valueOf(personId),
"PROJECT_UUID", projectUuid,
"QUALIFIER", qualifier);
- db.commit();
+
return db.select("select ID from projects where UUID='" + uuid + "'").stream()
.findFirst()
.map(f -> (Long) f.get("ID"))
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java
index c555dad92cb..af172c410cb 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java
@@ -25,8 +25,7 @@ import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -35,7 +34,7 @@ public class MakeAnalysisUuidNotNullOnMeasuresTest {
private static final String TABLE_MEASURES = "project_measures";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeAnalysisUuidNotNullOnMeasuresTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeAnalysisUuidNotNullOnMeasuresTest.class,
"in_progress_measures.sql");
@Rule
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java
index 35244cf7b14..383bc688fd6 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java
@@ -26,8 +26,7 @@ import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.class,
"in_progress_duplications_index.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java
index a46c0767fb6..c7949ea7eb1 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class MakeComponentUuidColumnsNotNullOnSnapshotsTest {
private static final String SNAPSHOTS_TABLE = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidColumnsNotNullOnSnapshotsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeComponentUuidColumnsNotNullOnSnapshotsTest.class,
"in_progress_snapshots.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java
index 65f33fc4524..cc9d86008af 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java
@@ -26,8 +26,7 @@ import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MakeComponentUuidNotNullOnMeasuresTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidNotNullOnMeasuresTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeComponentUuidNotNullOnMeasuresTest.class,
"in_progress_project_measures.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java
index 8357f169469..5671be20ec7 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java
@@ -24,15 +24,14 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class MakeProfileKeyNotNullOnActivitiesTest {
private static final String TABLE_ACTIVITIES = "activities";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeProfileKeyNotNullOnActivitiesTest.class, "activities.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeProfileKeyNotNullOnActivitiesTest.class, "activities.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java
index 9a1773c3ba3..a82ae3cacc1 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class MakeUuidColumnNotNullOnSnapshotsTest {
private static final String TABLE_SNAPSHOTS = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeUuidColumnNotNullOnSnapshotsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidColumnNotNullOnSnapshotsTest.class,
"in_progress_snapshots.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java
index aac0618ee0b..d0434f73082 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class MakeUuidColumnsNotNullOnProjectsTest {
private static final String PROJECTS_TABLE = "projects";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeUuidColumnsNotNullOnProjectsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidColumnsNotNullOnProjectsTest.class,
"in_progress_projects.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java
index 084605d7dc6..d6e8d719410 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java
@@ -24,15 +24,14 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
public class MakeUuidColumnsNotNullOnResourceIndexTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeUuidColumnsNotNullOnResourceIndexTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidColumnsNotNullOnResourceIndexTest.class,
"in_progress_resourceindex.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java
index 8bf60f98a4d..291f48789aa 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java
@@ -25,8 +25,7 @@ import javax.annotation.Nullable;
import org.apache.commons.lang.RandomStringUtils;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,7 +37,7 @@ public class PopulateAnalysisUuidColumnOnCeActivityTest {
private static final String TABLE_SNAPSHOTS = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateAnalysisUuidColumnOnCeActivityTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidColumnOnCeActivityTest.class,
"in_progress_ce_activity.sql");
private PopulateAnalysisUuidColumnOnCeActivity underTest = new PopulateAnalysisUuidColumnOnCeActivity(db.database());
@@ -57,7 +56,6 @@ public class PopulateAnalysisUuidColumnOnCeActivityTest {
insertCeActivity(1, null);
insertCeActivity(2, 1L);
insertCeActivity(3, 2L);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java
index 92ad08f3257..b4188311fd3 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java
@@ -26,8 +26,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,7 +37,7 @@ public class PopulateAnalysisUuidOnEventsTest {
private static final String TABLE_SNAPSHOTS = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateAnalysisUuidOnEventsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidOnEventsTest.class,
"in_progress_events_with_snapshots.sql");
private PopulateAnalysisUuidOnEvents underTest = new PopulateAnalysisUuidOnEvents(db.database());
@@ -75,7 +74,6 @@ public class PopulateAnalysisUuidOnEventsTest {
insertEvent(210, 9L);
insertEvent(211, 10L);
insertEvent(212, 11L);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java
index 10a074c7a86..6ce6d93de39 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java
@@ -25,8 +25,7 @@ import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,7 +36,7 @@ public class PopulateAnalysisUuidOnMeasuresTest {
private static final String TABLE_SNAPSHOTS = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateAnalysisUuidOnMeasuresTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidOnMeasuresTest.class,
"old_measures.sql");
private PopulateAnalysisUuidOnMeasures underTest = new PopulateAnalysisUuidOnMeasures(db.database());
@@ -57,7 +56,6 @@ public class PopulateAnalysisUuidOnMeasuresTest {
insertMeasure(21, 1);
insertMeasure(22, 2);
insertMeasure(23, 3);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java
index b670e24bec2..24a4975dc38 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java
@@ -25,8 +25,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.class,
"in_progress_measures_with_snapshots.sql");
private PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex underTest = new PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex(db.database());
@@ -60,7 +59,6 @@ public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest {
insertDuplicationIndex(4, 60, 110); // 110 doesn't exist
insertDuplicationIndex(5, 90, 120); // 90 and 120 does not exist
insertDuplicationIndex(6, 100, 70); // 100 does not exist
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java
index a3de98177a5..992b808ec56 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java
@@ -25,8 +25,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,7 +35,7 @@ public class PopulateComponentUuidColumnsOfSnapshotsTest {
private static final String SNAPSHOTS_TABLE = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidColumnsOfSnapshotsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateComponentUuidColumnsOfSnapshotsTest.class,
"in_progress_snapshots_with_projects.sql");
private PopulateComponentUuidColumnsOfSnapshots underTest = new PopulateComponentUuidColumnsOfSnapshots(db.database());
@@ -64,7 +63,6 @@ public class PopulateComponentUuidColumnsOfSnapshotsTest {
insertSnapshots(5, 110, 100L); // 110 and 100 do not exist
insertSnapshots(6, 80, null); // no root
insertSnapshots(7, 120, null); // no root and 120 does not exist
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java
index caddc23d2d9..cdd39ef3456 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java
@@ -25,8 +25,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -47,7 +46,7 @@ public class PopulateComponentUuidOfMeasuresTest {
private static final String COMPONENT_UUID_2 = "U500";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidOfMeasuresTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateComponentUuidOfMeasuresTest.class,
"in_progress_measures_with_projects.sql");
private PopulateComponentUuidOfMeasures underTest = new PopulateComponentUuidOfMeasures(db.database());
@@ -71,7 +70,6 @@ public class PopulateComponentUuidOfMeasuresTest {
insertMeasure(2, SNAPSHOT_ID_2, COMPONENT_ID_1);
insertMeasure(3, SNAPSHOT_ID_3, COMPONENT_ID_2);
insertMeasure(4, SNAPSHOT_ID_5, COMPONENT_ID_3); // snapshot does not exist
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java
index 0061d717263..55aae8f3bdc 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java
@@ -25,8 +25,7 @@ import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,7 +38,7 @@ public class PopulateLastUsedColumnOfRulesProfilesTest {
private static final String METRIC_ID = "1";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateLastUsedColumnOfRulesProfilesTest.class, "rules_profiles.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateLastUsedColumnOfRulesProfilesTest.class, "rules_profiles.sql");
PopulateLastUsedColumnOfRulesProfiles underTest = new PopulateLastUsedColumnOfRulesProfiles(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java
index 6100f618a11..e641f2f98de 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java
@@ -23,8 +23,7 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +33,7 @@ public class PopulateProfileKeyOfActivitiesTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateProfileKeyOfActivitiesTest.class, "activities.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateProfileKeyOfActivitiesTest.class, "activities.sql");
PopulateProfileKeyOfActivities underTest = new PopulateProfileKeyOfActivities(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java
index 11c226b0208..5bdcf9fe14f 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java
@@ -28,8 +28,7 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,7 +38,7 @@ public class PopulateUserUpdatedAtOfRulesProfilesTest {
private static final String TABLE_ACTIVITIES = "activities";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUserUpdatedAtOfRulesProfilesTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserUpdatedAtOfRulesProfilesTest.class, "schema.sql");
PopulateUserUpdatedAtOfRulesProfiles underTest = new PopulateUserUpdatedAtOfRulesProfiles(db.database());
@@ -100,8 +99,8 @@ public class PopulateUserUpdatedAtOfRulesProfilesTest {
private void insertActivity(String profileKey, @Nullable String login, @Nullable Long createdAt) {
final String sqlInsertActivity = "insert into activities (profile_key, user_login, created_at) values (?, ?, ?) ";
- Connection connection = db.getSession().getConnection();
- try (PreparedStatement ps = connection.prepareStatement(sqlInsertActivity)) {
+ try (Connection connection = db.openConnection();
+ PreparedStatement ps = connection.prepareStatement(sqlInsertActivity)) {
ps.setString(1, profileKey);
ps.setString(2, login);
ps.setTimestamp(3, createdAt == null ? null : new Timestamp(createdAt));
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java
index 3aa0ad7f798..c112b338349 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java
@@ -29,7 +29,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactoryImpl;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,7 +39,7 @@ public class PopulateUuidColumnOnSnapshotsTest {
private static final String TABLE_SNAPSHOTS = "snapshots";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidColumnOnSnapshotsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidColumnOnSnapshotsTest.class,
"in_progress_snapshots.sql");
private PopulateUuidColumnOnSnapshots underTest = new PopulateUuidColumnOnSnapshots(db.database(), UuidFactoryImpl.INSTANCE);
@@ -56,7 +56,6 @@ public class PopulateUuidColumnOnSnapshotsTest {
insertSnapshot(1);
insertSnapshot(2);
insertSnapshot(3);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java
index b6b541fb1c1..bd71ff83247 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java
@@ -25,8 +25,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PopulateUuidColumnsOfProjectsTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidColumnsOfProjectsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidColumnsOfProjectsTest.class,
"in_progress_projects.sql");
private PopulateUuidColumnsOfProjects underTest = new PopulateUuidColumnsOfProjects(db.database());
@@ -58,7 +57,6 @@ public class PopulateUuidColumnsOfProjectsTest {
insertComponent(8, 200L, 1L, 200L); // a project copy of project 1 for developer 200 (does't exist)
insertComponent(9, 6L, 300L, null); // a project view of project 300 (doesn't exist)
insertComponent(10, 400L, null, null); // a module of a non existing project
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java
index 3bd42776369..2605e582c45 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java
@@ -25,8 +25,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PopulateUuidColumnsOfResourceIndexTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidColumnsOfResourceIndexTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidColumnsOfResourceIndexTest.class,
"in_progress_resourceindex_with_projects.sql");
private PopulateUuidColumnsOfResourceIndex underTest = new PopulateUuidColumnsOfResourceIndex(db.database());
@@ -59,7 +58,6 @@ public class PopulateUuidColumnsOfResourceIndexTest {
insertResourceIndex(3, 90, 70); // 90 does not exist
insertResourceIndex(4, 40, 100); // 100 does not exist
insertResourceIndex(5, 110, 100); // 110 and 100 do not exist
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java
index f3063c9a979..50202a3ed0d 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java
@@ -23,8 +23,7 @@ import java.sql.SQLException;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
@@ -43,7 +42,7 @@ public class PopulateUuidPathColumnOnProjectsTest {
private static final String QUALIFIER_FILE = "FIL";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidPathColumnOnProjectsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidPathColumnOnProjectsTest.class,
"in_progress_projects_and_snapshots.sql");
private PopulateUuidPathColumnOnProjects underTest = new PopulateUuidPathColumnOnProjects(db.database());
@@ -149,7 +148,6 @@ public class PopulateUuidPathColumnOnProjectsTest {
"root_component_uuid", rootUuid,
"qualifier", qualifier);
}
- db.commit();
}
private void verifyPath(String componentUuid, String expectedUuidPath) {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java
index 6d43af7a0eb..6f40c163f4b 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java
@@ -25,7 +25,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -39,7 +39,7 @@ public class RemoveUsersPasswordWhenNotLocalTest {
System2 system2 = mock(System2.class);
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, RemoveUsersPasswordWhenNotLocalTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(RemoveUsersPasswordWhenNotLocalTest.class, "schema.sql");
private RemoveUsersPasswordWhenNotLocal migration = new RemoveUsersPasswordWhenNotLocal(db.database(), system2);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java
index fa77dad9afb..97badc80994 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/AddErrorColumnsToCeActivityTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class AddErrorColumnsToCeActivityTest {
private static final String TABLE = "CE_ACTIVITY";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddErrorColumnsToCeActivityTest.class, "old_ce_activity.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(AddErrorColumnsToCeActivityTest.class, "old_ce_activity.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -63,7 +62,6 @@ public class AddErrorColumnsToCeActivityTest {
"created_at", valueOf(9512),
"updated_at", valueOf(45120));
}
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java
index 2ecc1d07649..13e17f66864 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CopyActivitiesToQprofileChangesTest.java
@@ -25,8 +25,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,7 +37,7 @@ public class CopyActivitiesToQprofileChangesTest {
private static final String TABLE_QPROFILE_CHANGES = "qprofile_changes";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, CopyActivitiesToQprofileChangesTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(CopyActivitiesToQprofileChangesTest.class, "schema.sql");
private CopyActivitiesToQprofileChanges underTest = new CopyActivitiesToQprofileChanges(db.database());
@@ -123,11 +122,15 @@ public class CopyActivitiesToQprofileChangesTest {
assertThat(db.countRowsOfTable(TABLE_QPROFILE_CHANGES)).isEqualTo(0);
}
- private void insertActivity(String key, @Nullable String profileKey, @Nullable String login, @Nullable String activityType, @Nullable String type, @Nullable String data, @Nullable Long createdAt) {
- db.executeInsert(TABLE_ACTIVITIES, "log_key", key, "profile_key", profileKey, "user_login", login, "log_type", activityType, "log_action", type, "data_field", data, "created_at", createdAt != null ? new Date(createdAt) : null);
+ private void insertActivity(String key, @Nullable String profileKey, @Nullable String login, @Nullable String activityType, @Nullable String type, @Nullable String data,
+ @Nullable Long createdAt) {
+ db.executeInsert(TABLE_ACTIVITIES, "log_key", key, "profile_key", profileKey, "user_login", login, "log_type", activityType, "log_action", type, "data_field", data,
+ "created_at", createdAt != null ? new Date(createdAt) : null);
}
private Map<String, Object> selectChangeByKey(String key) {
- return db.selectFirst("select qprofile_key as \"qprofileKey\", created_at as \"createdAt\", user_login as \"login\", change_type as \"changeType\", change_data as \"changeData\" from qprofile_changes where kee='" + key + "'");
+ return db.selectFirst(
+ "select qprofile_key as \"qprofileKey\", created_at as \"createdAt\", user_login as \"login\", change_type as \"changeType\", change_data as \"changeData\" from qprofile_changes where kee='"
+ + key + "'");
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java
index d0cf946511a..b2fcfbbc2ce 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableCeTaskInputTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ public class CreateTableCeTaskInputTest {
private static final String TABLE_CE_TASK_INPUT = "ce_task_input";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableCeTaskInputTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableCeTaskInputTest.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java
index af8688dc37a..15f214eed04 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableInternalPropertiesTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ public class CreateTableInternalPropertiesTest {
private static final String TABLE_INTERNAL_PROPERTIES = "internal_properties";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableInternalPropertiesTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableInternalPropertiesTest.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java
index be39be19dc4..3bda71adb58 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableProperties2Test.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ public class CreateTableProperties2Test {
private static final String TABLE_PROPERTIES_2 = "properties2";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableProperties2Test.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableProperties2Test.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java
index da0b4e73ffb..d091f423e7b 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableQprofileChangesTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ public class CreateTableQprofileChangesTest {
private static final String TABLE_QPROFILE_CHANGES = "qprofile_changes";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableQprofileChangesTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableQprofileChangesTest.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java
index 25703c6bf7b..349295b9e2b 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableRuleRepositoriesTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ public class CreateTableRuleRepositoriesTest {
private static final String TABLE_RULE_REPOSITORIES = "rule_repositories";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableRuleRepositoriesTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableRuleRepositoriesTest.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java
index 5c8b6bdb891..74ccfbfe732 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/CreateTableScannerContextTest.java
@@ -24,8 +24,7 @@ import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +32,7 @@ public class CreateTableScannerContextTest {
private static final String TABLE_CE_SCANNER_CONTEXT = "ce_scanner_context";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableCeTaskInputTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableCeTaskInputTest.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java
index 486440993f3..c22747021da 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteProjectDashboardsTest.java
@@ -25,15 +25,14 @@ import java.util.List;
import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
public class DeleteProjectDashboardsTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeleteProjectDashboardsTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DeleteProjectDashboardsTest.class, "schema.sql");
private DeleteProjectDashboards underTest = new DeleteProjectDashboards(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java
index b17e71a6712..d300c8ae984 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/DeleteReportsFromCeQueueTest.java
@@ -24,9 +24,7 @@ import java.util.List;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,7 +34,7 @@ public class DeleteReportsFromCeQueueTest {
private static final String TABLE_NAME = "ce_queue";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeleteReportsFromCeQueueTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DeleteReportsFromCeQueueTest.class, "schema.sql");
private DeleteReportsFromCeQueue underTest = new DeleteReportsFromCeQueue(db.database());
@@ -49,7 +47,7 @@ public class DeleteReportsFromCeQueueTest {
@Test
public void delete_tasks_with_type_REPORT_only() throws SQLException {
- db.executeInsert("ce_queue", "uuid", "U1", "task_type", CeTaskTypes.REPORT, "status", "PENDING", "created_at", NOW, "updated_at", NOW);
+ db.executeInsert("ce_queue", "uuid", "U1", "task_type", "REPORT", "status", "PENDING", "created_at", NOW, "updated_at", NOW);
db.executeInsert("ce_queue", "uuid", "U2", "task_type", "REFRESH_VIEWS", "status", "PENDING", "created_at", NOW, "updated_at", NOW);
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java
index 37b9eb93470..787cabb55dd 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/PopulateTableProperties2Test.java
@@ -28,8 +28,7 @@ import org.assertj.core.api.AbstractAssert;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
@@ -52,7 +51,7 @@ public class PopulateTableProperties2Test {
private System2 system2 = mock(System2.class);
@Rule
- public DbTester dbTester = DbTester.createForSchema(system2, PopulateTableProperties2Test.class,
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateTableProperties2Test.class,
"properties_and_properties_2_tables.sql");
private PopulateTableProperties2 underTest = new PopulateTableProperties2(dbTester.database(), system2);
@@ -202,7 +201,6 @@ public class PopulateTableProperties2Test {
"text_value", value,
"resource_id", resourceId == null ? null : valueOf(resourceId),
"user_id", userId == null ? null : valueOf(userId));
- dbTester.commit();
}
private void insertProperty2(int idAndKey, @Nullable String value, @Nullable Integer resourceId, @Nullable Integer userId) {
@@ -215,22 +213,20 @@ public class PopulateTableProperties2Test {
"text_value", value != null && value.length() <= 4000 ? value : null,
"clob_value", value != null && value.length() > 4000 ? value : null,
"created_at", valueOf(1_55555_555));
- dbTester.commit();
}
private Property2Assert assertThatProperty2(int key) {
- return new Property2Assert(dbTester, dbTester.getSession(), valueOf(key));
+ return new Property2Assert(dbTester, valueOf(key));
}
private static class Property2Assert extends AbstractAssert<Property2Assert, Property2> {
- private Property2Assert(DbTester dbTester, DbSession dbSession, String internalPropertyKey) {
- super(asInternalProperty(dbTester, dbSession, internalPropertyKey), Property2Assert.class);
+ private Property2Assert(CoreDbTester dbTester, String internalPropertyKey) {
+ super(asInternalProperty(dbTester, internalPropertyKey), Property2Assert.class);
}
- private static Property2 asInternalProperty(DbTester dbTester, DbSession dbSession, String key) {
+ private static Property2 asInternalProperty(CoreDbTester dbTester, String key) {
Map<String, Object> row = dbTester.selectFirst(
- dbSession,
"select" +
" user_id as \"userId\", resource_id as \"resourceId\", is_empty as \"isEmpty\", text_value as \"textValue\", clob_value as \"clobValue\", created_at as \"createdAt\"" +
" from properties2" +
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java
index 03f6855b833..0ae2b2e32f4 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromPropertiesTest.java
@@ -26,7 +26,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.spy;
@@ -39,7 +39,7 @@ public class RemoveViewsDefinitionFromPropertiesTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, RemoveViewsDefinitionFromPropertiesTest.class, "properties_and_internal_properties.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(RemoveViewsDefinitionFromPropertiesTest.class, "properties_and_internal_properties.sql");
private System2 system2 = spy(System2.INSTANCE);
private RemoveViewsDefinitionFromProperties underTest = new RemoveViewsDefinitionFromProperties(db.database(), system2);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java
index ae9b923eb62..ce0617ac092 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddIsRootColumnOnTableUsersTest.java
@@ -25,11 +25,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddIsRootColumnOnTableUsersTest {
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddIsRootColumnOnTableUsersTest.class, "table_users.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIsRootColumnOnTableUsersTest.class, "table_users.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java
index 5ed6707d5c7..683e4319858 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupRolesTest.java
@@ -25,13 +25,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddOrganizationUuidToGroupRolesTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToGroupRolesTest.class, "previous-group_roles.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToGroupRolesTest.class, "previous-group_roles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java
index 9deeeca3077..fb5a7540102 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToGroupsTest.java
@@ -25,12 +25,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddOrganizationUuidToGroupsTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToGroupsTest.class, "previous-groups.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToGroupsTest.class, "previous-groups.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java
index 0d8c8a8845f..d324e3cc15f 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java
@@ -25,12 +25,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddOrganizationUuidToPermissionTemplatesTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToPermissionTemplatesTest.class, "previous-permission_templates.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToPermissionTemplatesTest.class, "previous-permission_templates.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java
index 94638e0c05d..a6b66b35cff 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/AddOrganizationUuidToUserRolesTest.java
@@ -25,13 +25,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddOrganizationUuidToUserRolesTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToUserRolesTest.class, "previous-user_roles.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToUserRolesTest.class, "previous-user_roles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java
index d906dd3db0b..3b124d0942a 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateDefaultOrganizationTest.java
@@ -23,12 +23,14 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Date;
+import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactory;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
@@ -43,7 +45,7 @@ public class CreateDefaultOrganizationTest {
private System2 system2 = mock(System2.class);
@Rule
- public final DbTester dbTester = DbTester.createForSchema(system2, CreateDefaultOrganizationTest.class, "organizations_and_internal_properties.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateDefaultOrganizationTest.class, "organizations_and_internal_properties.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -98,8 +100,14 @@ public class CreateDefaultOrganizationTest {
}
private void verifyInternalProperty(String expectedUuid) {
- assertThat(dbTester.getDbClient().internalPropertiesDao().selectByKey(dbTester.getSession(), INTERNAL_PROPERTY_ORGANIZATION_DEFAULT))
- .contains(expectedUuid);
+
+ Map<String, Object> row = dbTester.selectFirst("select" +
+ " kee as \"KEE\"," +
+ " is_empty as \"IS_EMPTY\"," +
+ " text_value as \"TEXT_VALUE\"" +
+ " from internal_properties" +
+ " where kee = '" + INTERNAL_PROPERTY_ORGANIZATION_DEFAULT + "'");
+ assertThat(row.get("TEXT_VALUE")).isEqualTo(expectedUuid);
}
@Test
@@ -128,8 +136,11 @@ public class CreateDefaultOrganizationTest {
}
private void insertExistingInternalProperty(String uuid) {
- dbTester.getDbClient().internalPropertiesDao().save(dbTester.getSession(), INTERNAL_PROPERTY_ORGANIZATION_DEFAULT, uuid);
- dbTester.commit();
+ dbTester.executeInsert("INTERNAL_PROPERTIES",
+ "KEE", INTERNAL_PROPERTY_ORGANIZATION_DEFAULT,
+ "TEXT_VALUE", uuid,
+ "CREATED_AT", new Date().getTime(),
+ "IS_EMPTY", false);
}
private void insertExistingOrganization(String uuid, long past) throws Exception {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java
index b5627f4afca..2eecc9174d8 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableOrganizationsTest.java
@@ -25,7 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +33,7 @@ public class CreateTableOrganizationsTest {
private static final String TABLE_ORGANIZATIONS = "organizations";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableOrganizationsTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableOrganizationsTest.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java
index 0995fdd714f..07e01d720e1 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/CreateTableWebhookDeliveriesTest.java
@@ -25,7 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +35,7 @@ public class CreateTableWebhookDeliveriesTest {
private static final String TABLE = "webhook_deliveries";
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableWebhookDeliveriesTest.class, "empty.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(CreateTableWebhookDeliveriesTest.class, "empty.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java
index 730920747eb..96a8b1c7ed8 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DeletePermissionShareDashboardTest.java
@@ -24,7 +24,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class DeletePermissionShareDashboardTest {
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeletePermissionShareDashboardTest.class, "roles.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DeletePermissionShareDashboardTest.class, "roles.sql");
private DeletePermissionShareDashboard underTest = new DeletePermissionShareDashboard(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java
index e2226eedafa..24c2dead008 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTableTest.java
@@ -23,12 +23,12 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class DropIssueFiltersTableTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropIssueFiltersTableTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DropIssueFiltersTableTest.class, "schema.sql");
private DropIssueFiltersTables underTest = new DropIssueFiltersTables(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java
index 7b40b0451ca..989d5a58db2 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTableTest.java
@@ -23,12 +23,12 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class DropMeasureFiltersTableTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropMeasureFiltersTableTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DropMeasureFiltersTableTest.class, "schema.sql");
private DropMeasureFiltersTables underTest = new DropMeasureFiltersTables(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java
index 5f44c1abd28..e69b99ad191 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTablesTest.java
@@ -23,12 +23,12 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class DropRelatedDashboardTablesTest {
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropRelatedDashboardTablesTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DropRelatedDashboardTablesTest.class, "schema.sql");
private DropRelatedDashboardTables underTest = new DropRelatedDashboardTables(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java
index 0e7f106dfdf..404a422203a 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java
@@ -25,7 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +34,7 @@ public class MakeOrganizationUuidNotNullOnGroupRolesTest {
private static final String TABLE_GROUP_ROLES = "group_roles";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnGroupRolesTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnGroupRolesTest.class,
"in_progress_group_roles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java
index b6d66522515..761e6c095a3 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java
@@ -25,7 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +34,7 @@ public class MakeOrganizationUuidNotNullOnGroupsTest {
private static final String TABLE_GROUPS = "groups";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnGroupsTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnGroupsTest.class,
"in_progress_groups.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java
index f17cf18bd7a..e9cf4ac2363 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java
@@ -25,7 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -35,7 +35,7 @@ public class MakeOrganizationUuidNotNullOnPermissionTemplatesTest {
private static final String TABLE_PERMISSION_TEMPLATES = "permission_templates";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnPermissionTemplatesTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnPermissionTemplatesTest.class,
"in_progress_permission_templates.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java
index c1bd3988305..df5b5642c0c 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java
@@ -25,7 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +34,7 @@ public class MakeOrganizationUuidNotNullOnUserRolesTest {
private static final String TABLE_USER_ROLES = "user_roles";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnUserRolesTest.class,
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationUuidNotNullOnUserRolesTest.class,
"in_progress_user_roles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java
index 5e15f77c814..aafee864d2b 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/MakeRootColumnNotNullOnTableUsersTest.java
@@ -25,11 +25,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class MakeRootColumnNotNullOnTableUsersTest {
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, MakeRootColumnNotNullOnTableUsersTest.class, "users_with_nullable_root.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeRootColumnNotNullOnTableUsersTest.class, "users_with_nullable_root.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java
index 1e86c29ef41..9285b715dc8 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateIsRootColumnOnTableUsersTest.java
@@ -24,8 +24,7 @@ import java.util.List;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +33,7 @@ public class PopulateIsRootColumnOnTableUsersTest {
private static final String ROLE_ADMIN = "admin";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateIsRootColumnOnTableUsersTest.class, "users_and_permissions_tables.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateIsRootColumnOnTableUsersTest.class, "users_and_permissions_tables.sql");
private PopulateIsRootColumnOnTableUsers underTest = new PopulateIsRootColumnOnTableUsers(dbTester.database());
@@ -57,7 +56,6 @@ public class PopulateIsRootColumnOnTableUsersTest {
@Test
public void execute_sets_inactive_user_with_no_permission_has_not_root() throws SQLException {
insertUser("foo", false);
- dbTester.commit();
underTest.execute();
@@ -114,14 +112,14 @@ public class PopulateIsRootColumnOnTableUsersTest {
insertGroupRole(adminGroupId, ROLE_ADMIN);
int groupId = insertGroup("other group");
int[] userIds = {
- insertUser("inactive_direct_admin", false),
- insertUser("active_direct_admin", true),
- insertUser("inactive_group_admin", false),
- insertUser("active_group_admin", true),
- insertUser("group_and_direct_admin", true),
- insertUser("group_perm_user", true),
- insertUser("no_perm_user", true),
- insertUser("all_groups_user", true)
+ insertUser("inactive_direct_admin", false),
+ insertUser("active_direct_admin", true),
+ insertUser("inactive_group_admin", false),
+ insertUser("active_group_admin", true),
+ insertUser("group_and_direct_admin", true),
+ insertUser("group_perm_user", true),
+ insertUser("no_perm_user", true),
+ insertUser("all_groups_user", true)
};
// inactive_direct_admin
insertRole(userIds[0], ROLE_ADMIN);
@@ -160,31 +158,26 @@ public class PopulateIsRootColumnOnTableUsersTest {
private void insertRole(int userId, String role) {
dbTester.executeInsert("user_roles", "user_id", userId, "role", role);
- dbTester.commit();
}
private int insertUser(String login, boolean active) {
dbTester.executeInsert(USERS_TABLE, "login", login, "active", active);
- dbTester.commit();
Long userId = (Long) dbTester.selectFirst("select id as \"id\" from users where login = '" + login + "'").get("id");
return userId.intValue();
}
private int insertGroup(String groupName) {
dbTester.executeInsert("groups", "name", groupName);
- dbTester.commit();
Long groupId = (Long) dbTester.selectFirst("select id as \"id\" from groups where name = '" + groupName + "'").get("id");
return groupId.intValue();
}
private void insertGroupRole(int groupId, String role) {
dbTester.executeInsert("group_roles", "group_id", groupId, "role", role);
- dbTester.commit();
}
private void addUserToGroup(int userId, int groupId) {
dbTester.executeInsert("groups_users", "user_id", userId, "group_id", groupId);
- dbTester.commit();
}
private void verifySingleUser(String login, boolean root) {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java
index b9b678d14d4..c3e54ab6d3c 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java
@@ -24,7 +24,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class PopulateOrganizationUuidOfGroupRolesTest {
private static final String AN_ORG_UUID = "org1";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidOfGroupRolesTest.class, "group_roles.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfGroupRolesTest.class, "group_roles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java
index 31827ec4e30..c36c568efe8 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfGroupsTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.internal.TestSystem2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,7 +40,7 @@ public class PopulateOrganizationUuidOfGroupsTest {
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public DbTester dbTester = DbTester.createForSchema(system2, PopulateOrganizationUuidOfGroupsTest.class, "user_groups.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfGroupsTest.class, "user_groups.sql");
private PopulateOrganizationUuidOfGroups underTest = new PopulateOrganizationUuidOfGroups(dbTester.database(), system2);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java
index 4e87186e073..a856c8ab0c7 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java
@@ -24,7 +24,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class PopulateOrganizationUuidOfPermissionTemplatesTest {
private static final String AN_ORG_UUID = "org1";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidOfPermissionTemplatesTest.class, "permission_templates.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfPermissionTemplatesTest.class, "permission_templates.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java
index 74932d6cf5d..12675ce9313 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/PopulateOrganizationUuidOfUserRolesTest.java
@@ -24,7 +24,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class PopulateOrganizationUuidOfUserRolesTest {
private static final String AN_ORG_UUID = "org1";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidOfUserRolesTest.class, "user_roles.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidOfUserRolesTest.class, "user_roles.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java
index d64260361a4..cf55e2c5e61 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverageTest.java
@@ -37,8 +37,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
@@ -50,7 +49,7 @@ public class UpdateQualityGateConditionsOnCoverageTest {
private static final String TABLE_QUALITY_GATE_CONDITIONS = "quality_gate_conditions";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, UpdateQualityGateConditionsOnCoverageTest.class, "schema.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(UpdateQualityGateConditionsOnCoverageTest.class, "schema.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -238,12 +237,12 @@ public class UpdateQualityGateConditionsOnCoverageTest {
private long insertMetric(String key) {
dbTester.executeInsert("metrics", "NAME", key);
- return (Long) dbTester.selectFirst(dbTester.getSession(), format("select id as \"id\" from metrics where name='%s'", key)).get("id");
+ return (Long) dbTester.selectFirst(format("select id as \"id\" from metrics where name='%s'", key)).get("id");
}
private long insertQualityGate(String qualityGate) {
dbTester.executeInsert(TABLE_QUALITY_GATES, "NAME", qualityGate);
- return (Long) dbTester.selectFirst(dbTester.getSession(), format("select id as \"id\" from %s where name='%s'", TABLE_QUALITY_GATES, qualityGate)).get("id");
+ return (Long) dbTester.selectFirst(format("select id as \"id\" from %s where name='%s'", TABLE_QUALITY_GATES, qualityGate)).get("id");
}
private long insertQualityGateCondition(long qualityGateId, long metricId, @Nullable Long period, String operator, @Nullable String error, @Nullable String warning) {
@@ -259,12 +258,12 @@ public class UpdateQualityGateConditionsOnCoverageTest {
}
dbTester.executeInsert(TABLE_QUALITY_GATE_CONDITIONS, values);
return (Long) dbTester
- .selectFirst(dbTester.getSession(), format("select id as \"id\" from %s where qgate_id='%s' and metric_id='%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId, metricId))
+ .selectFirst(format("select id as \"id\" from %s where qgate_id='%s' and metric_id='%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId, metricId))
.get("id");
}
private void verifyConditions(long qualityGateId, QualityGateCondition... expectedConditions) {
- List<Map<String, Object>> results = dbTester.select(dbTester.getSession(),
+ List<Map<String, Object>> results = dbTester.select(
format("select m.name as \"metricKey\", qgc.period as \"period\", qgc.operator as \"operator\", qgc.value_error as \"error\", qgc.value_warning as \"warning\" from %s qgc " +
"inner join metrics m on m.id=qgc.metric_id " +
"where qgc.qgate_id = '%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId));
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java
index edabf08650c..8c3981f1dfd 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddColumnGuardedToOrganizationsTest.java
@@ -25,12 +25,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddColumnGuardedToOrganizationsTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddColumnGuardedToOrganizationsTest.class, "previous-organizations.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddColumnGuardedToOrganizationsTest.class, "previous-organizations.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java
index d4a9dcc0540..722665f9b2a 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddDefaultPermTemplateColumnsToOrganizationsTest.java
@@ -25,12 +25,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddDefaultPermTemplateColumnsToOrganizationsTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddDefaultPermTemplateColumnsToOrganizationsTest.class, "previous-organizations.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddDefaultPermTemplateColumnsToOrganizationsTest.class, "previous-organizations.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java
index 90ca69e93a8..57fdefbe569 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddIndexOnOrganizationUuidOfProjectsTest.java
@@ -24,12 +24,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddIndexOnOrganizationUuidOfProjectsTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddIndexOnOrganizationUuidOfProjectsTest.class, "projects.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnOrganizationUuidOfProjectsTest.class, "projects.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java
index 8bf9cb76f2c..8ed2cdee74d 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddOrganizationUuidToProjectsTest.java
@@ -25,12 +25,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddOrganizationUuidToProjectsTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToProjectsTest.class, "previous-projects.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddOrganizationUuidToProjectsTest.class, "previous-projects.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java
index af9c7781f5d..647584f2c7c 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUserIdToOrganizationsTest.java
@@ -25,12 +25,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddUserIdToOrganizationsTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddUserIdToOrganizationsTest.class, "previous-organizations.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddUserIdToOrganizationsTest.class, "previous-organizations.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java
index 4fac5eb32b1..ce6f23c0a40 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/AddUuidToEventsTest.java
@@ -25,13 +25,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class AddUuidToEventsTest {
@Rule
- public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddUuidToEventsTest.class, "previous-events.sql");
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddUuidToEventsTest.class, "previous-events.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidImplTest.java
index 32a3bad09b1..6c4b101fd12 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DefaultOrganizationUuidImplTest.java
@@ -24,7 +24,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import org.sonar.server.platform.db.migration.step.DataChange;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +33,7 @@ public class DefaultOrganizationUuidImplTest {
private static final String AN_ORG_UUID = "org1";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, DefaultOrganizationUuidImplTest.class, "internal_properties.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(DefaultOrganizationUuidImplTest.class, "internal_properties.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java
index b65234b9e40..a6792c6106e 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteMeasuresHavingNoValueTest.java
@@ -27,8 +27,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
@@ -39,7 +38,7 @@ public class DeleteMeasuresHavingNoValueTest {
private static final String TABLE_MEASURES = "project_measures";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeleteMeasuresHavingNoValueTest.class, "project_measures.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DeleteMeasuresHavingNoValueTest.class, "project_measures.sql");
private DeleteMeasuresHavingNoValue underTest = new DeleteMeasuresHavingNoValue(db.database());
@@ -56,7 +55,6 @@ public class DeleteMeasuresHavingNoValueTest {
insertMeasure(null, "text", null, null);
insertMeasure(null, null, "data", null);
insertMeasure(null, null, null, 50d);
- db.commit();
underTest.execute();
@@ -68,7 +66,6 @@ public class DeleteMeasuresHavingNoValueTest {
insertMeasure(null, null, null, null);
insertMeasure(null, null, null, null);
insertMeasure(null, null, null, null);
- db.commit();
underTest.execute();
@@ -81,7 +78,6 @@ public class DeleteMeasuresHavingNoValueTest {
insertMeasureOnlyOnVariations(11d, 2d, null, null, null);
insertMeasureOnlyOnVariations(12d, null, 3d, 4d, 5d);
insertMeasureOnlyOnVariations(12d, 2d, 3d, 4d, 5d);
- db.commit();
underTest.execute();
@@ -95,7 +91,6 @@ public class DeleteMeasuresHavingNoValueTest {
insertMeasureOnlyOnVariations(null, null, null, 4d, null);
insertMeasureOnlyOnVariations(null, null, null, null, 5d);
insertMeasureOnlyOnVariations(null, 2d, 3d, 4d, 5d);
- db.commit();
underTest.execute();
@@ -108,7 +103,6 @@ public class DeleteMeasuresHavingNoValueTest {
insertMeasure(null, "text", null, null);
insertMeasure(null, null, null, null);
insertMeasure(null, null, null, null);
- db.commit();
underTest.execute();
assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(2);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java
index a0e50488e41..9893fb02797 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DeleteUselessPropertiesTest.java
@@ -29,8 +29,7 @@ import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -42,7 +41,7 @@ public class DeleteUselessPropertiesTest {
private static final int COMPONENT_ID_2 = 604;
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeleteUselessPropertiesTest.class, "properties.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DeleteUselessPropertiesTest.class, "properties.sql");
private DeleteUselessProperties underTest = new DeleteUselessProperties(db.database());
@@ -56,7 +55,6 @@ public class DeleteUselessPropertiesTest {
@Test
public void migration_removes_hours_in_day_setting() throws SQLException {
insertProperty("sonar.technicalDebt.hoursInDay", null);
- db.commit();
underTest.execute();
@@ -66,7 +64,6 @@ public class DeleteUselessPropertiesTest {
@Test
public void migration_removes_create_user_setting() throws SQLException {
insertProperty("sonar.authenticator.createUser", null);
- db.commit();
underTest.execute();
@@ -79,7 +76,6 @@ public class DeleteUselessPropertiesTest {
insertProperty("sonar.timemachine.period3", null);
insertProperty("sonar.timemachine.period4", null);
insertProperty("sonar.timemachine.period5", null);
- db.commit();
underTest.execute();
@@ -94,7 +90,6 @@ public class DeleteUselessPropertiesTest {
insertProperty("sonar.timemachine.period3", COMPONENT_ID_1);
insertProperty("sonar.timemachine.period4", COMPONENT_ID_2);
insertProperty("sonar.timemachine.period5", COMPONENT_ID_2);
- db.commit();
underTest.execute();
@@ -110,7 +105,6 @@ public class DeleteUselessPropertiesTest {
insertProperty("sonar.timemachine.period2", COMPONENT_ID_1);
insertProperty("sonar.timemachine.period3", COMPONENT_ID_2);
insertProperty("sonar.timemachine.period3.TRK", COMPONENT_ID_2);
- db.commit();
underTest.execute();
@@ -125,7 +119,6 @@ public class DeleteUselessPropertiesTest {
// Only these settings should be removed
insertProperty("sonar.timemachine.period4", null);
insertProperty("sonar.timemachine.period5", null);
- db.commit();
underTest.execute();
@@ -141,7 +134,6 @@ public class DeleteUselessPropertiesTest {
// Only these settings should be removed
insertProperty("sonar.timemachine.period4", null);
insertProperty("sonar.timemachine.period5", null);
- db.commit();
underTest.execute();
assertThat(db.countRowsOfTable(TABLE_PROPERTIES)).isEqualTo(3);
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java
index 7f7ca788727..cad0b2bc8eb 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/DropTableResourceIndexTest.java
@@ -24,7 +24,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class DropTableResourceIndexTest {
@@ -32,7 +32,7 @@ public class DropTableResourceIndexTest {
public ExpectedException expectedException = ExpectedException.none();
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropTableResourceIndexTest.class, "schema.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(DropTableResourceIndexTest.class, "schema.sql");
private DropTableResourceIndex underTest = new DropTableResourceIndex(db.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java
index 268777a7e32..ef7e016bfc7 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeColumnGuardedOfOrganizationsNotNullableTest.java
@@ -26,13 +26,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
public class MakeColumnGuardedOfOrganizationsNotNullableTest {
private static final String TABLE_ORGANIZATIONS = "organizations";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, MakeColumnGuardedOfOrganizationsNotNullableTest.class, "organizations_with_nullable_guarded.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(MakeColumnGuardedOfOrganizationsNotNullableTest.class, "organizations_with_nullable_guarded.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java
index 5a152eaaabf..1bb0a0e7261 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeDefaultOrganizationGuardedTest.java
@@ -26,8 +26,7 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,7 +36,7 @@ public class MakeDefaultOrganizationGuardedTest {
private static final String DEFAULT_ORGANIZATION_UUID = "def-org";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeDefaultOrganizationGuardedTest.class, "organizations_and_internal_properties.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeDefaultOrganizationGuardedTest.class, "organizations_and_internal_properties.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java
index 5a1b18d0aac..fc683c2ad0e 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeOrganizationUuidOfProjectsNotNullableTest.java
@@ -25,8 +25,7 @@ import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +33,7 @@ public class MakeOrganizationUuidOfProjectsNotNullableTest {
private static final String TABLE_PROJECTS = "projects";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidToProjectsTest.class, "projects_with_nullable_organization.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidToProjectsTest.class, "projects_with_nullable_organization.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java
index f51a0c897a1..7d41f31005a 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/MakeUuidNotNullOnEventsTest.java
@@ -25,7 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
@@ -34,7 +34,7 @@ public class MakeUuidNotNullOnEventsTest {
private static final String TABLE_EVENTS = "events";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeUuidNotNullOnEventsTest.class, "in_progress_events.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(MakeUuidNotNullOnEventsTest.class, "in_progress_events.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java
index fe6aba2793a..506cb38fa66 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateColumnGuardedOfOrganizationsTest.java
@@ -24,14 +24,14 @@ import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
public class PopulateColumnGuardedOfOrganizationsTest {
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateColumnGuardedOfOrganizationsTest.class, "organizations.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateColumnGuardedOfOrganizationsTest.class, "organizations.sql");
private PopulateColumnGuardedOfOrganizations underTest = new PopulateColumnGuardedOfOrganizations(dbTester.database());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java
index 6d8c56aeb70..8abdae37504 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateDefaultPermTemplateColumnsOfOrganizationsTest.java
@@ -26,7 +26,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,7 +38,7 @@ public class PopulateDefaultPermTemplateColumnsOfOrganizationsTest {
private static final String DEFAULT_ORGANIZATION_UUID = "def org uuid";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateDefaultPermTemplateColumnsOfOrganizationsTest.class, "properties_and_organizations.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateDefaultPermTemplateColumnsOfOrganizationsTest.class, "properties_and_organizations.sql");
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java
index 9f48e8c3017..605f418db93 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateOrganizationUuidToProjectsTest.java
@@ -23,7 +23,7 @@ import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +33,7 @@ public class PopulateOrganizationUuidToProjectsTest {
private static final String ORGANIZATION_UUID = "some uuid";
@Rule
- public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidToProjectsTest.class, "projects_with_nullable_organization.sql");
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(PopulateOrganizationUuidToProjectsTest.class, "projects_with_nullable_organization.sql");
private PopulateOrganizationUuidToProjects underTest = new PopulateOrganizationUuidToProjects(dbTester.database(), new TestDefaultOrganizationUuid(ORGANIZATION_UUID));
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java
index 17626973c70..0426035270c 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/PopulateUuidColumnOfEventsTest.java
@@ -27,9 +27,8 @@ import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactoryImpl;
-import org.sonar.db.DbTester;
+import org.sonar.db.CoreDbTester;
import static java.lang.String.valueOf;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,7 +38,7 @@ public class PopulateUuidColumnOfEventsTest {
private static final String TABLE_EVENTS = "events";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidColumnOfEventsTest.class, "in_progress_events.sql");
+ public CoreDbTester db = CoreDbTester.createForSchema(PopulateUuidColumnOfEventsTest.class, "in_progress_events.sql");
private PopulateUuidColumnOfEvents underTest = new PopulateUuidColumnOfEvents(db.database(), UuidFactoryImpl.INSTANCE);
@@ -55,7 +54,6 @@ public class PopulateUuidColumnOfEventsTest {
insertEvents(1);
insertEvents(2);
insertEvents(3);
- db.commit();
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java
index 276e8515fba..cf4596b8ac0 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v63/UnsetUserRootFlagsTest.java
@@ -20,63 +20,68 @@
package org.sonar.server.platform.db.migration.version.v63;
import java.sql.SQLException;
+import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.internal.TestSystem2;
-import org.sonar.db.DbTester;
-import org.sonar.db.user.UserDto;
-import org.sonar.db.user.UserTesting;
+import org.sonar.db.CoreDbTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
public class UnsetUserRootFlagsTest {
private static final long CREATED_AT = 1_500L;
private static final long FIXED_AT = 1_600L;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
private TestSystem2 system = new TestSystem2().setNow(FIXED_AT);
@Rule
- public DbTester db = DbTester.createForSchema(system, UnsetUserRootFlagsTest.class, "in_progress_users.sql");
+ public ExpectedException expectedException = ExpectedException.none();
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(UnsetUserRootFlagsTest.class, "in_progress_users.sql");
private UnsetUserRootFlags underTest = new UnsetUserRootFlags(db.database(), system);
@Test
public void sets_USERS_IS_ROOT_to_false() throws SQLException {
- UserDto root1 = db.users().makeRoot(createUser());
- UserDto user1 = createUser();
- UserDto root2 = db.users().makeRoot(createUser());
- UserDto user2 = createUser();
+ createUser("root1", true);
+ createUser("nonRoot1", false);
+ createUser("root2", true);
+ createUser("nonRoot2", false);
underTest.execute();
- verifyNotRoot(CREATED_AT, user1, user2);
- verifyNotRoot(FIXED_AT, root1, root2);
+ verifyNotRoot(CREATED_AT, "nonRoot1", "nonRoot2");
+ verifyNotRoot(FIXED_AT, "root1", "root2");
}
@Test
public void migration_is_reentrant() throws SQLException {
- UserDto root = db.users().makeRoot(createUser());
+ createUser("root", true);
underTest.execute();
- verifyNotRoot(FIXED_AT, root);
+ verifyNotRoot(FIXED_AT, "root");
system.setNow(FIXED_AT + 100L);
underTest.execute();
- verifyNotRoot(FIXED_AT, root);
+ verifyNotRoot(FIXED_AT, "root");
}
- private void verifyNotRoot(long updatedAt, UserDto... users) {
- for (UserDto user : users) {
- db.rootFlag().verify(user, false, updatedAt);
+ private void verifyNotRoot(long updatedAt, String... logins) {
+ for (String login : logins) {
+ Map<String, Object> row = db.selectFirst("select is_root as \"isRoot\", updated_at as \"updatedAt\" from users where login='" + login + "'");
+ assertThat(row.get("isRoot")).isEqualTo(false);
+ assertThat(row.get("updatedAt")).isEqualTo(updatedAt);
}
}
- private UserDto createUser() {
- return db.users().insertUser(UserTesting.newUserDto()
- .setCreatedAt(CREATED_AT)
- .setUpdatedAt(CREATED_AT));
+ private String createUser(String login, boolean isRoot) {
+ db.executeInsert("users",
+ "login", login,
+ "is_root", isRoot,
+ "created_at", CREATED_AT,
+ "updated_at", CREATED_AT);
+ return login;
}
}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SelectExecutorTest/users_table.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SelectExecutorTest/users_table.sql
new file mode 100644
index 00000000000..e86b74fd8ec
--- /dev/null
+++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SelectExecutorTest/users_table.sql
@@ -0,0 +1,4 @@
+CREATE TABLE "USERS" (
+ "LOGIN" VARCHAR(255),
+ "NAME" VARCHAR(200)
+);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SqlExecutorTest/users_table.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SqlExecutorTest/users_table.sql
new file mode 100644
index 00000000000..1920431bc40
--- /dev/null
+++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/charset/SqlExecutorTest/users_table.sql
@@ -0,0 +1,5 @@
+CREATE TABLE "USERS" (
+ "LOGIN" VARCHAR(255),
+ "NAME" VARCHAR(200),
+ "IS_ROOT" BOOLEAN
+);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest/schema_migration.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest/schema_migration.sql
new file mode 100644
index 00000000000..aad2a0750a7
--- /dev/null
+++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/history/MigrationHistoryImplTest/schema_migration.sql
@@ -0,0 +1,4 @@
+CREATE TABLE "SCHEMA_MIGRATIONS" (
+ "VERSION" VARCHAR(256) NOT NULL
+);
+CREATE INDEX "UNIQUE_SCHEMA_MIGRATIONS" ON "SCHEMA_MIGRATIONS" ("VERSION");