aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-06-27 00:10:46 +0200
committersonartech <sonartech@sonarsource.com>2018-06-29 09:10:18 +0200
commite2a451cf37afb4150f6af745344a5b55d7cbf149 (patch)
tree1f17705bc01c00baea83445730a523b7fcaeaefd /server/sonar-db-core
parent5089cb5947a4e02c7bbd234bc3de66bd6de7964c (diff)
downloadsonarqube-e2a451cf37afb4150f6af745344a5b55d7cbf149.tar.gz
sonarqube-e2a451cf37afb4150f6af745344a5b55d7cbf149.zip
SONARCLOUD-78 complete buckets of org histograms
Diffstat (limited to 'server/sonar-db-core')
-rw-r--r--server/sonar-db-core/src/main/java/org/sonar/db/dialect/AbstractDialect.java5
-rw-r--r--server/sonar-db-core/src/main/java/org/sonar/db/dialect/Dialect.java2
-rw-r--r--server/sonar-db-core/src/main/java/org/sonar/db/dialect/MySql.java5
-rw-r--r--server/sonar-db-core/src/main/java/org/sonar/db/dialect/Oracle.java5
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java25
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/MsSqlTest.java27
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/MySqlTest.java31
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/OracleTest.java5
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java27
9 files changed, 87 insertions, 45 deletions
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/AbstractDialect.java b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/AbstractDialect.java
index f2d3466ad77..0bc24005796 100644
--- a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/AbstractDialect.java
+++ b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/AbstractDialect.java
@@ -62,6 +62,11 @@ abstract class AbstractDialect implements Dialect {
}
@Override
+ public String getSqlFromDual() {
+ return "";
+ }
+
+ @Override
public final String getValidationQuery() {
return validationQuery;
}
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Dialect.java b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Dialect.java
index 459b2c38bcf..d5ef62217ff 100644
--- a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Dialect.java
+++ b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Dialect.java
@@ -56,6 +56,8 @@ public interface Dialect {
*/
String getFalseSqlValue();
+ String getSqlFromDual();
+
/**
* Query used to validate the jdbc connection.
*
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/MySql.java b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/MySql.java
index 8662f90fc82..86b19993813 100644
--- a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/MySql.java
+++ b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/MySql.java
@@ -51,4 +51,9 @@ public class MySql extends AbstractDialect {
public boolean supportsMigration() {
return true;
}
+
+ @Override
+ public String getSqlFromDual() {
+ return "from dual";
+ }
}
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Oracle.java b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Oracle.java
index 17afbcafe86..a55ac02157f 100644
--- a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Oracle.java
+++ b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/Oracle.java
@@ -49,4 +49,9 @@ public class Oracle extends AbstractDialect {
public List<String> getConnectionInitStatements() {
return INIT_STATEMENTS;
}
+
+ @Override
+ public String getSqlFromDual() {
+ return "from dual";
+ }
}
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
index 5ca459fe845..064c48fa259 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
@@ -25,34 +25,39 @@ import static org.assertj.core.api.Assertions.assertThat;
public class H2Test {
- H2 dialect = new H2();
+ private H2 underTest = new H2();
@Test
public void matchesJdbcURL() {
- assertThat(dialect.matchesJdbcURL("jdbc:h2:foo")).isTrue();
- assertThat(dialect.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
+ assertThat(underTest.matchesJdbcURL("jdbc:h2:foo")).isTrue();
+ assertThat(underTest.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
}
@Test
public void testBooleanSqlValues() {
- assertThat(dialect.getTrueSqlValue()).isEqualTo("true");
- assertThat(dialect.getFalseSqlValue()).isEqualTo("false");
+ assertThat(underTest.getTrueSqlValue()).isEqualTo("true");
+ assertThat(underTest.getFalseSqlValue()).isEqualTo("false");
}
@Test
public void should_configure() {
- assertThat(dialect.getId()).isEqualTo("h2");
- assertThat(dialect.getDefaultDriverClassName()).isEqualTo("org.h2.Driver");
- assertThat(dialect.getValidationQuery()).isEqualTo("SELECT 1");
+ assertThat(underTest.getId()).isEqualTo("h2");
+ assertThat(underTest.getDefaultDriverClassName()).isEqualTo("org.h2.Driver");
+ assertThat(underTest.getValidationQuery()).isEqualTo("SELECT 1");
}
@Test
public void testFetchSizeForScrolling() {
- assertThat(dialect.getScrollDefaultFetchSize()).isEqualTo(200);
+ assertThat(underTest.getScrollDefaultFetchSize()).isEqualTo(200);
}
@Test
public void h2_does_not_supportMigration() {
- assertThat(dialect.supportsMigration()).isFalse();
+ assertThat(underTest.supportsMigration()).isFalse();
+ }
+
+ @Test
+ public void getSqlFromDual() {
+ assertThat(underTest.getSqlFromDual()).isEqualTo("");
}
}
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MsSqlTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MsSqlTest.java
index 6fb49868151..6785f0bc126 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MsSqlTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MsSqlTest.java
@@ -25,37 +25,42 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MsSqlTest {
- private MsSql msSql = new MsSql();
+ private MsSql underTest = new MsSql();
@Test
public void matchesJdbcURL() {
- assertThat(msSql.matchesJdbcURL("jdbc:sqlserver://localhost:1433;databasename=sonar")).isTrue();
+ assertThat(underTest.matchesJdbcURL("jdbc:sqlserver://localhost:1433;databasename=sonar")).isTrue();
- assertThat(msSql.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
- assertThat(msSql.matchesJdbcURL("jdbc:mysql:foo")).isFalse();
+ assertThat(underTest.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
+ assertThat(underTest.matchesJdbcURL("jdbc:mysql:foo")).isFalse();
}
@Test
public void testBooleanSqlValues() {
- assertThat(msSql.getTrueSqlValue()).isEqualTo("1");
- assertThat(msSql.getFalseSqlValue()).isEqualTo("0");
+ assertThat(underTest.getTrueSqlValue()).isEqualTo("1");
+ assertThat(underTest.getFalseSqlValue()).isEqualTo("0");
}
@Test
public void should_configure() {
- assertThat(msSql.getId()).isEqualTo("mssql");
- assertThat(msSql.getDefaultDriverClassName()).isEqualTo("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- assertThat(msSql.getValidationQuery()).isEqualTo("SELECT 1");
+ assertThat(underTest.getId()).isEqualTo("mssql");
+ assertThat(underTest.getDefaultDriverClassName()).isEqualTo("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+ assertThat(underTest.getValidationQuery()).isEqualTo("SELECT 1");
}
@Test
public void do_not_support_jtds_since_5_2() {
- assertThat(msSql.matchesJdbcURL("jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor")).isFalse();
+ assertThat(underTest.matchesJdbcURL("jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor")).isFalse();
}
@Test
public void msSql_does_supportMigration() {
- assertThat(msSql.supportsMigration()).isTrue();
+ assertThat(underTest.supportsMigration()).isTrue();
+ }
+
+ @Test
+ public void getSqlFromDual() {
+ assertThat(underTest.getSqlFromDual()).isEqualTo("");
}
}
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MySqlTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MySqlTest.java
index 039bb76bbed..f9004ec9679 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MySqlTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/MySqlTest.java
@@ -25,38 +25,43 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MySqlTest {
- private MySql mySql = new MySql();
+ private MySql underTest = new MySql();
@Test
public void matchesJdbcURL() {
- assertThat(mySql.matchesJdbcURL("jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8")).isTrue();
- assertThat(mySql.matchesJdbcURL("JDBC:MYSQL://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8")).isTrue();
+ assertThat(underTest.matchesJdbcURL("jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8")).isTrue();
+ assertThat(underTest.matchesJdbcURL("JDBC:MYSQL://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8")).isTrue();
- assertThat(mySql.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
- assertThat(mySql.matchesJdbcURL("jdbc:oracle:foo")).isFalse();
+ assertThat(underTest.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
+ assertThat(underTest.matchesJdbcURL("jdbc:oracle:foo")).isFalse();
}
@Test
public void testBooleanSqlValues() {
- assertThat(mySql.getTrueSqlValue()).isEqualTo("true");
- assertThat(mySql.getFalseSqlValue()).isEqualTo("false");
+ assertThat(underTest.getTrueSqlValue()).isEqualTo("true");
+ assertThat(underTest.getFalseSqlValue()).isEqualTo("false");
}
@Test
public void should_configure() {
- assertThat(mySql.getId()).isEqualTo("mysql");
- assertThat(mySql.getDefaultDriverClassName()).isEqualTo("com.mysql.jdbc.Driver");
- assertThat(mySql.getValidationQuery()).isEqualTo("SELECT 1");
+ assertThat(underTest.getId()).isEqualTo("mysql");
+ assertThat(underTest.getDefaultDriverClassName()).isEqualTo("com.mysql.jdbc.Driver");
+ assertThat(underTest.getValidationQuery()).isEqualTo("SELECT 1");
}
@Test
public void testFetchSizeForScrolling() {
- assertThat(mySql.getScrollDefaultFetchSize()).isEqualTo(Integer.MIN_VALUE);
- assertThat(mySql.getScrollSingleRowFetchSize()).isEqualTo(Integer.MIN_VALUE);
+ assertThat(underTest.getScrollDefaultFetchSize()).isEqualTo(Integer.MIN_VALUE);
+ assertThat(underTest.getScrollSingleRowFetchSize()).isEqualTo(Integer.MIN_VALUE);
}
@Test
public void mysql_does_supportMigration() {
- assertThat(mySql.supportsMigration()).isTrue();
+ assertThat(underTest.supportsMigration()).isTrue();
+ }
+
+ @Test
+ public void getSqlFromDual() {
+ assertThat(underTest.getSqlFromDual()).isEqualTo("from dual");
}
}
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/OracleTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/OracleTest.java
index 3e7d55613b6..f2a2e3a502a 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/OracleTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/OracleTest.java
@@ -56,4 +56,9 @@ public class OracleTest {
public void oracle_does_supportMigration() {
assertThat(underTest.supportsMigration()).isTrue();
}
+
+ @Test
+ public void getSqlFromDual() {
+ assertThat(underTest.getSqlFromDual()).isEqualTo("from dual");
+ }
}
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
index 67dd06a7fdd..ef2ffadd329 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
@@ -25,39 +25,44 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PostgreSqlTest {
- PostgreSql dialect = new PostgreSql();
+ private PostgreSql underTest = new PostgreSql();
@Test
public void matchesJdbcURL() {
- assertThat(dialect.matchesJdbcURL("jdbc:postgresql://localhost/sonar")).isTrue();
- assertThat(dialect.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
+ assertThat(underTest.matchesJdbcURL("jdbc:postgresql://localhost/sonar")).isTrue();
+ assertThat(underTest.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
}
@Test
public void should_set_connection_properties() {
- assertThat(dialect.getConnectionInitStatements()).isEqualTo(PostgreSql.INIT_STATEMENTS);
+ assertThat(underTest.getConnectionInitStatements()).isEqualTo(PostgreSql.INIT_STATEMENTS);
}
@Test
public void testBooleanSqlValues() {
- assertThat(dialect.getTrueSqlValue()).isEqualTo("true");
- assertThat(dialect.getFalseSqlValue()).isEqualTo("false");
+ assertThat(underTest.getTrueSqlValue()).isEqualTo("true");
+ assertThat(underTest.getFalseSqlValue()).isEqualTo("false");
}
@Test
public void should_configure() {
- assertThat(dialect.getId()).isEqualTo("postgresql");
- assertThat(dialect.getDefaultDriverClassName()).isEqualTo("org.postgresql.Driver");
- assertThat(dialect.getValidationQuery()).isEqualTo("SELECT 1");
+ assertThat(underTest.getId()).isEqualTo("postgresql");
+ assertThat(underTest.getDefaultDriverClassName()).isEqualTo("org.postgresql.Driver");
+ assertThat(underTest.getValidationQuery()).isEqualTo("SELECT 1");
}
@Test
public void testFetchSizeForScrolling() {
- assertThat(dialect.getScrollDefaultFetchSize()).isEqualTo(200);
+ assertThat(underTest.getScrollDefaultFetchSize()).isEqualTo(200);
}
@Test
public void postgres_does_supportMigration() {
- assertThat(dialect.supportsMigration()).isTrue();
+ assertThat(underTest.supportsMigration()).isTrue();
+ }
+
+ @Test
+ public void getSqlFromDual() {
+ assertThat(underTest.getSqlFromDual()).isEqualTo("");
}
}