diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2021-12-17 10:07:10 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-02-02 20:02:54 +0000 |
commit | bf5f5f91ed7a6489fda3f6d4ee163ad94aaedcb6 (patch) | |
tree | bd3e7958534488ce2e8d02edb717fae8fb063402 /server/sonar-db-core | |
parent | da25d9b1d4a2459bb201dd9b6e8166bd55149c57 (diff) | |
download | sonarqube-bf5f5f91ed7a6489fda3f6d4ee163ad94aaedcb6.tar.gz sonarqube-bf5f5f91ed7a6489fda3f6d4ee163ad94aaedcb6.zip |
SONAR-15845 Upgrade H2 database dependency to 2.X
Diffstat (limited to 'server/sonar-db-core')
4 files changed, 8 insertions, 6 deletions
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java b/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java index 1ea01fe5532..be9cd2b872c 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java @@ -49,10 +49,10 @@ import static org.sonar.process.ProcessProperties.Property.JDBC_URL; * @since 2.12 */ public class DefaultDatabase implements Database { - + private static final String IGNORED_KEYWORDS_OPTION = ";NON_KEYWORDS=VALUE"; private static final Logger LOG = Loggers.get(Database.class); - private static final String DEFAULT_URL = "jdbc:h2:tcp://localhost/sonar"; + private static final String DEFAULT_URL = "jdbc:h2:tcp://localhost/sonar" + IGNORED_KEYWORDS_OPTION; private static final String SONAR_JDBC = "sonar.jdbc."; private static final String SONAR_JDBC_DIALECT = "sonar.jdbc.dialect"; private static final String SONAR_JDBC_DRIVER = "sonar.jdbc.driverClassName"; diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java index cfac879e089..67d05f4e1e8 100644 --- a/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java +++ b/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java @@ -48,9 +48,9 @@ public class DefaultDatabaseTest { db.initSettings(); Properties props = db.getProperties(); - assertThat(props.getProperty("sonar.jdbc.url")).isEqualTo("jdbc:h2:tcp://localhost/sonar"); + assertThat(props.getProperty("sonar.jdbc.url")).isEqualTo("jdbc:h2:tcp://localhost/sonar;NON_KEYWORDS=VALUE"); assertThat(props.getProperty("sonar.jdbc.driverClassName")).isEqualTo("org.h2.Driver"); - assertThat(db).hasToString("Database[jdbc:h2:tcp://localhost/sonar]"); + assertThat(db).hasToString("Database[jdbc:h2:tcp://localhost/sonar;NON_KEYWORDS=VALUE]"); } @Test @@ -113,7 +113,7 @@ public class DefaultDatabaseTest { @Test public void shouldStart() { MapSettings settings = new MapSettings(); - settings.setProperty("sonar.jdbc.url", "jdbc:h2:mem:sonar"); + settings.setProperty("sonar.jdbc.url", "jdbc:h2:mem:sonar;NON_KEYWORDS=VALUE"); settings.setProperty("sonar.jdbc.driverClassName", "org.h2.Driver"); settings.setProperty("sonar.jdbc.username", "sonar"); settings.setProperty("sonar.jdbc.password", "sonar"); diff --git a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreH2Database.java b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreH2Database.java index 524a9e39531..3a46a6b56e2 100644 --- a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreH2Database.java +++ b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreH2Database.java @@ -36,6 +36,7 @@ import static java.lang.String.format; * H2 in-memory database, used for unit tests only against an empty DB or a provided H2 SQL script. */ public class CoreH2Database implements Database { + private static final String IGNORED_KEYWORDS_OPTION = ";NON_KEYWORDS=VALUE"; private final String name; private BasicDataSource datasource; @@ -43,7 +44,7 @@ public class CoreH2Database implements Database { * IMPORTANT: change DB name in order to not conflict with {@link DefaultDatabaseTest} */ public CoreH2Database(String name) { - this.name = name; + this.name = name + IGNORED_KEYWORDS_OPTION; } @Override diff --git a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java index 7704aa89e98..789b7003326 100644 --- a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java +++ b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java @@ -91,6 +91,7 @@ class CoreTestDb implements TestDb { if (!databaseToUpper) { name = name + ";DATABASE_TO_UPPER=FALSE"; } + name = name + ";NON_KEYWORDS=VALUE"; return new CoreH2Database(name); }; Consumer<Database> databaseInitializer = database -> { |