From 121453ec2a6b7f69c6d4af85f0fd9c2f9027b280 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 22 Jan 2015 13:50:40 +0100 Subject: [PATCH] Speed-up tests with Oracle --- .../org/sonar/core/persistence/AbstractDaoTestCase.java | 5 ++++- .../test/java/org/sonar/core/persistence/DbTester.java | 9 +++++++-- .../java/org/sonar/jpa/test/AbstractDbUnitTestCase.java | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java b/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java index bad01424dfd..bd4f2912449 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java @@ -19,6 +19,7 @@ */ package org.sonar.core.persistence; +import com.google.common.base.Objects; import com.google.common.collect.Maps; import com.google.common.io.Closeables; import org.apache.commons.io.FileUtils; @@ -72,6 +73,7 @@ public abstract class AbstractDaoTestCase { private static Database database; private static DatabaseCommands databaseCommands; private static MyBatis myBatis; + private static String login; private IDatabaseTester databaseTester; @@ -82,6 +84,7 @@ public abstract class AbstractDaoTestCase { if (settings.hasKey("orchestrator.configUrl")) { loadOrchestratorSettings(settings); } + login = settings.getString("sonar.jdbc.username"); for (String key : settings.getKeysStartingWith("sonar.jdbc")) { LOG.info(key + ": " + settings.getString(key)); } @@ -103,7 +106,7 @@ public abstract class AbstractDaoTestCase { @Before public void startDbUnit() throws Exception { databaseCommands.truncateDatabase(database.getDataSource()); - databaseTester = new DataSourceDatabaseTester(database.getDataSource()); + databaseTester = new DataSourceDatabaseTester(database.getDataSource(), login); } /** 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 46b3f13d499..5c2a704d425 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,7 +56,11 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; import java.util.List; import java.util.Map; import java.util.Properties; @@ -95,6 +99,7 @@ public class DbTester extends ExternalResource { if (settings.hasKey("orchestrator.configUrl")) { loadOrchestratorSettings(settings); } + String login = settings.getString("sonar.jdbc.username"); for (String key : settings.getKeysStartingWith("sonar.jdbc")) { LOG.info(key + ": " + settings.getString(key)); } @@ -117,7 +122,7 @@ public class DbTester extends ExternalResource { LOG.info("Test Database: " + db); commands = DatabaseCommands.forDialect(db.getDialect()); - tester = new DataSourceDatabaseTester(db.getDataSource()); + tester = new DataSourceDatabaseTester(db.getDataSource(), login); myBatis = new MyBatis(db, new Logback(), new NullQueue()); myBatis.start(); diff --git a/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java b/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java index 66dfb239887..7eecf83d110 100644 --- a/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java +++ b/sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java @@ -55,7 +55,9 @@ import static org.junit.Assert.fail; /** * Heavily duplicates AbstractDaoTestCase as long as Hibernate is in use. + * @deprecated this class does not support non-H2 databases */ +@Deprecated public abstract class AbstractDbUnitTestCase { private static Database database; private static MyBatis myBatis; -- 2.39.5