aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-03-03 22:54:03 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-03-03 22:54:03 +0100
commitd1d9e77a365e3817c9a01a26350ff6eb94e600d1 (patch)
treef4d244a899999928d41fb928d79cfcae65195735 /sonar-core/src
parent82faa625e3e6471335321b5d5fb2258809afaa13 (diff)
downloadsonarqube-d1d9e77a365e3817c9a01a26350ff6eb94e600d1.tar.gz
sonarqube-d1d9e77a365e3817c9a01a26350ff6eb94e600d1.zip
Fix compatibility of tests with non-H2 dbs
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java b/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java
index b838a10f452..48470d92f36 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java
@@ -56,6 +56,7 @@ import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
+import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -220,14 +221,18 @@ public class DbTester extends ExternalResource {
return rows.get(0);
}
- private static List<Map<String, Object>> getHashMap(ResultSet resultSet) throws SQLException {
+ private static List<Map<String, Object>> getHashMap(ResultSet resultSet) throws Exception {
ResultSetMetaData metaData = resultSet.getMetaData();
int colCount = metaData.getColumnCount();
List<Map<String, Object>> rows = newArrayList();
while (resultSet.next()) {
Map<String, Object> columns = newHashMap();
for (int i = 1; i <= colCount; i++) {
- columns.put(metaData.getColumnLabel(i), resultSet.getObject(i));
+ Object value = resultSet.getObject(i);
+ if (value instanceof Clob) {
+ value = IOUtils.toString(((Clob)value).getAsciiStream());
+ }
+ columns.put(metaData.getColumnLabel(i), value);
}
rows.add(columns);
}