aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-06 15:17:49 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-06 15:17:49 +0200
commitcc40fc4d4f74aa1eab62cc1a144fdca04c92ed18 (patch)
tree471a449f8f40cb49e7dcd81acbb37289b480c5ad /sonar-db
parent34ac5d84f639df6643a7976593c6f00b4283f04b (diff)
downloadsonarqube-cc40fc4d4f74aa1eab62cc1a144fdca04c92ed18.tar.gz
sonarqube-cc40fc4d4f74aa1eab62cc1a144fdca04c92ed18.zip
Revert "Fix execution of tests on non-H2 databases"
This reverts commit 34ac5d84f639df6643a7976593c6f00b4283f04b.
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/DbTester.java17
-rw-r--r--sonar-db/src/test/java/org/sonar/db/TestDb.java13
2 files changed, 13 insertions, 17 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java
index 498f5f46eec..30bc65fa1e3 100644
--- a/sonar-db/src/test/java/org/sonar/db/DbTester.java
+++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java
@@ -96,7 +96,7 @@ public class DbTester extends ExternalResource {
@Override
protected void before() throws Throwable {
- db.start();
+ truncateTables();
}
@Override
@@ -104,7 +104,7 @@ public class DbTester extends ExternalResource {
if (session != null) {
MyBatis.closeQuietly(session);
}
- db.stop();
+ db.close();
}
public DbSession getSession() {
@@ -323,8 +323,8 @@ public class DbTester extends ExternalResource {
public void assertColumnDefinition(String table, String column, int expectedType, @Nullable Integer expectedSize) {
try (Connection connection = db.getDatabase().getDataSource().getConnection();
- PreparedStatement stmt = connection.prepareStatement("select * from " + table);
- ResultSet res = stmt.executeQuery()) {
+ PreparedStatement stmt = connection.prepareStatement("select * from " + table);
+ ResultSet res = stmt.executeQuery()) {
Integer columnIndex = getColumnIndex(res, column);
if (columnIndex == null) {
fail("The column '" + column + "' does not exist");
@@ -336,7 +336,7 @@ public class DbTester extends ExternalResource {
}
} catch (Exception e) {
- throw new IllegalStateException("Fail to check column", e);
+ throw new IllegalStateException("Fail to check column");
}
}
@@ -353,7 +353,7 @@ public class DbTester extends ExternalResource {
return null;
} catch (Exception e) {
- throw new IllegalStateException("Fail to get column index", e);
+ throw new IllegalStateException("Fail to get column idnex");
}
}
@@ -387,7 +387,6 @@ public class DbTester extends ExternalResource {
}
} catch (SQLException e) {
// ignore
- e.printStackTrace();
}
}
@@ -420,4 +419,8 @@ public class DbTester extends ExternalResource {
return db.getDatabase();
}
+ public DatabaseCommands getCommands() {
+ return db.getCommands();
+ }
+
}
diff --git a/sonar-db/src/test/java/org/sonar/db/TestDb.java b/sonar-db/src/test/java/org/sonar/db/TestDb.java
index 93509a42fab..3ab4fc41346 100644
--- a/sonar-db/src/test/java/org/sonar/db/TestDb.java
+++ b/sonar-db/src/test/java/org/sonar/db/TestDb.java
@@ -41,7 +41,6 @@ import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.db.deprecated.NullQueue;
-import org.sonar.db.dialect.H2;
/**
* This class should be call using @ClassRule in order to create the schema once (ft @Rule is used
@@ -92,11 +91,11 @@ class TestDb {
db.start();
if (schemaPath != null) {
// will fail if not H2
- if (H2.ID.equals(db.getDialect().getId())) {
+ if (db.getDialect().getId().equals("h2")) {
((H2Database) db).executeScript(schemaPath);
} else {
db.stop();
-
+ throw new AssumptionViolatedException("Test disabled because it supports only H2");
}
}
isDefault = (schemaPath == null);
@@ -110,12 +109,6 @@ class TestDb {
}
}
- void start() {
- if (!isDefault && !H2.ID.equals(db.getDialect().getId())) {
- throw new AssumptionViolatedException("Test disabled because it supports only H2");
- }
- }
-
void truncateTables() {
try {
commands.truncateDatabase(db.getDataSource());
@@ -124,7 +117,7 @@ class TestDb {
}
}
- void stop() {
+ void close() {
if (!isDefault) {
db.stop();
}