aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-01-27 17:56:09 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-01-28 09:18:44 +0100
commit9f12fac080a0176c772a91789b490b5b25364974 (patch)
treeb538b3c5d83dec346c3ce8a2de4ace7d689ac184 /sonar-db/src
parent9951423415ae5d3903cf9677d150f971d8ef51f6 (diff)
downloadsonarqube-9f12fac080a0176c772a91789b490b5b25364974.tar.gz
sonarqube-9f12fac080a0176c772a91789b490b5b25364974.zip
revert change to omponentDaoWithDuplicatedKeysTest
Diffstat (limited to 'sonar-db/src')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java14
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql34
2 files changed, 36 insertions, 12 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java
index ad19ef88dbc..10f6c501cd7 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.db.component;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -27,15 +26,13 @@ import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
-import org.sonar.db.dialect.MySql;
import org.sonar.test.DbTests;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
/**
- * On H2, the index on PROJECTS.KEE is unique. In order to simulate the MySQL behaviour we drop the index on DB other
- * than MySQL.
+ * On H2, the index on PROJECTS.KEE is unique. In order to simulate the MySQL behaviour where the index is not unique, we need to create a schema where there's no unique index on PROJECTS.KEE
*/
@Category(DbTests.class)
public class ComponentDaoWithDuplicatedKeysTest {
@@ -43,7 +40,7 @@ public class ComponentDaoWithDuplicatedKeysTest {
static final String PROJECT_KEY = "PROJECT_KEY";
@Rule
- public DbTester db = DbTester.create(System2.INSTANCE);
+ public DbTester db = DbTester.createForSchema(System2.INSTANCE, ComponentDaoWithDuplicatedKeysTest.class, "schema.sql");
DbClient dbClient = db.getDbClient();
@@ -51,13 +48,6 @@ public class ComponentDaoWithDuplicatedKeysTest {
ComponentDao underTest = new ComponentDao();
- @Before
- public void setUp() throws Exception {
- if (!MySql.ID.equals(db.getDbClient().getDatabase().getDialect().getId())) {
- db.executeUpdateSql("drop index if exists PROJECTS_KEE");
- }
- }
-
@Test
public void select_components_having_same_key() {
insertProject(newProjectDto().setKey(PROJECT_KEY));
diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql
new file mode 100644
index 00000000000..5b314d137e7
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql
@@ -0,0 +1,34 @@
+CREATE TABLE "PROJECTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "KEE" VARCHAR(400),
+ "ROOT_ID" INTEGER,
+ "UUID" VARCHAR(50),
+ "PROJECT_UUID" VARCHAR(50),
+ "MODULE_UUID" VARCHAR(50),
+ "MODULE_UUID_PATH" VARCHAR(4000),
+ "NAME" VARCHAR(256),
+ "DESCRIPTION" VARCHAR(2000),
+ "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE,
+ "SCOPE" VARCHAR(3),
+ "QUALIFIER" VARCHAR(10),
+ "DEPRECATED_KEE" VARCHAR(400),
+ "PATH" VARCHAR(2000),
+ "LANGUAGE" VARCHAR(20),
+ "COPY_RESOURCE_ID" INTEGER,
+ "LONG_NAME" VARCHAR(256),
+ "PERSON_ID" INTEGER,
+ "CREATED_AT" TIMESTAMP,
+ "AUTHORIZATION_UPDATED_AT" BIGINT
+);
+
+CREATE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE");
+
+CREATE INDEX "PROJECTS_ROOT_ID" ON "PROJECTS" ("ROOT_ID");
+
+CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID");
+
+CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID");
+
+CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID");
+
+CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER");